How to use the lsat-js.verifyCaveats 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
it('should only satisfy caveats that get more restrictive', () => {
      const interval = 1000
      const condition = 'expiration'
      const firstCaveat = new Caveat({
        condition,
        value: Date.now() + interval,
      })
      const secondCaveat = new Caveat({
        condition,
        value: Date.now() + interval / 2, // more restrictive time
      })

      expect(satisfier).to.have.property('satisfyPrevious')

      let isValid = verifyCaveats([firstCaveat, secondCaveat], satisfier)

      expect(isValid, 'Expected caveats w/ increasing restrictiveness to pass')
        .to.be.true

      isValid = verifyCaveats([secondCaveat, firstCaveat], satisfier)

      expect(
        isValid,
        'Expected caveats w/ decreasingly restrictive expirations to fail'
      ).to.be.false
    })
  })
github Tierion / boltwall / tests / configs.spec.ts View on Github external
condition,
        value: Date.now() + interval,
      })
      const secondCaveat = new Caveat({
        condition,
        value: Date.now() + interval / 2, // more restrictive time
      })

      expect(satisfier).to.have.property('satisfyPrevious')

      let isValid = verifyCaveats([firstCaveat, secondCaveat], satisfier)

      expect(isValid, 'Expected caveats w/ increasing restrictiveness to pass')
        .to.be.true

      isValid = verifyCaveats([secondCaveat, firstCaveat], satisfier)

      expect(
        isValid,
        'Expected caveats w/ decreasingly restrictive expirations to fail'
      ).to.be.false
    })
  })
github Tierion / boltwall / tests / configs.spec.ts View on Github external
it('should not support additional caveats from other origin', () => {
      const firstCaveat = new Caveat({ condition, value: '84.123.45.2' })
      const secondCaveat = new Caveat({ condition, value: '74.321.5.27' })
      const request = { ip: firstCaveat.value, boltwallConfig: config }
      const isValid = verifyCaveats(
        [firstCaveat, secondCaveat],
        satisfier,
        request
      )
      expect(isValid).to.be.false
    })
  })

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