@auth0/auth0-spa-js 1.22.1 → 1.22.4

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.
@@ -207,4 +207,11 @@ export default class Auth0Client {
207
207
  private _getTokenFromIFrame;
208
208
  private _getTokenUsingRefreshToken;
209
209
  private _getEntryFromCache;
210
+ /**
211
+ * Releases any lock acquired by the current page that's not released yet
212
+ *
213
+ * Get's called on the `pagehide` event.
214
+ * https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event
215
+ */
216
+ private _releaseLockOnPageHide;
210
217
  }
@@ -1,5 +1,5 @@
1
1
  interface ClientStorageOptions {
2
- daysUntilExpire: number;
2
+ daysUntilExpire?: number;
3
3
  cookieDomain?: string;
4
4
  }
5
5
  /**
@@ -8,7 +8,7 @@ interface ClientStorageOptions {
8
8
  export declare type ClientStorage = {
9
9
  get<T extends Object>(key: string): T | undefined;
10
10
  save(key: string, value: any, options?: ClientStorageOptions): void;
11
- remove(key: string): void;
11
+ remove(key: string, options?: ClientStorageOptions): void;
12
12
  };
13
13
  /**
14
14
  * A storage protocol for marshalling data to/from cookies
@@ -1,2 +1,2 @@
1
- declare const _default: "1.22.1";
1
+ declare const _default: "1.22.4";
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.1",
6
+ "version": "1.22.4",
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",
@@ -40,7 +40,6 @@
40
40
  "@typescript-eslint/parser": "^4.33.0",
41
41
  "browserstack-cypress-cli": "1.8.1",
42
42
  "cli-table": "^0.3.6",
43
- "codecov": "^3.8.3",
44
43
  "concurrently": "^6.4.0",
45
44
  "cypress": "7.2.0",
46
45
  "es-check": "^6.1.1",
@@ -53,7 +52,6 @@
53
52
  "jest-localstorage-mock": "^2.4.18",
54
53
  "jsonwebtoken": "^8.5.1",
55
54
  "oidc-provider": "^7.10.1",
56
- "pem": "^1.14.4",
57
55
  "prettier": "^2.4.1",
58
56
  "pretty-quick": "^3.1.2",
59
57
  "qss": "^2.0.3",
@@ -81,9 +79,9 @@
81
79
  "dependencies": {
82
80
  "abortcontroller-polyfill": "^1.7.3",
83
81
  "browser-tabs-lock": "^1.2.15",
84
- "core-js": "^3.22.6",
85
- "es-cookie": "^1.3.2",
86
- "fast-text-encoding": "^1.0.3",
82
+ "core-js": "^3.24.0",
83
+ "es-cookie": "~1.3.2",
84
+ "fast-text-encoding": "^1.0.4",
87
85
  "promise-polyfill": "^8.2.3",
88
86
  "unfetch": "^4.2.0"
89
87
  },
@@ -175,14 +175,17 @@ const getCustomInitialOptions = (
175
175
  auth0Client,
176
176
  authorizeTimeoutInSeconds,
177
177
  cacheLocation,
178
+ cache,
178
179
  client_id,
179
180
  domain,
180
181
  issuer,
181
182
  leeway,
182
183
  max_age,
184
+ nowProvider,
183
185
  redirect_uri,
184
186
  scope,
185
187
  useRefreshTokens,
188
+ useRefreshTokensFallback,
186
189
  useCookiesForTransactions,
187
190
  useFormData,
188
191
  ...customParams
@@ -400,7 +403,9 @@ export default class Auth0Client {
400
403
  cookieDomain: this.options.cookieDomain
401
404
  });
402
405
  } else {
403
- this.cookieStorage.remove(this.orgHintCookieName);
406
+ this.cookieStorage.remove(this.orgHintCookieName, {
407
+ cookieDomain: this.options.cookieDomain
408
+ });
404
409
  }
405
410
  }
406
411
 
@@ -889,6 +894,8 @@ export default class Auth0Client {
889
894
  )
890
895
  ) {
891
896
  try {
897
+ window.addEventListener('pagehide', this._releaseLockOnPageHide);
898
+
892
899
  // Check the cache a second time, because it may have been populated
893
900
  // by a previous call while this call was waiting to acquire the lock.
894
901
  if (!ignoreCache) {
@@ -933,6 +940,7 @@ export default class Auth0Client {
933
940
  return authResult.access_token;
934
941
  } finally {
935
942
  await lock.releaseLock(GET_TOKEN_SILENTLY_LOCK_KEY);
943
+ window.removeEventListener('pagehide', this._releaseLockOnPageHide);
936
944
  }
937
945
  } else {
938
946
  throw new TimeoutError();
@@ -1045,8 +1053,12 @@ export default class Auth0Client {
1045
1053
  }
1046
1054
 
1047
1055
  const postCacheClear = () => {
1048
- this.cookieStorage.remove(this.orgHintCookieName);
1049
- this.cookieStorage.remove(this.isAuthenticatedCookieName);
1056
+ this.cookieStorage.remove(this.orgHintCookieName, {
1057
+ cookieDomain: this.options.cookieDomain
1058
+ });
1059
+ this.cookieStorage.remove(this.isAuthenticatedCookieName, {
1060
+ cookieDomain: this.options.cookieDomain
1061
+ });
1050
1062
 
1051
1063
  if (localOnly) {
1052
1064
  return;
@@ -1305,4 +1317,16 @@ export default class Auth0Client {
1305
1317
  return entry.access_token;
1306
1318
  }
1307
1319
  }
1320
+
1321
+ /**
1322
+ * Releases any lock acquired by the current page that's not released yet
1323
+ *
1324
+ * Get's called on the `pagehide` event.
1325
+ * https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event
1326
+ */
1327
+ private _releaseLockOnPageHide = async () => {
1328
+ await lock.releaseLock(GET_TOKEN_SILENTLY_LOCK_KEY);
1329
+
1330
+ window.removeEventListener('pagehide', this._releaseLockOnPageHide);
1331
+ };
1308
1332
  }
