mumba-jwt

A service for working with JSON Web Tokens.

Usage no npm install needed!

<script type="module">
  import mumbaJwt from 'https://cdn.skypack.dev/mumba-jwt';
</script>

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.

List of all contributors

License

Apache 2.0


© 2017 Mumba Pty Ltd. All rights reserved.