@auth0/auth0-spa-js 2.19.0 → 2.19.1

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.
Files changed (50) hide show
  1. package/dist/auth0-spa-js.development.js +38 -24
  2. package/dist/auth0-spa-js.development.js.map +1 -1
  3. package/dist/auth0-spa-js.production.esm.js +1 -1
  4. package/dist/auth0-spa-js.production.esm.js.map +1 -1
  5. package/dist/auth0-spa-js.production.js +1 -1
  6. package/dist/auth0-spa-js.production.js.map +1 -1
  7. package/dist/lib/auth0-spa-js.cjs.js +38 -24
  8. package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
  9. package/dist/typings/Auth0Client.d.ts +476 -476
  10. package/dist/typings/Auth0Client.utils.d.ts +90 -90
  11. package/dist/typings/MyAccountApiClient.d.ts +92 -92
  12. package/dist/typings/TokenExchange.d.ts +77 -77
  13. package/dist/typings/api.d.ts +33 -33
  14. package/dist/typings/cache/cache-localstorage.d.ts +7 -7
  15. package/dist/typings/cache/cache-manager.d.ts +69 -69
  16. package/dist/typings/cache/cache-memory.d.ts +4 -4
  17. package/dist/typings/cache/index.d.ts +4 -4
  18. package/dist/typings/cache/key-manifest.d.ts +12 -12
  19. package/dist/typings/cache/shared.d.ts +68 -68
  20. package/dist/typings/constants.d.ts +58 -58
  21. package/dist/typings/dpop/dpop.d.ts +17 -17
  22. package/dist/typings/dpop/storage.d.ts +27 -27
  23. package/dist/typings/dpop/utils.d.ts +15 -15
  24. package/dist/typings/errors.d.ts +96 -96
  25. package/dist/typings/fetcher.d.ts +54 -54
  26. package/dist/typings/global.d.ts +826 -826
  27. package/dist/typings/http.d.ts +11 -11
  28. package/dist/typings/index.d.ts +24 -24
  29. package/dist/typings/jwt.d.ts +21 -21
  30. package/dist/typings/lock.d.ts +32 -32
  31. package/dist/typings/mfa/MfaApiClient.d.ts +225 -225
  32. package/dist/typings/mfa/MfaContextManager.d.ts +79 -79
  33. package/dist/typings/mfa/constants.d.ts +23 -23
  34. package/dist/typings/mfa/errors.d.ts +117 -117
  35. package/dist/typings/mfa/index.d.ts +4 -4
  36. package/dist/typings/mfa/types.d.ts +181 -181
  37. package/dist/typings/mfa/utils.d.ts +23 -23
  38. package/dist/typings/promise-utils.d.ts +2 -2
  39. package/dist/typings/scope.d.ts +35 -35
  40. package/dist/typings/storage.d.ts +26 -26
  41. package/dist/typings/transaction-manager.d.ts +33 -33
  42. package/dist/typings/utils.d.ts +36 -36
  43. package/dist/typings/version.d.ts +2 -2
  44. package/dist/typings/worker/token.worker.d.ts +1 -1
  45. package/dist/typings/worker/worker.types.d.ts +27 -27
  46. package/dist/typings/worker/worker.utils.d.ts +13 -13
  47. package/package.json +1 -1
  48. package/src/api.ts +15 -11
  49. package/src/cache/cache-manager.ts +28 -9
  50. package/src/version.ts +1 -1
@@ -15,7 +15,7 @@
15
15
  var e = new Error(message);
16
16
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
17
17
  };
18
- var version = "2.19.0";
18
+ var version = "2.19.1";
19
19
  const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
20
20
  const DEFAULT_POPUP_CONFIG_OPTIONS = {
21
21
  timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
@@ -1350,20 +1350,24 @@
1350
1350
  token_type_hint: token_type_hint
1351
1351
  };
1352
1352
  const body = useFormData ? createQueryParams(baseParams) : JSON.stringify(baseParams);
