Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "src/helpers"

Index

Type aliases

prefixMatchFn

prefixMatchFn: function

Type declaration

    • (value: string): boolean
    • Parameters

      • value: string

      Returns boolean

Variables

MACAROON_SUGGESTED_SECRET_LENGTH

MACAROON_SUGGESTED_SECRET_LENGTH: any

MacaroonsBuilder

MacaroonsBuilder: any

MacaroonsConstants

MacaroonsConstants: object

Type declaration

  • MACAROON_SUGGESTED_SECRET_LENGTH: any

MacaroonsVerifier

MacaroonsVerifier: any

TimestampCaveatVerifier

TimestampCaveatVerifier: any

Const lnService

lnService: any = require('ln-service')

verifier

verifier: object

Type declaration

  • TimestampCaveatVerifier: any

Functions

checkInvoiceStatus

  • checkInvoiceStatus(lnd: any, opennode: any, invoiceId: string): Promise<InvoiceResponse>
  • Checks the status of an invoice given an id

    params

    {express.request} - request object from expressjs

    params

    {req.query.id} invoiceId - id of invoice to check status of

    params

    {req.lnd} [lnd] - ln-service authenticated grpc object

    params

    {req.opennode} [opennode] - authenticated opennode object for communicating with OpenNode API

    Parameters

    • lnd: any
    • opennode: any
    • invoiceId: string

    Returns Promise<InvoiceResponse>

    • status - Object with status, amount, and payment request

createInvoice

  • Utility to create an invoice based on either an authenticated lnd grpc instance or an opennode connection

    params

    {Object} req - express request object that either contains an lnd or opennode object

    Parameters

    Returns Promise<InvoiceResponse>

    invoice - returns an invoice with a payreq, id, description, createdAt, and

createRootMacaroon

  • createRootMacaroon(invoiceId: string, location: string, has3rdPartyCaveat?: boolean): Promise<any>
  • Given an invoice object and a request we want to create a root macaroon with a third party caveat, which both need to be satisfied in order to authenticate the macaroon

    params

    {invoice.id} - invoice must at least have an id for creating the 3rd party caveat

    params

    {Object} req - request object is needed for identification of the macaroon, in particular the headers and the originating ip

    params

    {Boolean} has3rdPartyCaveat

    Parameters

    • invoiceId: string
    • location: string
    • Default value has3rdPartyCaveat: boolean = false

    Returns Promise<any>

    • serialized macaroon object

getDischargeMacaroon

  • getDischargeMacaroon(invoiceId: string, location: string, caveat?: undefined | string): string
  • Returns serealized discharge macaroon, signed with the server's caveat key and with an attached caveat (if passed)

    params

    {Express.request} - req object

    params

    {String} caveat - first party caveat such as time < ${now + 1000 seconds}

    Parameters

    • invoiceId: string
    • location: string
    • Optional caveat: undefined | string

    Returns string

    discharge macaroon

getEnvVars

  • getEnvVars(): any

getFirstPartyCaveat

getFirstPartyCaveatFromMacaroon

  • getFirstPartyCaveatFromMacaroon(serialized: Macaroon): any
  • Utility to extract first party caveat value from a serialized root macaroon See getFirstPartyCaveat for what this value represents

    Parameters

    Returns any

getLocation

  • getLocation(__namedParameters: object): string
  • Utility function to get a location string to describe where the server is. useful for setting identifiers in macaroons

    params

    {Express.request} req - expressjs request object

    params

    {Express.request.headers} [headers] - optional headers property added by zeit's now

    params

    {Express.request.hostname} - fallback if not in a now lambda

    Parameters

    Returns string

    • location string

testEnvVars

  • testEnvVars(): boolean

validateMacaroons

  • Validates a macaroon and should indicate reason for failure if possible

    params

    {Macaroon} root - root macaroon

    params

    {Macaroon} discharge - discharge macaroon from 3rd party validation

    params

    {String} exactCaveat - a first party, exact caveat to test on root macaroon

    Parameters

    Returns undefined | true

    will return true if passed or throw with failure

Generated using TypeDoc