JSPM

jwt-claims

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2571
  • Score
    100M100P100Q151737F
  • License MIT

Minimal utility for decoding JWT claims

Package Exports

  • jwt-claims

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jwt-claims) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

jwt-claims

Parse claims from a JWT payload.

npm install jwt-claims

Example:

var decode = require('jwt-claims');

var token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.' +
    'eyJuYW1lIjoi0JvQtdC-0L3RgtC40LkiLCJudW0iOjQyLCJib29sIjpmYWxzZX0.' +
    'icqeYQUXd1l84wHc-vIzVXOQx7DI4V2H-YV34su7cuY';

var claims = decode(token);

console.log(claims);
// { name: 'Леонтий', num: 42, bool: false }

Note that parsing the claims from a JWT payload does not mean that the token is valid. You can use something like jwt-simple to create new tokens and validate existing ones. This module is meant to be used in places where you don't want to share the secret used to mint the token (e.g. a browser).

The jwt-claims package works in Node and browsers using a CommonJS module loader (e.g. Browserify or Webpack). Tested on Node 0.12, Chrome, Firefox, and IE 11.

Current Status