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 = '';const kid = 'auth';client;
cache: false // Enable or disable cachettl: 60 // Amount of time in seconds to cache a keystrictSSL: true // Throw error if SSL certificate could not be validated
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
If an exception occurs when requesting the JWKs an HTTPError will also be thrown, but with a null