altwebtoken
v0.1.2
Published
> A helper module to sign and verify a web token. AWT, alternative web token is not JWT. use only for the closed system alone.
Downloads
8
Readme
altwebtoken
A helper module to sign and verify a web token. AWT, alternative web token is not JWT. use only for the closed system alone.
Install
Install with npm:
$ npm install --save altwebtoken
Usage
const AWT = require('.');
const key = 'my-foo-bar-key';
const secret = 'my-baz-qux-secret';
const payload = {
userId: '[email protected]'
};
const awt = new AWT();
awt.id = key;
awt.issuedAt = Date.now();
awt.expires = awt.issuedAt + (1000 * 60 * 60);
awt.payload = payload;
const token = awt.sign( key, secret );
console.log( token );
const isVerified = awt.verify( token, key, secret );
console.log( isVerified );
console.log( awt.header );
console.log( awt.payload );
License
Copyright © 2018, Seunghwan Noh. Released under the MIT License.