Skip to content

Commit 914dd42

Browse files
davidpatrickadamjmcgrath
andauthoredMar 5, 2021
V2 Release (#225)
Co-authored-by: Adam Mcgrath <adam.mcgrath@auth0.com>
1 parent 06217d7 commit 914dd42

File tree

4 files changed

+106
-7
lines changed

4 files changed

+106
-7
lines changed
 

‎CHANGELOG.md

+82
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,87 @@
11
# Changelog
22

3+
## [2.0.0] - (2021-03-01)
4+
With version 2 we have added full JWK/JWS support. With this we have bumped the node version to minimum 10. We have also removed Axios and exposed a `fetcher` option to allow user's to completely override how the request to the `jwksUri` endpoint is made.
5+
6+
### Breaking Changes
7+
* Drops support for Node < 10
8+
* No more callbacks, using async/await(promises)
9+
* Removed Axios and changed the API to JwksClient
10+
11+
### Changes
12+
**Added**
13+
- Full JWK/JWS Support [\#205](https://github.com/auth0/node-jwks-rsa/pull/205) ([panva](https://github.com/panva))
14+
15+
**Changed**
16+
- Simplify request wrapper [\#218](https://github.com/auth0/node-jwks-rsa/pull/218) ([davidpatrick](https://github.com/davidpatrick))
17+
- Pins to Node Version 10,12,14 [\#212](https://github.com/auth0/node-jwks-rsa/pull/212) ([davidpatrick](https://github.com/davidpatrick))
18+
- Migrate from callbacks to async/await [\#222](https://github.com/auth0/node-jwks-rsa/pull/222) ([davidpatrick](https://github.com/davidpatrick))
19+
20+
### Migration Guide from v1 to v2
21+
#### Proxies
22+
The proxy option has been removed from the JwksClient. Support for it was a little spotty through Axios, and we wanted to allow users to have more control over the flow. Now you can specify your proxy by overriding the `requestAgent` used with an [agent with built-in proxy support](https://github.com/TooTallNate/node-https-proxy-agent), or by completely overriding the request library with the `fetcher` option.
23+
24+
```js
25+
// OLD
26+
const oldClient = jwksClient({
27+
jwksUri: 'https://sandrino.auth0.com/.well-known/jwks.json',
28+
proxy: 'https://username:pass@address:port'
29+
});
30+
31+
// NEW
32+
const HttpsProxyAgent = require('https-proxy-agent');
33+
const newClient = jwksClient({
34+
jwksUri: 'https://sandrino.auth0.com/.well-known/jwks.json',
35+
requestAgent: new HttpsProxyAgent('https://username:pass@address:port')
36+
});
37+
```
38+
39+
#### Request Agent Options
40+
The library no longer gates what http(s) Agent is used, so we have removed `requestAgentOptions` and now expose the `requestAgent` option when creating a `jwksClient`.
41+
42+
```js
43+
// OLD
44+
const oldClient = jwksClient({
45+
jwksUri: 'https://sandrino.auth0.com/.well-known/jwks.json',
46+
requestAgentOptions: {
47+
ca: fs.readFileSync(caFile)
48+
}
49+
});
50+
51+
// NEW
52+
const newClient = jwksClient({
53+
jwksUri: 'https://sandrino.auth0.com/.well-known/jwks.json',
54+
requestAgent: new https.Agent({
55+
ca: fs.readFileSync(caFile)
56+
})
57+
});
58+
```
59+
60+
#### Migrated Callbacks to Async/Await
61+
The library no longer supports callbacks. We have migrated to async/await(promises).
62+
63+
```js
64+
// OLD
65+
client.getSigningKey(kid, (err, key) => {
66+
const signingKey = key.getPublicKey();
67+
});
68+
69+
// NEW
70+
const key = await client.getSigningKey(kid);
71+
const signingKey = key.getPublicKey();
72+
```
73+
74+
## [1.12.3] - (2021-02-25)
75+
76+
**Added**
77+
- Add alg to SigningKey types [\#220](https://github.com/auth0/node-jwks-rsa/pull/220) ([okko](https://github.com/okko))
78+
79+
**Fixed**
80+
81+
- Fix npmjs resolves [\#221](https://github.com/auth0/node-jwks-rsa/pull/221) ([adamjmcgrath](https://github.com/adamjmcgrath))
82+
- Fix Import default Axios instance [\#216](https://github.com/auth0/node-jwks-rsa/pull/216) ([dsebastien](https://github.com/dsebastien))
83+
84+
385
## [1.12.2] - (2021-01-07)
486

587
**Fixed**

‎README.md

+22-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ You'll provide the client with the JWKS endpoint which exposes your signing keys
1919
const jwksClient = require('jwks-rsa');
2020

2121
const client = jwksClient({
22-
strictSsl: true, // Default value
2322
jwksUri: 'https://sandrino.auth0.com/.well-known/jwks.json',
2423
requestHeaders: {}, // Optional
2524
timeout: 30000 // Defaults to 30s
@@ -30,15 +29,34 @@ const key = await client.getSigningKey(kid);
3029
const signingKey = key.getPublicKey();
3130
```
3231

33-
> Note that all methods on the `JwksClient` have asynchronous equivalents, where the promisified name is suffixed with `Async`, e.g., `client.getSigningKeyAsync(kid).then(key => { /* ... */ })`;
34-
35-
Integrations are also provided with:
32+
### Integrations
3633

3734
- [express/express-jwt](examples/express-demo)
3835
- [express/passport-jwt](examples/passport-demo)
3936
- [hapi/hapi-auth-jwt2](examples/hapi-demo)
4037
- [koa/koa-jwt](examples/koa-demo)
4138

39+
### API
40+
41+
#### JwksClient Options
42+
43+
- `jwksUri`: a string that represents the JWKS URI
44+
- `timeout = 30000`: (_optional_) an integer in miliseconds that controls the request timeout
45+
- `cache = true`: (_optional_) enables a LRU Cache [(details)](#caching)
46+
- `rateLimit`: (_optional_) the default fetcher function [(details)](#rate-limiting)
47+
- `fetcher`: (_optional_) a Promise returning function to fetch data from the JWKS URI
48+
- `requestHeaders`: (_optional_) an object of headers to pass to the request
49+
- `requestAgent`: (_optional_) a Node `http.Agent` to be passed to the http(s) request
50+
- `getKeysInterceptor`: (_optional_) a promise returning function hook [(details)](#loading-keys-from-local-file-environment-variable-or-other-externals)
51+
52+
#### Return Values
53+
54+
- `data`: data for the given key resolved by `fetcher` (or undefined if not loaded)
55+
- `error`: error thrown by `fetcher` (or undefined)
56+
- `isValidating`: if there's a request or revalidation loading
57+
- `mutate(data?, shouldRevalidate?)`: function to mutate the cached data
58+
59+
4260
### Caching
4361

4462
By default, signing key verification results are cached in order to prevent excessive HTTP requests to the JWKS endpoint. If a signing key matching the `kid` is found, this will be cached and the next time this `kid` is requested the signing key will be served from the cache. The caching behavior can be configured as seen below:
@@ -86,7 +104,6 @@ certificate authority to establish TLS communication with the `jwks_uri`.
86104
const jwksClient = require("jwks-rsa");
87105
const https = require('https');
88106
const client = jwksClient({
89-
strictSsl: true, // Default value
90107
jwksUri: 'https://my-enterprise-id-provider/.well-known/jwks.json',
91108
requestHeaders: {}, // Optional
92109
requestAgent: new https.Agent({

‎package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jwks-rsa",
3-
"version": "1.12.2",
3+
"version": "2.0.0",
44
"description": "Library to retrieve RSA public keys from a JWKS endpoint",
55
"main": "lib/index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)
Please sign in to comment.