jwt-simple
    Overview
    Insights & Analysis
    Code
    Versions
    Find an Expert
    Documentation
    Playground
    Issues
    Career Opportunities
    Alternatives
    Dependencies

jwt-simple

JWT(JSON Web Token) encode and decode module

0.5.6  •  Published 5 months ago  •  by Kazuhito Hokamura  •  MIT License

JWT(JSON Web Token) encode and decode module for node.js.

Install

$ npm install jwt-simple

Usage

var jwt = require('jwt-simple');
var payload = { foo: 'bar' };
var secret = 'xxx';

// HS256 secrets are typically 128-bit random strings, for example hex-encoded:
// var secret = Buffer.from('fe1a1915a379f3be5394b64d14794932', 'hex')

// encode
var token = jwt.encode(payload, secret);

// decode
var decoded = jwt.decode(token, secret);
console.log(decoded); //=> { foo: 'bar' }

decode params

/*
 * jwt.decode(token, key, noVerify, algorithm)
 */

// decode, by default the signature of the token is verified
var decoded = jwt.decode(token, secret);
console.log(decoded); //=> { foo: 'bar' }

// decode without verify the signature of the token,
// be sure to KNOW WHAT ARE YOU DOING because not verify the signature
// means you can't be sure that someone hasn't modified the token payload
var decoded = jwt.decode(token, secret, true);
console.log(decoded); //=> { foo: 'bar' }

// decode with a specific algorithm (not using the algorithm described in the token payload)
var decoded = jwt.decode(token, secret, false, 'HS256');
console.log(decoded); //=> { foo: 'bar' }

Algorithms

By default the algorithm to encode is HS256.

The supported algorithms for encoding and decoding are HS256, HS384, HS512 and RS256.

// encode using HS512
jwt.encode(payload, secret, 'HS512')

Dependencies

expect.js  ·  istanbul  ·  mocha

Tags

jwt
encode
decode
Avoid unsafe or low quality packages
Warn or block the installation of vulnerable, badly licensed, deprecated, outdated, unmaintained, or unpopular packages. Integrates with your npm and pre-commit/build scripts
Just $9/month per developer

Popularity

Weekly Downloads
112.8K
Stars
1.2K

Issues and PRs

Activity

Last ver 5 months ago
Created 6 years ago
Last commit 5 months ago
1 month between commits

Sustainability

23 contributors

Technology

Node version: 10.15.1
9K unpacked

Legal and Compliance

MIT License
OSI Approved
0 vulnerabilities

Top Experts

hokaccha
Maintainer, 45 commits, 19 merges
Works at cookpad
Alexandre Jablon
Maintainer, 11 commits, 3 merges, 4 PRs
Works at https://everoad.com
Ryan Block
3 commits, 1 PRs
Works at smallwins
Greg
3 commits
Ken Morishita
2 commits, 1 PRs
Works at https://www.sprocket.bz/
Renat Zubairov
1 commits, 1 PRs
Works at elastic.io GmbH