package/src/storage.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as Cookies from 'es-cookie';
2
2
 
3
3
  interface ClientStorageOptions {
4
- daysUntilExpire: number;
4
+ daysUntilExpire?: number;
5
5
  cookieDomain?: string;
6
6
  }
7
7
 
@@ -11,7 +11,7 @@ interface ClientStorageOptions {
11
11
  export type ClientStorage = {
12
12
  get<T extends Object>(key: string): T | undefined;
13
13
  save(key: string, value: any, options?: ClientStorageOptions): void;
14
- remove(key: string): void;
14
+ remove(key: string, options?: ClientStorageOptions): void;
15
15
  };
16
16
 
17
17
  /**
@@ -49,8 +49,14 @@ export const CookieStorage = {
49
49
  Cookies.set(key, JSON.stringify(value), cookieAttributes);
50
50
  },
51
51
 
52
- remove(key: string) {
53
- Cookies.remove(key);
52
+ remove(key: string, options?: ClientStorageOptions) {
53
+ let cookieAttributes: Cookies.CookieAttributes = {};
54
+
55
+ if (options?.cookieDomain) {
56
+ cookieAttributes.domain = options.cookieDomain;
57
+ }
58
+
59
+ Cookies.remove(key ,cookieAttributes);
54
60
  }
55
61
  } as ClientStorage;
56
62
 
@@ -93,9 +99,16 @@ export const CookieStorageWithLegacySameSite = {
93
99
  CookieStorage.save(key, value, options);
94
100
  },
95
101
 
96
- remove(key: string) {
97
- CookieStorage.remove(key);
98
- CookieStorage.remove(`${LEGACY_PREFIX}${key}`);
102
+ remove(key: string, options?: ClientStorageOptions) {
103
+ let cookieAttributes: Cookies.CookieAttributes = {};
104
+
105
+ if (options?.cookieDomain) {
106
+ cookieAttributes.domain = options.cookieDomain;
107
+ }
108
+
109
+ Cookies.remove(key ,cookieAttributes);
110
+ CookieStorage.remove(key, options);
111
+ CookieStorage.remove(`${LEGACY_PREFIX}${key}`, options);
99
112
  }
100
113
  } as ClientStorage;
101
114
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '1.22.1';
1
+ export default '1.22.4';