this package is a wrapper to jsonwebtoken as promise
Consult node-jsonwebtoken for detailed documentation.
Sign a token with key, with options defaulting to { algorithm: 'HS256' }
.
ES6:
jwt.sign({ username: 'myname' }, 'secret-dev-key').then(console.log)
ES7:
const token = await jwt.sign({ username: 'myname' }, 'secret-dev-key')
console.log(token)
Verify a token, with options defaulting to { algorithm: 'HS256' }
.
ES6:
jwt.verify(token, 'secret-dev-key')
.then(console.log)
ES7:
const token = await jwt.verify({ username: 'fl0w' }, 'secret-dev-key')
console.log(token)