@roudanio/awesome-comment 0.10.9 → 0.10.10

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