mumba-jwt
v0.1.1
Published
A service for working with JSON Web Tokens.
Downloads
2
Readme
Mumba JWT
A service for working with JSON Web Tokens based on jsonwebtoken.
Installation
$ npm install --save mumba-jwt
Examples
import {TokenService} from 'mumba-jwt';
// Sync example
let service = new TokenService({
passKey: 'abc123'
});
let data = {
foo: 'bar'
};
// Not a token.
service.decode('foo'); // null
// Creating and decoding token.
let token = service.sign(data, { subject: '123' });
let decoded = service.decode(token);
console.log(decoded.sub); // 123
console.log(decoded.foo); // bar
// Verifying a bad token.
service.verify('not.even.close')
.catch(function (err: Error) {
console.log(err);
});
service.verify(token)
.then(function (decoded: any) {
console.log(decoded.foo); // bar
});
Tests
To run the test suite, first install the dependencies, then run npm test
:
$ npm install
$ npm test
People
The original author of Mumba WAMP is Andrew Eddie.
License
© 2017 Mumba Pty Ltd. All rights reserved.