talira

jsonwebtoken

JSON Web Token signing and verification for Node.js

open sourceMITfree

jsonwebtoken is an implementation of JSON Web Tokens (RFC 7519) for Node.js, built on node-jws. jwt.sign creates tokens with HMAC, RSA or ECDSA keys, synchronously or with a callback, and sets claims such as expiry, not-before, audience, issuer, subject and key ID; jwt.verify checks a token's signature and claims, and jwt.decode reads it without verifying. It rejects RSA keys shorter than 2048 bits unless told otherwise.

Problems it solves

  • issue and verify JWTs in a Node.js API
  • check a JWT's signature and expiry in Express middleware
  • sign a token with an RSA private key in Node.js

Features

  • Sign tokens with HMAC, RSA or ECDSA keys
  • Verify a token's signature and claims
  • Expiry, not-before, audience, issuer, subject and key ID options
  • Synchronous or callback-based signing
  • Rejects RSA keys under 2048 bits by default