Minimal caching wrapper for async JSON Web Token generation functions. Current version 1.1.0. Maintained by ForbesLindesay with Rolling Versions release automation. Caches tokens based on their 'exp' claim, with configurable minimum validity and optional eager refresh. Ships TypeScript types. Distinguishes itself by its simplicity and direct integration with libraries like jsonwebtoken.
npm install jwt-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of jwtCache to cache a token generated by jsonwebtoken.sign with a 3-second expiry and 100ms minimum validity.
Use const jwtCache = require('jwt-cache').default or switch to ESM imports.Set a larger value based on your network latency and clock tolerance.
Ensure eagerRefreshMilliseconds < minimumValidityMilliseconds.
Use ESM imports or add .default in require.
const jwtCache = require('jwt-cache').defaultEnsure getToken signs a token with an 'expiresIn' or explicit 'exp' claim.
No dependency data recorded yet.