0.1.0 • Published 7 years ago

signed-jwt v0.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

signed-jwt

Create and validate signed JSON Web Tokens using SHA-512.

NPM Version NPM Downloads Known Vulnerabilities

Installation

npm install --save signed-jwt

Usage

const Token = require('signed-jwt');
const secret = 'iXytm8N6ZFmcWbCUfHC3u7mDmX4e0M1b';

const myToken = Token({ 'id': 1, 'role': 'admin' }, secret);

console.log(`Your token: ${myToken}`);

if (Token.validate(myToken, secret))
	console.log('Your token is valid!');
else
	console.log('Your token is not valid.');

Documentation

Token

Kind: global class

new Token(customObj, secret, validTime)

ParamTypeDescription
customObjobjectan object literal which contains customized information
secretstringsecret key
validTimenumberthe amount of miliseconds the token is valid for. Defaults to 2592000000 (30 days)

Token.validate(token, secret) ⇒ boolean

Checks if an access token is valid

Kind: static method of Token

ParamTypeDescription
tokenstringthe access token
secretstringsecret key
0.1.0

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago