How to use the lsat-js.Caveat.decode function in lsat-js

To help you get started, we’ve selected a few lsat-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tierion / boltwall / tests / configs.spec.ts View on Github external
const amount = 1000

      const result: string = getCaveats(
        {} as Request, // not used in this getter
        { amount } as InvoiceResponse
      )

      // time is in milliseconds, so need to convert amount paid
      // from satoshis (should be number of seconds) to milliseconds
      const time = amount * 1000

      const convertCaveat = (): Caveat => Caveat.decode(result)
      expect(convertCaveat).to.not.throw()

      const caveat = Caveat.decode(result)
      const value: number = +caveat.value

      expect(value).to.be.greaterThan(now)
      // increasing the range just to account for a buffer
      expect(value).to.be.lessThan(now + time + amount)
    })
github Tierion / boltwall / tests / configs.spec.ts View on Github external
      const convertCaveat = (): Caveat => Caveat.decode(result)
      expect(convertCaveat).to.not.throw()
github Tierion / boltwall / tests / configs.spec.ts View on Github external
{
          name: 'request without express',
          req: { connection: { remoteAddress: origin } },
        },
      ]

      for (const { req, name } of requests) {
        const caveat = getCaveats(
          (req as unknown) as Request,
          {} as InvoiceResponse
        )
        expect(
          caveat,
          `Expected ${name} request to generate expected caveat`
        ).to.equal(expected.encode())
        const decoded = Caveat.decode(caveat)

        expect(satisfier.condition).to.equal(decoded.condition)
        const isValid = satisfier.satisfyFinal(decoded, req)
        expect(isValid).to.be.true
      }
    })

lsat-js

Utility library for working with LSAT auth tokens in javascript

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages