@auth0/auth0-spa-js 2.18.0 → 2.18.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.
Files changed (55) hide show
  1. package/dist/auth0-spa-js.development.js +330 -296
  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/auth0-spa-js.worker.development.js +71 -21
  8. package/dist/auth0-spa-js.worker.development.js.map +1 -1
  9. package/dist/auth0-spa-js.worker.production.js +1 -1
  10. package/dist/auth0-spa-js.worker.production.js.map +1 -1
  11. package/dist/lib/auth0-spa-js.cjs.js +353 -316
  12. package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
  13. package/dist/typings/Auth0Client.d.ts +439 -439
  14. package/dist/typings/Auth0Client.utils.d.ts +90 -90
  15. package/dist/typings/MyAccountApiClient.d.ts +92 -92
  16. package/dist/typings/TokenExchange.d.ts +77 -77
  17. package/dist/typings/api.d.ts +2 -2
  18. package/dist/typings/cache/cache-localstorage.d.ts +7 -7
  19. package/dist/typings/cache/cache-manager.d.ts +56 -56
  20. package/dist/typings/cache/cache-memory.d.ts +4 -4
  21. package/dist/typings/cache/index.d.ts +4 -4
  22. package/dist/typings/cache/key-manifest.d.ts +12 -12
  23. package/dist/typings/cache/shared.d.ts +68 -68
  24. package/dist/typings/constants.d.ts +58 -58
  25. package/dist/typings/dpop/dpop.d.ts +17 -17
  26. package/dist/typings/dpop/storage.d.ts +27 -27
  27. package/dist/typings/dpop/utils.d.ts +15 -15
  28. package/dist/typings/errors.d.ts +96 -96
  29. package/dist/typings/fetcher.d.ts +54 -54
  30. package/dist/typings/global.d.ts +819 -819
  31. package/dist/typings/http.d.ts +5 -5
  32. package/dist/typings/index.d.ts +24 -23
  33. package/dist/typings/jwt.d.ts +21 -21
  34. package/dist/typings/lock.d.ts +32 -32
  35. package/dist/typings/mfa/MfaApiClient.d.ts +225 -225
  36. package/dist/typings/mfa/MfaContextManager.d.ts +79 -79
  37. package/dist/typings/mfa/constants.d.ts +23 -23
  38. package/dist/typings/mfa/errors.d.ts +117 -117
  39. package/dist/typings/mfa/index.d.ts +4 -4
  40. package/dist/typings/mfa/types.d.ts +181 -181
  41. package/dist/typings/mfa/utils.d.ts +23 -23
  42. package/dist/typings/promise-utils.d.ts +2 -2
  43. package/dist/typings/scope.d.ts +35 -35
  44. package/dist/typings/storage.d.ts +26 -26
  45. package/dist/typings/transaction-manager.d.ts +33 -33
  46. package/dist/typings/utils.d.ts +36 -36
  47. package/dist/typings/version.d.ts +2 -2
  48. package/dist/typings/worker/token.worker.d.ts +1 -1
  49. package/dist/typings/worker/worker.types.d.ts +15 -15
  50. package/dist/typings/worker/worker.utils.d.ts +7 -7
  51. package/package.json +6 -4
  52. package/src/Auth0Client.ts +10 -7
  53. package/src/index.ts +6 -3
  54. package/src/utils.ts +2 -1
  55. package/src/version.ts +1 -1
@@ -4,21 +4,163 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- function __rest(s, e) {
7
+ function _OverloadYield(e, d) {
8
+ this.v = e, this.k = d;
9
+ }
10
+
11
+ function _assertClassBrand(e, t, n) {
12
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
13
+ throw new TypeError("Private element is not present on this object");
14
+ }
15
+
16
+ function _awaitAsyncGenerator(e) {
17
+ return new _OverloadYield(e, 0);
18
+ }
19
+
20
+ function _checkPrivateRedeclaration(e, t) {
21
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
22
+ }
23
+
24
+ function _classPrivateFieldGet2(s, a) {
25
+ return s.get(_assertClassBrand(s, a));
26
+ }
27
+
28
+ function _classPrivateFieldInitSpec(e, t, a) {
29
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
30
+ }
31
+
32
+ function _classPrivateFieldSet2(s, a, r) {
33
+ return s.set(_assertClassBrand(s, a), r), r;
34
+ }
35
+
36
+ function _classPrivateMethodInitSpec(e, a) {
37
+ _checkPrivateRedeclaration(e, a), a.add(e);
38
+ }
39
+
40
+ function _defineProperty(e, r, t) {
41
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
42
+ value: t,
43
+ enumerable: !0,
44
+ configurable: !0,
45
+ writable: !0
46
+ }) : e[r] = t, e;
47
+ }
48
+
49
+ function ownKeys(e, r) {
50
+ var t = Object.keys(e);
51
+ if (Object.getOwnPropertySymbols) {
52
+ var o = Object.getOwnPropertySymbols(e);
53
+ r && (o = o.filter(function(r) {
54
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
55
+ })), t.push.apply(t, o);
56
+ }
57
+ return t;
58
+ }
59
+
60
+ function _objectSpread2(e) {
61
+ for (var r = 1; r < arguments.length; r++) {
62
+ var t = null != arguments[r] ? arguments[r] : {};
63
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
64
+ _defineProperty(e, r, t[r]);
65
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
66
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
67
+ });
68
+ }
69
+ return e;
70
+ }
71
+
72
+ function _objectWithoutProperties(e, t) {
73
+ if (null == e) return {};
74
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
75
+ if (Object.getOwnPropertySymbols) {
76
+ var n = Object.getOwnPropertySymbols(e);
77
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
78
+ }
79
+ return i;
80
+ }
81
+
82
+ function _objectWithoutPropertiesLoose(r, e) {
83
+ if (null == r) return {};
8
84
  var t = {};
9
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
10
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
85
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
86
+ if (-1 !== e.indexOf(n)) continue;
87
+ t[n] = r[n];
12
88
  }
13
89
  return t;
14
90
  }
15
91
 
16
- typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
17
- var e = new Error(message);
18
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
92
+ function _toPrimitive(t, r) {
93
+ if ("object" != typeof t || !t) return t;
94
+ var e = t[Symbol.toPrimitive];
95
+ if (void 0 !== e) {
96
+ var i = e.call(t, r || "default");
97
+ if ("object" != typeof i) return i;
98
+ throw new TypeError("@@toPrimitive must return a primitive value.");
99
+ }
100
+ return ("string" === r ? String : Number)(t);
101
+ }
102
+
103
+ function _toPropertyKey(t) {
104
+ var i = _toPrimitive(t, "string");
105
+ return "symbol" == typeof i ? i : i + "";
106
+ }
107
+
108
+ function _wrapAsyncGenerator(e) {
109
+ return function() {
110
+ return new AsyncGenerator(e.apply(this, arguments));
111
+ };
112
+ }
113
+
114
+ function AsyncGenerator(e) {
115
+ var t, n;
116
+ function resume(t, n) {
117
+ try {
118
+ var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
119
+ Promise.resolve(u ? o.v : o).then(function(n) {
120
+ if (u) {
121
+ var i = "return" === t && o.k ? t : "next";
122
+ if (!o.k || n.done) return resume(i, n);
123
+ n = e[i](n).value;
124
+ }
125
+ settle(!!r.done, n);
126
+ }, function(e) {
127
+ resume("throw", e);
128
+ });
129
+ } catch (e) {
130
+ settle(2, e);
131
+ }
132
+ }
133
+ function settle(e, r) {
134
+ 2 === e ? t.reject(r) : t.resolve({
135
+ value: r,
136
+ done: e
137
+ }), (t = t.next) ? resume(t.key, t.arg) : n = null;
138
+ }
139
+ this._invoke = function(e, r) {
140
+ return new Promise(function(o, u) {
141
+ var i = {
142
+ key: e,
143
+ arg: r,
144
+ resolve: o,
145
+ reject: u,
146
+ next: null
147
+ };
148
+ n ? n = n.next = i : (t = n = i, resume(e, r));
149
+ });
150
+ }, "function" != typeof e.return && (this.return = void 0);
151
+ }
152
+
153
+ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
154
+ return this;
155
+ }, AsyncGenerator.prototype.next = function(e) {
156
+ return this._invoke("next", e);
157
+ }, AsyncGenerator.prototype.throw = function(e) {
158
+ return this._invoke("throw", e);
159
+ }, AsyncGenerator.prototype.return = function(e) {
160
+ return this._invoke("return", e);
19
161
  };
20
162
 
21
- var version = "2.18.0";
163
+ var version = "2.18.2";
22
164
 
23
165
  const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
24
166
 
@@ -159,6 +301,8 @@ function valueOrEmptyString(value) {
159
301
  return value && !exclude.includes(value) ? value : "";
160
302
  }
161
303
 
