@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
@@ -18,7 +18,7 @@ typeof SuppressedError === "function" ? SuppressedError : function(error, suppre
18
18
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
19
19
  };
20
20
 
21
- var version = "2.19.0";
21
+ var version = "2.19.1";
22
22
 
23
23
  const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
24
24
 
@@ -1466,20 +1466,24 @@ async function revokeToken(_ref, worker) {
1466
1466
  token_type_hint: token_type_hint
1467
1467
  };
1468
1468
  const body = useFormData ? createQueryParams(baseParams) : JSON.stringify(baseParams);
1469
- return sendMessage({
1470
- type: "revoke",
1471
- timeout: resolvedTimeout,
1472
- fetchUrl: fetchUrl,
1473
- fetchOptions: {
1474
- method: "POST",
1475
- body: body,
1476
- headers: headers
1477
- },
1478
- useFormData: useFormData,
1479
- auth: {
1480
- audience: audience !== null && audience !== void 0 ? audience : DEFAULT_AUDIENCE
1481
- }
1482
- }, worker);
1469
+ try {
1470
+ return await sendMessage({
1471
+ type: "revoke",
1472
+ timeout: resolvedTimeout,
1473
+ fetchUrl: fetchUrl,
1474
+ fetchOptions: {
1475
+ method: "POST",
1476
+ body: body,
1477
+ headers: headers
1478
+ },
1479
+ useFormData: useFormData,
1480
+ auth: {
1481
+ audience: audience !== null && audience !== void 0 ? audience : DEFAULT_AUDIENCE
1482
+ }
1483
+ }, worker);
1484
+ } catch (e) {
1485
+ throw new GenericError("revoke_error", e.message);
1486
+ }
1483
1487
  }
1484
1488
  for (const refreshToken of refreshTokens) {
1485
1489
  const params = {
@@ -1673,12 +1677,14 @@ class CacheManager {
1673
1677
  let cacheMode = arguments.length > 3 ? arguments[3] : undefined;
1674
1678
  var _a;
1675
1679
  let wrappedEntry = await this.cache.get(cacheKey.toKey());
1680
+ let resolvedCacheKey = cacheKey;
1676
1681
  if (!wrappedEntry) {
1677
1682
  const keys = await this.getCacheKeys();
1678
1683
  if (!keys) return;
1679
1684
  const matchedKey = this.matchExistingCacheKey(cacheKey, keys);
1680
1685
  if (matchedKey) {
1681
1686
  wrappedEntry = await this.cache.get(matchedKey);
1687
+ resolvedCacheKey = CacheKey.fromKey(matchedKey);
1682
1688
  }
1683
1689
  if (!wrappedEntry && useMrrt && cacheMode !== "cache-only") {
1684
1690
  return this.getEntryWithRefreshToken(cacheKey, keys);
@@ -1691,25 +1697,29 @@ class CacheManager {
1691
1697
  const nowSeconds = Math.floor(now / 1e3);
1692
1698
  if (wrappedEntry.expiresAt - expiryAdjustmentSeconds < nowSeconds) {
1693
1699
  if (wrappedEntry.body.refresh_token) {
1694
- return this.modifiedCachedEntry(wrappedEntry, cacheKey);
1700
+ return this.modifiedCachedEntry(wrappedEntry, resolvedCacheKey);
1695
1701
  }
1696
- await this.cache.remove(cacheKey.toKey());
1697
- await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.remove(cacheKey.toKey()));
1702
+ await this.cache.remove(resolvedCacheKey.toKey());
1703
+ await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.remove(resolvedCacheKey.toKey()));
1698
1704
  return;
1699
1705
  }
1700
1706
  return wrappedEntry.body;
1701
1707
  }
1702
1708
  async modifiedCachedEntry(wrappedEntry, cacheKey) {
1703
- wrappedEntry.body = {
1709
+ const strippedBody = {
1704
1710
  refresh_token: wrappedEntry.body.refresh_token,
1705
1711
  audience: wrappedEntry.body.audience,
1706
1712
  scope: wrappedEntry.body.scope
1707
1713
  };
1708
- await this.cache.set(cacheKey.toKey(), wrappedEntry);
1714
+ const strippedEntry = {
1715
+ body: strippedBody,
1716
+ expiresAt: wrappedEntry.expiresAt
1717
+ };
1718
+ await this.cache.set(cacheKey.toKey(), strippedEntry);
1709
1719
  return {
1710
- refresh_token: wrappedEntry.body.refresh_token,
1711
- audience: wrappedEntry.body.audience,
1712
- scope: wrappedEntry.body.scope
1720
+ refresh_token: strippedBody.refresh_token,
1721
+ audience: strippedBody.audience,
1722
+ scope: strippedBody.scope
1713
1723
  };
1714
1724
  }
1715
1725
  async set(entry) {
@@ -1791,7 +1801,11 @@ class CacheManager {
1791
1801
  if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId) {
1792
1802
  const cachedEntry = await this.cache.get(key);
1793
1803
  if ((_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
1794
- return this.modifiedCachedEntry(cachedEntry, keyToMatch);
1804
+ return {
1805
+ refresh_token: cachedEntry.body.refresh_token,
1806
+ audience: cachedEntry.body.audience,
1807
+ scope: cachedEntry.body.scope
1808
+ };
1795
1809
  }
1796
1810
  }
1797
1811
  }