Fetch utility for JSON Web Key Sets (JWKS) with caching, issuer validation, and provider discovery. Current stable version: 11.0.3, requires Node.js >=20, ships TypeScript types. Uses lru-cache for key caching and supports OpenID Connect Discovery. Differentiators: built-in stale cache fallback on errors, configurable issuer whitelist/check, and fetch options customization. ESM-only since v10. Common alternatives: jwks-rsa (more features), this package is leaner for serverless.
npm install get-jwksNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to fetch a JWKS public key and verify a JWT using jsonwebtoken with TypeScript.
Use Node >=20 with ESM imports (import buildGetJwks from 'get-jwks'). If stuck on CJS, use dynamic import or stay on v9.x.
Replace allowedDomains with issuersWhitelist in the options object.
Use buildGetJwks() to create an instance. Old code like const getJwks = require('get-jwks')() still works due to callable default, but type signatures differ.Always provide a domain string. Validate the domain before calling these methods.
Set appropriate ttl values. Clear cache manually if rotation is detected: getJwks.cache.clear() (if cache is exposed).
const getJwks = buildGetJwks(); then getJwks.getJwk()
Upgrade Node to >=20 or use import() syntax: const getJwks = await import('get-jwks')Add the issuer URL to issuersWhitelist: buildGetJwks({ issuersWhitelist: ['https://yourdomain.com'] })Ensure the domain is correct and reachable. Increase timeout option. If using providerDiscovery, verify the OpenID configuration endpoint exists.
Switch to import buildGetJwks from 'get-jwks' and ensure tsconfig has "moduleResolution": "nodenext".