@auth0/auth0-spa-js 1.22.4 → 1.22.6

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.
@@ -1,2 +1,2 @@
1
- declare const _default: "1.22.4";
1
+ declare const _default: "1.22.6";
2
2
  export default _default;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "@auth0/auth0-spa-js",
4
4
  "description": "Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE",
5
5
  "license": "MIT",
6
- "version": "1.22.4",
6
+ "version": "1.22.6",
7
7
  "main": "dist/lib/auth0-spa-js.cjs.js",
8
8
  "types": "dist/typings/index.d.ts",
9
9
  "module": "dist/auth0-spa-js.production.esm.js",
@@ -42,7 +42,7 @@
42
42
  "cli-table": "^0.3.6",
43
43
  "concurrently": "^6.4.0",
44
44
  "cypress": "7.2.0",
45
- "es-check": "^6.1.1",
45
+ "es-check": "^7.0.1",
46
46
  "eslint": "^7.32.0",
47
47
  "gzip-size": "^6.0.0",
48
48
  "husky": "^7.0.4",
@@ -50,7 +50,7 @@
50
50
  "jest": "^27.3.1",
51
51
  "jest-junit": "^13.0.0",
52
52
  "jest-localstorage-mock": "^2.4.18",
53
- "jsonwebtoken": "^8.5.1",
53
+ "jsonwebtoken": "^9.0.0",
54
54
  "oidc-provider": "^7.10.1",
55
55
  "prettier": "^2.4.1",
56
56
  "pretty-quick": "^3.1.2",
@@ -79,9 +79,9 @@
79
79
  "dependencies": {
80
80
  "abortcontroller-polyfill": "^1.7.3",
81
81
  "browser-tabs-lock": "^1.2.15",
82
- "core-js": "^3.24.0",
82
+ "core-js": "^3.25.4",
83
83
  "es-cookie": "~1.3.2",
84
- "fast-text-encoding": "^1.0.4",
84
+ "fast-text-encoding": "^1.0.6",
85
85
  "promise-polyfill": "^8.2.3",
86
86
  "unfetch": "^4.2.0"
87
87
  },
@@ -857,7 +857,7 @@ export default class Auth0Client {
857
857
  scope: getUniqueScopes(this.defaultScope, this.scope, options.scope)
858
858
  };
859
859
 
860
- return singlePromise(
860
+ const result = await singlePromise(
861
861
  () =>
862
862
  this._getTokenSilently({
863
863
  ignoreCache,
@@ -865,11 +865,13 @@ export default class Auth0Client {
865
865
  }),
866
866
  `${this.options.client_id}::${getTokenOptions.audience}::${getTokenOptions.scope}`
867
867
  );
868
+
869
+ return options.detailedResponse ? result : result.access_token;
868
870
  }
869
871
 
870
872
  private async _getTokenSilently(
871
873
  options: GetTokenSilentlyOptions = {}
872
- ): Promise<string | GetTokenSilentlyVerboseResponse> {
874
+ ): Promise<GetTokenSilentlyVerboseResponse> {
873
875
  const { ignoreCache, ...getTokenOptions } = options;
874
876
 
875
877
  // Check the cache before acquiring the lock to avoid the latency of
@@ -878,8 +880,7 @@ export default class Auth0Client {
878
880
  const entry = await this._getEntryFromCache({
879
881
  scope: getTokenOptions.scope,
880
882
  audience: getTokenOptions.audience || 'default',
881
- client_id: this.options.client_id,
882
- getDetailedEntry: options.detailedResponse
883
+ client_id: this.options.client_id
883
884
  });
884
885
 
885
886
  if (entry) {
@@ -902,8 +903,7 @@ export default class Auth0Client {
902
903
  const entry = await this._getEntryFromCache({
903
904
  scope: getTokenOptions.scope,
904
905
  audience: getTokenOptions.audience || 'default',
905
- client_id: this.options.client_id,
906
- getDetailedEntry: options.detailedResponse
906
+ client_id: this.options.client_id
907
907
  });
908
908
 
909
909
  if (entry) {
@@ -925,19 +925,15 @@ export default class Auth0Client {
925
925
  cookieDomain: this.options.cookieDomain
926
926
  });
927
927
 
928
- if (options.detailedResponse) {
929
- const { id_token, access_token, oauthTokenScope, expires_in } =
930
- authResult;
931
-
932
- return {
933
- id_token,
934
- access_token,
935
- ...(oauthTokenScope ? { scope: oauthTokenScope } : null),
936
- expires_in
937
- };
938
- }
928
+ const { id_token, access_token, oauthTokenScope, expires_in } =
929
+ authResult;
939
930
 
940
- return authResult.access_token;
931
+ return {
932
+ id_token,
933
+ access_token,
934
+ ...(oauthTokenScope ? { scope: oauthTokenScope } : null),
935
+ expires_in
936
+ };
941
937
  } finally {
942
938
  await lock.releaseLock(GET_TOKEN_SILENTLY_LOCK_KEY);
943
939
  window.removeEventListener('pagehide', this._releaseLockOnPageHide);
@@ -1285,13 +1281,11 @@ export default class Auth0Client {
1285
1281
  private async _getEntryFromCache({
1286
1282
  scope,
1287
1283
  audience,
1288
- client_id,
1289
- getDetailedEntry = false
1284
+ client_id
1290
1285
  }: {
1291
1286
  scope: string;
1292
1287
  audience: string;
1293
1288
  client_id: string;
1294
- getDetailedEntry?: boolean;
1295
1289
  }) {
1296
1290
  const entry = await this.cacheManager.get(
1297
1291
  new CacheKey({
@@ -1303,18 +1297,14 @@ export default class Auth0Client {
1303
1297
  );
1304
1298
 
1305
1299
  if (entry && entry.access_token) {
1306
- if (getDetailedEntry) {
1307
- const { id_token, access_token, oauthTokenScope, expires_in } = entry;
1300
+ const { id_token, access_token, oauthTokenScope, expires_in } = entry;
1308
1301
 
1309
- return {
1310
- id_token,
1311
- access_token,
1312
- ...(oauthTokenScope ? { scope: oauthTokenScope } : null),
1313
- expires_in
1314
- };
1315
- }
1316
-
1317
- return entry.access_token;
1302
+ return {
1303
+ id_token,
1304
+ access_token,
1305
+ ...(oauthTokenScope ? { scope: oauthTokenScope } : null),
1306
+ expires_in
1307
+ };
1318
1308
  }
1319
1309
  }
1320
1310
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '1.22.4';
1
+ export default '1.22.6';
@@ -16,6 +16,7 @@ export const sendMessage = (message: WorkerRefreshTokenMessage, to: Worker) =>
16
16
  } else {
17
17
  resolve(event.data);
18
18
  }
19
+ messageChannel.port1.close();
19
20
  };
20
21
 
21
22
  to.postMessage(message, [messageChannel.port2]);