openid-client 4.4.1 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [4.4.2](https://github.com/panva/node-openid-client/compare/v4.4.1...v4.4.2) (2021-03-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * resolve discovery URIs one by one to yield consistent results ([6b18218](https://github.com/panva/node-openid-client/commit/6b18218cfa098195ec8442086221a88fa6aef654)), closes [#260](https://github.com/panva/node-openid-client/issues/260) [#267](https://github.com/panva/node-openid-client/issues/267)
11
+
5
12
  ## [4.4.1](https://github.com/panva/node-openid-client/compare/v4.4.0...v4.4.1) (2021-02-26)
6
13
 
7
14
 
package/lib/issuer.js CHANGED
@@ -3,8 +3,8 @@
3
3
  const { inspect } = require('util');
4
4
  const url = require('url');
5
5
 
6
+ const AggregateError = require('aggregate-error');
6
7
  const jose = require('jose');
7
- const pAny = require('p-any');
8
8
  const LRU = require('lru-cache');
9
9
  const objectHash = require('object-hash');
10
10
 
@@ -240,40 +240,46 @@ class Issuer {
240
240
  });
241
241
  }
242
242
 
243
- const uris = [];
244
- if (parsed.pathname === '/') {
245
- uris.push(`${OAUTH2_DISCOVERY}`);
243
+ const pathnames = [];
244
+ if (parsed.pathname.endsWith('/')) {
245
+ pathnames.push(`${parsed.pathname}${OIDC_DISCOVERY.substring(1)}`);
246
246
  } else {
247
- uris.push(`${OAUTH2_DISCOVERY}${parsed.pathname}`);
247
+ pathnames.push(`${parsed.pathname}${OIDC_DISCOVERY}`);
248
248
  }
249
- if (parsed.pathname.endsWith('/')) {
250
- uris.push(`${parsed.pathname}${OIDC_DISCOVERY.substring(1)}`);
249
+ if (parsed.pathname === '/') {
250
+ pathnames.push(`${OAUTH2_DISCOVERY}`);
251
251
  } else {
252
- uris.push(`${parsed.pathname}${OIDC_DISCOVERY}`);
252
+ pathnames.push(`${OAUTH2_DISCOVERY}${parsed.pathname}`);
253
253
  }
254
254
 
255
- return pAny(uris.map(async (pathname) => {
256
- const wellKnownUri = url.format({ ...parsed, pathname });
257
- const response = await request.call(this, {
258
- method: 'GET',
259
- responseType: 'json',
260
- url: wellKnownUri,
261
- });
262
- const body = processResponse(response);
263
- return new Issuer({
264
- ...ISSUER_DEFAULTS,
265
- ...body,
266
- [AAD_MULTITENANT]: !!AAD_MULTITENANT_DISCOVERY.find(
267
- (discoveryURL) => wellKnownUri.startsWith(discoveryURL),
268
- ),
269
- });
270
- })).catch((err) => {
271
- if (err instanceof pAny.AggregateError) {
272
- err.message = `Issuer.discover() failed.${err.message.split('\n')
273
- .filter((line) => !line.startsWith(' at')).join('\n')}`;
255
+ const errors = [];
256
+ // eslint-disable-next-line no-restricted-syntax
257
+ for (const pathname of pathnames) {
258
+ try {
259
+ const wellKnownUri = url.format({ ...parsed, pathname });
260
+ // eslint-disable-next-line no-await-in-loop
261
+ const response = await request.call(this, {
262
+ method: 'GET',
263
+ responseType: 'json',
264
+ url: wellKnownUri,
265
+ });
266
+ const body = processResponse(response);
267
+ return new Issuer({
268
+ ...ISSUER_DEFAULTS,
269
+ ...body,
270
+ [AAD_MULTITENANT]: !!AAD_MULTITENANT_DISCOVERY.find(
271
+ (discoveryURL) => wellKnownUri.startsWith(discoveryURL),
272
+ ),
273
+ });
274
+ } catch (err) {
275
+ errors.push(err);
274
276
  }
275
- throw err;
276
- });
277
+ }
278
+
279
+ const err = new AggregateError(errors);
280
+ err.message = `Issuer.discover() failed.${err.message.split('\n')
281
+ .filter((line) => !line.startsWith(' at')).join('\n')}`;
282
+ throw err;
277
283
  }
278
284
 
279
285
  /* istanbul ignore next */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openid-client",
3
- "version": "4.4.1",
3
+ "version": "4.4.2",
4
4
  "description": "OpenID Connect Relying Party (RP, Client) implementation for Node.js runtime, supports passportjs",
5
5
  "keywords": [
6
6
  "auth",
@@ -63,13 +63,13 @@
63
63
  ]
64
64
  },
65
65
  "dependencies": {
66
+ "aggregate-error": "^3.1.0",
66
67
  "got": "^11.8.0",
67
68
  "jose": "^2.0.4",
68
69
  "lru-cache": "^6.0.0",
69
70
  "make-error": "^1.3.6",
70
71
  "object-hash": "^2.0.1",
71
- "oidc-token-hash": "^5.0.1",
72
- "p-any": "^3.0.0"
72
+ "oidc-token-hash": "^5.0.1"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@commitlint/cli": "^11.0.0",