@xpresser/jwt
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

XpresserJs JWT Plugin

Easy and Fast jwt setup for your project.

This plugin makes use of fast-jwt with caching support out of the box.

MENU

Installation

npm i @xpresser/jwt
# OR
yarn add @xpresser/jwt

Add to plugins.json

{
  "npm://@xpresser/jwt": true
}

Add to your project config.

({
  // ... Other Configs
  "@xpresser/jwt": {
    secretKey: "My Secret Key!",
    signer: {
      expiresIn: 3_600_000 // in 1 hour
    },
    verifier: {cache: true}
  }
  
})

More signer and verifier configuration options can be found here

Usage

In your controller or anywhere in your project.

const {signJwt, verifyJwt} = require("@xpresser/jwt");

// Sign Data
const token = signJwt({user: 'john_doe'});

// Verify/Decode
verifyJwt(token) 
// { user: "john_doe", iat: 1634151036, exp: 1634151046}

Package Sidebar

Install

npm i @xpresser/jwt

Weekly Downloads

3

Version

1.0.9

License

MIT

Unpacked Size

14.2 kB

Total Files

8

Last publish

Collaborators

  • trapcode