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