token-verify
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

Warning This project is still experimental, not for production use - FEATURES MAY CHANGE WITHOUT WARNING

Token Verifier

CI

This project exports a JWT client with capabilities to verify and decode tokens encrypted by RSA. The package uses jsonwebtokens and jwks-rsa.

Usage Requirements

  • Node 14 || 16 || 18

Creating a JWT Client

To create a new client, provide the expected audience, public key issuer (jwksUri), and token issuers to the jwtClient.

const client = new wtClient({
  audience: 'apiAudience',
  jwksUri: 'pub-key.auth-issuer.com/.well-known/jwks.json',
  issuer: ['primary-issuer.com', 'secondary-issuer.com'],
  // jwt: {... advanced options escape-hatch} 
  // jwks: {...advanced options escape-hatch}
})

Verifying and Decoding Tokens

The verifyAndDecode method can by used by passing in the jwt as a single argument.

const payload = client.verifyAndDecode(token)

//Check for custom claims using hasClaim method
const hasEmailVerifiedClaim = hasClaim(payload, 'emailVerified')

Contributors

Package Sidebar

Install

npm i token-verify

Weekly Downloads

30

Version

0.1.6

License

MIT

Unpacked Size

7.81 kB

Total Files

5

Last publish

Collaborators

  • electblake