npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lndconnect

v0.2.10

Published

Generate and parse lndconnect uris

Downloads

574

Readme

lndconnect

standard-readme compliant Dependency Status Build Status

Generate and parse lndconnect uris https://github.com/LN-Zap/lndconnect ⚡️

This package provides utilities for generating and parsing lndconnect uris.

For more information take a look at the specification of the uri format.

Table of Contents

Install

npm install lndconnect --save

Usage

format({ host, cert, macaroon }):

Formats a host / cert / macaroon combo into an lndconnect link.

import { format } from 'lndconnect'

const connectionString = format({
  host: '1.2.3.4:10009',
  cert: 'MIICuDCCAl...',
  macaroon: '0201036c6...',
})

expect(connectionString).toEqual('lndconnect://1.2.3.4:10009?cert=MIICuDCCAl...&macaroon=0201036c6...')

encode({ host, cert, macaroon }):

Encodes a host / cert / macaroon combo and formats into an lndconnect link.

import { encode } from 'lndconnect'

const connectionString = encode({
  host: '1.2.3.4:10009',
  cert: '-----BEGIN CERTIFICATE-----\n...',
  macaroon: '0201036c6...',
})

expect(connectionString).toEqual('lndconnect://1.2.3.4:10009?cert=MIICuDCCAl...&macaroon=AgEDbG5kAr...')

decode(lndconnectUri):

Decodes an lndconnect link into it's component parts (host / cert as utf8 / macaroon as hex)

import { decode } from 'lndconnect'

const { host, cert, macaroon } = decode('lndconnect://1.2.3.4:10009?cert=MIICuDCCAl...&macaroon=AgEDbG5kAr...')

expect(host).toEqual('1.2.3.4:10009')
expect(cert).toEqual('MIICuDCCAl...')
expect(macaroon).toEqual('0201036c6...')

Certificate

encodeCert(cert, format):

Encodes a certificate (String or Buffer) to base64url encoded DER format.

import { encodeCert } from 'lndconnect'

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

// returns base64url encoded DER cert.
expect(cert).toEqual('MIICuDCCAl...')

decodeCert(encodedCert):

Decodes a certificate from base64url encoded DER format to a string.

import { decodeCert } from 'lndconnect'

// pass a base64url encoded DER cert
const cert = decodeCert(encodedCert)

// returns utf8 encoded PEM cert.
expect(cert).toEqual('-----BEGIN CERTIFICATE-----\n...')

Macaroon

encodeMacaroon(macaroon, format):

Encodes a binary macaroon (String or Buffer) to base64url encoded string.

import { encodeMacaroon } from 'lndconnect'

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

// returns base64url encoded macaroon.
expect(macaroon).toEqual('AgEDbG5kAr...')

decodeMacaroon(encodedMacaroon):

Decodes a base64url encoded macaroon to a hex encoded macaroon.

import { decodeMacaroon } from 'lndconnect'

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

// returns hex encoded macaroon.
expect(macaroon).toEqual('0201036c6...')

Testing

Run the tests suite:

  npm test

Maintainers

@Tom Kirkpatrick (mrfelton).

Contribute

Feel free to dive in! Open an issue or submit PRs.

lndconnect follows the Contributor Covenant Code of Conduct.

License

MIT © Tom Kirkpatrick