@versini/auth-provider 8.0.6 → 8.1.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.
package/dist/auth0.js DELETED
@@ -1,1334 +0,0 @@
1
- import { jsx as B } from "react/jsx-runtime";
2
- import Oe, { useState as Te, useReducer as Pe, useRef as Ce, useCallback as R, useEffect as je, useMemo as Ee, createContext as xe, useContext as ze } from "react";
3
- import { AuthHookContext as Re } from "./AuthHookContext-C9a2AwWZ.js";
4
- /*!
5
- @versini/auth-provider v8.0.6
6
- © 2025 gizmette.com
7
- */
8
- try {
9
- window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
10
- version: "8.0.6",
11
- buildTime: "11/23/2025 02:59 PM EST",
12
- homepage: "https://github.com/aversini/auth-client",
13
- license: "MIT"
14
- });
15
- } catch {
16
- }
17
- var q = function(i, e) {
18
- return q = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
19
- t.__proto__ = n;
20
- } || function(t, n) {
21
- for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
22
- }, q(i, e);
23
- };
24
- function Ue(i, e) {
25
- if (typeof e != "function" && e !== null)
26
- throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
27
- q(i, e);
28
- function t() {
29
- this.constructor = i;
30
- }
31
- i.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
32
- }
33
- var T = function() {
34
- return T = Object.assign || function(e) {
35
- for (var t, n = 1, o = arguments.length; n < o; n++) {
36
- t = arguments[n];
37
- for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
38
- }
39
- return e;
40
- }, T.apply(this, arguments);
41
- };
42
- function We(i, e) {
43
- var t = {};
44
- for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && e.indexOf(n) < 0 && (t[n] = i[n]);
45
- if (i != null && typeof Object.getOwnPropertySymbols == "function")
46
- for (var o = 0, n = Object.getOwnPropertySymbols(i); o < n.length; o++)
47
- e.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(i, n[o]) && (t[n[o]] = i[n[o]]);
48
- return t;
49
- }
50
- function L(i, e, t, n) {
51
- function o(r) {
52
- return r instanceof t ? r : new t(function(c) {
53
- c(r);
54
- });
55
- }
56
- return new (t || (t = Promise))(function(r, c) {
57
- function h(a) {
58
- try {
59
- d(n.next(a));
60
- } catch (s) {
61
- c(s);
62
- }
63
- }
64
- function l(a) {
65
- try {
66
- d(n.throw(a));
67
- } catch (s) {
68
- c(s);
69
- }
70
- }
71
- function d(a) {
72
- a.done ? r(a.value) : o(a.value).then(h, l);
73
- }
74
- d((n = n.apply(i, e || [])).next());
75
- });
76
- }
77
- function Z(i, e) {
78
- var t = { label: 0, sent: function() {
79
- if (r[0] & 1) throw r[1];
80
- return r[1];
81
- }, trys: [], ops: [] }, n, o, r, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
82
- return c.next = h(0), c.throw = h(1), c.return = h(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() {
83
- return this;
84
- }), c;
85
- function h(d) {
86
- return function(a) {
87
- return l([d, a]);
88
- };
89
- }
90
- function l(d) {
91
- if (n) throw new TypeError("Generator is already executing.");
92
- for (; c && (c = 0, d[0] && (t = 0)), t; ) try {
93
- if (n = 1, o && (r = d[0] & 2 ? o.return : d[0] ? o.throw || ((r = o.return) && r.call(o), 0) : o.next) && !(r = r.call(o, d[1])).done) return r;
94
- switch (o = 0, r && (d = [d[0] & 2, r.value]), d[0]) {
95
- case 0:
96
- case 1:
97
- r = d;
98
- break;
99
- case 4:
100
- return t.label++, { value: d[1], done: !1 };
101
- case 5:
102
- t.label++, o = d[1], d = [0];
103
- continue;
104
- case 7:
105
- d = t.ops.pop(), t.trys.pop();
106
- continue;
107
- default:
108
- if (r = t.trys, !(r = r.length > 0 && r[r.length - 1]) && (d[0] === 6 || d[0] === 2)) {
109
- t = 0;
110
- continue;
111
- }
112
- if (d[0] === 3 && (!r || d[1] > r[0] && d[1] < r[3])) {
113
- t.label = d[1];
114
- break;
115
- }
116
- if (d[0] === 6 && t.label < r[1]) {
117
- t.label = r[1], r = d;
118
- break;
119
- }
120
- if (r && t.label < r[2]) {
121
- t.label = r[2], t.ops.push(d);
122
- break;
123
- }
124
- r[2] && t.ops.pop(), t.trys.pop();
125
- continue;
126
- }
127
- d = e.call(i, t);
128
- } catch (a) {
129
- d = [6, a], o = 0;
130
- } finally {
131
- n = r = 0;
132
- }
133
- if (d[0] & 5) throw d[1];
134
- return { value: d[0] ? d[1] : void 0, done: !0 };
135
- }
136
- }
137
- function Le(i, e, t) {
138
- for (var n = 0, o = e.length, r; n < o; n++)
139
- (r || !(n in e)) && (r || (r = Array.prototype.slice.call(e, 0, n)), r[n] = e[n]);
140
- return i.concat(r || Array.prototype.slice.call(e));
141
- }
142
- function E(i, e) {
143
- var t = {};
144
- for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && e.indexOf(n) < 0 && (t[n] = i[n]);
145
- if (i != null && typeof Object.getOwnPropertySymbols == "function") {
146
- var o = 0;
147
- for (n = Object.getOwnPropertySymbols(i); o < n.length; o++) e.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(i, n[o]) && (t[n[o]] = i[n[o]]);
148
- }
149
- return t;
150
- }
151
- var W = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
152
- function ee(i) {
153
- return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
154
- }
155
- function te(i, e) {
156
- return i(e = { exports: {} }, e.exports), e.exports;
157
- }
158
- var U = te((function(i, e) {
159
- Object.defineProperty(e, "__esModule", { value: !0 });
160
- var t = (function() {
161
- function n() {
162
- var o = this;
163
- this.locked = /* @__PURE__ */ new Map(), this.addToLocked = function(r, c) {
164
- var h = o.locked.get(r);
165
- h === void 0 ? c === void 0 ? o.locked.set(r, []) : o.locked.set(r, [c]) : c !== void 0 && (h.unshift(c), o.locked.set(r, h));
166
- }, this.isLocked = function(r) {
167
- return o.locked.has(r);
168
- }, this.lock = function(r) {
169
- return new Promise((function(c, h) {
170
- o.isLocked(r) ? o.addToLocked(r, c) : (o.addToLocked(r), c());
171
- }));
172
- }, this.unlock = function(r) {
173
- var c = o.locked.get(r);
174
- if (c !== void 0 && c.length !== 0) {
175
- var h = c.pop();
176
- o.locked.set(r, c), h !== void 0 && setTimeout(h, 0);
177
- } else o.locked.delete(r);
178
- };
179
- }
180
- return n.getInstance = function() {
181
- return n.instance === void 0 && (n.instance = new n()), n.instance;
182
- }, n;
183
- })();
184
- e.default = function() {
185
- return t.getInstance();
186
- };
187
- }));
188
- ee(U);
189
- var Ze = ee(te((function(i, e) {
190
- var t = W && W.__awaiter || function(a, s, u, p) {
191
- return new (u || (u = Promise))((function(m, w) {
192
- function g(b) {
193
- try {
194
- S(p.next(b));
195
- } catch (f) {
196
- w(f);
197
- }
198
- }
199
- function k(b) {
200
- try {
201
- S(p.throw(b));
202
- } catch (f) {
203
- w(f);
204
- }
205
- }
206
- function S(b) {
207
- b.done ? m(b.value) : new u((function(f) {
208
- f(b.value);
209
- })).then(g, k);
210
- }
211
- S((p = p.apply(a, s || [])).next());
212
- }));
213
- }, n = W && W.__generator || function(a, s) {
214
- var u, p, m, w, g = { label: 0, sent: function() {
215
- if (1 & m[0]) throw m[1];
216
- return m[1];
217
- }, trys: [], ops: [] };
218
- return w = { next: k(0), throw: k(1), return: k(2) }, typeof Symbol == "function" && (w[Symbol.iterator] = function() {
219
- return this;
220
- }), w;
221
- function k(S) {
222
- return function(b) {
223
- return (function(f) {
224
- if (u) throw new TypeError("Generator is already executing.");
225
- for (; g; ) try {
226
- if (u = 1, p && (m = 2 & f[0] ? p.return : f[0] ? p.throw || ((m = p.return) && m.call(p), 0) : p.next) && !(m = m.call(p, f[1])).done) return m;
227
- switch (p = 0, m && (f = [2 & f[0], m.value]), f[0]) {
228
- case 0:
229
- case 1:
230
- m = f;
231
- break;
232
- case 4:
233
- return g.label++, { value: f[1], done: !1 };
234
- case 5:
235
- g.label++, p = f[1], f = [0];
236
- continue;
237
- case 7:
238
- f = g.ops.pop(), g.trys.pop();
239
- continue;
240
- default:
241
- if (m = g.trys, !((m = m.length > 0 && m[m.length - 1]) || f[0] !== 6 && f[0] !== 2)) {
242
- g = 0;
243
- continue;
244
- }
245
- if (f[0] === 3 && (!m || f[1] > m[0] && f[1] < m[3])) {
246
- g.label = f[1];
247
- break;
248
- }
249
- if (f[0] === 6 && g.label < m[1]) {
250
- g.label = m[1], m = f;
251
- break;
252
- }
253
- if (m && g.label < m[2]) {
254
- g.label = m[2], g.ops.push(f);
255
- break;
256
- }
257
- m[2] && g.ops.pop(), g.trys.pop();
258
- continue;
259
- }
260
- f = s.call(a, g);
261
- } catch (C) {
262
- f = [6, C], p = 0;
263
- } finally {
264
- u = m = 0;
265
- }
266
- if (5 & f[0]) throw f[1];
267
- return { value: f[0] ? f[1] : void 0, done: !0 };
268
- })([S, b]);
269
- };
270
- }
271
- }, o = W;
272
- Object.defineProperty(e, "__esModule", { value: !0 });
273
- var r = "browser-tabs-lock-key", c = { key: function(a) {
274
- return t(o, void 0, void 0, (function() {
275
- return n(this, (function(s) {
276
- throw new Error("Unsupported");
277
- }));
278
- }));
279
- }, getItem: function(a) {
280
- return t(o, void 0, void 0, (function() {
281
- return n(this, (function(s) {
282
- throw new Error("Unsupported");
283
- }));
284
- }));
285
- }, clear: function() {
286
- return t(o, void 0, void 0, (function() {
287
- return n(this, (function(a) {
288
- return [2, window.localStorage.clear()];
289
- }));
290
- }));
291
- }, removeItem: function(a) {
292
- return t(o, void 0, void 0, (function() {
293
- return n(this, (function(s) {
294
- throw new Error("Unsupported");
295
- }));
296
- }));
297
- }, setItem: function(a, s) {
298
- return t(o, void 0, void 0, (function() {
299
- return n(this, (function(u) {
300
- throw new Error("Unsupported");
301
- }));
302
- }));
303
- }, keySync: function(a) {
304
- return window.localStorage.key(a);
305
- }, getItemSync: function(a) {
306
- return window.localStorage.getItem(a);
307
- }, clearSync: function() {
308
- return window.localStorage.clear();
309
- }, removeItemSync: function(a) {
310
- return window.localStorage.removeItem(a);
311
- }, setItemSync: function(a, s) {
312
- return window.localStorage.setItem(a, s);
313
- } };
314
- function h(a) {
315
- return new Promise((function(s) {
316
- return setTimeout(s, a);
317
- }));
318
- }
319
- function l(a) {
320
- for (var s = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", u = "", p = 0; p < a; p++)
321
- u += s[Math.floor(Math.random() * s.length)];
322
- return u;
323
- }
324
- var d = (function() {
325
- function a(s) {
326
- this.acquiredIatSet = /* @__PURE__ */ new Set(), this.storageHandler = void 0, this.id = Date.now().toString() + l(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 = s, a.waiters === void 0 && (a.waiters = []);
327
- }
328
- return a.prototype.acquireLock = function(s, u) {
329
- return u === void 0 && (u = 5e3), t(this, void 0, void 0, (function() {
330
- var p, m, w, g, k, S, b;
331
- return n(this, (function(f) {
332
- switch (f.label) {
333
- case 0:
334
- p = Date.now() + l(4), m = Date.now() + u, w = r + "-" + s, g = this.storageHandler === void 0 ? c : this.storageHandler, f.label = 1;
335
- case 1:
336
- return Date.now() < m ? [4, h(30)] : [3, 8];
337
- case 2:
338
- return f.sent(), g.getItemSync(w) !== null ? [3, 5] : (k = this.id + "-" + s + "-" + p, [4, h(Math.floor(25 * Math.random()))]);
339
- case 3:
340
- return f.sent(), g.setItemSync(w, JSON.stringify({ id: this.id, iat: p, timeoutKey: k, timeAcquired: Date.now(), timeRefreshed: Date.now() })), [4, h(30)];
341
- case 4:
342
- return f.sent(), (S = g.getItemSync(w)) !== null && (b = JSON.parse(S)).id === this.id && b.iat === p ? (this.acquiredIatSet.add(p), this.refreshLockWhileAcquired(w, p), [2, !0]) : [3, 7];
343
- case 5:
344
- return a.lockCorrector(this.storageHandler === void 0 ? c : this.storageHandler), [4, this.waitForSomethingToChange(m)];
345
- case 6:
346
- f.sent(), f.label = 7;
347
- case 7:
348
- return p = Date.now() + l(4), [3, 1];
349
- case 8:
350
- return [2, !1];
351
- }
352
- }));
353
- }));
354
- }, a.prototype.refreshLockWhileAcquired = function(s, u) {
355
- return t(this, void 0, void 0, (function() {
356
- var p = this;
357
- return n(this, (function(m) {
358
- return setTimeout((function() {
359
- return t(p, void 0, void 0, (function() {
360
- var w, g, k;
361
- return n(this, (function(S) {
362
- switch (S.label) {
363
- case 0:
364
- return [4, U.default().lock(u)];
365
- case 1:
366
- return S.sent(), this.acquiredIatSet.has(u) ? (w = this.storageHandler === void 0 ? c : this.storageHandler, (g = w.getItemSync(s)) === null ? (U.default().unlock(u), [2]) : ((k = JSON.parse(g)).timeRefreshed = Date.now(), w.setItemSync(s, JSON.stringify(k)), U.default().unlock(u), this.refreshLockWhileAcquired(s, u), [2])) : (U.default().unlock(u), [2]);
367
- }
368
- }));
369
- }));
370
- }), 1e3), [2];
371
- }));
372
- }));
373
- }, a.prototype.waitForSomethingToChange = function(s) {
374
- return t(this, void 0, void 0, (function() {
375
- return n(this, (function(u) {
376
- switch (u.label) {
377
- case 0:
378
- return [4, new Promise((function(p) {
379
- var m = !1, w = Date.now(), g = !1;
380
- function k() {
381
- if (g || (window.removeEventListener("storage", k), a.removeFromWaiting(k), clearTimeout(S), g = !0), !m) {
382
- m = !0;
383
- var b = 50 - (Date.now() - w);
384
- b > 0 ? setTimeout(p, b) : p(null);
385
- }
386
- }
387
- window.addEventListener("storage", k), a.addToWaiting(k);
388
- var S = setTimeout(k, Math.max(0, s - Date.now()));
389
- }))];
390
- case 1:
391
- return u.sent(), [2];
392
- }
393
- }));
394
- }));
395
- }, a.addToWaiting = function(s) {
396
- this.removeFromWaiting(s), a.waiters !== void 0 && a.waiters.push(s);
397
- }, a.removeFromWaiting = function(s) {
398
- a.waiters !== void 0 && (a.waiters = a.waiters.filter((function(u) {
399
- return u !== s;
400
- })));
401
- }, a.notifyWaiters = function() {
402
- a.waiters !== void 0 && a.waiters.slice().forEach((function(s) {
403
- return s();
404
- }));
405
- }, a.prototype.releaseLock = function(s) {
406
- return t(this, void 0, void 0, (function() {
407
- return n(this, (function(u) {
408
- switch (u.label) {
409
- case 0:
410
- return [4, this.releaseLock__private__(s)];
411
- case 1:
412
- return [2, u.sent()];
413
- }
414
- }));
415
- }));
416
- }, a.prototype.releaseLock__private__ = function(s) {
417
- return t(this, void 0, void 0, (function() {
418
- var u, p, m, w;
419
- return n(this, (function(g) {
420
- switch (g.label) {
421
- case 0:
422
- return u = this.storageHandler === void 0 ? c : this.storageHandler, p = r + "-" + s, (m = u.getItemSync(p)) === null ? [2] : (w = JSON.parse(m)).id !== this.id ? [3, 2] : [4, U.default().lock(w.iat)];
423
- case 1:
424
- g.sent(), this.acquiredIatSet.delete(w.iat), u.removeItemSync(p), U.default().unlock(w.iat), a.notifyWaiters(), g.label = 2;
425
- case 2:
426
- return [2];
427
- }
428
- }));
429
- }));
430
- }, a.lockCorrector = function(s) {
431
- for (var u = Date.now() - 5e3, p = s, m = [], w = 0; ; ) {
432
- var g = p.keySync(w);
433
- if (g === null) break;
434
- m.push(g), w++;
435
- }
436
- for (var k = !1, S = 0; S < m.length; S++) {
437
- var b = m[S];
438
- if (b.includes(r)) {
439
- var f = p.getItemSync(b);
440
- if (f !== null) {
441
- var C = JSON.parse(f);
442
- (C.timeRefreshed === void 0 && C.timeAcquired < u || C.timeRefreshed !== void 0 && C.timeRefreshed < u) && (p.removeItemSync(b), k = !0);
443
- }
444
- }
445
- }
446
- k && a.notifyWaiters();
447
- }, a.waiters = void 0, a;
448
- })();
449
- e.default = d;
450
- })));
451
- const Ke = { timeoutInSeconds: 60 }, ge = { name: "auth0-spa-js", version: "2.3.0" }, we = () => Date.now();
452
- class P extends Error {
453
- constructor(e, t) {
454
- super(t), this.error = e, this.error_description = t, Object.setPrototypeOf(this, P.prototype);
455
- }
456
- static fromPayload({ error: e, error_description: t }) {
457
- return new P(e, t);
458
- }
459
- }
460
- class ne extends P {
461
- constructor(e, t, n, o = null) {
462
- super(e, t), this.state = n, this.appState = o, Object.setPrototypeOf(this, ne.prototype);
463
- }
464
- }
465
- class X extends P {
466
- constructor() {
467
- super("timeout", "Timeout"), Object.setPrototypeOf(this, X.prototype);
468
- }
469
- }
470
- class ie extends X {
471
- constructor(e) {
472
- super(), this.popup = e, Object.setPrototypeOf(this, ie.prototype);
473
- }
474
- }
475
- class oe extends P {
476
- constructor(e) {
477
- super("cancelled", "Popup closed"), this.popup = e, Object.setPrototypeOf(this, oe.prototype);
478
- }
479
- }
480
- class re extends P {
481
- constructor(e, t, n) {
482
- super(e, t), this.mfa_token = n, Object.setPrototypeOf(this, re.prototype);
483
- }
484
- }
485
- class H extends P {
486
- constructor(e, t) {
487
- super("missing_refresh_token", `Missing Refresh Token (audience: '${ae(e, ["default"])}', scope: '${ae(t)}')`), this.audience = e, this.scope = t, Object.setPrototypeOf(this, H.prototype);
488
- }
489
- }
490
- function ae(i, e = []) {
491
- return i && !e.includes(i) ? i : "";
492
- }
493
- const G = () => window.crypto, M = () => {
494
- const i = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
495
- let e = "";
496
- return Array.from(G().getRandomValues(new Uint8Array(43))).forEach(((t) => e += i[t % i.length])), e;
497
- }, se = (i) => btoa(i), Q = (i) => {
498
- var { clientId: e } = i, t = E(i, ["clientId"]);
499
- return new URLSearchParams(((n) => Object.keys(n).filter(((o) => n[o] !== void 0)).reduce(((o, r) => Object.assign(Object.assign({}, o), { [r]: n[r] })), {}))(Object.assign({ client_id: e }, t))).toString();
500
- }, ce = (i) => ((e) => decodeURIComponent(atob(e).split("").map(((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2))).join("")))(i.replace(/_/g, "/").replace(/-/g, "+")), Ae = async (i, e) => {
501
- const t = await fetch(i, e);
502
- return { ok: t.ok, json: await t.json() };
503
- }, Ne = async (i, e, t) => {
504
- const n = new AbortController();
505
- let o;
506
- return e.signal = n.signal, Promise.race([Ae(i, e), new Promise(((r, c) => {
507
- o = setTimeout((() => {
508
- n.abort(), c(new Error("Timeout when executing 'fetch'"));
509
- }), t);
510
- }))]).finally((() => {
511
- clearTimeout(o);
512
- }));
513
- }, De = async (i, e, t, n, o, r, c) => {
514
- return h = { auth: { audience: e, scope: t }, timeout: o, fetchUrl: i, fetchOptions: n, useFormData: c }, l = r, new Promise((function(d, a) {
515
- const s = new MessageChannel();
516
- s.port1.onmessage = function(u) {
517
- u.data.error ? a(new Error(u.data.error)) : d(u.data), s.port1.close();
518
- }, l.postMessage(h, [s.port2]);
519
- }));
520
- var h, l;
521
- }, Xe = async (i, e, t, n, o, r, c = 1e4) => o ? De(i, e, t, n, c, o, r) : Ne(i, n, c);
522
- async function Ge(i, e) {
523
- var { baseUrl: t, timeout: n, audience: o, scope: r, auth0Client: c, useFormData: h } = i, l = E(i, ["baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData"]);
524
- const d = l.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange", a = Object.assign(Object.assign(Object.assign({}, l), d && o && { audience: o }), d && r && { scope: r }), s = h ? Q(a) : JSON.stringify(a);
525
- return await (async function(u, p, m, w, g, k, S) {
526
- let b, f = null;
527
- for (let I = 0; I < 3; I++) try {
528
- b = await Xe(u, m, w, g, k, S, p), f = null;
529
- break;
530
- } catch (j) {
531
- f = j;
532
- }
533
- if (f) throw f;
534
- const C = b.json, { error: y, error_description: O } = C, v = E(C, ["error", "error_description"]), { ok: _ } = b;
535
- if (!_) {
536
- const I = O || `HTTP error. Unable to fetch ${u}`;
537
- throw y === "mfa_required" ? new re(y, I, v.mfa_token) : y === "missing_refresh_token" ? new H(m, w) : new P(y || "request_error", I);
538
- }
539
- return v;
540
- })(`${t}/oauth/token`, n, o || "default", r, { method: "POST", body: s, headers: { "Content-Type": h ? "application/x-www-form-urlencoded" : "application/json", "Auth0-Client": btoa(JSON.stringify(c || ge)) } }, e, h);
541
- }
542
- const N = (...i) => {
543
- return (e = i.filter(Boolean).join(" ").trim().split(/\s+/), Array.from(new Set(e))).join(" ");
544
- var e;
545
- };
546
- class x {
547
- constructor(e, t = "@@auth0spajs@@", n) {
548
- this.prefix = t, this.suffix = n, this.clientId = e.clientId, this.scope = e.scope, this.audience = e.audience;
549
- }
550
- toKey() {
551
- return [this.prefix, this.clientId, this.audience, this.scope, this.suffix].filter(Boolean).join("::");
552
- }
553
- static fromKey(e) {
554
- const [t, n, o, r] = e.split("::");
555
- return new x({ clientId: n, scope: r, audience: o }, t);
556
- }
557
- static fromCacheEntry(e) {
558
- const { scope: t, audience: n, client_id: o } = e;
559
- return new x({ scope: t, audience: n, clientId: o });
560
- }
561
- }
562
- class He {
563
- set(e, t) {
564
- localStorage.setItem(e, JSON.stringify(t));
565
- }
566
- get(e) {
567
- const t = window.localStorage.getItem(e);
568
- if (t) try {
569
- return JSON.parse(t);
570
- } catch {
571
- return;
572
- }
573
- }
574
- remove(e) {
575
- localStorage.removeItem(e);
576
- }
577
- allKeys() {
578
- return Object.keys(window.localStorage).filter(((e) => e.startsWith("@@auth0spajs@@")));
579
- }
580
- }
581
- class ye {
582
- constructor() {
583
- this.enclosedCache = /* @__PURE__ */ (function() {
584
- let e = {};
585
- return { set(t, n) {
586
- e[t] = n;
587
- }, get(t) {
588
- const n = e[t];
589
- if (n) return n;
590
- }, remove(t) {
591
- delete e[t];
592
- }, allKeys: () => Object.keys(e) };
593
- })();
594
- }
595
- }
596
- class Je {
597
- constructor(e, t, n) {
598
- this.cache = e, this.keyManifest = t, this.nowProvider = n || we;
599
- }
600
- async setIdToken(e, t, n) {
601
- var o;
602
- const r = this.getIdTokenCacheKey(e);
603
- await this.cache.set(r, { id_token: t, decodedToken: n }), await ((o = this.keyManifest) === null || o === void 0 ? void 0 : o.add(r));
604
- }
605
- async getIdToken(e) {
606
- const t = await this.cache.get(this.getIdTokenCacheKey(e.clientId));
607
- if (!t && e.scope && e.audience) {
608
- const n = await this.get(e);
609
- return !n || !n.id_token || !n.decodedToken ? void 0 : { id_token: n.id_token, decodedToken: n.decodedToken };
610
- }
611
- if (t) return { id_token: t.id_token, decodedToken: t.decodedToken };
612
- }
613
- async get(e, t = 0) {
614
- var n;
615
- let o = await this.cache.get(e.toKey());
616
- if (!o) {
617
- const h = await this.getCacheKeys();
618
- if (!h) return;
619
- const l = this.matchExistingCacheKey(e, h);
620
- l && (o = await this.cache.get(l));
621
- }
622
- if (!o) return;
623
- const r = await this.nowProvider(), c = Math.floor(r / 1e3);
624
- return o.expiresAt - t < c ? o.body.refresh_token ? (o.body = { refresh_token: o.body.refresh_token }, await this.cache.set(e.toKey(), o), o.body) : (await this.cache.remove(e.toKey()), void await ((n = this.keyManifest) === null || n === void 0 ? void 0 : n.remove(e.toKey()))) : o.body;
625
- }
626
- async set(e) {
627
- var t;
628
- const n = new x({ clientId: e.client_id, scope: e.scope, audience: e.audience }), o = await this.wrapCacheEntry(e);
629
- await this.cache.set(n.toKey(), o), await ((t = this.keyManifest) === null || t === void 0 ? void 0 : t.add(n.toKey()));
630
- }
631
- async clear(e) {
632
- var t;
633
- const n = await this.getCacheKeys();
634
- n && (await n.filter(((o) => !e || o.includes(e))).reduce((async (o, r) => {
635
- await o, await this.cache.remove(r);
636
- }), Promise.resolve()), await ((t = this.keyManifest) === null || t === void 0 ? void 0 : t.clear()));
637
- }
638
- async wrapCacheEntry(e) {
639
- const t = await this.nowProvider();
640
- return { body: e, expiresAt: Math.floor(t / 1e3) + e.expires_in };
641
- }
642
- async getCacheKeys() {
643
- var e;
644
- return this.keyManifest ? (e = await this.keyManifest.get()) === null || e === void 0 ? void 0 : e.keys : this.cache.allKeys ? this.cache.allKeys() : void 0;
645
- }
646
- getIdTokenCacheKey(e) {
647
- return new x({ clientId: e }, "@@auth0spajs@@", "@@user@@").toKey();
648
- }
649
- matchExistingCacheKey(e, t) {
650
- return t.filter(((n) => {
651
- var o;
652
- const r = x.fromKey(n), c = new Set(r.scope && r.scope.split(" ")), h = ((o = e.scope) === null || o === void 0 ? void 0 : o.split(" ")) || [], l = r.scope && h.reduce(((d, a) => d && c.has(a)), !0);
653
- return r.prefix === "@@auth0spajs@@" && r.clientId === e.clientId && r.audience === e.audience && l;
654
- }))[0];
655
- }
656
- }
657
- class Me {
658
- constructor(e, t, n) {
659
- this.storage = e, this.clientId = t, this.cookieDomain = n, this.storageKey = `a0.spajs.txs.${this.clientId}`;
660
- }
661
- create(e) {
662
- this.storage.save(this.storageKey, e, { daysUntilExpire: 1, cookieDomain: this.cookieDomain });
663
- }
664
- get() {
665
- return this.storage.get(this.storageKey);
666
- }
667
- remove() {
668
- this.storage.remove(this.storageKey, { cookieDomain: this.cookieDomain });
669
- }
670
- }
671
- const D = (i) => typeof i == "number", Fe = ["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"], Ve = (i) => {
672
- if (!i.id_token) throw new Error("ID token is required but missing");
673
- const e = ((r) => {
674
- const c = r.split("."), [h, l, d] = c;
675
- if (c.length !== 3 || !h || !l || !d) throw new Error("ID token could not be decoded");
676
- const a = JSON.parse(ce(l)), s = { __raw: r }, u = {};
677
- return Object.keys(a).forEach(((p) => {
678
- s[p] = a[p], Fe.includes(p) || (u[p] = a[p]);
679
- })), { encoded: { header: h, payload: l, signature: d }, header: JSON.parse(ce(h)), claims: s, user: u };
680
- })(i.id_token);
681
- if (!e.claims.iss) throw new Error("Issuer (iss) claim must be a string present in the ID token");
682
- if (e.claims.iss !== i.iss) throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${i.iss}", found "${e.claims.iss}"`);
683
- if (!e.user.sub) throw new Error("Subject (sub) claim must be a string present in the ID token");
684
- 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".`);
685
- 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");
686
- if (Array.isArray(e.claims.aud)) {
687
- 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(", ")}"`);
688
- if (e.claims.aud.length > 1) {
689
- 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");
690
- 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}"`);
691
- }
692
- } 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}"`);
693
- if (i.nonce) {
694
- if (!e.claims.nonce) throw new Error("Nonce (nonce) claim must be a string present in the ID token");
695
- if (e.claims.nonce !== i.nonce) throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${i.nonce}", found "${e.claims.nonce}"`);
696
- }
697
- if (i.max_age && !D(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");
698
- if (e.claims.exp == null || !D(e.claims.exp)) throw new Error("Expiration Time (exp) claim must be a number present in the ID token");
699
- if (!D(e.claims.iat)) throw new Error("Issued At (iat) claim must be a number present in the ID token");
700
- const t = i.leeway || 60, n = new Date(i.now || Date.now()), o = /* @__PURE__ */ new Date(0);
701
- if (o.setUTCSeconds(e.claims.exp + t), n > o) throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${n}) is after expiration time (${o})`);
702
- if (e.claims.nbf != null && D(e.claims.nbf)) {
703
- const r = /* @__PURE__ */ new Date(0);
704
- if (r.setUTCSeconds(e.claims.nbf - t), n < 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 (${n}) is before ${r}`);
705
- }
706
- if (e.claims.auth_time != null && D(e.claims.auth_time)) {
707
- const r = /* @__PURE__ */ new Date(0);
708
- if (r.setUTCSeconds(parseInt(e.claims.auth_time) + i.max_age + t), n > 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 (${n}) is after last auth at ${r}`);
709
- }
710
- if (i.organization) {
711
- const r = i.organization.trim();
712
- if (r.startsWith("org_")) {
713
- const c = r;
714
- if (!e.claims.org_id) throw new Error("Organization ID (org_id) claim must be a string present in the ID token");
715
- if (c !== e.claims.org_id) throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${c}", found "${e.claims.org_id}"`);
716
- } else {
717
- const c = r.toLowerCase();
718
- if (!e.claims.org_name) throw new Error("Organization Name (org_name) claim must be a string present in the ID token");
719
- if (c !== e.claims.org_name) throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${c}", found "${e.claims.org_name}"`);
720
- }
721
- }
722
- return e;
723
- };
724
- var J = te((function(i, e) {
725
- var t = W && W.__assign || function() {
726
- return t = Object.assign || function(l) {
727
- for (var d, a = 1, s = arguments.length; a < s; a++) for (var u in d = arguments[a]) Object.prototype.hasOwnProperty.call(d, u) && (l[u] = d[u]);
728
- return l;
729
- }, t.apply(this, arguments);
730
- };
731
- function n(l, d) {
732
- if (!d) return "";
733
- var a = "; " + l;
734
- return d === !0 ? a : a + "=" + d;
735
- }
736
- function o(l, d, a) {
737
- return encodeURIComponent(l).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/\(/g, "%28").replace(/\)/g, "%29") + "=" + encodeURIComponent(d).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent) + (function(s) {
738
- if (typeof s.expires == "number") {
739
- var u = /* @__PURE__ */ new Date();
740
- u.setMilliseconds(u.getMilliseconds() + 864e5 * s.expires), s.expires = u;
741
- }
742
- return n("Expires", s.expires ? s.expires.toUTCString() : "") + n("Domain", s.domain) + n("Path", s.path) + n("Secure", s.secure) + n("SameSite", s.sameSite);
743
- })(a);
744
- }
745
- function r(l) {
746
- for (var d = {}, a = l ? l.split("; ") : [], s = /(%[\dA-F]{2})+/gi, u = 0; u < a.length; u++) {
747
- var p = a[u].split("="), m = p.slice(1).join("=");
748
- m.charAt(0) === '"' && (m = m.slice(1, -1));
749
- try {
750
- d[p[0].replace(s, decodeURIComponent)] = m.replace(s, decodeURIComponent);
751
- } catch {
752
- }
753
- }
754
- return d;
755
- }
756
- function c() {
757
- return r(document.cookie);
758
- }
759
- function h(l, d, a) {
760
- document.cookie = o(l, d, t({ path: "/" }, a));
761
- }
762
- e.__esModule = !0, e.encode = o, e.parse = r, e.getAll = c, e.get = function(l) {
763
- return c()[l];
764
- }, e.set = h, e.remove = function(l, d) {
765
- h(l, "", t(t({}, d), { expires: -1 }));
766
- };
767
- }));
768
- ee(J);
769
- var Ye = J.get, ve = J.set, ke = J.remove;
770
- const K = { get(i) {
771
- const e = Ye(i);
772
- if (e !== void 0) return JSON.parse(e);
773
- }, save(i, e, t) {
774
- let n = {};
775
- window.location.protocol === "https:" && (n = { secure: !0, sameSite: "none" }), t?.daysUntilExpire && (n.expires = t.daysUntilExpire), t?.cookieDomain && (n.domain = t.cookieDomain), ve(i, JSON.stringify(e), n);
776
- }, remove(i, e) {
777
- let t = {};
778
- e?.cookieDomain && (t.domain = e.cookieDomain), ke(i, t);
779
- } }, $e = { get(i) {
780
- return K.get(i) || K.get(`_legacy_${i}`);
781
- }, save(i, e, t) {
782
- let n = {};
783
- window.location.protocol === "https:" && (n = { secure: !0 }), t?.daysUntilExpire && (n.expires = t.daysUntilExpire), t?.cookieDomain && (n.domain = t.cookieDomain), ve(`_legacy_${i}`, JSON.stringify(e), n), K.save(i, e, t);
784
- }, remove(i, e) {
785
- let t = {};
786
- e?.cookieDomain && (t.domain = e.cookieDomain), ke(i, t), K.remove(i, e), K.remove(`_legacy_${i}`, e);
787
- } }, Be = { get(i) {
788
- if (typeof sessionStorage > "u") return;
789
- const e = sessionStorage.getItem(i);
790
- return e != null ? JSON.parse(e) : void 0;
791
- }, save(i, e) {
792
- sessionStorage.setItem(i, JSON.stringify(e));
793
- }, remove(i) {
794
- sessionStorage.removeItem(i);
795
- } };
796
- function qe(i, e, t) {
797
- var n = e === void 0 ? null : e, o = (function(l, d) {
798
- var a = atob(l);
799
- if (d) {
800
- for (var s = new Uint8Array(a.length), u = 0, p = a.length; u < p; ++u) s[u] = a.charCodeAt(u);
801
- return String.fromCharCode.apply(null, new Uint16Array(s.buffer));
802
- }
803
- return a;
804
- })(i, t !== void 0 && t), r = o.indexOf(`
805
- `, 10) + 1, c = o.substring(r) + (n ? "//# sourceMappingURL=" + n : ""), h = new Blob([c], { type: "application/javascript" });
806
- return URL.createObjectURL(h);
807
- }
808
- var ue, le, de, F, Qe = (ue = "Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=", le = null, de = !1, function(i) {
809
- return F = F || qe(ue, le, de), new Worker(F, i);
810
- });
811
- const V = {};
812
- class et {
813
- constructor(e, t) {
814
- this.cache = e, this.clientId = t, this.manifestKey = this.createManifestKeyFrom(this.clientId);
815
- }
816
- async add(e) {
817
- var t;
818
- const n = new Set(((t = await this.cache.get(this.manifestKey)) === null || t === void 0 ? void 0 : t.keys) || []);
819
- n.add(e), await this.cache.set(this.manifestKey, { keys: [...n] });
820
- }
821
- async remove(e) {
822
- const t = await this.cache.get(this.manifestKey);
823
- if (t) {
824
- const n = new Set(t.keys);
825
- return n.delete(e), n.size > 0 ? await this.cache.set(this.manifestKey, { keys: [...n] }) : await this.cache.remove(this.manifestKey);
826
- }
827
- }
828
- get() {
829
- return this.cache.get(this.manifestKey);
830
- }
831
- clear() {
832
- return this.cache.remove(this.manifestKey);
833
- }
834
- createManifestKeyFrom(e) {
835
- return `@@auth0spajs@@::${e}`;
836
- }
837
- }
838
- const tt = { memory: () => new ye().enclosedCache, localstorage: () => new He() }, he = (i) => tt[i], pe = (i) => {
839
- const { openUrl: e, onRedirect: t } = i, n = E(i, ["openUrl", "onRedirect"]);
840
- return Object.assign(Object.assign({}, n), { openUrl: e === !1 || e ? e : t });
841
- }, Y = new Ze();
842
- class nt {
843
- constructor(e) {
844
- let t, n;
845
- if (this.userCache = new ye().enclosedCache, this.defaultOptions = { authorizationParams: { scope: "openid profile email" }, useRefreshTokensFallback: !1, useFormData: !0 }, this._releaseLockOnPageHide = async () => {
846
- await Y.releaseLock("auth0.lock.getTokenSilently"), window.removeEventListener("pagehide", this._releaseLockOnPageHide);
847
- }, this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), e), { authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), e.authorizationParams) }), typeof window < "u" && (() => {
848
- if (!G()) throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");
849
- if (G().subtle === void 0) throw new Error(`
850
- 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.
851
- `);
852
- })(), 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) n = e.cache;
853
- else {
854
- if (t = e.cacheLocation || "memory", !he(t)) throw new Error(`Invalid cache location "${t}"`);
855
- n = he(t)();
856
- }
857
- this.httpTimeoutMs = e.httpTimeoutInSeconds ? 1e3 * e.httpTimeoutInSeconds : 1e4, this.cookieStorage = e.legacySameSiteCookie === !1 ? K : $e, this.orgHintCookieName = `auth0.${this.options.clientId}.organization_hint`, this.isAuthenticatedCookieName = ((c) => `auth0.${c}.is.authenticated`)(this.options.clientId), this.sessionCheckExpiryDays = e.sessionCheckExpiryDays || 1;
858
- const o = e.useCookiesForTransactions ? this.cookieStorage : Be;
859
- var r;
860
- this.scope = N("openid", this.options.authorizationParams.scope, this.options.useRefreshTokens ? "offline_access" : ""), this.transactionManager = new Me(o, this.options.clientId, this.options.cookieDomain), this.nowProvider = this.options.nowProvider || we, this.cacheManager = new Je(n, n.allKeys ? void 0 : new et(n, this.options.clientId), this.nowProvider), this.domainUrl = (r = this.options.domain, /^https?:\/\//.test(r) ? r : `https://${r}`), this.tokenIssuer = ((c, h) => c ? c.startsWith("https://") ? c : `https://${c}/` : `${h}/`)(this.options.issuer, this.domainUrl), typeof window < "u" && window.Worker && this.options.useRefreshTokens && t === "memory" && (this.options.workerUrl ? this.worker = new Worker(this.options.workerUrl) : this.worker = new Qe());
861
- }
862
- _url(e) {
863
- const t = encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client || ge)));
864
- return `${this.domainUrl}${e}&auth0Client=${t}`;
865
- }
866
- _authorizeUrl(e) {
867
- return this._url(`/authorize?${Q(e)}`);
868
- }
869
- async _verifyIdToken(e, t, n) {
870
- const o = await this.nowProvider();
871
- return Ve({ iss: this.tokenIssuer, aud: this.options.clientId, id_token: e, nonce: t, organization: n, leeway: this.options.leeway, max_age: (r = this.options.authorizationParams.max_age, typeof r != "string" ? r : parseInt(r, 10) || void 0), now: o });
872
- var r;
873
- }
874
- _processOrgHint(e) {
875
- e ? this.cookieStorage.save(this.orgHintCookieName, e, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }) : this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain });
876
- }
877
- async _prepareAuthorizeUrl(e, t, n) {
878
- const o = se(M()), r = se(M()), c = M(), h = ((a) => {
879
- const s = new Uint8Array(a);
880
- return ((u) => {
881
- const p = { "+": "-", "/": "_", "=": "" };
882
- return u.replace(/[+/=]/g, ((m) => p[m]));
883
- })(window.btoa(String.fromCharCode(...Array.from(s))));
884
- })(await (async (a) => await G().subtle.digest({ name: "SHA-256" }, new TextEncoder().encode(a)))(c)), l = ((a, s, u, p, m, w, g, k) => Object.assign(Object.assign(Object.assign({ client_id: a.clientId }, a.authorizationParams), u), { scope: N(s, u.scope), response_type: "code", response_mode: k || "query", state: p, nonce: m, redirect_uri: g || a.authorizationParams.redirect_uri, code_challenge: w, code_challenge_method: "S256" }))(this.options, this.scope, e, o, r, h, e.redirect_uri || this.options.authorizationParams.redirect_uri || n, t?.response_mode), d = this._authorizeUrl(l);
885
- return { nonce: r, code_verifier: c, scope: l.scope, audience: l.audience || "default", redirect_uri: l.redirect_uri, state: o, url: d };
886
- }
887
- async loginWithPopup(e, t) {
888
- var n;
889
- if (e = e || {}, !(t = t || {}).popup && (t.popup = ((h) => {
890
- const l = window.screenX + (window.innerWidth - 400) / 2, d = window.screenY + (window.innerHeight - 600) / 2;
891
- return window.open(h, "auth0:authorize:popup", `left=${l},top=${d},width=400,height=600,resizable,scrollbars=yes,status=1`);
892
- })(""), !t.popup)) throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");
893
- const o = await this._prepareAuthorizeUrl(e.authorizationParams || {}, { response_mode: "web_message" }, window.location.origin);
894
- t.popup.location.href = o.url;
895
- const r = await ((h) => new Promise(((l, d) => {
896
- let a;
897
- const s = setInterval((() => {
898
- h.popup && h.popup.closed && (clearInterval(s), clearTimeout(u), window.removeEventListener("message", a, !1), d(new oe(h.popup)));
899
- }), 1e3), u = setTimeout((() => {
900
- clearInterval(s), d(new ie(h.popup)), window.removeEventListener("message", a, !1);
901
- }), 1e3 * (h.timeoutInSeconds || 60));
902
- a = function(p) {
903
- if (p.data && p.data.type === "authorization_response") {
904
- if (clearTimeout(u), clearInterval(s), window.removeEventListener("message", a, !1), h.popup.close(), p.data.response.error) return d(P.fromPayload(p.data.response));
905
- l(p.data.response);
906
- }
907
- }, window.addEventListener("message", a);
908
- })))(Object.assign(Object.assign({}, t), { timeoutInSeconds: t.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || 60 }));
909
- if (o.state !== r.state) throw new P("state_mismatch", "Invalid state");
910
- const c = ((n = e.authorizationParams) === null || n === void 0 ? void 0 : n.organization) || this.options.authorizationParams.organization;
911
- await this._requestToken({ audience: o.audience, scope: o.scope, code_verifier: o.code_verifier, grant_type: "authorization_code", code: r.code, redirect_uri: o.redirect_uri }, { nonceIn: o.nonce, organization: c });
912
- }
913
- async getUser() {
914
- var e;
915
- const t = await this._getIdTokenFromCache();
916
- return (e = t?.decodedToken) === null || e === void 0 ? void 0 : e.user;
917
- }
918
- async getIdTokenClaims() {
919
- var e;
920
- const t = await this._getIdTokenFromCache();
921
- return (e = t?.decodedToken) === null || e === void 0 ? void 0 : e.claims;
922
- }
923
- async loginWithRedirect(e = {}) {
924
- var t;
925
- const n = pe(e), { openUrl: o, fragment: r, appState: c } = n, h = E(n, ["openUrl", "fragment", "appState"]), l = ((t = h.authorizationParams) === null || t === void 0 ? void 0 : t.organization) || this.options.authorizationParams.organization, d = await this._prepareAuthorizeUrl(h.authorizationParams || {}), { url: a } = d, s = E(d, ["url"]);
926
- this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, s), { appState: c }), l && { organization: l }));
927
- const u = r ? `${a}#${r}` : a;
928
- o ? await o(u) : window.location.assign(u);
929
- }
930
- async handleRedirectCallback(e = window.location.href) {
931
- const t = e.split("?").slice(1);
932
- if (t.length === 0) throw new Error("There are no query params available for parsing.");
933
- const { state: n, code: o, error: r, error_description: c } = ((s) => {
934
- s.indexOf("#") > -1 && (s = s.substring(0, s.indexOf("#")));
935
- const u = new URLSearchParams(s);
936
- return { state: u.get("state"), code: u.get("code") || void 0, error: u.get("error") || void 0, error_description: u.get("error_description") || void 0 };
937
- })(t.join("")), h = this.transactionManager.get();
938
- if (!h) throw new P("missing_transaction", "Invalid state");
939
- if (this.transactionManager.remove(), r) throw new ne(r, c || r, n, h.appState);
940
- if (!h.code_verifier || h.state && h.state !== n) throw new P("state_mismatch", "Invalid state");
941
- const l = h.organization, d = h.nonce, a = h.redirect_uri;
942
- return await this._requestToken(Object.assign({ audience: h.audience, scope: h.scope, code_verifier: h.code_verifier, grant_type: "authorization_code", code: o }, a ? { redirect_uri: a } : {}), { nonceIn: d, organization: l }), { appState: h.appState };
943
- }
944
- async checkSession(e) {
945
- if (!this.cookieStorage.get(this.isAuthenticatedCookieName)) {
946
- if (!this.cookieStorage.get("auth0.is.authenticated")) return;
947
- this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove("auth0.is.authenticated");
948
- }
949
- try {
950
- await this.getTokenSilently(e);
951
- } catch {
952
- }
953
- }
954
- async getTokenSilently(e = {}) {
955
- var t;
956
- const n = Object.assign(Object.assign({ cacheMode: "on" }, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: N(this.scope, (t = e.authorizationParams) === null || t === void 0 ? void 0 : t.scope) }) }), o = await ((r, c) => {
957
- let h = V[c];
958
- return h || (h = r().finally((() => {
959
- delete V[c], h = null;
960
- })), V[c] = h), h;
961
- })((() => this._getTokenSilently(n)), `${this.options.clientId}::${n.authorizationParams.audience}::${n.authorizationParams.scope}`);
962
- return e.detailedResponse ? o : o?.access_token;
963
- }
964
- async _getTokenSilently(e) {
965
- const { cacheMode: t } = e, n = E(e, ["cacheMode"]);
966
- if (t !== "off") {
967
- const o = await this._getEntryFromCache({ scope: n.authorizationParams.scope, audience: n.authorizationParams.audience || "default", clientId: this.options.clientId });
968
- if (o) return o;
969
- }
970
- if (t !== "cache-only") {
971
- if (!await (async (o, r = 3) => {
972
- for (let c = 0; c < r; c++) if (await o()) return !0;
973
- return !1;
974
- })((() => Y.acquireLock("auth0.lock.getTokenSilently", 5e3)), 10)) throw new X();
975
- try {
976
- if (window.addEventListener("pagehide", this._releaseLockOnPageHide), t !== "off") {
977
- const d = await this._getEntryFromCache({ scope: n.authorizationParams.scope, audience: n.authorizationParams.audience || "default", clientId: this.options.clientId });
978
- if (d) return d;
979
- }
980
- const o = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(n) : await this._getTokenFromIFrame(n), { id_token: r, access_token: c, oauthTokenScope: h, expires_in: l } = o;
981
- return Object.assign(Object.assign({ id_token: r, access_token: c }, h ? { scope: h } : null), { expires_in: l });
982
- } finally {
983
- await Y.releaseLock("auth0.lock.getTokenSilently"), window.removeEventListener("pagehide", this._releaseLockOnPageHide);
984
- }
985
- }
986
- }
987
- async getTokenWithPopup(e = {}, t = {}) {
988
- var n;
989
- const o = Object.assign(Object.assign({}, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: N(this.scope, (n = e.authorizationParams) === null || n === void 0 ? void 0 : n.scope) }) });
990
- return t = Object.assign(Object.assign({}, Ke), t), await this.loginWithPopup(o, t), (await this.cacheManager.get(new x({ scope: o.authorizationParams.scope, audience: o.authorizationParams.audience || "default", clientId: this.options.clientId }))).access_token;
991
- }
992
- async isAuthenticated() {
993
- return !!await this.getUser();
994
- }
995
- _buildLogoutUrl(e) {
996
- e.clientId !== null ? e.clientId = e.clientId || this.options.clientId : delete e.clientId;
997
- const t = e.logoutParams || {}, { federated: n } = t, o = E(t, ["federated"]), r = n ? "&federated" : "";
998
- return this._url(`/v2/logout?${Q(Object.assign({ clientId: e.clientId }, o))}`) + r;
999
- }
1000
- async logout(e = {}) {
1001
- const t = pe(e), { openUrl: n } = t, o = E(t, ["openUrl"]);
1002
- 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@@");
1003
- const r = this._buildLogoutUrl(o);
1004
- n ? await n(r) : n !== !1 && window.location.assign(r);
1005
- }
1006
- async _getTokenFromIFrame(e) {
1007
- const t = Object.assign(Object.assign({}, e.authorizationParams), { prompt: "none" }), n = this.cookieStorage.get(this.orgHintCookieName);
1008
- n && !t.organization && (t.organization = n);
1009
- const { url: o, state: r, nonce: c, code_verifier: h, redirect_uri: l, scope: d, audience: a } = await this._prepareAuthorizeUrl(t, { response_mode: "web_message" }, window.location.origin);
1010
- try {
1011
- if (window.crossOriginIsolated) throw new P("login_required", "The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");
1012
- const s = e.timeoutInSeconds || this.options.authorizeTimeoutInSeconds;
1013
- let u;
1014
- try {
1015
- u = new URL(this.domainUrl).origin;
1016
- } catch {
1017
- u = this.domainUrl;
1018
- }
1019
- const p = await ((w, g, k = 60) => new Promise(((S, b) => {
1020
- const f = window.document.createElement("iframe");
1021
- f.setAttribute("width", "0"), f.setAttribute("height", "0"), f.style.display = "none";
1022
- const C = () => {
1023
- window.document.body.contains(f) && (window.document.body.removeChild(f), window.removeEventListener("message", y, !1));
1024
- };
1025
- let y;
1026
- const O = setTimeout((() => {
1027
- b(new X()), C();
1028
- }), 1e3 * k);
1029
- y = function(v) {
1030
- if (v.origin != g || !v.data || v.data.type !== "authorization_response") return;
1031
- const _ = v.source;
1032
- _ && _.close(), v.data.response.error ? b(P.fromPayload(v.data.response)) : S(v.data.response), clearTimeout(O), window.removeEventListener("message", y, !1), setTimeout(C, 2e3);
1033
- }, window.addEventListener("message", y, !1), window.document.body.appendChild(f), f.setAttribute("src", w);
1034
- })))(o, u, s);
1035
- if (r !== p.state) throw new P("state_mismatch", "Invalid state");
1036
- const m = await this._requestToken(Object.assign(Object.assign({}, e.authorizationParams), { code_verifier: h, code: p.code, grant_type: "authorization_code", redirect_uri: l, timeout: e.authorizationParams.timeout || this.httpTimeoutMs }), { nonceIn: c, organization: t.organization });
1037
- return Object.assign(Object.assign({}, m), { scope: d, oauthTokenScope: m.scope, audience: a });
1038
- } catch (s) {
1039
- throw s.error === "login_required" && this.logout({ openUrl: !1 }), s;
1040
- }
1041
- }
1042
- async _getTokenUsingRefreshToken(e) {
1043
- const t = await this.cacheManager.get(new x({ scope: e.authorizationParams.scope, audience: e.authorizationParams.audience || "default", clientId: this.options.clientId }));
1044
- if (!(t && t.refresh_token || this.worker)) {
1045
- if (this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
1046
- throw new H(e.authorizationParams.audience || "default", e.authorizationParams.scope);
1047
- }
1048
- const n = e.authorizationParams.redirect_uri || this.options.authorizationParams.redirect_uri || window.location.origin, o = typeof e.timeoutInSeconds == "number" ? 1e3 * e.timeoutInSeconds : null;
1049
- try {
1050
- const r = await this._requestToken(Object.assign(Object.assign(Object.assign({}, e.authorizationParams), { grant_type: "refresh_token", refresh_token: t && t.refresh_token, redirect_uri: n }), o && { timeout: o }));
1051
- return Object.assign(Object.assign({}, r), { scope: e.authorizationParams.scope, oauthTokenScope: r.scope, audience: e.authorizationParams.audience || "default" });
1052
- } catch (r) {
1053
- if ((r.message.indexOf("Missing Refresh Token") > -1 || r.message && r.message.indexOf("invalid refresh token") > -1) && this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
1054
- throw r;
1055
- }
1056
- }
1057
- async _saveEntryInCache(e) {
1058
- const { id_token: t, decodedToken: n } = e, o = E(e, ["id_token", "decodedToken"]);
1059
- this.userCache.set("@@user@@", { id_token: t, decodedToken: n }), await this.cacheManager.setIdToken(this.options.clientId, e.id_token, e.decodedToken), await this.cacheManager.set(o);
1060
- }
1061
- async _getIdTokenFromCache() {
1062
- const e = this.options.authorizationParams.audience || "default", t = await this.cacheManager.getIdToken(new x({ clientId: this.options.clientId, audience: e, scope: this.scope })), n = this.userCache.get("@@user@@");
1063
- return t && t.id_token === n?.id_token ? n : (this.userCache.set("@@user@@", t), t);
1064
- }
1065
- async _getEntryFromCache({ scope: e, audience: t, clientId: n }) {
1066
- const o = await this.cacheManager.get(new x({ scope: e, audience: t, clientId: n }), 60);
1067
- if (o && o.access_token) {
1068
- const { access_token: r, oauthTokenScope: c, expires_in: h } = o, l = await this._getIdTokenFromCache();
1069
- return l && Object.assign(Object.assign({ id_token: l.id_token, access_token: r }, c ? { scope: c } : null), { expires_in: h });
1070
- }
1071
- }
1072
- async _requestToken(e, t) {
1073
- const { nonceIn: n, organization: o } = t || {}, r = await Ge(Object.assign({ baseUrl: this.domainUrl, client_id: this.options.clientId, auth0Client: this.options.auth0Client, useFormData: this.options.useFormData, timeout: this.httpTimeoutMs }, e), this.worker), c = await this._verifyIdToken(r.id_token, n, o);
1074
- return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, r), { decodedToken: c, scope: e.scope, audience: e.audience || "default" }), r.scope ? { oauthTokenScope: r.scope } : null), { client_id: this.options.clientId })), this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this._processOrgHint(o || c.claims.org_id), Object.assign(Object.assign({}, r), { decodedToken: c });
1075
- }
1076
- async exchangeToken(e) {
1077
- 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: N(e.scope, this.scope), audience: e.audience || this.options.authorizationParams.audience });
1078
- }
1079
- }
1080
- var be = {
1081
- isAuthenticated: !1,
1082
- isLoading: !0,
1083
- error: void 0,
1084
- user: void 0
1085
- }, z = function() {
1086
- throw new Error("You forgot to wrap your component in <Auth0Provider>.");
1087
- }, it = T(T({}, be), { buildAuthorizeUrl: z, buildLogoutUrl: z, getAccessTokenSilently: z, getAccessTokenWithPopup: z, getIdTokenClaims: z, loginWithRedirect: z, loginWithPopup: z, logout: z, handleRedirectCallback: z }), _e = xe(it), me = (
1088
- /** @class */
1089
- (function(i) {
1090
- Ue(e, i);
1091
- function e(t, n) {
1092
- var o = i.call(this, n ?? t) || this;
1093
- return o.error = t, o.error_description = n, Object.setPrototypeOf(o, e.prototype), o;
1094
- }
1095
- return e;
1096
- })(Error)
1097
- ), ot = /[?&]code=[^&]+/, rt = /[?&]state=[^&]+/, at = /[?&]error=[^&]+/, st = function(i) {
1098
- return i === void 0 && (i = window.location.search), (ot.test(i) || at.test(i)) && rt.test(i);
1099
- }, Ie = function(i) {
1100
- return function(e) {
1101
- return e instanceof Error ? e : e !== null && typeof e == "object" && "error" in e && typeof e.error == "string" ? "error_description" in e && typeof e.error_description == "string" ? new me(e.error, e.error_description) : new me(e.error) : new Error(i);
1102
- };
1103
- }, fe = Ie("Login failed"), $ = Ie("Get access token failed"), Se = function(i) {
1104
- var e, t;
1105
- i?.redirectUri && (console.warn("Using `redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `redirectUri` will be no longer supported in a future version"), i.authorizationParams = (e = i.authorizationParams) !== null && e !== void 0 ? e : {}, i.authorizationParams.redirect_uri = i.redirectUri, delete i.redirectUri), !((t = i?.authorizationParams) === null || t === void 0) && t.redirectUri && (console.warn("Using `authorizationParams.redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `authorizationParams.redirectUri` will be removed in a future version"), i.authorizationParams.redirect_uri = i.authorizationParams.redirectUri, delete i.authorizationParams.redirectUri);
1106
- }, ct = function(i, e) {
1107
- switch (e.type) {
1108
- case "LOGIN_POPUP_STARTED":
1109
- return T(T({}, i), { isLoading: !0 });
1110
- case "LOGIN_POPUP_COMPLETE":
1111
- case "INITIALISED":
1112
- return T(T({}, i), { isAuthenticated: !!e.user, user: e.user, isLoading: !1, error: void 0 });
1113
- case "HANDLE_REDIRECT_COMPLETE":
1114
- case "GET_ACCESS_TOKEN_COMPLETE":
1115
- return i.user === e.user ? i : T(T({}, i), { isAuthenticated: !!e.user, user: e.user });
1116
- case "LOGOUT":
1117
- return T(T({}, i), { isAuthenticated: !1, user: void 0 });
1118
- case "ERROR":
1119
- return T(T({}, i), { isLoading: !1, error: e.error });
1120
- }
1121
- }, ut = function(i) {
1122
- return Se(i), T(T({}, i), { auth0Client: {
1123
- name: "auth0-react",
1124
- version: "2.4.0"
1125
- } });
1126
- }, lt = function(i) {
1127
- var e;
1128
- window.history.replaceState({}, document.title, (e = i?.returnTo) !== null && e !== void 0 ? e : window.location.pathname);
1129
- }, dt = function(i) {
1130
- var e = i.children, t = i.skipRedirectCallback, n = i.onRedirectCallback, o = n === void 0 ? lt : n, r = i.context, c = r === void 0 ? _e : r, h = We(i, ["children", "skipRedirectCallback", "onRedirectCallback", "context"]), l = Te(function() {
1131
- return new nt(ut(h));
1132
- })[0], d = Pe(ct, be), a = d[0], s = d[1], u = Ce(!1), p = R(function(y) {
1133
- return s({ type: "ERROR", error: y }), y;
1134
- }, []);
1135
- je(function() {
1136
- u.current || (u.current = !0, (function() {
1137
- return L(void 0, void 0, void 0, function() {
1138
- var y, O, v;
1139
- return Z(this, function(_) {
1140
- switch (_.label) {
1141
- case 0:
1142
- return _.trys.push([0, 7, , 8]), y = void 0, st() && !t ? [4, l.handleRedirectCallback()] : [3, 3];
1143
- case 1:
1144
- return O = _.sent().appState, [4, l.getUser()];
1145
- case 2:
1146
- return y = _.sent(), o(O, y), [3, 6];
1147
- case 3:
1148
- return [4, l.checkSession()];
1149
- case 4:
1150
- return _.sent(), [4, l.getUser()];
1151
- case 5:
1152
- y = _.sent(), _.label = 6;
1153
- case 6:
1154
- return s({ type: "INITIALISED", user: y }), [3, 8];
1155
- case 7:
1156
- return v = _.sent(), p(fe(v)), [3, 8];
1157
- case 8:
1158
- return [
1159
- 2
1160
- /*return*/
1161
- ];
1162
- }
1163
- });
1164
- });
1165
- })());
1166
- }, [l, o, t, p]);
1167
- var m = R(function(y) {
1168
- return Se(y), l.loginWithRedirect(y);
1169
- }, [l]), w = R(function(y, O) {
1170
- return L(void 0, void 0, void 0, function() {
1171
- var v, _;
1172
- return Z(this, function(I) {
1173
- switch (I.label) {
1174
- case 0:
1175
- s({ type: "LOGIN_POPUP_STARTED" }), I.label = 1;
1176
- case 1:
1177
- return I.trys.push([1, 3, , 4]), [4, l.loginWithPopup(y, O)];
1178
- case 2:
1179
- return I.sent(), [3, 4];
1180
- case 3:
1181
- return v = I.sent(), p(fe(v)), [
1182
- 2
1183
- /*return*/
1184
- ];
1185
- case 4:
1186
- return [4, l.getUser()];
1187
- case 5:
1188
- return _ = I.sent(), s({ type: "LOGIN_POPUP_COMPLETE", user: _ }), [
1189
- 2
1190
- /*return*/
1191
- ];
1192
- }
1193
- });
1194
- });
1195
- }, [l, p]), g = R(function() {
1196
- for (var y = [], O = 0; O < arguments.length; O++)
1197
- y[O] = arguments[O];
1198
- return L(void 0, Le([], y), void 0, function(v) {
1199
- return v === void 0 && (v = {}), Z(this, function(_) {
1200
- switch (_.label) {
1201
- case 0:
1202
- return [4, l.logout(v)];
1203
- case 1:
1204
- return _.sent(), (v.openUrl || v.openUrl === !1) && s({ type: "LOGOUT" }), [
1205
- 2
1206
- /*return*/
1207
- ];
1208
- }
1209
- });
1210
- });
1211
- }, [l]), k = R(
1212
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1213
- function(y) {
1214
- return L(void 0, void 0, void 0, function() {
1215
- var O, v, _, I;
1216
- return Z(this, function(j) {
1217
- switch (j.label) {
1218
- case 0:
1219
- return j.trys.push([0, 2, 3, 5]), [4, l.getTokenSilently(y)];
1220
- case 1:
1221
- return O = j.sent(), [3, 5];
1222
- case 2:
1223
- throw v = j.sent(), $(v);
1224
- case 3:
1225
- return _ = s, I = {
1226
- type: "GET_ACCESS_TOKEN_COMPLETE"
1227
- }, [4, l.getUser()];
1228
- case 4:
1229
- return _.apply(void 0, [(I.user = j.sent(), I)]), [
1230
- 7
1231
- /*endfinally*/
1232
- ];
1233
- case 5:
1234
- return [2, O];
1235
- }
1236
- });
1237
- });
1238
- },
1239
- [l]
1240
- ), S = R(function(y, O) {
1241
- return L(void 0, void 0, void 0, function() {
1242
- var v, _, I, j;
1243
- return Z(this, function(A) {
1244
- switch (A.label) {
1245
- case 0:
1246
- return A.trys.push([0, 2, 3, 5]), [4, l.getTokenWithPopup(y, O)];
1247
- case 1:
1248
- return v = A.sent(), [3, 5];
1249
- case 2:
1250
- throw _ = A.sent(), $(_);
1251
- case 3:
1252
- return I = s, j = {
1253
- type: "GET_ACCESS_TOKEN_COMPLETE"
1254
- }, [4, l.getUser()];
1255
- case 4:
1256
- return I.apply(void 0, [(j.user = A.sent(), j)]), [
1257
- 7
1258
- /*endfinally*/
1259
- ];
1260
- case 5:
1261
- return [2, v];
1262
- }
1263
- });
1264
- });
1265
- }, [l]), b = R(function() {
1266
- return l.getIdTokenClaims();
1267
- }, [l]), f = R(function(y) {
1268
- return L(void 0, void 0, void 0, function() {
1269
- var O, v, _;
1270
- return Z(this, function(I) {
1271
- switch (I.label) {
1272
- case 0:
1273
- return I.trys.push([0, 2, 3, 5]), [4, l.handleRedirectCallback(y)];
1274
- case 1:
1275
- return [2, I.sent()];
1276
- case 2:
1277
- throw O = I.sent(), $(O);
1278
- case 3:
1279
- return v = s, _ = {
1280
- type: "HANDLE_REDIRECT_COMPLETE"
1281
- }, [4, l.getUser()];
1282
- case 4:
1283
- return v.apply(void 0, [(_.user = I.sent(), _)]), [
1284
- 7
1285
- /*endfinally*/
1286
- ];
1287
- case 5:
1288
- return [
1289
- 2
1290
- /*return*/
1291
- ];
1292
- }
1293
- });
1294
- });
1295
- }, [l]), C = Ee(function() {
1296
- return T(T({}, a), { getAccessTokenSilently: k, getAccessTokenWithPopup: S, getIdTokenClaims: b, loginWithRedirect: m, loginWithPopup: w, logout: g, handleRedirectCallback: f });
1297
- }, [
1298
- a,
1299
- k,
1300
- S,
1301
- b,
1302
- m,
1303
- w,
1304
- g,
1305
- f
1306
- ]);
1307
- return Oe.createElement(c.Provider, { value: C }, e);
1308
- }, ht = function(i) {
1309
- return i === void 0 && (i = _e), ze(i);
1310
- };
1311
- const pt = () => {
1312
- const i = ht();
1313
- return {
1314
- authenticationType: "auth0",
1315
- ...i,
1316
- login: async (e, t) => (console.warn("Attempting to log in loginWithRedirect"), await i.loginWithRedirect(), !0),
1317
- logout: i.logout,
1318
- getAccessToken: i.getAccessTokenSilently,
1319
- getIdToken: () => "Please call await getIdTokenClaims() to get the ID token",
1320
- registeringForPasskey: async () => !1,
1321
- loginWithPasskey: async () => (await i.loginWithRedirect(), !0)
1322
- };
1323
- }, yt = ({
1324
- children: i,
1325
- domain: e,
1326
- clientId: t,
1327
- ...n
1328
- }) => /* @__PURE__ */ B(dt, { domain: e, clientId: t, ...n, children: /* @__PURE__ */ B(mt, { children: i }) }), mt = ({ children: i }) => {
1329
- const e = pt();
1330
- return /* @__PURE__ */ B(Re.Provider, { value: e, children: i });
1331
- };
1332
- export {
1333
- yt as Auth0Provider
1334
- };