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