@wandelbots/wandelbots-js-react-components 2.54.5 → 3.0.0

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 (109) hide show
  1. package/README.md +1 -1
  2. package/dist/auth0-spa-js.production.esm-Bb4L9JDU.js +1423 -0
  3. package/dist/auth0-spa-js.production.esm-Bb4L9JDU.js.map +1 -0
  4. package/dist/auth0-spa-js.production.esm-CEI5Uihg.cjs +5 -0
  5. package/dist/auth0-spa-js.production.esm-CEI5Uihg.cjs.map +1 -0
  6. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +1 -1
  7. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts.map +1 -1
  8. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts.map +1 -1
  9. package/dist/components/3d-viewport/collider/ColliderCollection.d.ts +1 -1
  10. package/dist/components/3d-viewport/collider/ColliderCollection.d.ts.map +1 -1
  11. package/dist/components/3d-viewport/collider/ColliderElement.d.ts +1 -1
  12. package/dist/components/3d-viewport/collider/ColliderElement.d.ts.map +1 -1
  13. package/dist/components/3d-viewport/collider/CollisionSceneRenderer.d.ts +1 -1
  14. package/dist/components/3d-viewport/collider/CollisionSceneRenderer.d.ts.map +1 -1
  15. package/dist/components/3d-viewport/collider/colliderShapeToBufferGeometry.d.ts +1 -1
  16. package/dist/components/3d-viewport/collider/colliderShapeToBufferGeometry.d.ts.map +1 -1
  17. package/dist/components/ProgramStateIndicator.d.ts +3 -3
  18. package/dist/components/ProgramStateIndicator.d.ts.map +1 -1
  19. package/dist/components/RobotCard.d.ts +4 -3
  20. package/dist/components/RobotCard.d.ts.map +1 -1
  21. package/dist/components/jogging/JoggingBlocked.d.ts +7 -0
  22. package/dist/components/jogging/JoggingBlocked.d.ts.map +1 -0
  23. package/dist/components/jogging/JoggingCartesianTab.d.ts.map +1 -1
  24. package/dist/components/jogging/JoggingJointTab.d.ts.map +1 -1
  25. package/dist/components/jogging/JoggingPanel.d.ts +1 -1
  26. package/dist/components/jogging/JoggingPanel.d.ts.map +1 -1
  27. package/dist/components/jogging/JoggingStore.d.ts +10 -5
  28. package/dist/components/jogging/JoggingStore.d.ts.map +1 -1
  29. package/dist/components/jogging/PoseCartesianValues.d.ts +2 -2
  30. package/dist/components/jogging/PoseCartesianValues.d.ts.map +1 -1
  31. package/dist/components/jogging/PoseJointValues.d.ts +1 -2
  32. package/dist/components/jogging/PoseJointValues.d.ts.map +1 -1
  33. package/dist/components/robots/DHRobot.d.ts.map +1 -1
  34. package/dist/components/robots/Robot.d.ts +1 -1
  35. package/dist/components/robots/Robot.d.ts.map +1 -1
  36. package/dist/components/robots/RobotAnimator.d.ts +2 -2
  37. package/dist/components/robots/RobotAnimator.d.ts.map +1 -1
  38. package/dist/components/robots/SupportedRobot.d.ts +3 -3
  39. package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
  40. package/dist/components/robots/manufacturerHomePositions.d.ts +1 -1
  41. package/dist/components/robots/manufacturerHomePositions.d.ts.map +1 -1
  42. package/dist/components/safetyBar/OperationModeIndicator.d.ts +2 -2
  43. package/dist/components/safetyBar/OperationModeIndicator.d.ts.map +1 -1
  44. package/dist/components/safetyBar/SafetyBar.d.ts +3 -3
  45. package/dist/components/safetyBar/SafetyBar.d.ts.map +1 -1
  46. package/dist/components/safetyBar/SafetyStateIndicator.d.ts +2 -2
  47. package/dist/components/safetyBar/SafetyStateIndicator.d.ts.map +1 -1
  48. package/dist/components/utils/errorHandling.d.ts.map +1 -1
  49. package/dist/components/utils/errorHandling.test.d.ts +2 -0
  50. package/dist/components/utils/errorHandling.test.d.ts.map +1 -0
  51. package/dist/index.cjs +48 -50
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.js +14058 -18706
  54. package/dist/index.js.map +1 -1
  55. package/dist/lib/ConnectedMotionGroup.d.ts +90 -0
  56. package/dist/lib/ConnectedMotionGroup.d.ts.map +1 -0
  57. package/dist/lib/JoggerConnection.d.ts +113 -0
  58. package/dist/lib/JoggerConnection.d.ts.map +1 -0
  59. package/dist/lib/JoggerConnection.test.d.ts +2 -0
  60. package/dist/lib/JoggerConnection.test.d.ts.map +1 -0
  61. package/dist/lib/MotionStreamConnection.d.ts +24 -0
  62. package/dist/lib/MotionStreamConnection.d.ts.map +1 -0
  63. package/dist/lib/MotionStreamConnection.test.d.ts +2 -0
  64. package/dist/lib/MotionStreamConnection.test.d.ts.map +1 -0
  65. package/dist/lib/motionStateUpdate.d.ts +7 -0
  66. package/dist/lib/motionStateUpdate.d.ts.map +1 -0
  67. package/dist/lib/motionStateUpdate.test.d.ts +2 -0
  68. package/dist/lib/motionStateUpdate.test.d.ts.map +1 -0
  69. package/package.json +2 -2
  70. package/src/components/3d-viewport/CoordinateSystemTransform.tsx +1 -1
  71. package/src/components/3d-viewport/SafetyZonesRenderer.tsx +1 -2
  72. package/src/components/3d-viewport/collider/ColliderCollection.tsx +1 -1
  73. package/src/components/3d-viewport/collider/ColliderElement.tsx +1 -1
  74. package/src/components/3d-viewport/collider/CollisionSceneRenderer.tsx +1 -1
  75. package/src/components/3d-viewport/collider/colliderShapeToBufferGeometry.ts +1 -1
  76. package/src/components/ProgramStateIndicator.tsx +3 -6
  77. package/src/components/RobotCard.tsx +4 -7
  78. package/src/components/jogging/JoggingBlocked.tsx +37 -0
  79. package/src/components/jogging/JoggingCartesianTab.tsx +13 -11
  80. package/src/components/jogging/JoggingJointLimitDetector.tsx +2 -2
  81. package/src/components/jogging/JoggingJointTab.tsx +4 -3
  82. package/src/components/jogging/JoggingPanel.tsx +6 -3
  83. package/src/components/jogging/JoggingStore.ts +66 -39
  84. package/src/components/jogging/PoseCartesianValues.tsx +3 -4
  85. package/src/components/jogging/PoseJointValues.tsx +3 -4
  86. package/src/components/robots/DHRobot.tsx +2 -3
  87. package/src/components/robots/Robot.tsx +1 -1
  88. package/src/components/robots/RobotAnimator.test.tsx +7 -22
  89. package/src/components/robots/RobotAnimator.tsx +8 -13
  90. package/src/components/robots/SupportedRobot.tsx +3 -6
  91. package/src/components/robots/manufacturerHomePositions.ts +1 -1
  92. package/src/components/safetyBar/OperationModeIndicator.tsx +2 -2
  93. package/src/components/safetyBar/SafetyBar.tsx +3 -6
  94. package/src/components/safetyBar/SafetyStateIndicator.tsx +2 -2
  95. package/src/components/utils/errorHandling.test.ts +41 -0
  96. package/src/components/utils/errorHandling.ts +4 -0
  97. package/src/i18n/locales/de/translations.json +3 -0
  98. package/src/i18n/locales/en/translations.json +3 -0
  99. package/src/lib/ConnectedMotionGroup.ts +444 -0
  100. package/src/lib/JoggerConnection.test.ts +120 -0
  101. package/src/lib/JoggerConnection.ts +674 -0
  102. package/src/lib/MotionStreamConnection.test.ts +23 -0
  103. package/src/lib/MotionStreamConnection.ts +186 -0
  104. package/src/lib/motionStateUpdate.test.ts +28 -0
  105. package/src/lib/motionStateUpdate.ts +117 -0
  106. package/dist/auth0-spa-js.production.esm-1QXzndwB.js +0 -950
  107. package/dist/auth0-spa-js.production.esm-1QXzndwB.js.map +0 -1
  108. package/dist/auth0-spa-js.production.esm-BLRAk7Yh.cjs +0 -5
  109. package/dist/auth0-spa-js.production.esm-BLRAk7Yh.cjs.map +0 -1
