0.1.1 • Published 7 years ago

mumba-jwt v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
gitlab
Last release
7 years ago

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.

List of all contributors

License

Apache 2.0


© 2017 Mumba Pty Ltd. All rights reserved.

0.1.1

7 years ago

0.1.0

9 years ago