@xpresser/jwt
v1.1.0
Published
Jwt helper using fast-jwt
Downloads
10
Readme
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}