@@ -0,0 +1,1423 @@
1
+ function I(i, e) {
2
+ var t = {};
3
+ for (var o in i) Object.prototype.hasOwnProperty.call(i, o) && e.indexOf(o) < 0 && (t[o] = i[o]);
4
+ if (i != null && typeof Object.getOwnPropertySymbols == "function") {
5
+ var n = 0;
6
+ for (o = Object.getOwnPropertySymbols(i); n < o.length; n++) e.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(i, o[n]) && (t[o[n]] = i[o[n]]);
7
+ }
8
+ return t;
9
+ }
10
+ var C = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
11
+ function Q(i) {
12
+ return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
13
+ }
14
+ function ee(i, e) {
15
+ return i(e = { exports: {} }, e.exports), e.exports;
16
+ }
17
+ var O = ee(function(i, e) {
18
+ Object.defineProperty(e, "__esModule", { value: !0 });
19
+ var t = function() {
20
+ function o() {
21
+ var n = this;
22
+ this.locked = /* @__PURE__ */ new Map(), this.addToLocked = function(r, a) {
23
+ var h = n.locked.get(r);
24
+ h === void 0 ? a === void 0 ? n.locked.set(r, []) : n.locked.set(r, [a]) : a !== void 0 && (h.unshift(a), n.locked.set(r, h));
25
+ }, this.isLocked = function(r) {
26
+ return n.locked.has(r);
27
+ }, this.lock = function(r) {
28
+ return new Promise(function(a, h) {
29
+ n.isLocked(r) ? n.addToLocked(r, a) : (n.addToLocked(r), a());
30
+ });
31
+ }, this.unlock = function(r) {
32
+ var a = n.locked.get(r);
33
+ if (a !== void 0 && a.length !== 0) {
34
+ var h = a.pop();
35
+ n.locked.set(r, a), h !== void 0 && setTimeout(h, 0);
36
+ } else n.locked.delete(r);
37
+ };
38
+ }
39
+ return o.getInstance = function() {
40
+ return o.instance === void 0 && (o.instance = new o()), o.instance;
41
+ }, o;
42
+ }();
43
+ e.default = function() {
44
+ return t.getInstance();
45
+ };
46
+ });
47
+ Q(O);
48
+ var Ce = Q(ee(function(i, e) {
49
+ var t = C && C.__awaiter || function(s, c, d, l) {
50
+ return new (d || (d = Promise))(function(m, y) {
51
+ function g(w) {
52
+ try {
53
+ b(l.next(w));
54
+ } catch (f) {
55
+ y(f);
56
+ }
57
+ }
58
+ function k(w) {
59
+ try {
60
+ b(l.throw(w));
61
+ } catch (f) {
62
+ y(f);
63
+ }
64
+ }
65
+ function b(w) {
66
+ w.done ? m(w.value) : new d(function(f) {
67
+ f(w.value);
68
+ }).then(g, k);
69
+ }
70
+ b((l = l.apply(s, c || [])).next());
71
+ });
72
+ }, o = C && C.__generator || function(s, c) {
73
+ var d, l, m, y, g = { label: 0, sent: function() {
74
+ if (1 & m[0]) throw m[1];
75
+ return m[1];
76
+ }, trys: [], ops: [] };
77
+ return y = { next: k(0), throw: k(1), return: k(2) }, typeof Symbol == "function" && (y[Symbol.iterator] = function() {
78
+ return this;
79
+ }), y;
80
+ function k(b) {
81
+ return function(w) {
82
+ return function(f) {
83
+ if (d) throw new TypeError("Generator is already executing.");
84
+ for (; g; ) try {
85
+ if (d = 1, l && (m = 2 & f[0] ? l.return : f[0] ? l.throw || ((m = l.return) && m.call(l), 0) : l.next) && !(m = m.call(l, f[1])).done) return m;
86
+ switch (l = 0, m && (f = [2 & f[0], m.value]), f[0]) {
87
+ case 0:
88
+ case 1:
89
+ m = f;
90
+ break;
91
+ case 4:
92
+ return g.label++, { value: f[1], done: !1 };
93
+ case 5:
94
+ g.label++, l = f[1], f = [0];
95
+ continue;
96
+ case 7:
97
+ f = g.ops.pop(), g.trys.pop();
98
+ continue;
99
+ default:
100
+ if (m = g.trys, !((m = m.length > 0 && m[m.length - 1]) || f[0] !== 6 && f[0] !== 2)) {
101
+ g = 0;
102
+ continue;
103
+ }
104
+ if (f[0] === 3 && (!m || f[1] > m[0] && f[1] < m[3])) {
105
+ g.label = f[1];
106
+ break;
107
+ }
108
+ if (f[0] === 6 && g.label < m[1]) {
109
+ g.label = m[1], m = f;
110
+ break;
111
+ }
112
+ if (m && g.label < m[2]) {
113
+ g.label = m[2], g.ops.push(f);
114
+ break;
115
+ }
116
+ m[2] && g.ops.pop(), g.trys.pop();
117
+ continue;
118
+ }
119
+ f = c.call(s, g);
120
+ } catch (S) {
121
+ f = [6, S], l = 0;
122
+ } finally {
123
+ d = m = 0;
124
+ }
125
+ if (5 & f[0]) throw f[1];
126
+ return { value: f[0] ? f[1] : void 0, done: !0 };
127
+ }([b, w]);
128
+ };
129
+ }
130
+ }, n = C;
131
+ Object.defineProperty(e, "__esModule", { value: !0 });
132
+ var r = "browser-tabs-lock-key", a = { key: function(s) {
133
+ return t(n, void 0, void 0, function() {
134
+ return o(this, function(c) {
135
+ throw new Error("Unsupported");
136
+ });
137
+ });
138
+ }, getItem: function(s) {
139
+ return t(n, void 0, void 0, function() {
140
+ return o(this, function(c) {
141
+ throw new Error("Unsupported");
142
+ });
143
+ });
144
+ }, clear: function() {
145
+ return t(n, void 0, void 0, function() {
146
+ return o(this, function(s) {
147
+ return [2, window.localStorage.clear()];
148
+ });
149
+ });
150
+ }, removeItem: function(s) {
151
+ return t(n, void 0, void 0, function() {
152
+ return o(this, function(c) {
153
+ throw new Error("Unsupported");
154
+ });
155
+ });
156
+ }, setItem: function(s, c) {
157
+ return t(n, void 0, void 0, function() {
158
+ return o(this, function(d) {
159
+ throw new Error("Unsupported");
160
+ });
161
+ });
162
+ }, keySync: function(s) {
163
+ return window.localStorage.key(s);
164
+ }, getItemSync: function(s) {
165
+ return window.localStorage.getItem(s);
166
+ }, clearSync: function() {
167
+ return window.localStorage.clear();
168
+ }, removeItemSync: function(s) {
169
+ return window.localStorage.removeItem(s);
170
+ }, setItemSync: function(s, c) {
171
+ return window.localStorage.setItem(s, c);
172
+ } };
173
+ function h(s) {
174
+ return new Promise(function(c) {
175
+ return setTimeout(c, s);
176
+ });
177
+ }
178
+ function u(s) {
179
+ for (var c = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", d = "", l = 0; l < s; l++)
180
+ d += c[Math.floor(Math.random() * c.length)];
181
+ return d;
182
+ }
183
+ var p = function() {
184
+ function s(c) {
185
+ this.acquiredIatSet = /* @__PURE__ */ new Set(), this.storageHandler = void 0, this.id = Date.now().toString() + u(15), this.acquireLock = this.acquireLock.bind(this), this.releaseLock = this.releaseLock.bind(this), this.releaseLock__private__ = this.releaseLock__private__.bind(this), this.waitForSomethingToChange = this.waitForSomethingToChange.bind(this), this.refreshLockWhileAcquired = this.refreshLockWhileAcquired.bind(this), this.storageHandler = c, s.waiters === void 0 && (s.waiters = []);
186
+ }
187
+ return s.prototype.acquireLock = function(c, d) {
188
+ return d === void 0 && (d = 5e3), t(this, void 0, void 0, function() {
189
+ var l, m, y, g, k, b, w;
190
+ return o(this, function(f) {
191
+ switch (f.label) {
192
+ case 0:
193
+ l = Date.now() + u(4), m = Date.now() + d, y = r + "-" + c, g = this.storageHandler === void 0 ? a : this.storageHandler, f.label = 1;
194
+ case 1:
195
+ return Date.now() < m ? [4, h(30)] : [3, 8];
196
+ case 2:
197
+ return f.sent(), g.getItemSync(y) !== null ? [3, 5] : (k = this.id + "-" + c + "-" + l, [4, h(Math.floor(25 * Math.random()))]);
198
+ case 3:
199
+ return f.sent(), g.setItemSync(y, JSON.stringify({ id: this.id, iat: l, timeoutKey: k, timeAcquired: Date.now(), timeRefreshed: Date.now() })), [4, h(30)];
200
+ case 4:
201
+ return f.sent(), (b = g.getItemSync(y)) !== null && (w = JSON.parse(b)).id === this.id && w.iat === l ? (this.acquiredIatSet.add(l), this.refreshLockWhileAcquired(y, l), [2, !0]) : [3, 7];
202
+ case 5:
203
+ return s.lockCorrector(this.storageHandler === void 0 ? a : this.storageHandler), [4, this.waitForSomethingToChange(m)];
204
+ case 6:
205
+ f.sent(), f.label = 7;
206
+ case 7:
207
+ return l = Date.now() + u(4), [3, 1];
208
+ case 8:
209
+ return [2, !1];
210
+ }
211
+ });
212
+ });
213
+ }, s.prototype.refreshLockWhileAcquired = function(c, d) {
214
+ return t(this, void 0, void 0, function() {
215
+ var l = this;
216
+ return o(this, function(m) {
217
+ return setTimeout(function() {
218
+ return t(l, void 0, void 0, function() {
219
+ var y, g, k;
220
+ return o(this, function(b) {
221
+ switch (b.label) {
222
+ case 0:
223
+ return [4, O.default().lock(d)];
224
+ case 1:
225
+ return b.sent(), this.acquiredIatSet.has(d) ? (y = this.storageHandler === void 0 ? a : this.storageHandler, (g = y.getItemSync(c)) === null ? (O.default().unlock(d), [2]) : ((k = JSON.parse(g)).timeRefreshed = Date.now(), y.setItemSync(c, JSON.stringify(k)), O.default().unlock(d), this.refreshLockWhileAcquired(c, d), [2])) : (O.default().unlock(d), [2]);
226
+ }
227
+ });
228
+ });
229
+ }, 1e3), [2];
230
+ });
231
+ });
232
+ }, s.prototype.waitForSomethingToChange = function(c) {
233
+ return t(this, void 0, void 0, function() {
234
+ return o(this, function(d) {
235
+ switch (d.label) {
236
+ case 0:
237
+ return [4, new Promise(function(l) {
238
+ var m = !1, y = Date.now(), g = !1;
239
+ function k() {
240
+ if (g || (window.removeEventListener("storage", k), s.removeFromWaiting(k), clearTimeout(b), g = !0), !m) {
241
+ m = !0;
242
+ var w = 50 - (Date.now() - y);
243
+ w > 0 ? setTimeout(l, w) : l(null);
244
+ }
245
+ }
246
+ window.addEventListener("storage", k), s.addToWaiting(k);
247
+ var b = setTimeout(k, Math.max(0, c - Date.now()));
248
+ })];
249
+ case 1:
250
+ return d.sent(), [2];
251
+ }
252
+ });
253
+ });
254
+ }, s.addToWaiting = function(c) {
255
+ this.removeFromWaiting(c), s.waiters !== void 0 && s.waiters.push(c);
256
+ }, s.removeFromWaiting = function(c) {
257
+ s.waiters !== void 0 && (s.waiters = s.waiters.filter(function(d) {
258
+ return d !== c;
259
+ }));
260
+ }, s.notifyWaiters = function() {
261
+ s.waiters !== void 0 && s.waiters.slice().forEach(function(c) {
262
+ return c();
263
+ });
264
+ }, s.prototype.releaseLock = function(c) {
265
+ return t(this, void 0, void 0, function() {
266
+ return o(this, function(d) {
267
+ switch (d.label) {
268
+ case 0:
269
+ return [4, this.releaseLock__private__(c)];
270
+ case 1:
271
+ return [2, d.sent()];
272
+ }
273
+ });
274
+ });
275
+ }, s.prototype.releaseLock__private__ = function(c) {
276
+ return t(this, void 0, void 0, function() {
277
+ var d, l, m, y;
278
+ return o(this, function(g) {
279
+ switch (g.label) {
280
+ case 0:
281
+ return d = this.storageHandler === void 0 ? a : this.storageHandler, l = r + "-" + c, (m = d.getItemSync(l)) === null ? [2] : (y = JSON.parse(m)).id !== this.id ? [3, 2] : [4, O.default().lock(y.iat)];
282
+ case 1:
283
+ g.sent(), this.acquiredIatSet.delete(y.iat), d.removeItemSync(l), O.default().unlock(y.iat), s.notifyWaiters(), g.label = 2;
284
+ case 2:
285
+ return [2];
286
+ }
287
+ });
288
+ });
289
+ }, s.lockCorrector = function(c) {
290
+ for (var d = Date.now() - 5e3, l = c, m = [], y = 0; ; ) {
291
+ var g = l.keySync(y);
292
+ if (g === null) break;
293
+ m.push(g), y++;
294
+ }
295
+ for (var k = !1, b = 0; b < m.length; b++) {
296
+ var w = m[b];
297
+ if (w.includes(r)) {
298
+ var f = l.getItemSync(w);
299
+ if (f !== null) {
300
+ var S = JSON.parse(f);
301
+ (S.timeRefreshed === void 0 && S.timeAcquired < d || S.timeRefreshed !== void 0 && S.timeRefreshed < d) && (l.removeItemSync(w), k = !0);
302
+ }
303
+ }
304
+ }
305
+ k && s.notifyWaiters();
306
+ }, s.waiters = void 0, s;
307
+ }();
308
+ e.default = p;
309
+ }));
310
+ const je = { timeoutInSeconds: 60 }, we = { name: "auth0-spa-js", version: "2.8.0" }, be = () => Date.now();
311
+ class v extends Error {
312
+ constructor(e, t) {
313
+ super(t), this.error = e, this.error_description = t, Object.setPrototypeOf(this, v.prototype);
314
+ }
315
+ static fromPayload({ error: e, error_description: t }) {
316
+ return new v(e, t);
317
+ }
318
+ }
319
+ class te extends v {
320
+ constructor(e, t, o, n = null) {
321
+ super(e, t), this.state = o, this.appState = n, Object.setPrototypeOf(this, te.prototype);
322
+ }
323
+ }
324
+ class oe extends v {
325
+ constructor(e, t, o, n, r = null) {
326
+ super(e, t), this.connection = o, this.state = n, this.appState = r, Object.setPrototypeOf(this, oe.prototype);
327
+ }
328
+ }
329
+ class U extends v {
330
+ constructor() {
331
+ super("timeout", "Timeout"), Object.setPrototypeOf(this, U.prototype);
332
+ }
333
+ }
334
+ class ne extends U {
335
+ constructor(e) {
336
+ super(), this.popup = e, Object.setPrototypeOf(this, ne.prototype);
337
+ }
338
+ }
339
+ class ie extends v {
340
+ constructor(e) {
341
+ super("cancelled", "Popup closed"), this.popup = e, Object.setPrototypeOf(this, ie.prototype);
342
+ }
343
+ }
344
+ class re extends v {
345
+ constructor(e, t, o) {
346
+ super(e, t), this.mfa_token = o, Object.setPrototypeOf(this, re.prototype);
347
+ }
348
+ }
349
+ class V extends v {
350
+ constructor(e, t) {
351
+ super("missing_refresh_token", `Missing Refresh Token (audience: '${W(e, ["default"])}', scope: '${W(t)}')`), this.audience = e, this.scope = t, Object.setPrototypeOf(this, V.prototype);
352
+ }
353
+ }
354
+ class se extends v {
355
+ constructor(e, t) {
356
+ super("missing_scopes", `Missing requested scopes after refresh (audience: '${W(e, ["default"])}', missing scope: '${W(t)}')`), this.audience = e, this.scope = t, Object.setPrototypeOf(this, se.prototype);
357
+ }
358
+ }
359
+ class F extends v {
360
+ constructor(e) {
361
+ super("use_dpop_nonce", "Server rejected DPoP proof: wrong nonce"), this.newDpopNonce = e, Object.setPrototypeOf(this, F.prototype);
362
+ }
363
+ }
364
+ function W(i, e = []) {
365
+ return i && !e.includes(i) ? i : "";
366
+ }
367
+ const J = () => window.crypto, N = () => {
368
+ const i = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
369
+ let e = "";
370
+ return Array.from(J().getRandomValues(new Uint8Array(43))).forEach((t) => e += i[t % i.length]), e;
371
+ }, G = (i) => btoa(i), Ke = [{ key: "name", type: ["string"] }, { key: "version", type: ["string", "number"] }, { key: "env", type: ["object"] }], xe = (i) => Object.keys(i).reduce((e, t) => {
372
+ const o = Ke.find((n) => n.key === t);
373
+ return o && o.type.includes(typeof i[t]) && (e[t] = i[t]), e;
374
+ }, {}), B = (i) => {
375
+ var { clientId: e } = i, t = I(i, ["clientId"]);
376
+ return new URLSearchParams(((o) => Object.keys(o).filter((n) => o[n] !== void 0).reduce((n, r) => Object.assign(Object.assign({}, n), { [r]: o[r] }), {}))(Object.assign({ client_id: e }, t))).toString();
377
+ }, ce = async (i) => await J().subtle.digest({ name: "SHA-256" }, new TextEncoder().encode(i)), ue = (i) => ((e) => decodeURIComponent(atob(e).split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")))(i.replace(/_/g, "/").replace(/-/g, "+")), he = (i) => {
378
+ const e = new Uint8Array(i);
379
+ return ((t) => {
380
+ const o = { "+": "-", "/": "_", "=": "" };
381
+ return t.replace(/[+/=]/g, (n) => o[n]);
382
+ })(window.btoa(String.fromCharCode(...Array.from(e))));
383
+ }, Ee = new TextEncoder(), ze = new TextDecoder();
384
+ function D(i) {
385
+ return typeof i == "string" ? Ee.encode(i) : ze.decode(i);
386
+ }
387
+ function de(i) {
388
+ if (typeof i.modulusLength != "number" || i.modulusLength < 2048) throw new Re(`${i.name} modulusLength must be at least 2048 bits`);
389
+ }
390
+ async function Ne(i, e, t) {
391
+ if (t.usages.includes("sign") === !1) throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');
392
+ const o = `${A(D(JSON.stringify(i)))}.${A(D(JSON.stringify(e)))}`;
393
+ return `${o}.${A(await crypto.subtle.sign(function(n) {
394
+ switch (n.algorithm.name) {
395
+ case "ECDSA":
396
+ return { name: n.algorithm.name, hash: "SHA-256" };
397
+ case "RSA-PSS":
398
+ return de(n.algorithm), { name: n.algorithm.name, saltLength: 32 };
399
+ case "RSASSA-PKCS1-v1_5":
400
+ return de(n.algorithm), { name: n.algorithm.name };
401
+ case "Ed25519":
402
+ return { name: n.algorithm.name };
403
+ }
404
+ throw new K();
405
+ }(t), t, D(o)))}`;
406
+ }
407
+ let q;
408
+ Uint8Array.prototype.toBase64 ? q = (i) => (i instanceof ArrayBuffer && (i = new Uint8Array(i)), i.toBase64({ alphabet: "base64url", omitPadding: !0 })) : q = (e) => {
409
+ e instanceof ArrayBuffer && (e = new Uint8Array(e));
410
+ const t = [];
411
+ for (let o = 0; o < e.byteLength; o += 32768) t.push(String.fromCharCode.apply(null, e.subarray(o, o + 32768)));
412
+ return btoa(t.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
413
+ };
414
+ function A(i) {
415
+ return q(i);
416
+ }
417
+ class K extends Error {
418
+ constructor(e) {
419
+ var t;
420
+ super(e ?? "operation not supported"), this.name = this.constructor.name, (t = Error.captureStackTrace) === null || t === void 0 || t.call(Error, this, this.constructor);
421
+ }
422
+ }
423
+ class Re extends Error {
424
+ constructor(e) {
425
+ var t;
426
+ super(e), this.name = this.constructor.name, (t = Error.captureStackTrace) === null || t === void 0 || t.call(Error, this, this.constructor);
427
+ }
428
+ }
429
+ function De(i) {
430
+ switch (i.algorithm.name) {
431
+ case "RSA-PSS":
432
+ return function(e) {
433
+ if (e.algorithm.hash.name === "SHA-256") return "PS256";
434
+ throw new K("unsupported RsaHashedKeyAlgorithm hash name");
435
+ }(i);
436
+ case "RSASSA-PKCS1-v1_5":
437
+ return function(e) {
438
+ if (e.algorithm.hash.name === "SHA-256") return "RS256";
439
+ throw new K("unsupported RsaHashedKeyAlgorithm hash name");
440
+ }(i);
441
+ case "ECDSA":
442
+ return function(e) {
443
+ if (e.algorithm.namedCurve === "P-256") return "ES256";
444
+ throw new K("unsupported EcKeyAlgorithm namedCurve");
445
+ }(i);
446
+ case "Ed25519":
447
+ return "Ed25519";
448
+ default:
449
+ throw new K("unsupported CryptoKey algorithm name");
450
+ }
451
+ }
452
+ function ke(i) {
453
+ return i instanceof CryptoKey;
454
+ }
455
+ function ve(i) {
456
+ return ke(i) && i.type === "public";
457
+ }
458
+ async function Ae(i, e, t, o, n, r) {
459
+ const a = i == null ? void 0 : i.privateKey, h = i == null ? void 0 : i.publicKey;
460
+ if (!ke(u = a) || u.type !== "private") throw new TypeError('"keypair.privateKey" must be a private CryptoKey');
461
+ var u;
462
+ if (!ve(h)) throw new TypeError('"keypair.publicKey" must be a public CryptoKey');
463
+ if (h.extractable !== !0) throw new TypeError('"keypair.publicKey.extractable" must be true');
464
+ if (typeof e != "string") throw new TypeError('"htu" must be a string');
465
+ if (typeof t != "string") throw new TypeError('"htm" must be a string');
466
+ if (o !== void 0 && typeof o != "string") throw new TypeError('"nonce" must be a string or undefined');
467
+ if (n !== void 0 && typeof n != "string") throw new TypeError('"accessToken" must be a string or undefined');
468
+ return Ne({ alg: De(a), typ: "dpop+jwt", jwk: await _e(h) }, Object.assign(Object.assign({}, r), { iat: Math.floor(Date.now() / 1e3), jti: crypto.randomUUID(), htm: t, nonce: o, htu: e, ath: n ? A(await crypto.subtle.digest("SHA-256", D(n))) : void 0 }), a);
469
+ }
470
+ async function _e(i) {
471
+ const { kty: e, e: t, n: o, x: n, y: r, crv: a } = await crypto.subtle.exportKey("jwk", i);
472
+ return { kty: e, crv: a, e: t, n: o, x: n, y: r };
473
+ }
474
+ const Ue = ["authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:token-exchange"];
475
+ function Le() {
476
+ return async function(i, e) {
477
+ var t;
478
+ let o;
479
+ if (i.length === 0) throw new TypeError('"alg" must be a non-empty string');
480
+ switch (i) {
481
+ case "PS256":
482
+ o = { name: "RSA-PSS", hash: "SHA-256", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]) };
483
+ break;
484
+ case "RS256":
485
+ o = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]) };
486
+ break;
487
+ case "ES256":
488
+ o = { name: "ECDSA", namedCurve: "P-256" };
489
+ break;
490
+ case "Ed25519":
491
+ o = { name: "Ed25519" };
492
+ break;
493
+ default:
494
+ throw new K();
495
+ }
496
+ return crypto.subtle.generateKey(o, (t = e == null ? void 0 : e.extractable) !== null && t !== void 0 && t, ["sign", "verify"]);
497
+ }("ES256", { extractable: !1 });
498
+ }
499
+ function Ze(i) {
500
+ return async function(e) {
501
+ if (!ve(e)) throw new TypeError('"publicKey" must be a public CryptoKey');
502
+ if (e.extractable !== !0) throw new TypeError('"publicKey.extractable" must be true');
503
+ const t = await _e(e);
504
+ let o;
505
+ switch (t.kty) {
506
+ case "EC":
507
+ o = { crv: t.crv, kty: t.kty, x: t.x, y: t.y };
508
+ break;
509
+ case "OKP":
510
+ o = { crv: t.crv, kty: t.kty, x: t.x };
511
+ break;
512
+ case "RSA":
513
+ o = { e: t.e, kty: t.kty, n: t.n };
514
+ break;
515
+ default:
516
+ throw new K("unsupported JWK kty");
517
+ }
518
+ return A(await crypto.subtle.digest({ name: "SHA-256" }, D(JSON.stringify(o))));
519
+ }(i.publicKey);
520
+ }
521
+ function He({ keyPair: i, url: e, method: t, nonce: o, accessToken: n }) {
522
+ const r = function(a) {
523
+ const h = new URL(a);
524
+ return h.search = "", h.hash = "", h.href;
525
+ }(e);
526
+ return Ae(i, r, t, o, n);
527
+ }
528
+ const We = async (i, e) => {
529
+ const t = await fetch(i, e);
530
+ return { ok: t.ok, json: await t.json(), headers: (o = t.headers, [...o].reduce((n, [r, a]) => (n[r] = a, n), {})) };
531
+ var o;
532
+ }, Je = async (i, e, t) => {
533
+ const o = new AbortController();
534
+ let n;
535
+ return e.signal = o.signal, Promise.race([We(i, e), new Promise((r, a) => {
536
+ n = setTimeout(() => {
537
+ o.abort(), a(new Error("Timeout when executing 'fetch'"));
538
+ }, t);
539
+ })]).finally(() => {
540
+ clearTimeout(n);
541
+ });
542
+ }, Xe = async (i, e, t, o, n, r, a, h) => {
543
+ return u = { auth: { audience: e, scope: t }, timeout: n, fetchUrl: i, fetchOptions: o, useFormData: a, useMrrt: h }, p = r, new Promise(function(s, c) {
544
+ const d = new MessageChannel();
545
+ d.port1.onmessage = function(l) {
546
+ l.data.error ? c(new Error(l.data.error)) : s(l.data), d.port1.close();
547
+ }, p.postMessage(u, [d.port2]);
548
+ });
549
+ var u, p;
550
+ }, Ve = async (i, e, t, o, n, r, a = 1e4, h) => n ? Xe(i, e, t, o, a, n, r, h) : Je(i, o, a);
551
+ async function Se(i, e, t, o, n, r, a, h, u, p) {
552
+ if (u) {
553
+ const w = await u.generateProof({ url: i, method: n.method || "GET", nonce: await u.getNonce() });
554
+ n.headers = Object.assign(Object.assign({}, n.headers), { dpop: w });
555
+ }
556
+ let s, c = null;
557
+ for (let w = 0; w < 3; w++) try {
558
+ s = await Ve(i, t, o, n, r, a, e, h), c = null;
559
+ break;
560
+ } catch (f) {
561
+ c = f;
562
+ }
563
+ if (c) throw c;
564
+ const d = s.json, { error: l, error_description: m } = d, y = I(d, ["error", "error_description"]), { headers: g, ok: k } = s;
565
+ let b;
566
+ if (u && (b = g["dpop-nonce"], b && await u.setNonce(b)), !k) {
567
+ const w = m || `HTTP error. Unable to fetch ${i}`;
568
+ if (l === "mfa_required") throw new re(l, w, y.mfa_token);
569
+ if (l === "missing_refresh_token") throw new V(t, o);
570
+ if (l === "use_dpop_nonce") {
571
+ if (!u || !b || p) throw new F(b);
572
+ return Se(i, e, t, o, n, r, a, h, u, !0);
573
+ }
574
+ throw new v(l || "request_error", w);
575
+ }
576
+ return y;
577
+ }
578
+ async function Fe(i, e) {
579
+ var { baseUrl: t, timeout: o, audience: n, scope: r, auth0Client: a, useFormData: h, useMrrt: u, dpop: p } = i, s = I(i, ["baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData", "useMrrt", "dpop"]);
580
+ const c = s.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange", d = s.grant_type === "refresh_token" && u, l = Object.assign(Object.assign(Object.assign(Object.assign({}, s), c && n && { audience: n }), c && r && { scope: r }), d && { audience: n, scope: r }), m = h ? B(l) : JSON.stringify(l), y = (g = s.grant_type, Ue.includes(g));
581
+ var g;
582
+ return await Se(`${t}/oauth/token`, o, n || "default", r, { method: "POST", body: m, headers: { "Content-Type": h ? "application/x-www-form-urlencoded" : "application/json", "Auth0-Client": btoa(JSON.stringify(xe(a || we))) } }, e, h, u, y ? p : void 0);
583
+ }
584
+ const H = (...i) => {
585
+ return (e = i.filter(Boolean).join(" ").trim().split(/\s+/), Array.from(new Set(e))).join(" ");
586
+ var e;
587
+ }, Z = (i, e, t) => {
588
+ let o;
589
+ return t && (o = i[t]), o || (o = i.default), H(o, e);
590
+ };
591
+ class _ {
592
+ constructor(e, t = "@@auth0spajs@@", o) {
593
+ this.prefix = t, this.suffix = o, this.clientId = e.clientId, this.scope = e.scope, this.audience = e.audience;
594
+ }
595
+ toKey() {
596
+ return [this.prefix, this.clientId, this.audience, this.scope, this.suffix].filter(Boolean).join("::");
597
+ }
598
+ static fromKey(e) {
599
+ const [t, o, n, r] = e.split("::");
600
+ return new _({ clientId: o, scope: r, audience: n }, t);
601
+ }
602
+ static fromCacheEntry(e) {
603
+ const { scope: t, audience: o, client_id: n } = e;
604
+ return new _({ scope: t, audience: o, clientId: n });
605
+ }
606
+ }
607
+ class Ge {
608
+ set(e, t) {
609
+ localStorage.setItem(e, JSON.stringify(t));
610
+ }
611
+ get(e) {
612
+ const t = window.localStorage.getItem(e);
613
+ if (t) try {
614
+ return JSON.parse(t);
615
+ } catch {
616
+ return;
617
+ }
618
+ }
619
+ remove(e) {
620
+ localStorage.removeItem(e);
621
+ }
622
+ allKeys() {
623
+ return Object.keys(window.localStorage).filter((e) => e.startsWith("@@auth0spajs@@"));
624
+ }
625
+ }
626
+ class Ie {
627
+ constructor() {
628
+ this.enclosedCache = /* @__PURE__ */ function() {
629
+ let e = {};
630
+ return { set(t, o) {
631
+ e[t] = o;
632
+ }, get(t) {
633
+ const o = e[t];
634
+ if (o) return o;
635
+ }, remove(t) {
636
+ delete e[t];
637
+ }, allKeys: () => Object.keys(e) };
638
+ }();
639
+ }
640
+ }
641
+ class Me {
642
+ constructor(e, t, o) {
643
+ this.cache = e, this.keyManifest = t, this.nowProvider = o || be;
644
+ }
645
+ async setIdToken(e, t, o) {
646
+ var n;
647
+ const r = this.getIdTokenCacheKey(e);
648
+ await this.cache.set(r, { id_token: t, decodedToken: o }), await ((n = this.keyManifest) === null || n === void 0 ? void 0 : n.add(r));
649
+ }
650
+ async getIdToken(e) {
651
+ const t = await this.cache.get(this.getIdTokenCacheKey(e.clientId));
652
+ if (!t && e.scope && e.audience) {
653
+ const o = await this.get(e);
654
+ return !o || !o.id_token || !o.decodedToken ? void 0 : { id_token: o.id_token, decodedToken: o.decodedToken };
655
+ }
656
+ if (t) return { id_token: t.id_token, decodedToken: t.decodedToken };
657
+ }
658
+ async get(e, t = 0, o = !1, n) {
659
+ var r;
660
+ let a = await this.cache.get(e.toKey());
661
+ if (!a) {
662
+ const p = await this.getCacheKeys();
663
+ if (!p) return;
664
+ const s = this.matchExistingCacheKey(e, p);
665
+ if (s && (a = await this.cache.get(s)), !s && o && n !== "cache-only") return this.getEntryWithRefreshToken(e, p);
666
+ }
667
+ if (!a) return;
668
+ const h = await this.nowProvider(), u = Math.floor(h / 1e3);
669
+ return a.expiresAt - t < u ? a.body.refresh_token ? this.modifiedCachedEntry(a, e) : (await this.cache.remove(e.toKey()), void await ((r = this.keyManifest) === null || r === void 0 ? void 0 : r.remove(e.toKey()))) : a.body;
670
+ }
671
+ async modifiedCachedEntry(e, t) {
672
+ return e.body = { refresh_token: e.body.refresh_token, audience: e.body.audience, scope: e.body.scope }, await this.cache.set(t.toKey(), e), { refresh_token: e.body.refresh_token, audience: e.body.audience, scope: e.body.scope };
673
+ }
674
+ async set(e) {
675
+ var t;
676
+ const o = new _({ clientId: e.client_id, scope: e.scope, audience: e.audience }), n = await this.wrapCacheEntry(e);
677
+ await this.cache.set(o.toKey(), n), await ((t = this.keyManifest) === null || t === void 0 ? void 0 : t.add(o.toKey()));
678
+ }
679
+ async remove(e, t, o) {
680
+ const n = new _({ clientId: e, scope: o, audience: t });
681
+ await this.cache.remove(n.toKey());
682
+ }
683
+ async clear(e) {
684
+ var t;
685
+ const o = await this.getCacheKeys();
686
+ o && (await o.filter((n) => !e || n.includes(e)).reduce(async (n, r) => {
687
+ await n, await this.cache.remove(r);
688
+ }, Promise.resolve()), await ((t = this.keyManifest) === null || t === void 0 ? void 0 : t.clear()));
689
+ }
690
+ async wrapCacheEntry(e) {
691
+ const t = await this.nowProvider();
692
+ return { body: e, expiresAt: Math.floor(t / 1e3) + e.expires_in };
693
+ }
694
+ async getCacheKeys() {
695
+ var e;
696
+ return this.keyManifest ? (e = await this.keyManifest.get()) === null || e === void 0 ? void 0 : e.keys : this.cache.allKeys ? this.cache.allKeys() : void 0;
697
+ }
698
+ getIdTokenCacheKey(e) {
699
+ return new _({ clientId: e }, "@@auth0spajs@@", "@@user@@").toKey();
700
+ }
701
+ matchExistingCacheKey(e, t) {
702
+ return t.filter((o) => {
703
+ var n;
704
+ const r = _.fromKey(o), a = new Set(r.scope && r.scope.split(" ")), h = ((n = e.scope) === null || n === void 0 ? void 0 : n.split(" ")) || [], u = r.scope && h.reduce((p, s) => p && a.has(s), !0);
705
+ return r.prefix === "@@auth0spajs@@" && r.clientId === e.clientId && r.audience === e.audience && u;
706
+ })[0];
707
+ }
708
+ async getEntryWithRefreshToken(e, t) {
709
+ var o;
710
+ for (const n of t) {
711
+ const r = _.fromKey(n);
712
+ if (r.prefix === "@@auth0spajs@@" && r.clientId === e.clientId) {
713
+ const a = await this.cache.get(n);
714
+ if (!((o = a == null ? void 0 : a.body) === null || o === void 0) && o.refresh_token) return this.modifiedCachedEntry(a, e);
715
+ }
716
+ }
717
+ }
718
+ async updateEntry(e, t) {
719
+ var o;
720
+ const n = await this.getCacheKeys();
721
+ if (n) for (const r of n) {
722
+ const a = await this.cache.get(r);
723
+ if (((o = a == null ? void 0 : a.body) === null || o === void 0 ? void 0 : o.refresh_token) === e) {
724
+ const h = Object.assign(Object.assign({}, a.body), { refresh_token: t });
725
+ await this.set(h);
726
+ }
727
+ }
728
+ }
729
+ }
730
+ class Ye {
731
+ constructor(e, t, o) {
732
+ this.storage = e, this.clientId = t, this.cookieDomain = o, this.storageKey = `a0.spajs.txs.${this.clientId}`;
733
+ }
734
+ create(e) {
735
+ this.storage.save(this.storageKey, e, { daysUntilExpire: 1, cookieDomain: this.cookieDomain });
736
+ }
737
+ get() {
738
+ return this.storage.get(this.storageKey);
739
+ }
740
+ remove() {
741
+ this.storage.remove(this.storageKey, { cookieDomain: this.cookieDomain });
742
+ }
743
+ }
744
+ const R = (i) => typeof i == "number", $e = ["iss", "aud", "exp", "nbf", "iat", "jti", "azp", "nonce", "auth_time", "at_hash", "c_hash", "acr", "amr", "sub_jwk", "cnf", "sip_from_tag", "sip_date", "sip_callid", "sip_cseq_num", "sip_via_branch", "orig", "dest", "mky", "events", "toe", "txn", "rph", "sid", "vot", "vtm"], Be = (i) => {
745
+ if (!i.id_token) throw new Error("ID token is required but missing");
746
+ const e = ((r) => {
747
+ const a = r.split("."), [h, u, p] = a;
748
+ if (a.length !== 3 || !h || !u || !p) throw new Error("ID token could not be decoded");
749
+ const s = JSON.parse(ue(u)), c = { __raw: r }, d = {};
750
+ return Object.keys(s).forEach((l) => {
751
+ c[l] = s[l], $e.includes(l) || (d[l] = s[l]);
752
+ }), { encoded: { header: h, payload: u, signature: p }, header: JSON.parse(ue(h)), claims: c, user: d };
753
+ })(i.id_token);
754
+ if (!e.claims.iss) throw new Error("Issuer (iss) claim must be a string present in the ID token");
755
+ if (e.claims.iss !== i.iss) throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${i.iss}", found "${e.claims.iss}"`);
756
+ if (!e.user.sub) throw new Error("Subject (sub) claim must be a string present in the ID token");
757
+ if (e.header.alg !== "RS256") throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);
758
+ if (!e.claims.aud || typeof e.claims.aud != "string" && !Array.isArray(e.claims.aud)) throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");
759
+ if (Array.isArray(e.claims.aud)) {
760
+ if (!e.claims.aud.includes(i.aud)) throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${i.aud}" but was not one of "${e.claims.aud.join(", ")}"`);
761
+ if (e.claims.aud.length > 1) {
762
+ if (!e.claims.azp) throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");
763
+ if (e.claims.azp !== i.aud) throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${i.aud}", found "${e.claims.azp}"`);
764
+ }
765
+ } else if (e.claims.aud !== i.aud) throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${i.aud}" but found "${e.claims.aud}"`);
766
+ if (i.nonce) {
767
+ if (!e.claims.nonce) throw new Error("Nonce (nonce) claim must be a string present in the ID token");
768
+ if (e.claims.nonce !== i.nonce) throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${i.nonce}", found "${e.claims.nonce}"`);
769
+ }
770
+ if (i.max_age && !R(e.claims.auth_time)) throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");
771
+ if (e.claims.exp == null || !R(e.claims.exp)) throw new Error("Expiration Time (exp) claim must be a number present in the ID token");
772
+ if (!R(e.claims.iat)) throw new Error("Issued At (iat) claim must be a number present in the ID token");
773
+ const t = i.leeway || 60, o = new Date(i.now || Date.now()), n = /* @__PURE__ */ new Date(0);
774
+ if (n.setUTCSeconds(e.claims.exp + t), o > n) throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${o}) is after expiration time (${n})`);
775
+ if (e.claims.nbf != null && R(e.claims.nbf)) {
776
+ const r = /* @__PURE__ */ new Date(0);
777
+ if (r.setUTCSeconds(e.claims.nbf - t), o < r) throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${o}) is before ${r}`);
778
+ }
779
+ if (e.claims.auth_time != null && R(e.claims.auth_time)) {
780
+ const r = /* @__PURE__ */ new Date(0);
781
+ if (r.setUTCSeconds(parseInt(e.claims.auth_time) + i.max_age + t), o > r) throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${o}) is after last auth at ${r}`);
782
+ }
783
+ if (i.organization) {
784
+ const r = i.organization.trim();
785
+ if (r.startsWith("org_")) {
786
+ const a = r;
787
+ if (!e.claims.org_id) throw new Error("Organization ID (org_id) claim must be a string present in the ID token");
788
+ if (a !== e.claims.org_id) throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`);
789
+ } else {
790
+ const a = r.toLowerCase();
791
+ if (!e.claims.org_name) throw new Error("Organization Name (org_name) claim must be a string present in the ID token");
792
+ if (a !== e.claims.org_name) throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`);
793
+ }
794
+ }
795
+ return e;
796
+ };
797
+ var x = ee(function(i, e) {
798
+ var t = C && C.__assign || function() {
799
+ return t = Object.assign || function(u) {
800
+ for (var p, s = 1, c = arguments.length; s < c; s++) for (var d in p = arguments[s]) Object.prototype.hasOwnProperty.call(p, d) && (u[d] = p[d]);
801
+ return u;
802
+ }, t.apply(this, arguments);
803
+ };
804
+ function o(u, p) {
805
+ if (!p) return "";
806
+ var s = "; " + u;
807
+ return p === !0 ? s : s + "=" + p;
808
+ }
809
+ function n(u, p, s) {
810
+ return encodeURIComponent(u).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/\(/g, "%28").replace(/\)/g, "%29") + "=" + encodeURIComponent(p).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent) + function(c) {
811
+ if (typeof c.expires == "number") {
812
+ var d = /* @__PURE__ */ new Date();
813
+ d.setMilliseconds(d.getMilliseconds() + 864e5 * c.expires), c.expires = d;
814
+ }
815
+ return o("Expires", c.expires ? c.expires.toUTCString() : "") + o("Domain", c.domain) + o("Path", c.path) + o("Secure", c.secure) + o("SameSite", c.sameSite);
816
+ }(s);
817
+ }
818
+ function r(u) {
819
+ for (var p = {}, s = u ? u.split("; ") : [], c = /(%[\dA-F]{2})+/gi, d = 0; d < s.length; d++) {
820
+ var l = s[d].split("="), m = l.slice(1).join("=");
821
+ m.charAt(0) === '"' && (m = m.slice(1, -1));
822
+ try {
823
+ p[l[0].replace(c, decodeURIComponent)] = m.replace(c, decodeURIComponent);
824
+ } catch {
825
+ }
826
+ }
827
+ return p;
828
+ }
829
+ function a() {
830
+ return r(document.cookie);
831
+ }
832
+ function h(u, p, s) {
833
+ document.cookie = n(u, p, t({ path: "/" }, s));
834
+ }
835
+ e.__esModule = !0, e.encode = n, e.parse = r, e.getAll = a, e.get = function(u) {
836
+ return a()[u];
837
+ }, e.set = h, e.remove = function(u, p) {
838
+ h(u, "", t(t({}, p), { expires: -1 }));
839
+ };
840
+ });
841
+ Q(x), x.encode, x.parse, x.getAll;
842
+ var qe = x.get, Pe = x.set, Te = x.remove;
843
+ const E = { get(i) {
844
+ const e = qe(i);
845
+ if (e !== void 0) return JSON.parse(e);
846
+ }, save(i, e, t) {
847
+ let o = {};
848
+ window.location.protocol === "https:" && (o = { secure: !0, sameSite: "none" }), t != null && t.daysUntilExpire && (o.expires = t.daysUntilExpire), t != null && t.cookieDomain && (o.domain = t.cookieDomain), Pe(i, JSON.stringify(e), o);
849
+ }, remove(i, e) {
850
+ let t = {};
851
+ e != null && e.cookieDomain && (t.domain = e.cookieDomain), Te(i, t);
852
+ } }, Qe = { get(i) {
853
+ return E.get(i) || E.get(`_legacy_${i}`);
854
+ }, save(i, e, t) {
855
+ let o = {};
856
+ window.location.protocol === "https:" && (o = { secure: !0 }), t != null && t.daysUntilExpire && (o.expires = t.daysUntilExpire), t != null && t.cookieDomain && (o.domain = t.cookieDomain), Pe(`_legacy_${i}`, JSON.stringify(e), o), E.save(i, e, t);
857
+ }, remove(i, e) {
858
+ let t = {};
859
+ e != null && e.cookieDomain && (t.domain = e.cookieDomain), Te(i, t), E.remove(i, e), E.remove(`_legacy_${i}`, e);
860
+ } }, et = { get(i) {
861
+ if (typeof sessionStorage > "u") return;
862
+ const e = sessionStorage.getItem(i);
863
+ return e != null ? JSON.parse(e) : void 0;
864
+ }, save(i, e) {
865
+ sessionStorage.setItem(i, JSON.stringify(e));
866
+ }, remove(i) {
867
+ sessionStorage.removeItem(i);
868
+ } };
869
+ var j;
870
+ (function(i) {
871
+ i.Code = "code", i.ConnectCode = "connect_code";
872
+ })(j || (j = {}));
873
+ function tt(i, e, t) {
874
+ var o = e === void 0 ? null : e, n = function(u, p) {
875
+ var s = atob(u);
876
+ if (p) {
877
+ for (var c = new Uint8Array(s.length), d = 0, l = s.length; d < l; ++d) c[d] = s.charCodeAt(d);
878
+ return String.fromCharCode.apply(null, new Uint16Array(c.buffer));
879
+ }
880
+ return s;
881
+ }(i, t !== void 0 && t), r = n.indexOf(`
882
+ `, 10) + 1, a = n.substring(r) + (o ? "//# sourceMappingURL=" + o : ""), h = new Blob([a], { type: "application/javascript" });
883
+ return URL.createObjectURL(h);
884
+ }
885
+ var le, pe, me, M, ot = (le = "Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YSx1c2VNcnJ0OmZ9LHBvcnRzOltwXX0pPT57bGV0IGgsdSxsPXt9O2NvbnN0e2F1ZGllbmNlOmQsc2NvcGU6eX09cnx8e307dHJ5e2NvbnN0IHI9YT8oZT0+e2NvbnN0IHQ9bmV3IFVSTFNlYXJjaFBhcmFtcyhlKSxyPXt9O3JldHVybiB0LmZvckVhY2goKChlLHQpPT57clt0XT1lfSkpLHJ9KShjLmJvZHkpOkpTT04ucGFyc2UoYy5ib2R5KTtpZighci5yZWZyZXNoX3Rva2VuJiYicmVmcmVzaF90b2tlbiI9PT1yLmdyYW50X3R5cGUpe2lmKHU9KChlLHQpPT5vW24oZSx0KV0pKGQseSksIXUmJmYpe2NvbnN0IGU9by5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+e2NvbnN0IHI9T2JqZWN0LmtleXMobykuZmluZCgocj0+e2lmKCJsYXRlc3RfcmVmcmVzaF90b2tlbiIhPT1yKXtjb25zdCBzPSgoZSx0KT0+dC5zdGFydHNXaXRoKGAke2V9fGApKSh0LHIpLG89ci5zcGxpdCgifCIpWzFdLnNwbGl0KCIgIiksbj1lLnNwbGl0KCIgIikuZXZlcnkoKGU9Pm8uaW5jbHVkZXMoZSkpKTtyZXR1cm4gcyYmbn19KSk7cmV0dXJuISFyfSkoeSxkKTtlJiYhdCYmKHU9ZSl9aWYoIXUpdGhyb3cgbmV3IHQoZCx5KTtjLmJvZHk9YT9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7cmVmcmVzaF90b2tlbjp1fSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7cmVmcmVzaF90b2tlbjp1fSkpfWxldCBqLGs7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGo9bmV3IEFib3J0Q29udHJvbGxlcixjLnNpZ25hbD1qLnNpZ25hbCk7dHJ5e2s9YXdhaXQgUHJvbWlzZS5yYWNlKFsoXz1lLG5ldyBQcm9taXNlKChlPT5zZXRUaW1lb3V0KGUsXykpKSksZmV0Y2goaSxPYmplY3QuYXNzaWduKHt9LGMpKV0pfWNhdGNoKGUpe3JldHVybiB2b2lkIHAucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfWlmKCFrKXJldHVybiBqJiZqLmFib3J0KCksdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjoiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIn0pO2c9ay5oZWFkZXJzLGw9Wy4uLmddLnJlZHVjZSgoKGUsW3Qscl0pPT4oZVt0XT1yLGUpKSx7fSksaD1hd2FpdCBrLmpzb24oKSxoLnJlZnJlc2hfdG9rZW4/KGYmJihvLmxhdGVzdF9yZWZyZXNoX3Rva2VuPWgucmVmcmVzaF90b2tlbixPPXUsYj1oLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMobykuZm9yRWFjaCgoKFtlLHRdKT0+e3Q9PT1PJiYob1tlXT1iKX0pKSksKChlLHQscik9PntvW24odCxyKV09ZX0pKGgucmVmcmVzaF90b2tlbixkLHkpLGRlbGV0ZSBoLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KShkLHkpLHAucG9zdE1lc3NhZ2Uoe29rOmsub2ssanNvbjpoLGhlYWRlcnM6bH0pfWNhdGNoKGUpe3AucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOmx9KX12YXIgTyxiLGcsX30pKX0oKTsKCg==", pe = null, me = !1, function(i) {
886
+ return M = M || tt(le, pe, me), new Worker(M, i);
887
+ });
888
+ const Y = {};
889
+ class nt {
890
+ constructor(e, t) {
891
+ this.cache = e, this.clientId = t, this.manifestKey = this.createManifestKeyFrom(this.clientId);
892
+ }
893
+ async add(e) {
894
+ var t;
895
+ const o = new Set(((t = await this.cache.get(this.manifestKey)) === null || t === void 0 ? void 0 : t.keys) || []);
896
+ o.add(e), await this.cache.set(this.manifestKey, { keys: [...o] });
897
+ }
898
+ async remove(e) {
899
+ const t = await this.cache.get(this.manifestKey);
900
+ if (t) {
901
+ const o = new Set(t.keys);
902
+ return o.delete(e), o.size > 0 ? await this.cache.set(this.manifestKey, { keys: [...o] }) : await this.cache.remove(this.manifestKey);
903
+ }
904
+ }
905
+ get() {
906
+ return this.cache.get(this.manifestKey);
907
+ }
908
+ clear() {
909
+ return this.cache.remove(this.manifestKey);
910
+ }
911
+ createManifestKeyFrom(e) {
912
+ return `@@auth0spajs@@::${e}`;
913
+ }
914
+ }
915
+ const it = { memory: () => new Ie().enclosedCache, localstorage: () => new Ge() }, fe = (i) => it[i], ge = (i) => {
916
+ const { openUrl: e, onRedirect: t } = i, o = I(i, ["openUrl", "onRedirect"]);
917
+ return Object.assign(Object.assign({}, o), { openUrl: e === !1 || e ? e : t });
918
+ }, ye = (i, e) => {
919
+ const t = (e == null ? void 0 : e.split(" ")) || [];
920
+ return ((i == null ? void 0 : i.split(" ")) || []).every((o) => t.includes(o));
921
+ }, T = { NONCE: "nonce", KEYPAIR: "keypair" };
922
+ class rt {
923
+ constructor(e) {
924
+ this.clientId = e;
925
+ }
926
+ getVersion() {
927
+ return 1;
928
+ }
929
+ createDbHandle() {
930
+ const e = window.indexedDB.open("auth0-spa-js", this.getVersion());
931
+ return new Promise((t, o) => {
932
+ e.onupgradeneeded = () => Object.values(T).forEach((n) => e.result.createObjectStore(n)), e.onerror = () => o(e.error), e.onsuccess = () => t(e.result);
933
+ });
934
+ }
935
+ async getDbHandle() {
936
+ return this.dbHandle || (this.dbHandle = await this.createDbHandle()), this.dbHandle;
937
+ }
938
+ async executeDbRequest(e, t, o) {
939
+ const n = o((await this.getDbHandle()).transaction(e, t).objectStore(e));
940
+ return new Promise((r, a) => {
941
+ n.onsuccess = () => r(n.result), n.onerror = () => a(n.error);
942
+ });
943
+ }
944
+ buildKey(e) {
945
+ const t = e ? `_${e}` : "auth0";
946
+ return `${this.clientId}::${t}`;
947
+ }
948
+ setNonce(e, t) {
949
+ return this.save(T.NONCE, this.buildKey(t), e);
950
+ }
951
+ setKeyPair(e) {
952
+ return this.save(T.KEYPAIR, this.buildKey(), e);
953
+ }
954
+ async save(e, t, o) {
955
+ await this.executeDbRequest(e, "readwrite", (n) => n.put(o, t));
956
+ }
957
+ findNonce(e) {
958
+ return this.find(T.NONCE, this.buildKey(e));
959
+ }
960
+ findKeyPair() {
961
+ return this.find(T.KEYPAIR, this.buildKey());
962
+ }
963
+ find(e, t) {
964
+ return this.executeDbRequest(e, "readonly", (o) => o.get(t));
965
+ }
966
+ async deleteBy(e, t) {
967
+ const o = await this.executeDbRequest(e, "readonly", (n) => n.getAllKeys());
968
+ o == null || o.filter(t).map((n) => this.executeDbRequest(e, "readwrite", (r) => r.delete(n)));
969
+ }
970
+ deleteByClientId(e, t) {
971
+ return this.deleteBy(e, (o) => typeof o == "string" && o.startsWith(`${t}::`));
972
+ }
973
+ clearNonces() {
974
+ return this.deleteByClientId(T.NONCE, this.clientId);
975
+ }
976
+ clearKeyPairs() {
977
+ return this.deleteByClientId(T.KEYPAIR, this.clientId);
978
+ }
979
+ }
980
+ class st {
981
+ constructor(e) {
982
+ this.storage = new rt(e);
983
+ }
984
+ getNonce(e) {
985
+ return this.storage.findNonce(e);
986
+ }
987
+ setNonce(e, t) {
988
+ return this.storage.setNonce(e, t);
989
+ }
990
+ async getOrGenerateKeyPair() {
991
+ let e = await this.storage.findKeyPair();
992
+ return e || (e = await Le(), await this.storage.setKeyPair(e)), e;
993
+ }
994
+ async generateProof(e) {
995
+ const t = await this.getOrGenerateKeyPair();
996
+ return He(Object.assign({ keyPair: t }, e));
997
+ }
998
+ async calculateThumbprint() {
999
+ return Ze(await this.getOrGenerateKeyPair());
1000
+ }
1001
+ async clear() {
1002
+ await Promise.all([this.storage.clearNonces(), this.storage.clearKeyPairs()]);
1003
+ }
1004
+ }
1005
+ var z;
1006
+ (function(i) {
1007
+ i.Bearer = "Bearer", i.DPoP = "DPoP";
1008
+ })(z || (z = {}));
1009
+ class at {
1010
+ constructor(e, t) {
1011
+ this.hooks = t, this.config = Object.assign(Object.assign({}, e), { fetch: e.fetch || (typeof window > "u" ? fetch : window.fetch.bind(window)) });
1012
+ }
1013
+ isAbsoluteUrl(e) {
1014
+ return /^(https?:)?\/\//i.test(e);
1015
+ }
1016
+ buildUrl(e, t) {
1017
+ if (t) {
1018
+ if (this.isAbsoluteUrl(t)) return t;
1019
+ if (e) return `${e.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}`;
1020
+ }
1021
+ throw new TypeError("`url` must be absolute or `baseUrl` non-empty.");
1022
+ }
1023
+ getAccessToken(e) {
1024
+ return this.config.getAccessToken ? this.config.getAccessToken(e) : this.hooks.getAccessToken(e);
1025
+ }
1026
+ extractUrl(e) {
1027
+ return typeof e == "string" ? e : e instanceof URL ? e.href : e.url;
1028
+ }
1029
+ buildBaseRequest(e, t) {
1030
+ if (!this.config.baseUrl) return new Request(e, t);
1031
+ const o = this.buildUrl(this.config.baseUrl, this.extractUrl(e)), n = e instanceof Request ? new Request(o, e) : o;
1032
+ return new Request(n, t);
1033
+ }
1034
+ setAuthorizationHeader(e, t, o = z.Bearer) {
1035
+ e.headers.set("authorization", `${o} ${t}`);
1036
+ }
1037
+ async setDpopProofHeader(e, t) {
1038
+ if (!this.config.dpopNonceId) return;
1039
+ const o = await this.hooks.getDpopNonce(), n = await this.hooks.generateDpopProof({ accessToken: t, method: e.method, nonce: o, url: e.url });
1040
+ e.headers.set("dpop", n);
1041
+ }
1042
+ async prepareRequest(e, t) {
1043
+ const o = await this.getAccessToken(t);
1044
+ let n, r;
1045
+ typeof o == "string" ? (n = this.config.dpopNonceId ? z.DPoP : z.Bearer, r = o) : (n = o.token_type, r = o.access_token), this.setAuthorizationHeader(e, r, n), n === z.DPoP && await this.setDpopProofHeader(e, r);
1046
+ }
1047
+ getHeader(e, t) {
1048
+ return Array.isArray(e) ? new Headers(e).get(t) || "" : typeof e.get == "function" ? e.get(t) || "" : e[t] || "";
1049
+ }
1050
+ hasUseDpopNonceError(e) {
1051
+ if (e.status !== 401) return !1;
1052
+ const t = this.getHeader(e.headers, "www-authenticate");
1053
+ return t.includes("invalid_dpop_nonce") || t.includes("use_dpop_nonce");
1054
+ }
1055
+ async handleResponse(e, t) {
1056
+ const o = this.getHeader(e.headers, "dpop-nonce");
1057
+ if (o && await this.hooks.setDpopNonce(o), !this.hasUseDpopNonceError(e)) return e;
1058
+ if (!o || !t.onUseDpopNonceError) throw new F(o);
1059
+ return t.onUseDpopNonceError();
1060
+ }
1061
+ async internalFetchWithAuth(e, t, o, n) {
1062
+ const r = this.buildBaseRequest(e, t);
1063
+ await this.prepareRequest(r, n);
1064
+ const a = await this.config.fetch(r);
1065
+ return this.handleResponse(a, o);
1066
+ }
1067
+ fetchWithAuth(e, t, o) {
1068
+ const n = { onUseDpopNonceError: () => this.internalFetchWithAuth(e, t, Object.assign(Object.assign({}, n), { onUseDpopNonceError: void 0 }), o) };
1069
+ return this.internalFetchWithAuth(e, t, n, o);
1070
+ }
1071
+ }
1072
+ class ct {
1073
+ constructor(e, t) {
1074
+ this.myAccountFetcher = e, this.apiBase = t;
1075
+ }
1076
+ async connectAccount(e) {
1077
+ const t = await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/connect`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(e) });
1078
+ return this._handleResponse(t);
1079
+ }
1080
+ async completeAccount(e) {
1081
+ const t = await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/complete`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(e) });
1082
+ return this._handleResponse(t);
1083
+ }
1084
+ async _handleResponse(e) {
1085
+ let t;
1086
+ try {
1087
+ t = await e.text(), t = JSON.parse(t);
1088
+ } catch (o) {
1089
+ throw new X({ type: "invalid_json", status: e.status, title: "Invalid JSON response", detail: t || String(o) });
1090
+ }
1091
+ if (e.ok) return t;
1092
+ throw new X(t);
1093
+ }
1094
+ }
1095
+ class X extends Error {
1096
+ constructor({ type: e, status: t, title: o, detail: n, validation_errors: r }) {
1097
+ super(n), this.name = "MyAccountApiError", this.type = e, this.status = t, this.title = o, this.detail = n, this.validation_errors = r, Object.setPrototypeOf(this, X.prototype);
1098
+ }
1099
+ }
1100
+ const $ = new Ce();
1101
+ class ut {
1102
+ constructor(e) {
1103
+ let t, o;
1104
+ if (this.userCache = new Ie().enclosedCache, this.activeLockKeys = /* @__PURE__ */ new Set(), this.defaultOptions = { authorizationParams: { scope: "openid profile email" }, useRefreshTokensFallback: !1, useFormData: !0 }, this._releaseLockOnPageHide = async () => {
1105
+ const u = Array.from(this.activeLockKeys);
1106
+ for (const p of u) await $.releaseLock(p);
1107
+ this.activeLockKeys.clear(), window.removeEventListener("pagehide", this._releaseLockOnPageHide);
1108
+ }, this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), e), { authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), e.authorizationParams) }), typeof window < "u" && (() => {
1109
+ if (!J()) throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");
1110
+ if (J().subtle === void 0) throw new Error(`
1111
+ auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
1112
+ `);
1113
+ })(), e.cache && e.cacheLocation && console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."), e.cache) o = e.cache;
1114
+ else {
1115
+ if (t = e.cacheLocation || "memory", !fe(t)) throw new Error(`Invalid cache location "${t}"`);
1116
+ o = fe(t)();
1117
+ }
1118
+ this.httpTimeoutMs = e.httpTimeoutInSeconds ? 1e3 * e.httpTimeoutInSeconds : 1e4, this.cookieStorage = e.legacySameSiteCookie === !1 ? E : Qe, this.orgHintCookieName = `auth0.${this.options.clientId}.organization_hint`, this.isAuthenticatedCookieName = ((u) => `auth0.${u}.is.authenticated`)(this.options.clientId), this.sessionCheckExpiryDays = e.sessionCheckExpiryDays || 1;
1119
+ const n = e.useCookiesForTransactions ? this.cookieStorage : et;
1120
+ var r;
1121
+ this.scope = ((u, p, ...s) => {
1122
+ if (typeof u != "object") return { default: H(p, u, ...s) };
1123
+ let c = { default: H(p, ...s) };
1124
+ return Object.keys(u).forEach((d) => {
1125
+ const l = u[d];
1126
+ c[d] = H(p, l, ...s);
1127
+ }), c;
1128
+ })(this.options.authorizationParams.scope, "openid", this.options.useRefreshTokens ? "offline_access" : ""), this.transactionManager = new Ye(n, this.options.clientId, this.options.cookieDomain), this.nowProvider = this.options.nowProvider || be, this.cacheManager = new Me(o, o.allKeys ? void 0 : new nt(o, this.options.clientId), this.nowProvider), this.dpop = this.options.useDpop ? new st(this.options.clientId) : void 0, this.domainUrl = (r = this.options.domain, /^https?:\/\//.test(r) ? r : `https://${r}`), this.tokenIssuer = ((u, p) => u ? u.startsWith("https://") ? u : `https://${u}/` : `${p}/`)(this.options.issuer, this.domainUrl);
1129
+ const a = `${this.domainUrl}/me/`, h = this.createFetcher(Object.assign(Object.assign({}, this.options.useDpop && { dpopNonceId: "__auth0_my_account_api__" }), { getAccessToken: () => this.getTokenSilently({ authorizationParams: { scope: "create:me:connected_accounts", audience: a }, detailedResponse: !0 }) }));
1130
+ this.myAccountApi = new ct(h, a), typeof window < "u" && window.Worker && this.options.useRefreshTokens && t === "memory" && (this.options.workerUrl ? this.worker = new Worker(this.options.workerUrl) : this.worker = new ot());
1131
+ }
1132
+ _url(e) {
1133
+ const t = encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client || we)));
1134
+ return `${this.domainUrl}${e}&auth0Client=${t}`;
1135
+ }
1136
+ _authorizeUrl(e) {
1137
+ return this._url(`/authorize?${B(e)}`);
1138
+ }
1139
+ async _verifyIdToken(e, t, o) {
1140
+ const n = await this.nowProvider();
1141
+ return Be({ iss: this.tokenIssuer, aud: this.options.clientId, id_token: e, nonce: t, organization: o, leeway: this.options.leeway, max_age: (r = this.options.authorizationParams.max_age, typeof r != "string" ? r : parseInt(r, 10) || void 0), now: n });
1142
+ var r;
1143
+ }
1144
+ _processOrgHint(e) {
1145
+ e ? this.cookieStorage.save(this.orgHintCookieName, e, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }) : this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain });
1146
+ }
1147
+ async _prepareAuthorizeUrl(e, t, o) {
1148
+ var n;
1149
+ const r = G(N()), a = G(N()), h = N(), u = await ce(h), p = he(u), s = await ((n = this.dpop) === null || n === void 0 ? void 0 : n.calculateThumbprint()), c = ((l, m, y, g, k, b, w, f, S) => Object.assign(Object.assign(Object.assign({ client_id: l.clientId }, l.authorizationParams), y), { scope: Z(m, y.scope, y.audience), response_type: "code", response_mode: f || "query", state: g, nonce: k, redirect_uri: w || l.authorizationParams.redirect_uri, code_challenge: b, code_challenge_method: "S256", dpop_jkt: S }))(this.options, this.scope, e, r, a, p, e.redirect_uri || this.options.authorizationParams.redirect_uri || o, t == null ? void 0 : t.response_mode, s), d = this._authorizeUrl(c);
1150
+ return { nonce: a, code_verifier: h, scope: c.scope, audience: c.audience || "default", redirect_uri: c.redirect_uri, state: r, url: d };
1151
+ }
1152
+ async loginWithPopup(e, t) {
1153
+ var o;
1154
+ if (e = e || {}, !(t = t || {}).popup && (t.popup = ((h) => {
1155
+ const u = window.screenX + (window.innerWidth - 400) / 2, p = window.screenY + (window.innerHeight - 600) / 2;
1156
+ return window.open(h, "auth0:authorize:popup", `left=${u},top=${p},width=400,height=600,resizable,scrollbars=yes,status=1`);
1157
+ })(""), !t.popup)) throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");
1158
+ const n = await this._prepareAuthorizeUrl(e.authorizationParams || {}, { response_mode: "web_message" }, window.location.origin);
1159
+ t.popup.location.href = n.url;
1160
+ const r = await ((h) => new Promise((u, p) => {
1161
+ let s;
1162
+ const c = setInterval(() => {
1163
+ h.popup && h.popup.closed && (clearInterval(c), clearTimeout(d), window.removeEventListener("message", s, !1), p(new ie(h.popup)));
1164
+ }, 1e3), d = setTimeout(() => {
1165
+ clearInterval(c), p(new ne(h.popup)), window.removeEventListener("message", s, !1);
1166
+ }, 1e3 * (h.timeoutInSeconds || 60));
1167
+ s = function(l) {
1168
+ if (l.data && l.data.type === "authorization_response") {
1169
+ if (clearTimeout(d), clearInterval(c), window.removeEventListener("message", s, !1), h.popup.close(), l.data.response.error) return p(v.fromPayload(l.data.response));
1170
+ u(l.data.response);
1171
+ }
1172
+ }, window.addEventListener("message", s);
1173
+ }))(Object.assign(Object.assign({}, t), { timeoutInSeconds: t.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || 60 }));
1174
+ if (n.state !== r.state) throw new v("state_mismatch", "Invalid state");
1175
+ const a = ((o = e.authorizationParams) === null || o === void 0 ? void 0 : o.organization) || this.options.authorizationParams.organization;
1176
+ await this._requestToken({ audience: n.audience, scope: n.scope, code_verifier: n.code_verifier, grant_type: "authorization_code", code: r.code, redirect_uri: n.redirect_uri }, { nonceIn: n.nonce, organization: a });
1177
+ }
1178
+ async getUser() {
1179
+ var e;
1180
+ const t = await this._getIdTokenFromCache();
1181
+ return (e = t == null ? void 0 : t.decodedToken) === null || e === void 0 ? void 0 : e.user;
1182
+ }
1183
+ async getIdTokenClaims() {
1184
+ var e;
1185
+ const t = await this._getIdTokenFromCache();
1186
+ return (e = t == null ? void 0 : t.decodedToken) === null || e === void 0 ? void 0 : e.claims;
1187
+ }
1188
+ async loginWithRedirect(e = {}) {
1189
+ var t;
1190
+ const o = ge(e), { openUrl: n, fragment: r, appState: a } = o, h = I(o, ["openUrl", "fragment", "appState"]), u = ((t = h.authorizationParams) === null || t === void 0 ? void 0 : t.organization) || this.options.authorizationParams.organization, p = await this._prepareAuthorizeUrl(h.authorizationParams || {}), { url: s } = p, c = I(p, ["url"]);
1191
+ this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, c), { appState: a, response_type: j.Code }), u && { organization: u }));
1192
+ const d = r ? `${s}#${r}` : s;
1193
+ n ? await n(d) : window.location.assign(d);
1194
+ }
1195
+ async handleRedirectCallback(e = window.location.href) {
1196
+ const t = e.split("?").slice(1);
1197
+ if (t.length === 0) throw new Error("There are no query params available for parsing.");
1198
+ const o = this.transactionManager.get();
1199
+ if (!o) throw new v("missing_transaction", "Invalid state");
1200
+ this.transactionManager.remove();
1201
+ const n = ((r) => {
1202
+ r.indexOf("#") > -1 && (r = r.substring(0, r.indexOf("#")));
1203
+ const a = new URLSearchParams(r);
1204
+ return { state: a.get("state"), code: a.get("code") || void 0, connect_code: a.get("connect_code") || void 0, error: a.get("error") || void 0, error_description: a.get("error_description") || void 0 };
1205
+ })(t.join(""));
1206
+ return o.response_type === j.ConnectCode ? this._handleConnectAccountRedirectCallback(n, o) : this._handleLoginRedirectCallback(n, o);
1207
+ }
1208
+ async _handleLoginRedirectCallback(e, t) {
1209
+ const { code: o, state: n, error: r, error_description: a } = e;
1210
+ if (r) throw new te(r, a || r, n, t.appState);
1211
+ if (!t.code_verifier || t.state && t.state !== n) throw new v("state_mismatch", "Invalid state");
1212
+ const h = t.organization, u = t.nonce, p = t.redirect_uri;
1213
+ return await this._requestToken(Object.assign({ audience: t.audience, scope: t.scope, code_verifier: t.code_verifier, grant_type: "authorization_code", code: o }, p ? { redirect_uri: p } : {}), { nonceIn: u, organization: h }), { appState: t.appState, response_type: j.Code };
1214
+ }
1215
+ async _handleConnectAccountRedirectCallback(e, t) {
1216
+ const { connect_code: o, state: n, error: r, error_description: a } = e;
1217
+ if (r) throw new oe(r, a || r, t.connection, n, t.appState);
1218
+ if (!o) throw new v("missing_connect_code", "Missing connect code");
1219
+ if (!(t.code_verifier && t.state && t.auth_session && t.redirect_uri && t.state === n)) throw new v("state_mismatch", "Invalid state");
1220
+ const h = await this.myAccountApi.completeAccount({ auth_session: t.auth_session, connect_code: o, redirect_uri: t.redirect_uri, code_verifier: t.code_verifier });
1221
+ return Object.assign(Object.assign({}, h), { appState: t.appState, response_type: j.ConnectCode });
1222
+ }
1223
+ async checkSession(e) {
1224
+ if (!this.cookieStorage.get(this.isAuthenticatedCookieName)) {
1225
+ if (!this.cookieStorage.get("auth0.is.authenticated")) return;
1226
+ this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove("auth0.is.authenticated");
1227
+ }
1228
+ try {
1229
+ await this.getTokenSilently(e);
1230
+ } catch {
1231
+ }
1232
+ }
1233
+ async getTokenSilently(e = {}) {
1234
+ var t, o;
1235
+ const n = Object.assign(Object.assign({ cacheMode: "on" }, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: Z(this.scope, (t = e.authorizationParams) === null || t === void 0 ? void 0 : t.scope, ((o = e.authorizationParams) === null || o === void 0 ? void 0 : o.audience) || this.options.authorizationParams.audience) }) }), r = await ((a, h) => {
1236
+ let u = Y[h];
1237
+ return u || (u = a().finally(() => {
1238
+ delete Y[h], u = null;
1239
+ }), Y[h] = u), u;
1240
+ })(() => this._getTokenSilently(n), `${this.options.clientId}::${n.authorizationParams.audience}::${n.authorizationParams.scope}`);
1241
+ return e.detailedResponse ? r : r == null ? void 0 : r.access_token;
1242
+ }
1243
+ async _getTokenSilently(e) {
1244
+ const { cacheMode: t } = e, o = I(e, ["cacheMode"]);
1245
+ if (t !== "off") {
1246
+ const h = await this._getEntryFromCache({ scope: o.authorizationParams.scope, audience: o.authorizationParams.audience || "default", clientId: this.options.clientId, cacheMode: t });
1247
+ if (h) return h;
1248
+ }
1249
+ if (t === "cache-only") return;
1250
+ const n = (r = this.options.clientId, a = o.authorizationParams.audience || "default", `auth0.lock.getTokenSilently.${r}.${a}`);
1251
+ var r, a;
1252
+ if (!await (async (h, u = 3) => {
1253
+ for (let p = 0; p < u; p++) if (await h()) return !0;
1254
+ return !1;
1255
+ })(() => $.acquireLock(n, 5e3), 10)) throw new U();
1256
+ this.activeLockKeys.add(n), this.activeLockKeys.size === 1 && window.addEventListener("pagehide", this._releaseLockOnPageHide);
1257
+ try {
1258
+ if (t !== "off") {
1259
+ const l = await this._getEntryFromCache({ scope: o.authorizationParams.scope, audience: o.authorizationParams.audience || "default", clientId: this.options.clientId });
1260
+ if (l) return l;
1261
+ }
1262
+ const h = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(o) : await this._getTokenFromIFrame(o), { id_token: u, token_type: p, access_token: s, oauthTokenScope: c, expires_in: d } = h;
1263
+ return Object.assign(Object.assign({ id_token: u, token_type: p, access_token: s }, c ? { scope: c } : null), { expires_in: d });
1264
+ } finally {
1265
+ await $.releaseLock(n), this.activeLockKeys.delete(n), this.activeLockKeys.size === 0 && window.removeEventListener("pagehide", this._releaseLockOnPageHide);
1266
+ }
1267
+ }
1268
+ async getTokenWithPopup(e = {}, t = {}) {
1269
+ var o, n;
1270
+ const r = Object.assign(Object.assign({}, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: Z(this.scope, (o = e.authorizationParams) === null || o === void 0 ? void 0 : o.scope, ((n = e.authorizationParams) === null || n === void 0 ? void 0 : n.audience) || this.options.authorizationParams.audience) }) });
1271
+ return t = Object.assign(Object.assign({}, je), t), await this.loginWithPopup(r, t), (await this.cacheManager.get(new _({ scope: r.authorizationParams.scope, audience: r.authorizationParams.audience || "default", clientId: this.options.clientId }), void 0, this.options.useMrrt)).access_token;
1272
+ }
1273
+ async isAuthenticated() {
1274
+ return !!await this.getUser();
1275
+ }
1276
+ _buildLogoutUrl(e) {
1277
+ e.clientId !== null ? e.clientId = e.clientId || this.options.clientId : delete e.clientId;
1278
+ const t = e.logoutParams || {}, { federated: o } = t, n = I(t, ["federated"]), r = o ? "&federated" : "";
1279
+ return this._url(`/v2/logout?${B(Object.assign({ clientId: e.clientId }, n))}`) + r;
1280
+ }
1281
+ async logout(e = {}) {
1282
+ var t;
1283
+ const o = ge(e), { openUrl: n } = o, r = I(o, ["openUrl"]);
1284
+ e.clientId === null ? await this.cacheManager.clear() : await this.cacheManager.clear(e.clientId || this.options.clientId), this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove(this.isAuthenticatedCookieName, { cookieDomain: this.options.cookieDomain }), this.userCache.remove("@@user@@"), await ((t = this.dpop) === null || t === void 0 ? void 0 : t.clear());
1285
+ const a = this._buildLogoutUrl(r);
1286
+ n ? await n(a) : n !== !1 && window.location.assign(a);
1287
+ }
1288
+ async _getTokenFromIFrame(e) {
1289
+ const t = Object.assign(Object.assign({}, e.authorizationParams), { prompt: "none" }), o = this.cookieStorage.get(this.orgHintCookieName);
1290
+ o && !t.organization && (t.organization = o);
1291
+ const { url: n, state: r, nonce: a, code_verifier: h, redirect_uri: u, scope: p, audience: s } = await this._prepareAuthorizeUrl(t, { response_mode: "web_message" }, window.location.origin);
1292
+ try {
1293
+ if (window.crossOriginIsolated) throw new v("login_required", "The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");
1294
+ const c = e.timeoutInSeconds || this.options.authorizeTimeoutInSeconds;
1295
+ let d;
1296
+ try {
1297
+ d = new URL(this.domainUrl).origin;
1298
+ } catch {
1299
+ d = this.domainUrl;
1300
+ }
1301
+ const l = await ((y, g, k = 60) => new Promise((b, w) => {
1302
+ const f = window.document.createElement("iframe");
1303
+ f.setAttribute("width", "0"), f.setAttribute("height", "0"), f.style.display = "none";
1304
+ const S = () => {
1305
+ window.document.body.contains(f) && (window.document.body.removeChild(f), window.removeEventListener("message", L, !1));
1306
+ };
1307
+ let L;
1308
+ const Oe = setTimeout(() => {
1309
+ w(new U()), S();
1310
+ }, 1e3 * k);
1311
+ L = function(P) {
1312
+ if (P.origin != g || !P.data || P.data.type !== "authorization_response") return;
1313
+ const ae = P.source;
1314
+ ae && ae.close(), P.data.response.error ? w(v.fromPayload(P.data.response)) : b(P.data.response), clearTimeout(Oe), window.removeEventListener("message", L, !1), setTimeout(S, 2e3);
1315
+ }, window.addEventListener("message", L, !1), window.document.body.appendChild(f), f.setAttribute("src", y);
1316
+ }))(n, d, c);
1317
+ if (r !== l.state) throw new v("state_mismatch", "Invalid state");
1318
+ const m = await this._requestToken(Object.assign(Object.assign({}, e.authorizationParams), { code_verifier: h, code: l.code, grant_type: "authorization_code", redirect_uri: u, timeout: e.authorizationParams.timeout || this.httpTimeoutMs }), { nonceIn: a, organization: t.organization });
1319
+ return Object.assign(Object.assign({}, m), { scope: p, oauthTokenScope: m.scope, audience: s });
1320
+ } catch (c) {
1321
+ throw c.error === "login_required" && this.logout({ openUrl: !1 }), c;
1322
+ }
1323
+ }
1324
+ async _getTokenUsingRefreshToken(e) {
1325
+ const t = await this.cacheManager.get(new _({ scope: e.authorizationParams.scope, audience: e.authorizationParams.audience || "default", clientId: this.options.clientId }), void 0, this.options.useMrrt);
1326
+ if (!(t && t.refresh_token || this.worker)) {
1327
+ if (this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
1328
+ throw new V(e.authorizationParams.audience || "default", e.authorizationParams.scope);
1329
+ }
1330
+ const o = e.authorizationParams.redirect_uri || this.options.authorizationParams.redirect_uri || window.location.origin, n = typeof e.timeoutInSeconds == "number" ? 1e3 * e.timeoutInSeconds : null, r = ((s, c, d, l) => {
1331
+ var m;
1332
+ if (s && d && l) {
1333
+ if (c.audience !== d) return c.scope;
1334
+ const y = l.split(" "), g = ((m = c.scope) === null || m === void 0 ? void 0 : m.split(" ")) || [], k = g.every((b) => y.includes(b));
1335
+ return y.length >= g.length && k ? l : c.scope;
1336
+ }
1337
+ return c.scope;
1338
+ })(this.options.useMrrt, e.authorizationParams, t == null ? void 0 : t.audience, t == null ? void 0 : t.scope);
1339
+ try {
1340
+ const s = await this._requestToken(Object.assign(Object.assign(Object.assign({}, e.authorizationParams), { grant_type: "refresh_token", refresh_token: t && t.refresh_token, redirect_uri: o }), n && { timeout: n }), { scopesToRequest: r });
1341
+ if (s.refresh_token && this.options.useMrrt && (t != null && t.refresh_token) && await this.cacheManager.updateEntry(t.refresh_token, s.refresh_token), this.options.useMrrt && (a = t == null ? void 0 : t.audience, h = t == null ? void 0 : t.scope, u = e.authorizationParams.audience, p = e.authorizationParams.scope, (a !== u || !ye(p, h)) && !ye(r, s.scope))) {
1342
+ if (this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
1343
+ await this.cacheManager.remove(this.options.clientId, e.authorizationParams.audience, e.authorizationParams.scope);
1344
+ const c = ((d, l) => {
1345
+ const m = (d == null ? void 0 : d.split(" ")) || [], y = (l == null ? void 0 : l.split(" ")) || [];
1346
+ return m.filter((g) => y.indexOf(g) == -1).join(",");
1347
+ })(r, s.scope);
1348
+ throw new se(e.authorizationParams.audience || "default", c);
1349
+ }
1350
+ return Object.assign(Object.assign({}, s), { scope: e.authorizationParams.scope, oauthTokenScope: s.scope, audience: e.authorizationParams.audience || "default" });
1351
+ } catch (s) {
1352
+ if ((s.message.indexOf("Missing Refresh Token") > -1 || s.message && s.message.indexOf("invalid refresh token") > -1) && this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
1353
+ throw s;
1354
+ }
1355
+ var a, h, u, p;
1356
+ }
1357
+ async _saveEntryInCache(e) {
1358
+ const { id_token: t, decodedToken: o } = e, n = I(e, ["id_token", "decodedToken"]);
1359
+ this.userCache.set("@@user@@", { id_token: t, decodedToken: o }), await this.cacheManager.setIdToken(this.options.clientId, e.id_token, e.decodedToken), await this.cacheManager.set(n);
1360
+ }
1361
+ async _getIdTokenFromCache() {
1362
+ const e = this.options.authorizationParams.audience || "default", t = this.scope[e], o = await this.cacheManager.getIdToken(new _({ clientId: this.options.clientId, audience: e, scope: t })), n = this.userCache.get("@@user@@");
1363
+ return o && o.id_token === (n == null ? void 0 : n.id_token) ? n : (this.userCache.set("@@user@@", o), o);
1364
+ }
1365
+ async _getEntryFromCache({ scope: e, audience: t, clientId: o, cacheMode: n }) {
1366
+ const r = await this.cacheManager.get(new _({ scope: e, audience: t, clientId: o }), 60, this.options.useMrrt, n);
1367
+ if (r && r.access_token) {
1368
+ const { token_type: a, access_token: h, oauthTokenScope: u, expires_in: p } = r, s = await this._getIdTokenFromCache();
1369
+ return s && Object.assign(Object.assign({ id_token: s.id_token, token_type: a || "Bearer", access_token: h }, u ? { scope: u } : null), { expires_in: p });
1370
+ }
1371
+ }
1372
+ async _requestToken(e, t) {
1373
+ const { nonceIn: o, organization: n, scopesToRequest: r } = t || {}, a = await Fe(Object.assign(Object.assign({ baseUrl: this.domainUrl, client_id: this.options.clientId, auth0Client: this.options.auth0Client, useFormData: this.options.useFormData, timeout: this.httpTimeoutMs, useMrrt: this.options.useMrrt, dpop: this.dpop }, e), { scope: r || e.scope }), this.worker), h = await this._verifyIdToken(a.id_token, o, n);
1374
+ return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, a), { decodedToken: h, scope: e.scope, audience: e.audience || "default" }), a.scope ? { oauthTokenScope: a.scope } : null), { client_id: this.options.clientId })), this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this._processOrgHint(n || h.claims.org_id), Object.assign(Object.assign({}, a), { decodedToken: h });
1375
+ }
1376
+ async exchangeToken(e) {
1377
+ return this._requestToken({ grant_type: "urn:ietf:params:oauth:grant-type:token-exchange", subject_token: e.subject_token, subject_token_type: e.subject_token_type, scope: Z(this.scope, e.scope, e.audience || this.options.authorizationParams.audience), audience: e.audience || this.options.authorizationParams.audience });
1378
+ }
1379
+ _assertDpop(e) {
1380
+ if (!e) throw new Error("`useDpop` option must be enabled before using DPoP.");
1381
+ }
1382
+ getDpopNonce(e) {
1383
+ return this._assertDpop(this.dpop), this.dpop.getNonce(e);
1384
+ }
1385
+ setDpopNonce(e, t) {
1386
+ return this._assertDpop(this.dpop), this.dpop.setNonce(e, t);
1387
+ }
1388
+ generateDpopProof(e) {
1389
+ return this._assertDpop(this.dpop), this.dpop.generateProof(e);
1390
+ }
1391
+ createFetcher(e = {}) {
1392
+ return new at(e, { isDpopEnabled: () => !!this.options.useDpop, getAccessToken: (t) => {
1393
+ var o;
1394
+ return this.getTokenSilently({ authorizationParams: { scope: (o = t == null ? void 0 : t.scope) === null || o === void 0 ? void 0 : o.join(" "), audience: t == null ? void 0 : t.audience }, detailedResponse: !0 });
1395
+ }, getDpopNonce: () => this.getDpopNonce(e.dpopNonceId), setDpopNonce: (t) => this.setDpopNonce(t, e.dpopNonceId), generateDpopProof: (t) => this.generateDpopProof(t) });
1396
+ }
1397
+ async connectAccountWithRedirect(e) {
1398
+ const { openUrl: t, appState: o, connection: n, authorization_params: r, redirectUri: a = this.options.authorizationParams.redirect_uri || window.location.origin } = e;
1399
+ if (!n) throw new Error("connection is required");
1400
+ const h = G(N()), u = N(), p = await ce(u), s = he(p), { connect_uri: c, connect_params: d, auth_session: l } = await this.myAccountApi.connectAccount({ connection: n, redirect_uri: a, state: h, code_challenge: s, code_challenge_method: "S256", authorization_params: r });
1401
+ this.transactionManager.create({ state: h, code_verifier: u, auth_session: l, redirect_uri: a, appState: o, connection: n, response_type: j.ConnectCode });
1402
+ const m = new URL(c);
1403
+ m.searchParams.set("ticket", d.ticket), t ? await t(m.toString()) : window.location.assign(m);
1404
+ }
1405
+ }
1406
+ export {
1407
+ ut as Auth0Client,
1408
+ te as AuthenticationError,
1409
+ _ as CacheKey,
1410
+ oe as ConnectError,
1411
+ v as GenericError,
1412
+ Ie as InMemoryCache,
1413
+ Ge as LocalStorageCache,
1414
+ re as MfaRequiredError,
1415
+ V as MissingRefreshTokenError,
1416
+ X as MyAccountApiError,
1417
+ ie as PopupCancelledError,
1418
+ ne as PopupTimeoutError,
1419
+ j as ResponseType,
1420
+ U as TimeoutError,
1421
+ F as UseDpopNonceError
1422
+ };
1423
+ //# sourceMappingURL=auth0-spa-js.production.esm-Bb4L9JDU.js.map