1.0.3 ā€¢ Published 4 years ago

simple-tokens v1.0.3

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

simple-tokens

šŸ— A simple package for signing and verifying simple-tokens.

Token

The token contains two parts: a) the payload b) the signature.

  • payload: base64encode(JSON.stringify(object))
  • signature: SHA256(payload + '.' + secret)
  • token: payload + '.' + signature

Install

Install as NPM package:

$ npm install simple-tokens

Use simple-tokens

Require simpletokens

const simpletokens = require('simple-tokens');

Set secret:

simpletokens.configure('YOUR_SECRET_FRO_ENV');

Sign token:

const payload = { id: 1 }
const token = simpletokens.sign(payload);

Verify token:

const verified = simpletokens.verify(token);

Get payload from token:

const payloadObject = simpletokens.getPayload(token);
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago