JSON Web Token implementation (symmetric and asymmetric). Use when: `algorithm` (default: `HS256`); `expiresIn`: expressed in seconds or a string describing a time span vercel/ms; `notBefore`: expressed in seconds or a string describing a time span vercel/ms. NOT for: fine-grained authorization rules; user profile CRUD.
Install
npx skillscat add yusenthebot/skills-pack/jsonwebtoken Install via the SkillsCat registry.
SKILL.md
jsonwebtoken
Overview
JSON Web Token implementation (symmetric and asymmetric). This was developed against draft-ietf-oauth-json-web-token-08.
Installation
npm install jsonwebtokenCore API / Usage
$ npm install jsonwebtokenvar jwt = require('jsonwebtoken');
var token = jwt.sign({ foo: 'bar' }, 'shhhhh');Common Patterns
Pattern 1
// sign with RSA SHA256
var privateKey = fs.readFileSync('private.key');
var token = jwt.sign({ foo: 'bar' }, privateKey, { algorithm: 'RS256' });Configuration
See the official documentation for configuration options and advanced settings.
Tips & Gotchas
- Current version: 9.0.3. Check the changelog when upgrading across major versions.
- Refer to the official npm page for edge cases and advanced configuration.