304
+ const _excluded$5 = [ "clientId" ];
305
+
162
306
  const parseAuthenticationResult = queryString => {
163
307
  if (queryString.indexOf("#") > -1) {
164
308
  queryString = queryString.substring(0, queryString.indexOf("#"));
@@ -217,7 +361,7 @@ const openPopup = url => {
217
361
  return window.open(url, "auth0:authorize:popup", "left=".concat(left, ",top=").concat(top, ",width=").concat(width, ",height=").concat(height, ",resizable,scrollbars=yes,status=1"));
218
362
  };
219
363
 
220
- const runPopup = config => new Promise((resolve, reject) => {
364
+ const runPopup = (config, eventOrigin) => new Promise((resolve, reject) => {
221
365
  let _popupEventListener;
222
366
  const popupTimer = setInterval(() => {
223
367
  if (config.popup && config.popup.closed) {
@@ -233,6 +377,7 @@ const runPopup = config => new Promise((resolve, reject) => {
233
377
  window.removeEventListener("message", _popupEventListener, false);
234
378
  }, (config.timeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) * 1e3);
235
379
  _popupEventListener = function popupEventListener(e) {
380
+ if (e.origin !== eventOrigin) return;
236
381
  if (!e.data || e.data.type !== "authorization_response") {
237
382
  return;
238
383
  }
@@ -269,7 +414,7 @@ const createRandomString = () => {
269
414
 
270
415
  const encode$2 = value => btoa(value);
271
416
 
272
- const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) => Object.assign(Object.assign({}, acc), {
417
+ const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) => _objectSpread2(_objectSpread2({}, acc), {}, {
273
418
  [key]: params[key]
274
419
  }), {});
275
420
 
@@ -298,9 +443,9 @@ const stripAuth0Client = function stripAuth0Client(auth0Client) {
298
443
  }, {});
299
444
  };
300
445
 
301
- const createQueryParams = _a => {
302
- var {clientId: client_id} = _a, params = __rest(_a, [ "clientId" ]);
303
- return new URLSearchParams(stripUndefined(Object.assign({
446
+ const createQueryParams = _ref => {
447
+ let {clientId: client_id} = _ref, params = _objectWithoutProperties(_ref, _excluded$5);
448
+ return new URLSearchParams(stripUndefined(_objectSpread2({
304
449
  client_id: client_id
305
450
  }, params))).toString();
306
451
  };
@@ -360,8 +505,8 @@ const parseNumber = value => {
360
505
  return parseInt(value, 10) || undefined;
361
506
  };
362
507
 
363
- const fromEntries = iterable => [ ...iterable ].reduce((obj, _ref) => {
364
- let [key, val] = _ref;
508
+ const fromEntries = iterable => [ ...iterable ].reduce((obj, _ref2) => {
509
+ let [key, val] = _ref2;
365
510
  obj[key] = val;
366
511
  return obj;
367
512
  }, {});
@@ -922,7 +1067,7 @@ class WebLocksApiManager {
922
1067
 
923
1068
  class LegacyLockManager {
924
1069
  constructor() {
925
- this.activeLocks = new Set;
1070
+ _defineProperty(this, "activeLocks", new Set);
926
1071
  this.lock = new _default;
927
1072
  this.pagehideHandler = () => {
928
1073
  this.activeLocks.forEach(key => this.lock.releaseLock(key));
@@ -955,8 +1100,8 @@ class LegacyLockManager {
955
1100
  }
956
1101
 
957
1102
  function isWebLocksSupported() {
958
- var _a;
959
- return typeof navigator !== "undefined" && typeof ((_a = navigator.locks) === null || _a === void 0 ? void 0 : _a.request) === "function";
1103
+ var _navigator$locks;
1104
+ return typeof navigator !== "undefined" && typeof ((_navigator$locks = navigator.locks) === null || _navigator$locks === void 0 ? void 0 : _navigator$locks.request) === "function";
960
1105
  }
961
1106
 
962
1107
  function createLockManager() {
@@ -1326,6 +1471,8 @@ const sendMessage = (message, to) => new Promise(function(resolve, reject) {
1326
1471
  to.postMessage(message, [ messageChannel.port2 ]);
1327
1472
  });
1328
1473
 
1474
+ const _excluded$4 = [ "error", "error_description" ];
1475
+
1329
1476
  const createAbortController = () => new AbortController;
1330
1477
 
1331
1478
  const dofetch = async (fetchUrl, fetchOptions) => {
@@ -1380,7 +1527,7 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
1380
1527
  method: options.method || "GET",
1381
1528
  nonce: await dpop.getNonce()
1382
1529
  });
1383
- options.headers = Object.assign(Object.assign({}, options.headers), {
1530
+ options.headers = _objectSpread2(_objectSpread2({}, options.headers), {}, {
1384
1531
  dpop: dpopProof
1385
1532
  });
1386
1533
  }
@@ -1398,7 +1545,7 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
1398
1545
  if (fetchError) {
1399
1546
  throw fetchError;
1400
1547
  }
1401
- const _a = response.json, {error: error, error_description: error_description} = _a, data = __rest(_a, [ "error", "error_description" ]), {headers: headers, ok: ok} = response;
1548
+ const {json: {error: error, error_description: error_description}, headers: headers, ok: ok} = response, data = _objectWithoutProperties(response.json, _excluded$4);
1402
1549
  let newDpopNonce;
1403
1550
  if (dpop) {
1404
1551
  newDpopNonce = headers[DPOP_NONCE_HEADER];
@@ -1425,11 +1572,13 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
1425
1572
  return data;
1426
1573
  }
1427
1574
 
1428
- async function oauthToken(_a, worker) {
1429
- var {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData, useMrrt: useMrrt, dpop: dpop} = _a, options = __rest(_a, [ "baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData", "useMrrt", "dpop" ]);
1575
+ const _excluded$3 = [ "baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData", "useMrrt", "dpop" ];
1576
+
1577
+ async function oauthToken(_ref, worker) {
1578
+ let {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData, useMrrt: useMrrt, dpop: dpop} = _ref, options = _objectWithoutProperties(_ref, _excluded$3);
1430
1579
  const isTokenExchange = options.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange";
1431
1580
  const refreshWithMrrt = options.grant_type === "refresh_token" && useMrrt;
1432
- const allParams = Object.assign(Object.assign(Object.assign(Object.assign({}, options), isTokenExchange && audience && {
1581
+ const allParams = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, options), isTokenExchange && audience && {
1433
1582
  audience: audience
1434
1583
  }), isTokenExchange && scope && {
1435
1584
  scope: scope
@@ -1547,7 +1696,7 @@ class LocalStorageCache {
1547
1696
 
1548
1697
  class InMemoryCache {
1549
1698
  constructor() {
1550
- this.enclosedCache = function() {
1699
+ _defineProperty(this, "enclosedCache", function() {
1551
1700
  let cache = {};
1552
1701
  return {
1553
1702
  set(key, entry) {
@@ -1567,7 +1716,7 @@ class InMemoryCache {
1567
1716
  return Object.keys(cache);
1568
1717
  }
1569
1718
  };
1570
- }();
1719
+ }());
1571
1720
  }
1572
1721
  }
1573
1722
 
@@ -1580,13 +1729,13 @@ class CacheManager {
1580
1729
  this.nowProvider = nowProvider || DEFAULT_NOW_PROVIDER;
1581
1730
  }
1582
1731
  async setIdToken(clientId, idToken, decodedToken) {
1583
- var _a;
1732
+ var _this$keyManifest;
1584
1733
  const cacheKey = this.getIdTokenCacheKey(clientId);
1585
1734
  await this.cache.set(cacheKey, {
1586
1735
  id_token: idToken,
1587
1736
  decodedToken: decodedToken
1588
1737
  });
1589
- await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.add(cacheKey));
1738
+ await ((_this$keyManifest = this.keyManifest) === null || _this$keyManifest === void 0 ? void 0 : _this$keyManifest.add(cacheKey));
1590
1739
  }
1591
1740
  async getIdToken(cacheKey) {
1592
1741
  const entry = await this.cache.get(this.getIdTokenCacheKey(cacheKey.clientId));
@@ -1615,7 +1764,6 @@ class CacheManager {
1615
1764
  let expiryAdjustmentSeconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_EXPIRY_ADJUSTMENT_SECONDS;
1616
1765
  let useMrrt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1617
1766
  let cacheMode = arguments.length > 3 ? arguments[3] : undefined;
1618
- var _a;
1619
1767
  let wrappedEntry = await this.cache.get(cacheKey.toKey());
1620
1768
  if (!wrappedEntry) {
1621
1769
  const keys = await this.getCacheKeys();
@@ -1634,11 +1782,12 @@ class CacheManager {
1634
1782
  const now = await this.nowProvider();
1635
1783
  const nowSeconds = Math.floor(now / 1e3);
1636
1784
  if (wrappedEntry.expiresAt - expiryAdjustmentSeconds < nowSeconds) {
1785
+ var _this$keyManifest2;
1637
1786
  if (wrappedEntry.body.refresh_token) {
1638
1787
  return this.modifiedCachedEntry(wrappedEntry, cacheKey);
1639
1788
  }
1640
1789
  await this.cache.remove(cacheKey.toKey());
1641
- await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.remove(cacheKey.toKey()));
1790
+ await ((_this$keyManifest2 = this.keyManifest) === null || _this$keyManifest2 === void 0 ? void 0 : _this$keyManifest2.remove(cacheKey.toKey()));
1642
1791
  return;
1643
1792
  }
1644
1793
  return wrappedEntry.body;
@@ -1657,7 +1806,7 @@ class CacheManager {
1657
1806
  };
1658
1807
  }
1659
1808
  async set(entry) {
1660
- var _a;
1809
+ var _this$keyManifest3;
1661
1810
  const cacheKey = new CacheKey({
1662
1811
  clientId: entry.client_id,
1663
1812
  scope: entry.scope,
@@ -1665,7 +1814,7 @@ class CacheManager {
1665
1814
  });
1666
1815
  const wrappedEntry = await this.wrapCacheEntry(entry);
1667
1816
  await this.cache.set(cacheKey.toKey(), wrappedEntry);
1668
- await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.add(cacheKey.toKey()));
1817
+ await ((_this$keyManifest3 = this.keyManifest) === null || _this$keyManifest3 === void 0 ? void 0 : _this$keyManifest3.add(cacheKey.toKey()));
1669
1818
  }
1670
1819
  async remove(client_id, audience, scope) {
1671
1820
  const cacheKey = new CacheKey({
@@ -1676,14 +1825,14 @@ class CacheManager {
1676
1825
  await this.cache.remove(cacheKey.toKey());
1677
1826
  }
1678
1827
  async clear(clientId) {
1679
- var _a;
1828
+ var _this$keyManifest4;
1680
1829
  const keys = await this.getCacheKeys();
1681
1830
  if (!keys) return;
1682
1831
  await keys.filter(key => clientId ? key.includes(clientId) : true).reduce(async (memo, key) => {
1683
1832
  await memo;
1684
1833
  await this.cache.remove(key);
1685
1834
  }, Promise.resolve());
1686
- await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.clear());
1835
+ await ((_this$keyManifest4 = this.keyManifest) === null || _this$keyManifest4 === void 0 ? void 0 : _this$keyManifest4.clear());
1687
1836
  }
1688
1837
  async wrapCacheEntry(entry) {
1689
1838
  const now = await this.nowProvider();
@@ -1694,9 +1843,9 @@ class CacheManager {
1694
1843
  };
1695
1844
  }
1696
1845
  async getCacheKeys() {
1697
- var _a;
1698
1846
  if (this.keyManifest) {
1699
- return (_a = await this.keyManifest.get()) === null || _a === void 0 ? void 0 : _a.keys;
1847
+ var _await$this$keyManife;
1848
+ return (_await$this$keyManife = await this.keyManifest.get()) === null || _await$this$keyManife === void 0 ? void 0 : _await$this$keyManife.keys;
1700
1849
  } else if (this.cache.allKeys) {
1701
1850
  return this.cache.allKeys();
1702
1851
  }
@@ -1708,21 +1857,21 @@ class CacheManager {
1708
1857
  }
1709
1858
  matchExistingCacheKey(keyToMatch, allKeys) {
1710
1859
  return allKeys.filter(key => {
1711
- var _a;
1860
+ var _keyToMatch$scope;
1712
1861
  const cacheKey = CacheKey.fromKey(key);
1713
1862
  const scopeSet = new Set(cacheKey.scope && cacheKey.scope.split(" "));
1714
- const scopesToMatch = ((_a = keyToMatch.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
1863
+ const scopesToMatch = ((_keyToMatch$scope = keyToMatch.scope) === null || _keyToMatch$scope === void 0 ? void 0 : _keyToMatch$scope.split(" ")) || [];
1715
1864
  const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((acc, current) => acc && scopeSet.has(current), true);
1716
1865
  return cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId && cacheKey.audience === keyToMatch.audience && hasAllScopes;
1717
1866
  })[0];
1718
1867
  }
1719
1868
  async getEntryWithRefreshToken(keyToMatch, allKeys) {
1720
- var _a;
1721
1869
  for (const key of allKeys) {
1722
1870
  const cacheKey = CacheKey.fromKey(key);
1723
1871
  if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId) {
1872
+ var _cachedEntry$body;
1724
1873
  const cachedEntry = await this.cache.get(key);
1725
- if ((_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
1874
+ if (cachedEntry !== null && cachedEntry !== void 0 && (_cachedEntry$body = cachedEntry.body) !== null && _cachedEntry$body !== void 0 && _cachedEntry$body.refresh_token) {
1726
1875
  return this.modifiedCachedEntry(cachedEntry, keyToMatch);
1727
1876
  }
1728
1877
  }
@@ -1730,12 +1879,12 @@ class CacheManager {
1730
1879
  return undefined;
1731
1880
  }
1732
1881
  async updateEntry(oldRefreshToken, newRefreshToken) {
1733
- var _a;
1734
1882
  const allKeys = await this.getCacheKeys();
1735
1883
  if (!allKeys) return;
1736
1884
  for (const key of allKeys) {
1885
+ var _entry$body;
1737
1886
  const entry = await this.cache.get(key);
1738
- if (((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) === oldRefreshToken) {
1887
+ if ((entry === null || entry === void 0 || (_entry$body = entry.body) === null || _entry$body === void 0 ? void 0 : _entry$body.refresh_token) === oldRefreshToken) {
1739
1888
  entry.body.refresh_token = newRefreshToken;
1740
1889
  await this.cache.set(key, entry);
1741
1890
  }
@@ -1990,17 +2139,17 @@ const CookieStorage = {
1990
2139
  sameSite: "none"
1991
2140
  };
1992
2141
  }
1993
- if (options === null || options === void 0 ? void 0 : options.daysUntilExpire) {
2142
+ if (options !== null && options !== void 0 && options.daysUntilExpire) {
1994
2143
  cookieAttributes.expires = options.daysUntilExpire;
1995
2144
  }
1996
- if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
2145
+ if (options !== null && options !== void 0 && options.cookieDomain) {
1997
2146
  cookieAttributes.domain = options.cookieDomain;
1998
2147
  }
1999
2148
  set_1(key, JSON.stringify(value), cookieAttributes);
2000
2149
  },
2001
2150
  remove(key, options) {
2002
2151
  let cookieAttributes = {};
2003
- if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
2152
+ if (options !== null && options !== void 0 && options.cookieDomain) {
2004
2153
  cookieAttributes.domain = options.cookieDomain;
2005
2154
  }
2006
2155
  remove_1(key, cookieAttributes);
@@ -2024,10 +2173,10 @@ const CookieStorageWithLegacySameSite = {
2024
2173
  secure: true
2025
2174
  };
2026
2175
  }
2027
- if (options === null || options === void 0 ? void 0 : options.daysUntilExpire) {
2176
+ if (options !== null && options !== void 0 && options.daysUntilExpire) {
2028
2177
  cookieAttributes.expires = options.daysUntilExpire;
2029
2178
  }
2030
- if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
2179
+ if (options !== null && options !== void 0 && options.cookieDomain) {
2031
2180
  cookieAttributes.domain = options.cookieDomain;
2032
2181
  }
2033
2182
  set_1("".concat(LEGACY_PREFIX).concat(key), JSON.stringify(value), cookieAttributes);
@@ -2035,7 +2184,7 @@ const CookieStorageWithLegacySameSite = {
2035
2184
  },
2036
2185
  remove(key, options) {
2037
2186
  let cookieAttributes = {};
2038
- if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
2187
+ if (options !== null && options !== void 0 && options.cookieDomain) {
2039
2188
  cookieAttributes.domain = options.cookieDomain;
2040
2189
  }
2041
2190
  remove_1(key, cookieAttributes);
@@ -2063,12 +2212,11 @@ const SessionStorage = {
2063
2212
  }
2064
2213
  };
2065
2214
 
2066
- exports.ResponseType = void 0;
2067
-
2068
- (function(ResponseType) {
2215
+ let ResponseType = function(ResponseType) {
2069
2216
  ResponseType["Code"] = "code";
2070
2217
  ResponseType["ConnectCode"] = "connect_code";
2071
- })(exports.ResponseType || (exports.ResponseType = {}));
2218
+ return ResponseType;
2219
+ }({});
2072
2220
 
2073
2221
  class User {}
2074
2222
 
@@ -2104,7 +2252,7 @@ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
2104
2252
  };
2105
2253
  }
2106
2254
 
2107
- var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBjbGFzcyBHZW5lcmljRXJyb3IgZXh0ZW5kcyBFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uKSB7CiAgICAgICAgICAgIHN1cGVyKGVycm9yX2Rlc2NyaXB0aW9uKTsKICAgICAgICAgICAgdGhpcy5lcnJvciA9IGVycm9yOwogICAgICAgICAgICB0aGlzLmVycm9yX2Rlc2NyaXB0aW9uID0gZXJyb3JfZGVzY3JpcHRpb247CiAgICAgICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLCBHZW5lcmljRXJyb3IucHJvdG90eXBlKTsKICAgICAgICB9CiAgICAgICAgc3RhdGljIGZyb21QYXlsb2FkKF9yZWYpIHsKICAgICAgICAgICAgbGV0IHtlcnJvc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1ZGllbmNlLCBzY29wZSldID0gcmVmcmVzaFRva2VuOwogICAgY29uc3QgZGVsZXRlUmVmcmVzaFRva2VuID0gKGF1ZGllbmNlLCBzY29wZSkgPT4gZGVsZXRlIHJlZnJlc2hUb2tlbnNbY2FjaGVLZXkoYXVkaWVuY2UsIHNjb3BlKV07CiAgICBjb25zdCB3YWl0ID0gdGltZSA9PiBuZXcgUHJvbWlzZShyZXNvbHZlID0+IHNldFRpbWVvdXQocmVzb2x2ZSwgdGltZSkpOwogICAgY29uc3QgZm9ybURhdGFUb09iamVjdCA9IGZvcm1EYXRhID0+IHsKICAgICAgICBjb25zdCBxdWVyeVBhcmFtcyA9IG5ldyBVUkxTZWFyY2hQYXJhbXMoZm9ybURhdGEpOwogICAgICAgIGNvbnN0IHBhcnNlZFF1ZXJ5ID0ge307CiAgICAgICAgcXVlcnlQYXJhbXMuZm9yRWFjaCgodmFsLCBrZXkpID0+IHsKICAgICAgICAgICAgcGFyc2VkUXVlcnlba2V5XSA9IHZhbDsKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gcGFyc2VkUXVlcnk7CiAgICB9OwogICAgY29uc3QgdXBkYXRlUmVmcmVzaFRva2VucyA9IChvbGRSZWZyZXNoVG9rZW4sIG5ld1JlZnJlc2hUb2tlbikgPT4gewogICAgICAgIE9iamVjdC5lbnRyaWVzKHJlZnJlc2hUb2tlbnMpLmZvckVhY2goX3JlZiA9PiB7CiAgICAgICAgICAgIGxldCBba2V5LCB0b2tlbl0gPSBfcmVmOwogICAgICAgICAgICBpZiAodG9rZW4gPT09IG9sZFJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1trZXldID0gbmV3UmVmcmVzaFRva2VuOwogICAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICB9OwogICAgY29uc3QgY2hlY2tEb3duc2NvcGluZyA9IChzY29wZSwgYXVkaWVuY2UpID0+IHsKICAgICAgICBjb25zdCBmaW5kQ29pbmNpZGVuY2U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U6IGF1ZGllbmNlLCBzY29wZTogc2NvcGV9ID0gYXV0aCB8fCB7fTsKICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBib2R5ID0gdXNlRm9ybURhdGEgPyBmb3JtRGF0YVRvT2JqZWN0KGZldGNoT3B0aW9ucy5ib2R5KSA6IEpTT04ucGFyc2UoZmV0Y2hPcHRpb25zLmJvZHkpOwogICAgICAgICAgICBpZiAoIWJvZHkucmVmcmVzaF90b2tlbiAmJiBib2R5LmdyYW50X3R5cGUgPT09ICJyZWZyZXNoX3Rva2VuIikgewogICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gZ2V0UmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBpZiAoIXJlZnJlc2hUb2tlbiAmJiB1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF0ZXN0UmVmcmVzaFRva2VuID0gcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0Rvd25zY29waW5nID0gY2hlY2tEb3duc2NvcGluZyhzY29wZSwgYXVkaWVuY2UpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXRlc3RSZWZyZXNoVG9rZW4gJiYgIWlzRG93bnNjb3BpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gbGF0ZXN0UmVmcmVzaFRva2VuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvcihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLmJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKSA6IEpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICBpZiAodHlwZW9mIEFib3J0Q29udHJvbGxlciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5zaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgUHJvbWlzZS5yYWNlKFsgd2FpdCh0aW1lb3V0KSwgZmV0Y2goZmV0Y2hVcmwsIE9iamVjdC5hc3NpZ24oe30sIGZldGNoT3B0aW9ucykpIF0pOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6ICJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCciCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXJzID0gZnJvbUVudHJpZXMocmVzcG9uc2UuaGVhZGVycyk7CiAgICAgICAgICAgIGpzb24gPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICAgIGlmIChqc29uLnJlZnJlc2hfdG9rZW4pIHsKICAgICAgICAgICAgICAgIGlmICh1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXSA9IGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWZyZXNoVG9rZW5zKHJlZnJlc2hUb2tlbiwganNvbi5yZWZyZXNoX3Rva2VuKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHNldFJlZnJlc2hUb2tlbihqc29uLnJlZnJlc2hfdG9rZW4sIGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBkZWxldGUganNvbi5yZWZyZXNoX3Rva2VuOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZGVsZXRlUmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogcmVzcG9uc2Uub2ssCiAgICAgICAgICAgICAgICBqc29uOiBqc29uLAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIG9rOiBmYWxzZSwKICAgICAgICAgICAgICAgIGpzb246IHsKICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3IuZXJyb3IsCiAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH07CiAgICB7CiAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsIG1lc3NhZ2VIYW5kbGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
2255
+ var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBmdW5jdGlvbiBfZGVmaW5lUHJvcGVydHkoZSwgciwgdCkgewogICAgICAgIHJldHVybiAociA9IF90b1Byb3BlcnR5S2V5KHIpKSBpbiBlID8gT2JqZWN0LmRlZmluZVByb3BlcnR5KGUsIHIsIHsKICAgICAgICAgICAgdmFsdWU6IHQsCiAgICAgICAgICAgIGVudW1lcmFibGU6ICEwLAogICAgICAgICAgICBjb25maWd1cmFibGU6ICEwLAogICAgICAgICAgICB3cml0YWJsZTogITAKICAgICAgICB9KSA6IGVbcl0gPSB0LCBlOwogICAgfQogICAgZnVuY3Rpb24gb3duS2V5cyhlLCByKSB7CiAgICAgICAgdmFyIHQgPSBPYmplY3Qua2V5cyhlKTsKICAgICAgICBpZiAoT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scykgewogICAgICAgICAgICB2YXIgbyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7CiAgICAgICAgICAgIHIgJiYgKG8gPSBvLmZpbHRlcihmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihlLCByKS5lbnVtZXJhYmxlOwogICAgICAgICAgICB9KSksIHQucHVzaC5hcHBseSh0LCBvKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHQ7CiAgICB9CiAgICBmdW5jdGlvbiBfb2JqZWN0U3ByZWFkMihlKSB7CiAgICAgICAgZm9yICh2YXIgciA9IDE7IHIgPCBhcmd1bWVudHMubGVuZ3RoOyByKyspIHsKICAgICAgICAgICAgdmFyIHQgPSBudWxsICE9IGFyZ3VtZW50c1tyXSA/IGFyZ3VtZW50c1tyXSA6IHt9OwogICAgICAgICAgICByICUgMiA/IG93bktleXMoT2JqZWN0KHQpLCAhMCkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoZSwgciwgdFtyXSk7CiAgICAgICAgICAgIH0pIDogT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnMgPyBPYmplY3QuZGVmaW5lUHJvcGVydGllcyhlLCBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyh0KSkgOiBvd25LZXlzKE9iamVjdCh0KSkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZSwgciwgT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcih0LCByKSk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllcyhlLCB0KSB7CiAgICAgICAgaWYgKG51bGwgPT0gZSkgcmV0dXJuIHt9OwogICAgICAgIHZhciBvLCByLCBpID0gX29iamVjdFdpdGhvdXRQcm9wZXJ0aWVzTG9vc2UoZSwgdCk7CiAgICAgICAgaWYgKE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMpIHsKICAgICAgICAgICAgdmFyIG4gPSBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpOwogICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgbi5sZW5ndGg7IHIrKykgbyA9IG5bcl0sIC0xID09PSB0LmluZGV4T2YobykgJiYge30ucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLCBvKSAmJiAoaVtvXSA9IGVbb10pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllc0xvb3NlKHIsIGUpIHsKICAgICAgICBpZiAobnVsbCA9PSByKSByZXR1cm4ge307CiAgICAgICAgdmFyIHQgPSB7fTsKICAgICAgICBmb3IgKHZhciBuIGluIHIpIGlmICh7fS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHIsIG4pKSB7CiAgICAgICAgICAgIGlmICgtMSAhPT0gZS5pbmRleE9mKG4pKSBjb250aW51ZTsKICAgICAgICAgICAgdFtuXSA9IHJbbl07CiAgICAgICAgfQogICAgICAgIHJldHVybiB0OwogICAgfQogICAgZnVuY3Rpb24gX3RvUHJpbWl0aXZlKHQsIHIpIHsKICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIHQgfHwgIXQpIHJldHVybiB0OwogICAgICAgIHZhciBlID0gdFtTeW1ib2wudG9QcmltaXRpdmVdOwogICAgICAgIGlmICh2b2lkIDAgIT09IGUpIHsKICAgICAgICAgICAgdmFyIGkgPSBlLmNhbGwodCwgciB8fCAiZGVmYXVsdCIpOwogICAgICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIGkpIHJldHVybiBpOwogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJAQHRvUHJpbWl0aXZlIG11c3QgcmV0dXJuIGEgcHJpbWl0aXZlIHZhbHVlLiIpOwogIC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vbnN0IGJvZHkgPSB1c2VGb3JtRGF0YSA/IGZvcm1EYXRhVG9PYmplY3QoZmV0Y2hPcHRpb25zLmJvZHkpIDogSlNPTi5wYXJzZShmZXRjaE9wdGlvbnMuYm9keSk7CiAgICAgICAgICAgIGlmICghYm9keS5yZWZyZXNoX3Rva2VuICYmIGJvZHkuZ3JhbnRfdHlwZSA9PT0gInJlZnJlc2hfdG9rZW4iKSB7CiAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW4gPSBnZXRSZWZyZXNoVG9rZW4oYXVkaWVuY2UsIHNjb3BlKTsKICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuICYmIHVzZU1ycnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXRlc3RSZWZyZXNoVG9rZW4gPSByZWZyZXNoVG9rZW5zWyJsYXRlc3RfcmVmcmVzaF90b2tlbiJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRG93bnNjb3BpbmcgPSBjaGVja0Rvd25zY29waW5nKHNjb3BlLCBhdWRpZW5jZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxhdGVzdFJlZnJlc2hUb2tlbiAmJiAhaXNEb3duc2NvcGluZykgewogICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW4gPSBsYXRlc3RSZWZyZXNoVG9rZW47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFyZWZyZXNoVG9rZW4pIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgTWlzc2luZ1JlZnJlc2hUb2tlbkVycm9yKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmZXRjaE9wdGlvbnMuYm9keSA9IHVzZUZvcm1EYXRhID8gY3JlYXRlUXVlcnlQYXJhbXMoX29iamVjdFNwcmVhZDIoX29iamVjdFNwcmVhZDIoe30sIGJvZHkpLCB7fSwgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpIDogSlNPTi5zdHJpbmdpZnkoX29iamVjdFNwcmVhZDIoX29iamVjdFNwcmVhZDIoe30sIGJvZHkpLCB7fSwgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCBhYm9ydENvbnRyb2xsZXI7CiAgICAgICAgICAgIGlmICh0eXBlb2YgQWJvcnRDb250cm9sbGVyID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICBhYm9ydENvbnRyb2xsZXIgPSBuZXcgQWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLnNpZ25hbCA9IGFib3J0Q29udHJvbGxlci5zaWduYWw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IHJlc3BvbnNlOwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBhd2FpdCBQcm9taXNlLnJhY2UoWyB3YWl0KHRpbWVvdXQpLCBmZXRjaChmZXRjaFVybCwgX29iamVjdFNwcmVhZDIoe30sIGZldGNoT3B0aW9ucykpIF0pOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6ICJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCciCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXJzID0gZnJvbUVudHJpZXMocmVzcG9uc2UuaGVhZGVycyk7CiAgICAgICAgICAgIGpzb24gPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICAgIGlmIChqc29uLnJlZnJlc2hfdG9rZW4pIHsKICAgICAgICAgICAgICAgIGlmICh1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXSA9IGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWZyZXNoVG9rZW5zKHJlZnJlc2hUb2tlbiwganNvbi5yZWZyZXNoX3Rva2VuKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHNldFJlZnJlc2hUb2tlbihqc29uLnJlZnJlc2hfdG9rZW4sIGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBkZWxldGUganNvbi5yZWZyZXNoX3Rva2VuOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZGVsZXRlUmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogcmVzcG9uc2Uub2ssCiAgICAgICAgICAgICAgICBqc29uOiBqc29uLAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIG9rOiBmYWxzZSwKICAgICAgICAgICAgICAgIGpzb246IHsKICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3IuZXJyb3IsCiAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH07CiAgICB7CiAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsIG1lc3NhZ2VIYW5kbGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
2108
2256
 
2109
2257
  const singlePromiseMap = {};
2110
2258
 
@@ -2127,8 +2275,8 @@ class CacheKeyManifest {
2127
2275
  this.manifestKey = this.createManifestKeyFrom(this.clientId);
2128
2276
  }
2129
2277
  async add(key) {
2130
- var _a;
2131
- const keys = new Set(((_a = await this.cache.get(this.manifestKey)) === null || _a === void 0 ? void 0 : _a.keys) || []);
2278
+ var _await$this$cache$get;
2279
+ const keys = new Set(((_await$this$cache$get = await this.cache.get(this.manifestKey)) === null || _await$this$cache$get === void 0 ? void 0 : _await$this$cache$get.keys) || []);
2132
2280
  keys.add(key);
2133
2281
  await this.cache.set(this.manifestKey, {
2134
2282
  keys: [ ...keys ]
@@ -2158,6 +2306,8 @@ class CacheKeyManifest {
2158
2306
  }
2159
2307
  }
2160
2308
 
2309
+ const _excluded$2 = [ "openUrl", "onRedirect" ];
2310
+
2161
2311
  const GET_TOKEN_SILENTLY_LOCK_KEY = "auth0.lock.getTokenSilently";
2162
2312
 
2163
2313
  const GET_TOKEN_FROM_IFRAME_LOCK_KEY = "auth0.lock.getTokenFromIFrame";
@@ -2179,9 +2329,9 @@ const cacheLocationBuilders = {
2179
2329
 
2180
2330
  const cacheFactory = location => cacheLocationBuilders[location];
2181
2331
 
2182
- const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) => Object.assign(Object.assign(Object.assign({
2332
+ const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) => _objectSpread2(_objectSpread2(_objectSpread2({
2183
2333
  client_id: clientOptions.clientId
2184
- }, clientOptions.authorizationParams), authorizationParams), {
2334
+ }, clientOptions.authorizationParams), authorizationParams), {}, {
2185
2335
  scope: scopesToRequest(scope, authorizationParams.scope, authorizationParams.audience),
2186
2336
  response_type: "code",
2187
2337
  response_mode: response_mode || "query",
@@ -2194,8 +2344,8 @@ const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, no
2194
2344
  });
2195
2345
 
2196
2346
  const patchOpenUrlWithOnRedirect = options => {
2197
- const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions = __rest(options, [ "openUrl", "onRedirect" ]);
2198
- const result = Object.assign(Object.assign({}, originalOptions), {
2347
+ const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions = _objectWithoutProperties(options, _excluded$2);
2348
+ const result = _objectSpread2(_objectSpread2({}, originalOptions), {}, {
2199
2349
  openUrl: openUrl === false || openUrl ? openUrl : onRedirect
2200
2350
  });
2201
2351
  return result;
@@ -2215,13 +2365,13 @@ const getMissingScopes = (requestedScope, respondedScope) => {
2215
2365
  };
2216
2366
 
2217
2367
  const getScopeToRequest = (useMrrt, authorizationParams, cachedAudience, cachedScope) => {
2218
- var _a;
2219
2368
  if (useMrrt && cachedAudience && cachedScope) {
2369
+ var _authorizationParams$;
2220
2370
  if (authorizationParams.audience !== cachedAudience) {
2221
2371
  return authorizationParams.scope;
2222
2372
  }
2223
2373
  const cachedScopes = cachedScope.split(" ");
2224
- const newScopes = ((_a = authorizationParams.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
2374
+ const newScopes = ((_authorizationParams$ = authorizationParams.scope) === null || _authorizationParams$ === void 0 ? void 0 : _authorizationParams$.split(" ")) || [];
2225
2375
  const newScopesAreIncluded = newScopes.every(scope => cachedScopes.includes(scope));
2226
2376
  return cachedScopes.length >= newScopes.length && newScopesAreIncluded ? cachedScope : authorizationParams.scope;
2227
2377
  }
@@ -2301,7 +2451,7 @@ class DpopStorage {
2301
2451
  }
2302
2452
  async deleteBy(table, predicate) {
2303
2453
  const allKeys = await this.executeDbRequest(table, "readonly", table => table.getAllKeys());
2304
- allKeys === null || allKeys === void 0 ? void 0 : allKeys.filter(predicate).map(k => this.executeDbRequest(table, "readwrite", table => table.delete(k)));
2454
+ allKeys === null || allKeys === void 0 || allKeys.filter(predicate).map(k => this.executeDbRequest(table, "readwrite", table => table.delete(k)));
2305
2455
  }
2306
2456
  deleteByClientId(table, clientId) {
2307
2457
  return this.deleteBy(table, k => typeof k === "string" && k.startsWith("".concat(clientId, "::")));
@@ -2334,7 +2484,7 @@ class Dpop {
2334
2484
  }
2335
2485
  async generateProof(params) {
2336
2486
  const keyPair = await this.getOrGenerateKeyPair();
2337
- return generateProof(Object.assign({
2487
+ return generateProof(_objectSpread2({
2338
2488
  keyPair: keyPair
2339
2489
  }, params));
2340
2490
  }
@@ -2347,17 +2497,16 @@ class Dpop {
2347
2497
  }
2348
2498
  }
2349
2499
 
2350
- var TokenType;
2351
-
2352
- (function(TokenType) {
2500
+ var TokenType = function(TokenType) {
2353
2501
  TokenType["Bearer"] = "Bearer";
2354
2502
  TokenType["DPoP"] = "DPoP";
2355
- })(TokenType || (TokenType = {}));
2503
+ return TokenType;
2504
+ }(TokenType || {});
2356
2505
 
2357
2506
  class Fetcher {
2358
2507
  constructor(config, hooks) {
2359
2508
  this.hooks = hooks;
2360
- this.config = Object.assign(Object.assign({}, config), {
2509
+ this.config = _objectSpread2(_objectSpread2({}, config), {}, {
2361
2510
  fetch: config.fetch || (typeof window === "undefined" ? fetch : window.fetch.bind(window))
2362
2511
  });
2363
2512
  }
@@ -2465,7 +2614,7 @@ class Fetcher {
2465
2614
  }
2466
2615
  fetchWithAuth(info, init, authParams) {
2467
2616
  const callbacks = {
2468
- onUseDpopNonceError: () => this.internalFetchWithAuth(info, init, Object.assign(Object.assign({}, callbacks), {
2617
+ onUseDpopNonceError: () => this.internalFetchWithAuth(info, init, _objectSpread2(_objectSpread2({}, callbacks), {}, {
2469
2618
  onUseDpopNonceError: undefined
2470
2619
  }), authParams)
2471
2620
  };
@@ -2563,7 +2712,7 @@ const MfaGrantTypes = {
2563
2712
 
2564
2713
  function getAuthJsEnrollParams(params) {
2565
2714
  const mapping = FACTOR_MAPPING[params.factorType];
2566
- return Object.assign(Object.assign(Object.assign({
2715
+ return _objectSpread2(_objectSpread2(_objectSpread2({
2567
2716
  mfaToken: params.mfaToken,
2568
2717
  authenticatorTypes: mapping.authenticatorTypes
2569
2718
  }, mapping.oobChannels && {
@@ -2588,162 +2737,6 @@ function getGrantType(params) {
2588
2737
  return undefined;
2589
2738
  }
2590
2739
 
2591
- function _OverloadYield(e, d) {
2592
- this.v = e, this.k = d;
2593
- }
2594
-
2595
- function _assertClassBrand(e, t, n) {
2596
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2597
- throw new TypeError("Private element is not present on this object");
2598
- }
2599
-
2600
- function _awaitAsyncGenerator(e) {
2601
- return new _OverloadYield(e, 0);
2602
- }
2603
-
2604
- function _checkPrivateRedeclaration(e, t) {
2605
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
2606
- }
2607
-
2608
- function _classPrivateFieldGet2(s, a) {
2609
- return s.get(_assertClassBrand(s, a));
2610
- }
2611
-
2612
- function _classPrivateFieldInitSpec(e, t, a) {
2613
- _checkPrivateRedeclaration(e, t), t.set(e, a);
2614
- }
2615
-
2616
- function _classPrivateFieldSet2(s, a, r) {
2617
- return s.set(_assertClassBrand(s, a), r), r;
2618
- }
2619
-
2620
- function _classPrivateMethodInitSpec(e, a) {
2621
- _checkPrivateRedeclaration(e, a), a.add(e);
2622
- }
2623
-
2624
- function _defineProperty(e, r, t) {
2625
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
2626
- value: t,
2627
- enumerable: !0,
2628
- configurable: !0,
2629
- writable: !0
2630
- }) : e[r] = t, e;
2631
- }
2632
-
2633
- function ownKeys(e, r) {
2634
- var t = Object.keys(e);
2635
- if (Object.getOwnPropertySymbols) {
2636
- var o = Object.getOwnPropertySymbols(e);
2637
- r && (o = o.filter(function(r) {
2638
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
2639
- })), t.push.apply(t, o);
2640
- }
2641
- return t;
2642
- }
2643
-
2644
- function _objectSpread2(e) {
2645
- for (var r = 1; r < arguments.length; r++) {
2646
- var t = null != arguments[r] ? arguments[r] : {};
2647
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
2648
- _defineProperty(e, r, t[r]);
2649
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
2650
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
2651
- });
2652
- }
2653
- return e;
2654
- }
2655
-
2656
- function _objectWithoutProperties(e, t) {
2657
- if (null == e) return {};
2658
- var o, r, i = _objectWithoutPropertiesLoose(e, t);
2659
- if (Object.getOwnPropertySymbols) {
2660
- var n = Object.getOwnPropertySymbols(e);
2661
- for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
2662
- }
2663
- return i;
2664
- }
2665
-
2666
- function _objectWithoutPropertiesLoose(r, e) {
2667
- if (null == r) return {};
2668
- var t = {};
2669
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
2670
- if (-1 !== e.indexOf(n)) continue;
2671
- t[n] = r[n];
2672
- }
2673
- return t;
2674
- }
2675
-
2676
- function _toPrimitive(t, r) {
2677
- if ("object" != typeof t || !t) return t;
2678
- var e = t[Symbol.toPrimitive];
2679
- if (void 0 !== e) {
2680
- var i = e.call(t, r || "default");
2681
- if ("object" != typeof i) return i;
2682
- throw new TypeError("@@toPrimitive must return a primitive value.");
2683
- }
2684
- return ("string" === r ? String : Number)(t);
2685
- }
2686
-
2687
- function _toPropertyKey(t) {
2688
- var i = _toPrimitive(t, "string");
2689
- return "symbol" == typeof i ? i : i + "";
2690
- }
2691
-
2692
- function _wrapAsyncGenerator(e) {
2693
- return function() {
2694
- return new AsyncGenerator(e.apply(this, arguments));
2695
- };
2696
- }
2697
-
2698
- function AsyncGenerator(e) {
2699
- var t, n;
2700
- function resume(t, n) {
2701
- try {
2702
- var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
2703
- Promise.resolve(u ? o.v : o).then(function(n) {
2704
- if (u) {
2705
- var i = "return" === t && o.k ? t : "next";
2706
- if (!o.k || n.done) return resume(i, n);
2707
- n = e[i](n).value;
2708
- }
2709
- settle(!!r.done, n);
2710
- }, function(e) {
2711
- resume("throw", e);
2712
- });
2713
- } catch (e) {
2714
- settle(2, e);
2715
- }
2716
- }
2717
- function settle(e, r) {
2718
- 2 === e ? t.reject(r) : t.resolve({
2719
- value: r,
2720
- done: e
2721
- }), (t = t.next) ? resume(t.key, t.arg) : n = null;
2722
- }
2723
- this._invoke = function(e, r) {
2724
- return new Promise(function(o, u) {
2725
- var i = {
2726
- key: e,
2727
- arg: r,
2728
- resolve: o,
2729
- reject: u,
2730
- next: null
2731
- };
2732
- n ? n = n.next = i : (t = n = i, resume(e, r));
2733
- });
2734
- }, "function" != typeof e.return && (this.return = void 0);
2735
- }
2736
-
2737
- AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
2738
- return this;
2739
- }, AsyncGenerator.prototype.next = function(e) {
2740
- return this._invoke("next", e);
2741
- }, AsyncGenerator.prototype.throw = function(e) {
2742
- return this._invoke("throw", e);
2743
- }, AsyncGenerator.prototype.return = function(e) {
2744
- return this._invoke("return", e);
2745
- };
2746
-
2747
2740
  var _navigator$userAgent$2, _navigator$userAgent$$2;
2748
2741
 
2749
2742
  let USER_AGENT$2;
@@ -7024,7 +7017,7 @@ function createRemoteJWKSet(url, options) {
7024
7017
  return remoteJWKSet;
7025
7018
  }
7026
7019
 
7027
- const _excluded = [ "mfaToken" ], _excluded2 = [ "mfaToken" ];
7020
+ const _excluded$1 = [ "mfaToken" ], _excluded2$1 = [ "mfaToken" ];
7028
7021
 
7029
7022
  var _baseUrl, _clientId, _customFetch, _entries, _ttlMs, _maxEntries, _configuration, _serverMetadata, _clientAuthPromise, _options, _customFetch2, _jwks, _discoveryCache, _inFlightDiscovery, _jwksCache, _Class9_brand;
7030
7023
 
@@ -7072,6 +7065,13 @@ var TokenByRefreshTokenError = class extends ApiError {
7072
7065
  }
7073
7066
  };
7074
7067
 
7068
+ var TokenByPasswordError = class extends ApiError {
7069
+ constructor(message, cause) {
7070
+ super("token_by_password_error", message, cause);
7071
+ this.name = "TokenByPasswordError";
7072
+ }
7073
+ };
7074
+
7075
7075
  var TokenForConnectionError = class extends ApiError {
7076
7076
  constructor(message, cause) {
7077
7077
  super("token_for_connection_error", message, cause);
@@ -7262,7 +7262,7 @@ class MfaClient {
7262
7262
  }
7263
7263
  async enrollAuthenticator(options) {
7264
7264
  const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/associate");
7265
- const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded);
7265
+ const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded$1);
7266
7266
  const apiParams = {
7267
7267
  authenticator_types: sdkParams.authenticatorTypes
7268
7268
  };
@@ -7307,7 +7307,7 @@ class MfaClient {
7307
7307
  }
7308
7308
  async challengeAuthenticator(options) {
7309
7309
  const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/challenge");
7310
- const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2);
7310
+ const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2$1);
7311
7311
  const body = {
7312
7312
  mfa_token: mfaToken,
7313
7313
  client_id: _classPrivateFieldGet2(_clientId, this),
@@ -7364,7 +7364,7 @@ function getTelemetryConfig(config) {
7364
7364
  return {
7365
7365
  enabled: true,
7366
7366
  name: (_config$name = config === null || config === void 0 ? void 0 : config.name) !== null && _config$name !== void 0 ? _config$name : "@auth0/auth0-auth-js",
7367
- version: (_config$version = config === null || config === void 0 ? void 0 : config.version) !== null && _config$version !== void 0 ? _config$version : "1.5.0"
7367
+ version: (_config$version = config === null || config === void 0 ? void 0 : config.version) !== null && _config$version !== void 0 ? _config$version : "1.6.0"
7368
7368
  };
7369
7369
  }
7370
7370
 
@@ -7731,6 +7731,38 @@ class AuthClient {
7731
7731
  throw new TokenByRefreshTokenError("The access token has expired and there was an error while trying to refresh it.", e);
7732
7732
  }
7733
7733
  }
7734
+ async getTokenByPassword(options) {
7735
+ const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
7736
+ const params = new URLSearchParams({
7737
+ username: options.username,
7738
+ password: options.password
7739
+ });
7740
+ if (options.audience) {
7741
+ params.append("audience", options.audience);
7742
+ }
7743
+ if (options.scope) {
7744
+ params.append("scope", options.scope);
7745
+ }
7746
+ if (options.realm) {
7747
+ params.append("realm", options.realm);
7748
+ }
7749
+ let requestConfig = configuration;
7750
+ if (options.auth0ForwardedFor) {
7751
+ const clientAuth = await _assertClassBrand(_Class9_brand, this, _getClientAuth).call(this);
7752
+ requestConfig = new Configuration(configuration.serverMetadata(), _classPrivateFieldGet2(_options, this).clientId, _classPrivateFieldGet2(_options, this).clientSecret, clientAuth);
7753
+ requestConfig[customFetch$1] = (url, init) => _classPrivateFieldGet2(_customFetch2, this).call(this, url, _objectSpread2(_objectSpread2({}, init), {}, {
7754
+ headers: _objectSpread2(_objectSpread2({}, init.headers), {}, {
7755
+ "auth0-forwarded-for": options.auth0ForwardedFor
7756
+ })
7757
+ }));
7758
+ }
7759
+ try {
7760
+ const tokenEndpointResponse = await genericGrantRequest(requestConfig, "password", params);
7761
+ return TokenResponse.fromTokenEndpointResponse(tokenEndpointResponse);
7762
+ } catch (e) {
7763
+ throw new TokenByPasswordError("There was an error while trying to request a token.", e);
7764
+ }
7765
+ }
7734
7766
  async getTokenByClientCredentials(options) {
7735
7767
  const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
7736
7768
  try {
@@ -8030,12 +8062,12 @@ const DEFAULT_TTL_MS = 10 * 60 * 1e3;
8030
8062
  class MfaContextManager {
8031
8063
  constructor() {
8032
8064
  let ttlMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_TTL_MS;
8033
- this.contexts = new Map;
8065
+ _defineProperty(this, "contexts", new Map);
8034
8066
  this.ttlMs = ttlMs;
8035
8067
  }
8036
8068
  set(mfaToken, context) {
8037
8069
  this.cleanup();
8038
- this.contexts.set(mfaToken, Object.assign(Object.assign({}, context), {
8070
+ this.contexts.set(mfaToken, _objectSpread2(_objectSpread2({}, context), {}, {
8039
8071
  createdAt: Date.now()
8040
8072
  }));
8041
8073
  }
@@ -8080,9 +8112,9 @@ class MfaApiClient {
8080
8112
  });
8081
8113
  }
8082
8114
  async getAuthenticators(mfaToken) {
8083
- var _a, _b;
8115
+ var _context$mfaRequireme;
8084
8116
  const context = this.contextManager.get(mfaToken);
8085
- if (!((_a = context === null || context === void 0 ? void 0 : context.mfaRequirements) === null || _a === void 0 ? void 0 : _a.challenge) || context.mfaRequirements.challenge.length === 0) {
8117
+ if (!(context !== null && context !== void 0 && (_context$mfaRequireme = context.mfaRequirements) !== null && _context$mfaRequireme !== void 0 && _context$mfaRequireme.challenge) || context.mfaRequirements.challenge.length === 0) {
8086
8118
  throw new MfaListAuthenticatorsError("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
8087
8119
  }
8088
8120
  const challengeTypes = context.mfaRequirements.challenge.map(c => c.type);
@@ -8096,25 +8128,25 @@ class MfaApiClient {
8096
8128
  });
8097
8129
  } catch (error) {
8098
8130
  if (error instanceof MfaListAuthenticatorsError$1) {
8099
- throw new MfaListAuthenticatorsError((_b = error.cause) === null || _b === void 0 ? void 0 : _b.error, error.message);
8131
+ var _error$cause;
8132
+ throw new MfaListAuthenticatorsError((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.error, error.message);
8100
8133
  }
8101
8134
  throw error;
8102
8135
  }
8103
8136
  }
8104
8137
  async enroll(params) {
8105
- var _a;
8106
8138
  const authJsParams = getAuthJsEnrollParams(params);
8107
8139
  try {
8108
8140
  return await this.authJsMfaClient.enrollAuthenticator(authJsParams);
8109
8141
  } catch (error) {
8110
8142
  if (error instanceof MfaEnrollmentError$1) {
8111
- throw new MfaEnrollmentError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
8143
+ var _error$cause2;
8144
+ throw new MfaEnrollmentError((_error$cause2 = error.cause) === null || _error$cause2 === void 0 ? void 0 : _error$cause2.error, error.message);
8112
8145
  }
8113
8146
  throw error;
8114
8147
  }
8115
8148
  }
8116
8149
  async challenge(params) {
8117
- var _a;
8118
8150
  try {
8119
8151
  const authJsParams = {
8120
8152
  challengeType: params.challengeType,
@@ -8126,7 +8158,8 @@ class MfaApiClient {
8126
8158
  return await this.authJsMfaClient.challengeAuthenticator(authJsParams);
8127
8159
  } catch (error) {
8128
8160
  if (error instanceof MfaChallengeError$1) {
8129
- throw new MfaChallengeError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
8161
+ var _error$cause3;
8162
+ throw new MfaChallengeError((_error$cause3 = error.cause) === null || _error$cause3 === void 0 ? void 0 : _error$cause3.error, error.message);
8130
8163
  }
8131
8164
  throw error;
8132
8165
  }
@@ -8176,18 +8209,20 @@ class MfaApiClient {
8176
8209
  }
8177
8210
  }
8178
8211
 
8212
+ const _excluded = [ "openUrl", "fragment", "appState" ], _excluded2 = [ "url" ], _excluded3 = [ "cacheMode" ], _excluded4 = [ "federated" ], _excluded5 = [ "openUrl" ], _excluded6 = [ "id_token", "decodedToken" ], _excluded7 = [ "mfaToken" ];
8213
+
8179
8214
  class Auth0Client {
8180
8215
  constructor(options) {
8181
- this.userCache = (new InMemoryCache).enclosedCache;
8182
- this.defaultOptions = {
8216
+ _defineProperty(this, "userCache", (new InMemoryCache).enclosedCache);
8217
+ _defineProperty(this, "defaultOptions", {
8183
8218
  authorizationParams: {
8184
8219
  scope: DEFAULT_SCOPE
8185
8220
  },
8186
8221
  useRefreshTokensFallback: false,
8187
8222
  useFormData: true
8188
- };
8189
- this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), options), {
8190
- authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), options.authorizationParams)
8223
+ });
8224
+ this.options = _objectSpread2(_objectSpread2(_objectSpread2({}, this.defaultOptions), options), {}, {
8225
+ authorizationParams: _objectSpread2(_objectSpread2({}, this.defaultOptions.authorizationParams), options.authorizationParams)
8191
8226
  });
8192
8227
  typeof window !== "undefined" && validateCrypto();
8193
8228
  this.lockManager = getLockManager();
@@ -8219,9 +8254,9 @@ class Auth0Client {
8219
8254
  this.domainUrl = getDomain(this.options.domain);
8220
8255
  this.tokenIssuer = getTokenIssuer(this.options.issuer, this.domainUrl);
8221
8256
  const myAccountApiIdentifier = "".concat(this.domainUrl, "/me/");
8222
- const myAccountFetcher = this.createFetcher(Object.assign(Object.assign({}, this.options.useDpop && {
8257
+ const myAccountFetcher = this.createFetcher(_objectSpread2(_objectSpread2({}, this.options.useDpop && {
8223
8258
  dpopNonceId: "__auth0_my_account_api__"
8224
- }), {
8259
+ }), {}, {
8225
8260
  getAccessToken: () => this.getTokenSilently({
8226
8261
  authorizationParams: {
8227
8262
  scope: "create:me:connected_accounts",
@@ -8295,7 +8330,7 @@ class Auth0Client {
8295
8330
  url.searchParams.delete(paramName);
8296
8331
  window.history.replaceState({}, "", url.toString());
8297
8332
  }
8298
- } catch (_a) {}
8333
+ } catch (_unused) {}
8299
8334
  }
8300
8335
  _applySessionTransferToken(authorizationParams) {
8301
8336
  const paramName = this.options.sessionTransferTokenQueryParamName;
@@ -8305,18 +8340,18 @@ class Auth0Client {
8305
8340
  const token = this._extractSessionTransferToken(paramName);
8306
8341
  if (!token) return authorizationParams;
8307
8342
  this._clearSessionTransferTokenFromUrl(paramName);
8308
- return Object.assign(Object.assign({}, authorizationParams), {
8343
+ return _objectSpread2(_objectSpread2({}, authorizationParams), {}, {
8309
8344
  session_transfer_token: token
8310
8345
  });
8311
8346
  }
8312
8347
  async _prepareAuthorizeUrl(authorizationParams, authorizeOptions, fallbackRedirectUri) {
8313
- var _a;
8348
+ var _this$dpop;
8314
8349
  const state = encode$2(createRandomString());
8315
8350
  const nonce = encode$2(createRandomString());
8316
8351
  const code_verifier = createRandomString();
8317
8352
  const code_challengeBuffer = await sha256(code_verifier);
8318
8353
  const code_challenge = bufferToBase64UrlEncoded(code_challengeBuffer);
8319
- const thumbprint = await ((_a = this.dpop) === null || _a === void 0 ? void 0 : _a.calculateThumbprint());
8354
+ const thumbprint = await ((_this$dpop = this.dpop) === null || _this$dpop === void 0 ? void 0 : _this$dpop.calculateThumbprint());
8320
8355
  const params = getAuthorizeParams(this.options, this.scope, authorizationParams, state, nonce, code_challenge, authorizationParams.redirect_uri || this.options.authorizationParams.redirect_uri || fallbackRedirectUri, authorizeOptions === null || authorizeOptions === void 0 ? void 0 : authorizeOptions.response_mode, thumbprint);
8321
8356
  const url = this._authorizeUrl(params);
8322
8357
  return {
@@ -8330,7 +8365,7 @@ class Auth0Client {
8330
8365
  };
8331
8366
  }
8332
8367
  async loginWithPopup(options, config) {
8333
- var _a;
8368
+ var _options$authorizatio;
8334
8369
  options = options || {};
8335
8370
  config = config || {};
8336
8371
  if (!config.popup) {
@@ -8344,13 +8379,13 @@ class Auth0Client {
8344
8379
  response_mode: "web_message"
8345
8380
  }, window.location.origin);
8346
8381
  config.popup.location.href = params.url;
8347
- const codeResult = await runPopup(Object.assign(Object.assign({}, config), {
8382
+ const codeResult = await runPopup(_objectSpread2(_objectSpread2({}, config), {}, {
8348
8383
  timeoutInSeconds: config.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
8349
- }));
8384
+ }), new URL(params.url).origin);
8350
8385
  if (params.state !== codeResult.state) {
8351
8386
  throw new GenericError("state_mismatch", "Invalid state");
8352
8387
  }
8353
- const organization = ((_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
8388
+ const organization = ((_options$authorizatio = options.authorizationParams) === null || _options$authorizatio === void 0 ? void 0 : _options$authorizatio.organization) || this.options.authorizationParams.organization;
8354
8389
  await this._requestToken({
8355
8390
  audience: params.audience,
8356
8391
  scope: params.scope,
@@ -8364,26 +8399,26 @@ class Auth0Client {
8364
8399
  });
8365
8400
  }
8366
8401
  async getUser() {
8367
- var _a;
8402
+ var _cache$decodedToken;
8368
8403
  const cache = await this._getIdTokenFromCache();
8369
- return (_a = cache === null || cache === void 0 ? void 0 : cache.decodedToken) === null || _a === void 0 ? void 0 : _a.user;
8404
+ return cache === null || cache === void 0 || (_cache$decodedToken = cache.decodedToken) === null || _cache$decodedToken === void 0 ? void 0 : _cache$decodedToken.user;
8370
8405
  }
8371
8406
  async getIdTokenClaims() {
8372
- var _a;
8407
+ var _cache$decodedToken2;
8373
8408
  const cache = await this._getIdTokenFromCache();
8374
- return (_a = cache === null || cache === void 0 ? void 0 : cache.decodedToken) === null || _a === void 0 ? void 0 : _a.claims;
8409
+ return cache === null || cache === void 0 || (_cache$decodedToken2 = cache.decodedToken) === null || _cache$decodedToken2 === void 0 ? void 0 : _cache$decodedToken2.claims;
8375
8410
  }
8376
8411
  async loginWithRedirect() {
8412
+ var _urlOptions$authoriza;
8377
8413
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8378
- var _a;
8379
- const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl, fragment: fragment, appState: appState} = _b, urlOptions = __rest(_b, [ "openUrl", "fragment", "appState" ]);
8380
- const organization = ((_a = urlOptions.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
8414
+ const _patchOpenUrlWithOnRe = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl, fragment: fragment, appState: appState} = _patchOpenUrlWithOnRe, urlOptions = _objectWithoutProperties(_patchOpenUrlWithOnRe, _excluded);
8415
+ const organization = ((_urlOptions$authoriza = urlOptions.authorizationParams) === null || _urlOptions$authoriza === void 0 ? void 0 : _urlOptions$authoriza.organization) || this.options.authorizationParams.organization;
8381
8416
  const authorizationParams = this._applySessionTransferToken(urlOptions.authorizationParams || {});
8382
- const _c = await this._prepareAuthorizeUrl(authorizationParams), {url: url} = _c, transaction = __rest(_c, [ "url" ]);
8383
- this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, transaction), {
8417
+ const _await$this$_prepareA = await this._prepareAuthorizeUrl(authorizationParams), {url: url} = _await$this$_prepareA, transaction = _objectWithoutProperties(_await$this$_prepareA, _excluded2);
8418
+ this.transactionManager.create(_objectSpread2(_objectSpread2({}, transaction), {}, {
8384
8419
  appState: appState,
8385
- response_type: exports.ResponseType.Code
8386
- }), organization && {
8420
+ response_type: ResponseType.Code
8421
+ }, organization && {
8387
8422
  organization: organization
8388
8423
  }));
8389
8424
  const urlWithFragment = fragment ? "".concat(url, "#").concat(fragment) : url;
@@ -8405,7 +8440,7 @@ class Auth0Client {
8405
8440
  }
8406
8441
  this.transactionManager.remove();
8407
8442
  const authenticationResult = parseAuthenticationResult(queryStringFragments.join(""));
8408
- if (transaction.response_type === exports.ResponseType.ConnectCode) {
8443
+ if (transaction.response_type === ResponseType.ConnectCode) {
8409
8444
  return this._handleConnectAccountRedirectCallback(authenticationResult, transaction);
8410
8445
  }
8411
8446
  return this._handleLoginRedirectCallback(authenticationResult, transaction);
@@ -8421,7 +8456,7 @@ class Auth0Client {
8421
8456
  const organization = transaction.organization;
8422
8457
  const nonceIn = transaction.nonce;
8423
8458
  const redirect_uri = transaction.redirect_uri;
8424
- await this._requestToken(Object.assign({
8459
+ await this._requestToken(_objectSpread2({
8425
8460
  audience: transaction.audience,
8426
8461
  scope: transaction.scope,
8427
8462
  code_verifier: transaction.code_verifier,
@@ -8435,7 +8470,7 @@ class Auth0Client {
8435
8470
  });
8436
8471
  return {
8437
8472
  appState: transaction.appState,
8438
- response_type: exports.ResponseType.Code
8473
+ response_type: ResponseType.Code
8439
8474
  };
8440
8475
  }
8441
8476
  async _handleConnectAccountRedirectCallback(connectResult, transaction) {
@@ -8455,9 +8490,9 @@ class Auth0Client {
8455
8490
  redirect_uri: transaction.redirect_uri,
8456
8491
  code_verifier: transaction.code_verifier
8457
8492
  });
8458
- return Object.assign(Object.assign({}, data), {
8493
+ return _objectSpread2(_objectSpread2({}, data), {}, {
8459
8494
  appState: transaction.appState,
8460
- response_type: exports.ResponseType.ConnectCode
8495
+ response_type: ResponseType.ConnectCode
8461
8496
  });
8462
8497
  }
8463
8498
  async checkSession(options) {
@@ -8477,20 +8512,20 @@ class Auth0Client {
8477
8512
  } catch (_) {}
8478
8513
  }
8479
8514
  async getTokenSilently() {
8515
+ var _options$authorizatio2, _options$authorizatio3;
8480
8516
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8481
- var _a, _b;
8482
- const localOptions = Object.assign(Object.assign({
8517
+ const localOptions = _objectSpread2(_objectSpread2({
8483
8518
  cacheMode: "on"
8484
- }, options), {
8485
- authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), options.authorizationParams), {
8486
- scope: scopesToRequest(this.scope, (_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.scope, ((_b = options.authorizationParams) === null || _b === void 0 ? void 0 : _b.audience) || this.options.authorizationParams.audience)
8519
+ }, options), {}, {
8520
+ authorizationParams: _objectSpread2(_objectSpread2(_objectSpread2({}, this.options.authorizationParams), options.authorizationParams), {}, {
8521
+ scope: scopesToRequest(this.scope, (_options$authorizatio2 = options.authorizationParams) === null || _options$authorizatio2 === void 0 ? void 0 : _options$authorizatio2.scope, ((_options$authorizatio3 = options.authorizationParams) === null || _options$authorizatio3 === void 0 ? void 0 : _options$authorizatio3.audience) || this.options.authorizationParams.audience)
8487
8522
  })
8488
8523
  });
8489
8524
  const result = await singlePromise(() => this._getTokenSilently(localOptions), "".concat(this.options.clientId, "::").concat(localOptions.authorizationParams.audience, "::").concat(localOptions.authorizationParams.scope));
8490
8525
  return options.detailedResponse ? result : result === null || result === void 0 ? void 0 : result.access_token;
8491
8526
  }
8492
8527
  async _getTokenSilently(options) {
8493
- const {cacheMode: cacheMode} = options, getTokenOptions = __rest(options, [ "cacheMode" ]);
8528
+ const {cacheMode: cacheMode} = options, getTokenOptions = _objectWithoutProperties(options, _excluded3);
8494
8529
  if (cacheMode !== "off") {
8495
8530
  const entry = await this._getEntryFromCache({
8496
8531
  scope: getTokenOptions.authorizationParams.scope,
@@ -8520,13 +8555,13 @@ class Auth0Client {
8520
8555
  }
8521
8556
  const authResult = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(getTokenOptions) : await this._getTokenFromIFrame(getTokenOptions);
8522
8557
  const {id_token: id_token, token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = authResult;
8523
- return Object.assign(Object.assign({
8558
+ return _objectSpread2(_objectSpread2({
8524
8559
  id_token: id_token,
8525
8560
  token_type: token_type,
8526
8561
  access_token: access_token
8527
8562
  }, oauthTokenScope ? {
8528
8563
  scope: oauthTokenScope
8529
- } : null), {
8564
+ } : null), {}, {
8530
8565
  expires_in: expires_in
8531
8566
  });
8532
8567
  });
@@ -8562,15 +8597,15 @@ class Auth0Client {
8562
8597
  }
8563
8598
  }
8564
8599
  async getTokenWithPopup() {
8600
+ var _options$authorizatio4, _options$authorizatio5;
8565
8601
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8566
8602
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8567
- var _a, _b;
8568
- const localOptions = Object.assign(Object.assign({}, options), {
8569
- authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), options.authorizationParams), {
8570
- scope: scopesToRequest(this.scope, (_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.scope, ((_b = options.authorizationParams) === null || _b === void 0 ? void 0 : _b.audience) || this.options.authorizationParams.audience)
8603
+ const localOptions = _objectSpread2(_objectSpread2({}, options), {}, {
8604
+ authorizationParams: _objectSpread2(_objectSpread2(_objectSpread2({}, this.options.authorizationParams), options.authorizationParams), {}, {
8605
+ scope: scopesToRequest(this.scope, (_options$authorizatio4 = options.authorizationParams) === null || _options$authorizatio4 === void 0 ? void 0 : _options$authorizatio4.scope, ((_options$authorizatio5 = options.authorizationParams) === null || _options$authorizatio5 === void 0 ? void 0 : _options$authorizatio5.audience) || this.options.authorizationParams.audience)
8571
8606
  })
8572
8607
  });
8573
- config = Object.assign(Object.assign({}, DEFAULT_POPUP_CONFIG_OPTIONS), config);
8608
+ config = _objectSpread2(_objectSpread2({}, DEFAULT_POPUP_CONFIG_OPTIONS), config);
8574
8609
  await this.loginWithPopup(localOptions, config);
8575
8610
  const cache = await this.cacheManager.get(new CacheKey({
8576
8611
  scope: localOptions.authorizationParams.scope,
@@ -8589,17 +8624,17 @@ class Auth0Client {
8589
8624
  } else {
8590
8625
  delete options.clientId;
8591
8626
  }
8592
- const _a = options.logoutParams || {}, {federated: federated} = _a, logoutOptions = __rest(_a, [ "federated" ]);
8627
+ const _ref = options.logoutParams || {}, {federated: federated} = _ref, logoutOptions = _objectWithoutProperties(_ref, _excluded4);
8593
8628
  const federatedQuery = federated ? "&federated" : "";
8594
- const url = this._url("/v2/logout?".concat(createQueryParams(Object.assign({
8629
+ const url = this._url("/v2/logout?".concat(createQueryParams(_objectSpread2({
8595
8630
  clientId: options.clientId
8596
8631
  }, logoutOptions))));
8597
8632
  return url + federatedQuery;
8598
8633
  }
8599
8634
  async logout() {
8635
+ var _this$dpop2;
8600
8636
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8601
- var _a;
8602
- const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _b, logoutOptions = __rest(_b, [ "openUrl" ]);
8637
+ const _patchOpenUrlWithOnRe2 = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _patchOpenUrlWithOnRe2, logoutOptions = _objectWithoutProperties(_patchOpenUrlWithOnRe2, _excluded5);
8603
8638
  if (options.clientId === null) {
8604
8639
  await this.cacheManager.clear();
8605
8640
  } else {
@@ -8612,7 +8647,7 @@ class Auth0Client {
8612
8647
  cookieDomain: this.options.cookieDomain
8613
8648
  });
8614
8649
  this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
8615
- await ((_a = this.dpop) === null || _a === void 0 ? void 0 : _a.clear());
8650
+ await ((_this$dpop2 = this.dpop) === null || _this$dpop2 === void 0 ? void 0 : _this$dpop2.clear());
8616
8651
  const url = this._buildLogoutUrl(logoutOptions);
8617
8652
  if (openUrl) {
8618
8653
  await openUrl(url);
@@ -8624,7 +8659,7 @@ class Auth0Client {
8624
8659
  const iframeLockKey = buildIframeLockKey(this.options.clientId);
8625
8660
  try {
8626
8661
  return await this.lockManager.runWithLock(iframeLockKey, 5e3, async () => {
8627
- const params = Object.assign(Object.assign({}, options.authorizationParams), {
8662
+ const params = _objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
8628
8663
  prompt: "none"
8629
8664
  });
8630
8665
  const orgHint = this.cookieStorage.get(this.orgHintCookieName);
@@ -8641,14 +8676,14 @@ class Auth0Client {
8641
8676
  let eventOrigin;
8642
8677
  try {
8643
8678
  eventOrigin = new URL(this.domainUrl).origin;
8644
- } catch (_a) {
8679
+ } catch (_unused2) {
8645
8680
  eventOrigin = this.domainUrl;
8646
8681
  }
8647
8682
  const codeResult = await runIframe(url, eventOrigin, authorizeTimeout);
8648
8683
  if (stateIn !== codeResult.state) {
8649
8684
  throw new GenericError("state_mismatch", "Invalid state");
8650
8685
  }
8651
- const tokenResult = await this._requestToken(Object.assign(Object.assign({}, options.authorizationParams), {
8686
+ const tokenResult = await this._requestToken(_objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
8652
8687
  code_verifier: code_verifier,
8653
8688
  code: codeResult.code,
8654
8689
  grant_type: "authorization_code",
@@ -8658,7 +8693,7 @@ class Auth0Client {
8658
8693
  nonceIn: nonceIn,
8659
8694
  organization: params.organization
8660
8695
  });
8661
- return Object.assign(Object.assign({}, tokenResult), {
8696
+ return _objectSpread2(_objectSpread2({}, tokenResult), {}, {
8662
8697
  scope: scope,
8663
8698
  oauthTokenScope: tokenResult.scope,
8664
8699
  audience: audience
@@ -8677,7 +8712,6 @@ class Auth0Client {
8677
8712
  }
8678
8713
  }
8679
8714
  async _getTokenUsingRefreshToken(options) {
8680
- var _a, _b;
8681
8715
  const cache = await this.cacheManager.get(new CacheKey({
8682
8716
  scope: options.authorizationParams.scope,
8683
8717
  audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
@@ -8693,16 +8727,16 @@ class Auth0Client {
8693
8727
  const timeout = typeof options.timeoutInSeconds === "number" ? options.timeoutInSeconds * 1e3 : null;
8694
8728
  const scopesToRequest = getScopeToRequest(this.options.useMrrt, options.authorizationParams, cache === null || cache === void 0 ? void 0 : cache.audience, cache === null || cache === void 0 ? void 0 : cache.scope);
8695
8729
  try {
8696
- const tokenResult = await this._requestToken(Object.assign(Object.assign(Object.assign({}, options.authorizationParams), {
8730
+ const tokenResult = await this._requestToken(_objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
8697
8731
  grant_type: "refresh_token",
8698
8732
  refresh_token: cache && cache.refresh_token,
8699
8733
  redirect_uri: redirect_uri
8700
- }), timeout && {
8734
+ }, timeout && {
8701
8735
  timeout: timeout
8702
8736
  }), {
8703
8737
  scopesToRequest: scopesToRequest
8704
8738
  });
8705
- if (tokenResult.refresh_token && (cache === null || cache === void 0 ? void 0 : cache.refresh_token)) {
8739
+ if (tokenResult.refresh_token && cache !== null && cache !== void 0 && cache.refresh_token) {
8706
8740
  await this.cacheManager.updateEntry(cache.refresh_token, tokenResult.refresh_token);
8707
8741
  }
8708
8742
  if (this.options.useMrrt) {
@@ -8719,7 +8753,7 @@ class Auth0Client {
8719
8753
  }
8720
8754
  }
8721
8755
  }
8722
- return Object.assign(Object.assign({}, tokenResult), {
8756
+ return _objectSpread2(_objectSpread2({}, tokenResult), {}, {
8723
8757
  scope: options.authorizationParams.scope,
8724
8758
  oauthTokenScope: tokenResult.scope,
8725
8759
  audience: options.authorizationParams.audience || DEFAULT_AUDIENCE
@@ -8737,13 +8771,14 @@ class Auth0Client {
8737
8771
  }
8738
8772
  }
8739
8773
  if (e instanceof MfaRequiredError) {
8740
- this.mfa.setMFAAuthDetails(e.mfa_token, (_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.scope, (_b = options.authorizationParams) === null || _b === void 0 ? void 0 : _b.audience, e.mfa_requirements);
8774
+ var _options$authorizatio6, _options$authorizatio7;
8775
+ this.mfa.setMFAAuthDetails(e.mfa_token, (_options$authorizatio6 = options.authorizationParams) === null || _options$authorizatio6 === void 0 ? void 0 : _options$authorizatio6.scope, (_options$authorizatio7 = options.authorizationParams) === null || _options$authorizatio7 === void 0 ? void 0 : _options$authorizatio7.audience, e.mfa_requirements);
8741
8776
  }
8742
8777
  throw e;
8743
8778
  }
8744
8779
  }
8745
8780
  async _saveEntryInCache(entry) {
8746
- const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken = __rest(entry, [ "id_token", "decodedToken" ]);
8781
+ const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken = _objectWithoutProperties(entry, _excluded6);
8747
8782
  this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, {
8748
8783
  id_token: id_token,
8749
8784
  decodedToken: decodedToken
@@ -8766,8 +8801,8 @@ class Auth0Client {
8766
8801
  this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, cache);
8767
8802
  return cache;
8768
8803
  }
8769
- async _getEntryFromCache(_ref) {
8770
- let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} = _ref;
8804
+ async _getEntryFromCache(_ref2) {
8805
+ let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} = _ref2;
8771
8806
  const entry = await this.cacheManager.get(new CacheKey({
8772
8807
  scope: scope,
8773
8808
  audience: audience,
@@ -8776,21 +8811,20 @@ class Auth0Client {
8776
8811
  if (entry && entry.access_token) {
8777
8812
  const {token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = entry;
8778
8813
  const cache = await this._getIdTokenFromCache();
8779
- return cache && Object.assign(Object.assign({
8814
+ return cache && _objectSpread2(_objectSpread2({
8780
8815
  id_token: cache.id_token,
8781
8816
  token_type: token_type ? token_type : "Bearer",
8782
8817
  access_token: access_token
8783
8818
  }, oauthTokenScope ? {
8784
8819
  scope: oauthTokenScope
8785
- } : null), {
8820
+ } : null), {}, {
8786
8821
  expires_in: expires_in
8787
8822
  });
8788
8823
  }
8789
8824
  }
8790
8825
  async _requestToken(options, additionalParameters) {
8791
- var _a, _b;
8792
8826
  const {nonceIn: nonceIn, organization: organization, scopesToRequest: scopesToRequest} = additionalParameters || {};
8793
- const authResult = await oauthToken(Object.assign(Object.assign({
8827
+ const authResult = await oauthToken(_objectSpread2(_objectSpread2({
8794
8828
  baseUrl: this.domainUrl,
8795
8829
  client_id: this.options.clientId,
8796
8830
  auth0Client: this.options.auth0Client,
@@ -8798,24 +8832,25 @@ class Auth0Client {
8798
8832
  timeout: this.httpTimeoutMs,
8799
8833
  useMrrt: this.options.useMrrt,
8800
8834
  dpop: this.dpop
8801
- }, options), {
8835
+ }, options), {}, {
8802
8836
  scope: scopesToRequest || options.scope
8803
8837
  }), this.worker);
8804
8838
  const decodedToken = await this._verifyIdToken(authResult.id_token, nonceIn, organization);
8805
8839
  if (options.grant_type === "authorization_code") {
8840
+ var _existingIdToken$deco;
8806
8841
  const existingIdToken = await this._getIdTokenFromCache();
8807
- if (((_b = (_a = existingIdToken === null || existingIdToken === void 0 ? void 0 : existingIdToken.decodedToken) === null || _a === void 0 ? void 0 : _a.claims) === null || _b === void 0 ? void 0 : _b.sub) && existingIdToken.decodedToken.claims.sub !== decodedToken.claims.sub) {
8842
+ if (existingIdToken !== null && existingIdToken !== void 0 && (_existingIdToken$deco = existingIdToken.decodedToken) !== null && _existingIdToken$deco !== void 0 && (_existingIdToken$deco = _existingIdToken$deco.claims) !== null && _existingIdToken$deco !== void 0 && _existingIdToken$deco.sub && existingIdToken.decodedToken.claims.sub !== decodedToken.claims.sub) {
8808
8843
  await this.cacheManager.clear(this.options.clientId);
8809
8844
  this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
8810
8845
  }
8811
8846
  }
8812
- await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, authResult), {
8847
+ await this._saveEntryInCache(_objectSpread2(_objectSpread2(_objectSpread2({}, authResult), {}, {
8813
8848
  decodedToken: decodedToken,
8814
8849
  scope: options.scope,
8815
8850
  audience: options.audience || DEFAULT_AUDIENCE
8816
- }), authResult.scope ? {
8851
+ }, authResult.scope ? {
8817
8852
  oauthTokenScope: authResult.scope
8818
- } : null), {
8853
+ } : null), {}, {
8819
8854
  client_id: this.options.clientId
8820
8855
  }));
8821
8856
  this.cookieStorage.save(this.isAuthenticatedCookieName, true, {
@@ -8823,12 +8858,12 @@ class Auth0Client {
8823
8858
  cookieDomain: this.options.cookieDomain
8824
8859
  });
8825
8860
  this._processOrgHint(organization || decodedToken.claims.org_id);
8826
- return Object.assign(Object.assign({}, authResult), {
8861
+ return _objectSpread2(_objectSpread2({}, authResult), {}, {
8827
8862
  decodedToken: decodedToken
8828
8863
  });
8829
8864
  }
8830
8865
  async loginWithCustomTokenExchange(options) {
8831
- return this._requestToken(Object.assign(Object.assign({}, options), {
8866
+ return this._requestToken(_objectSpread2(_objectSpread2({}, options), {}, {
8832
8867
  grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
8833
8868
  subject_token: options.subject_token,
8834
8869
  subject_token_type: options.subject_token_type,
@@ -8862,10 +8897,10 @@ class Auth0Client {
8862
8897
  return new Fetcher(config, {
8863
8898
  isDpopEnabled: () => !!this.options.useDpop,
8864
8899
  getAccessToken: authParams => {
8865
- var _a;
8900
+ var _authParams$scope;
8866
8901
  return this.getTokenSilently({
8867
8902
  authorizationParams: {
8868
- scope: (_a = authParams === null || authParams === void 0 ? void 0 : authParams.scope) === null || _a === void 0 ? void 0 : _a.join(" "),
8903
+ scope: authParams === null || authParams === void 0 || (_authParams$scope = authParams.scope) === null || _authParams$scope === void 0 ? void 0 : _authParams$scope.join(" "),
8869
8904
  audience: authParams === null || authParams === void 0 ? void 0 : authParams.audience
8870
8905
  },
8871
8906
  detailedResponse: true
@@ -8901,7 +8936,7 @@ class Auth0Client {
8901
8936
  redirect_uri: redirectUri,
8902
8937
  appState: appState,
8903
8938
  connection: connection,
8904
- response_type: exports.ResponseType.ConnectCode
8939
+ response_type: ResponseType.ConnectCode
8905
8940
  });
8906
8941
  const url = new URL(connect_uri);
8907
8942
  url.searchParams.set("ticket", connect_params.ticket);
@@ -8912,8 +8947,8 @@ class Auth0Client {
8912
8947
  }
8913
8948
  }
8914
8949
  async _requestTokenForMfa(options, additionalParameters) {
8915
- const {mfaToken: mfaToken} = options, restOptions = __rest(options, [ "mfaToken" ]);
8916
- return this._requestToken(Object.assign(Object.assign({}, restOptions), {
8950
+ const {mfaToken: mfaToken} = options, restOptions = _objectWithoutProperties(options, _excluded7);
8951
+ return this._requestToken(_objectSpread2(_objectSpread2({}, restOptions), {}, {
8917
8952
  mfa_token: mfaToken
8918
8953
  }), additionalParameters);
8919
8954
  }
@@ -8965,6 +9000,8 @@ exports.PopupOpenError = PopupOpenError;
8965
9000
 
8966
9001
  exports.PopupTimeoutError = PopupTimeoutError;
8967
9002
 
9003
+ exports.ResponseType = ResponseType;
9004
+
8968
9005
  exports.TimeoutError = TimeoutError;
8969
9006
 
8970
9007
  exports.UseDpopNonceError = UseDpopNonceError;