MIT
npm i vv-jwt
import { Create as CreateJwtManager } from 'vv-jwt'
const jwtManager = CreateJwtManager({
secret: 'my secret',
issDefault: 'my application',
expDelta: 1000 * 60 * 60 *24, //create tokens with one day life
})
// create token
const j = jwtManager.create()
if (j.error) {
console.error(j.error)
} else {
console.log(`token - ${j.jwtString}`)
}
// check token
const c = jwtManager.check(j.jwtString)
if (c.deny) {
console.log(`NO SUCCESS CHECK TOKEN: ${c.deny.code} - ${c.deny.message}`)
} else {
console.log(c.jwt)
}