JWKs Fetch
jwks-fetch is a NodeJS library which retrieves asymmetric keys in JWKs format. It supports both RSA and EC keys.
npm install --save jwks-fetch
It implements a Promise based API. NodeJS 8 or above is required. For now it's only compatible with Node, but isomorphic support is planned.
const JWKSClient HTTPError = ; const client = ;const url = 'https://demo.com/static/jwks.json';const kid = 'auth'; client ;
Options
cache: false // Enable or disable cache ttl: 60 // Amount of time in seconds to cache a key strictSSL: true // Throw error if SSL certificate could not be validated
HTTPError
If the jwks_uri
didn't respond with an HTTP status code 200 a custom HTTPError exception will be thrown. From there you can access the raw response with err.res
and the status code with err.status
.
If an exception occurs when requesting the JWKs an HTTPError will also be thrown, but with a null res
.