1353
- return sendMessage({
1354
- type: "revoke",
1355
- timeout: resolvedTimeout,
1356
- fetchUrl: fetchUrl,
1357
- fetchOptions: {
1358
- method: "POST",
1359
- body: body,
1360
- headers: headers
1361
- },
1362
- useFormData: useFormData,
1363
- auth: {
1364
- audience: audience !== null && audience !== void 0 ? audience : DEFAULT_AUDIENCE
1365
- }
1366
- }, worker);
1353
+ try {
1354
+ return await sendMessage({
1355
+ type: "revoke",
1356
+ timeout: resolvedTimeout,
1357
+ fetchUrl: fetchUrl,
1358
+ fetchOptions: {
1359
+ method: "POST",
1360
+ body: body,
1361
+ headers: headers
1362
+ },
1363
+ useFormData: useFormData,
1364
+ auth: {
1365
+ audience: audience !== null && audience !== void 0 ? audience : DEFAULT_AUDIENCE
1366
+ }
1367
+ }, worker);
1368
+ } catch (e) {
1369
+ throw new GenericError("revoke_error", e.message);
1370
+ }
1367
1371
  }
1368
1372
  for (const refreshToken of refreshTokens) {
1369
1373
  const params = {
@@ -1546,12 +1550,14 @@
1546
1550
  let cacheMode = arguments.length > 3 ? arguments[3] : undefined;
1547
1551
  var _a;
1548
1552
  let wrappedEntry = await this.cache.get(cacheKey.toKey());
1553
+ let resolvedCacheKey = cacheKey;
1549
1554
  if (!wrappedEntry) {
1550
1555
  const keys = await this.getCacheKeys();
1551
1556
  if (!keys) return;
1552
1557
  const matchedKey = this.matchExistingCacheKey(cacheKey, keys);
1553
1558
  if (matchedKey) {
1554
1559
  wrappedEntry = await this.cache.get(matchedKey);
1560
+ resolvedCacheKey = CacheKey.fromKey(matchedKey);
1555
1561
  }
1556
1562
  if (!wrappedEntry && useMrrt && cacheMode !== "cache-only") {
1557
1563
  return this.getEntryWithRefreshToken(cacheKey, keys);
@@ -1564,25 +1570,29 @@
1564
1570
  const nowSeconds = Math.floor(now / 1e3);
1565
1571
  if (wrappedEntry.expiresAt - expiryAdjustmentSeconds < nowSeconds) {
1566
1572
  if (wrappedEntry.body.refresh_token) {
1567
- return this.modifiedCachedEntry(wrappedEntry, cacheKey);
1573
+ return this.modifiedCachedEntry(wrappedEntry, resolvedCacheKey);
1568
1574
  }
1569
- await this.cache.remove(cacheKey.toKey());
1570
- await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.remove(cacheKey.toKey()));
1575
+ await this.cache.remove(resolvedCacheKey.toKey());
1576
+ await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.remove(resolvedCacheKey.toKey()));
1571
1577
  return;
1572
1578
  }
1573
1579
  return wrappedEntry.body;
1574
1580
  }
1575
1581
  async modifiedCachedEntry(wrappedEntry, cacheKey) {
1576
- wrappedEntry.body = {
1582
+ const strippedBody = {
1577
1583
  refresh_token: wrappedEntry.body.refresh_token,
1578
1584
  audience: wrappedEntry.body.audience,
1579
1585
  scope: wrappedEntry.body.scope
1580
1586
  };
1581
- await this.cache.set(cacheKey.toKey(), wrappedEntry);
1587
+ const strippedEntry = {
1588
+ body: strippedBody,
1589
+ expiresAt: wrappedEntry.expiresAt
1590
+ };
1591
+ await this.cache.set(cacheKey.toKey(), strippedEntry);
1582
1592
  return {
1583
- refresh_token: wrappedEntry.body.refresh_token,
1584
- audience: wrappedEntry.body.audience,
1585
- scope: wrappedEntry.body.scope
1593
+ refresh_token: strippedBody.refresh_token,
1594
+ audience: strippedBody.audience,
1595
+ scope: strippedBody.scope
1586
1596
  };
1587
1597
  }
1588
1598
  async set(entry) {
@@ -1664,7 +1674,11 @@
1664
1674
  if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId) {
1665
1675
  const cachedEntry = await this.cache.get(key);
1666
1676
  if ((_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
1667
- return this.modifiedCachedEntry(cachedEntry, keyToMatch);
1677
+ return {
1678
+ refresh_token: cachedEntry.body.refresh_token,
1679
+ audience: cachedEntry.body.audience,
1680
+ scope: cachedEntry.body.scope
1681
+ };
1668
1682
  }
1669
1683
  }
1670
1684
  }