0.1.2 • Published 4 years ago

altwebtoken v0.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

altwebtoken NPM version

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: 'foo@bar.baz'
};

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.

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago