Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Lsat

description

A a class for creating and converting LSATs

Hierarchy

  • any
    • Lsat

Index

Constructors

constructor

Properties

amountPaid

amountPaid: number | null

baseMacaroon

baseMacaroon: string

id

id: string

invoice

invoice: string

paymentHash

paymentHash: string

paymentPreimage

paymentPreimage: string | null

routingFeePaid

routingFeePaid: number | null

timeCreated

timeCreated: number

validUntil

validUntil: number

Static type

type: string = "LSAT"

Methods

fromOptions

getExpirationFromMacaroon

  • getExpirationFromMacaroon(macaroon?: undefined | string): number
  • description

    A utility for returning the expiration date of the LSAT's macaroon based on an optional caveat

    Parameters

    • Optional macaroon: undefined | string

    Returns number

    expiration date

getMacaroon

isExpired

  • isExpired(): boolean
  • Determine if the LSAT is expired or not. This is based on the validUntil property of the lsat which is evaluated at creation time based on the macaroon and any existing expiration caveats

    Returns boolean

isPending

  • isPending(): boolean
  • Determines if the lsat is valid or not depending on if there is a preimage or not

    Returns boolean

setPreimage

  • setPreimage(preimage: string): void
  • A utility for setting the preimage for an LSAT. This method will validate the preimage and throw if it is either of the incorrect length or does not match the paymentHash

    Parameters

    • preimage: string

      32-byte hex string of the preimage that is used as proof of payment of a lightning invoice

    Returns void

toChallenge

  • toChallenge(): string
  • description

    Converts LSAT into a challenge header to return in the WWW-Authenticate response header. Returns base64 encoded string with macaroon and invoice information prefixed with authentication type ("LSAT")

    Returns string

toToken

  • toToken(): string
  • description

    Converts the lsat into a valid LSAT token for use in an http Authorization header. This will return a string in the form: "LSAT [macaroon]:[preimage?]". If no preimage is available the last character should be a colon, which would be an "incomplete" LSAT

    Returns string

Static fromChallenge

  • fromChallenge(challenge: string): Lsat
  • description

    Validates and converts an LSAT challenge from a WWW-Authenticate header response into an LSAT object. This method expects an invoice and a macaroon in the challenge

    Parameters

    • challenge: string

    Returns Lsat

Static fromHeader

  • fromHeader(header: string): Lsat
  • description

    Given an LSAT WWW-Authenticate challenge header (with token type, "LSAT", prefix) will return an Lsat.

    Parameters

    • header: string

    Returns Lsat

Static fromMacaroon

  • fromMacaroon(macaroon: string, invoice?: undefined | string): Lsat
  • description

    generates a new LSAT from an invoice and an optional invoice

    Parameters

    • macaroon: string

      macaroon to parse and generate relevant lsat properties from

    • Optional invoice: undefined | string

    Returns Lsat

Static fromToken

  • fromToken(token: string): Lsat
  • description

    Create an LSAT from an http Authorization header. A useful utility when trying to parse an LSAT sent in a request and determining its validity

    Parameters

    • token: string

      LSAT token sent in request

    Returns Lsat

Generated using TypeDoc