Skip to content

Commit

Permalink
Merge pull request #13 from dennisreimann/patch-2
Browse files Browse the repository at this point in the history
Improve code samples
  • Loading branch information
mrfelton authored May 19, 2019
2 parents a7021bb + 003c0f6 commit aaf9a05
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Encodes a certificate (String or Buffer) to base64url encoded DER format.
import { encodeCert } from 'lndconnect'

const certPath = path.join(__dirname, 'tls.cert')
const cert = await encodeCert(certPath)
const cert = encodeCert(certPath)

// returns base64url encoded DER cert.
expect(cert).toEqual('MIICuDCCAl...')
Expand Down Expand Up @@ -113,7 +113,7 @@ Encodes a binary macaroon (String or Buffer) to base64url encoded string.
import { encodeMacaroon } from 'lndconnect'

const macaroonPath = path.join(__dirname, 'admin.macaroon')
const macaroon = await encodeMacaroon(macaroonPath)
const macaroon = encodeMacaroon(macaroonPath)

// returns base64url encoded macaroon.
expect(macaroon).toEqual('AgEDbG5kAr...')
Expand All @@ -127,7 +127,7 @@ Decodes a base64url encoded macaroon to a hex encoded macaroon.
import { decodeMacaroon } from 'lndconnect'

// pass a base64url encoded macaroon
const macaroon = await decodeMacaroon(encodedMacaroon)
const macaroon = decodeMacaroon(encodedMacaroon)

// returns hex encoded macaroon.
expect(macaroon).toEqual('0201036c6...')
Expand Down
3 changes: 2 additions & 1 deletion src/decodeCert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import base64url from 'base64url'
import decodeUriComponent from 'decode-uri-component'
import untildify from 'untildify'
import { isAbsolute } from './utils'

/**
* decode a tls certificate from a base64 encoded url string.
* @param {String} certString base64url encoded string to decode
* @return {Promise} decoded certificate
* @return {String} decoded certificate
*/
const decodeCert = certString => {
if (!certString) {
Expand Down
2 changes: 1 addition & 1 deletion src/decodeMacaroon.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isAbsolute } from './utils'
/**
* decode a binary macaroon as a base64 decoded url string.
* @param {String} macaroonPath Path to macaroon file.
* @return {Promise} decoded macaroon
* @return {String} decoded macaroon
*/
const decodeMacaroon = macaroonString => {
if (!macaroonString) {
Expand Down
2 changes: 1 addition & 1 deletion src/encodeCert.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import strictUriEncode from 'strict-uri-encode'
/**
* Encode a tls certificate as a base64 encoded url string.
* @param {String} certPath Path to vertificate file.
* @return {Promise} Encoded certificate
* @return {String} Encoded certificate
*/
const encodeCert = (input, format = 'utf8') => {
if (!input) {
Expand Down
2 changes: 1 addition & 1 deletion src/encodeMacaroon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import strictUriEncode from 'strict-uri-encode'
/**
* Encode a binary macaroon as a base64 encoded url string.
* @param {String} macaroonPath Path to macaroon file.
* @return {Promise} Encoded macaroon
* @return {String} Encoded macaroon
*/
const encodeMacaroon = (input, format = 'hex') => {
if (!input) {
Expand Down

0 comments on commit aaf9a05

Please sign in to comment.