@auth0/auth0-spa-js 2.18.3 → 2.19.1
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 +1 -1
- package/dist/auth0-spa-js.development.js +427 -370
- package/dist/auth0-spa-js.development.js.map +1 -1
- package/dist/auth0-spa-js.production.esm.js +1 -1
- package/dist/auth0-spa-js.production.esm.js.map +1 -1
- package/dist/auth0-spa-js.production.js +1 -1
- package/dist/auth0-spa-js.production.js.map +1 -1
- package/dist/auth0-spa-js.worker.development.js +132 -81
- package/dist/auth0-spa-js.worker.development.js.map +1 -1
- package/dist/auth0-spa-js.worker.production.js +1 -1
- package/dist/auth0-spa-js.worker.production.js.map +1 -1
- package/dist/lib/auth0-spa-js.cjs.js +449 -393
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/Auth0Client.d.ts +476 -439
- package/dist/typings/Auth0Client.utils.d.ts +90 -90
- package/dist/typings/MyAccountApiClient.d.ts +92 -92
- package/dist/typings/TokenExchange.d.ts +77 -77
- package/dist/typings/api.d.ts +33 -2
- package/dist/typings/cache/cache-localstorage.d.ts +7 -7
- package/dist/typings/cache/cache-manager.d.ts +69 -56
- package/dist/typings/cache/cache-memory.d.ts +4 -4
- package/dist/typings/cache/index.d.ts +4 -4
- package/dist/typings/cache/key-manifest.d.ts +12 -12
- package/dist/typings/cache/shared.d.ts +68 -68
- package/dist/typings/constants.d.ts +58 -58
- package/dist/typings/dpop/dpop.d.ts +17 -17
- package/dist/typings/dpop/storage.d.ts +27 -27
- package/dist/typings/dpop/utils.d.ts +15 -15
- package/dist/typings/errors.d.ts +96 -96
- package/dist/typings/fetcher.d.ts +54 -54
- package/dist/typings/global.d.ts +826 -819
- package/dist/typings/http.d.ts +11 -5
- package/dist/typings/index.d.ts +24 -24
- package/dist/typings/jwt.d.ts +21 -21
- package/dist/typings/lock.d.ts +32 -32
- package/dist/typings/mfa/MfaApiClient.d.ts +225 -225
- package/dist/typings/mfa/MfaContextManager.d.ts +79 -79
- package/dist/typings/mfa/constants.d.ts +23 -23
- package/dist/typings/mfa/errors.d.ts +117 -117
- package/dist/typings/mfa/index.d.ts +4 -4
- package/dist/typings/mfa/types.d.ts +181 -181
- package/dist/typings/mfa/utils.d.ts +23 -23
- package/dist/typings/promise-utils.d.ts +2 -2
- package/dist/typings/scope.d.ts +35 -35
- package/dist/typings/storage.d.ts +26 -26
- package/dist/typings/transaction-manager.d.ts +33 -33
- package/dist/typings/utils.d.ts +36 -36
- package/dist/typings/version.d.ts +2 -2
- package/dist/typings/worker/token.worker.d.ts +1 -1
- package/dist/typings/worker/worker.types.d.ts +27 -20
- package/dist/typings/worker/worker.utils.d.ts +13 -7
- package/package.json +2 -2
- package/src/Auth0Client.ts +73 -2
- package/src/api.ts +116 -2
- package/src/cache/cache-manager.ts +85 -9
- package/src/global.ts +8 -0
- package/src/http.ts +28 -21
- package/src/version.ts +1 -1
- package/src/worker/token.worker.ts +120 -5
- package/src/worker/worker.types.ts +17 -6
- package/src/worker/worker.utils.ts +18 -7
|
@@ -4,163 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
this.v = e, this.k = d;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function _assertClassBrand(e, t, n) {
|
|
12
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
13
|
-
throw new TypeError("Private element is not present on this object");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function _awaitAsyncGenerator(e) {
|
|
17
|
-
return new _OverloadYield(e, 0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
21
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function _classPrivateFieldGet2(s, a) {
|
|
25
|
-
return s.get(_assertClassBrand(s, a));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _classPrivateFieldInitSpec(e, t, a) {
|
|
29
|
-
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
33
|
-
return s.set(_assertClassBrand(s, a), r), r;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
37
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _defineProperty(e, r, t) {
|
|
41
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
|
-
value: t,
|
|
43
|
-
enumerable: !0,
|
|
44
|
-
configurable: !0,
|
|
45
|
-
writable: !0
|
|
46
|
-
}) : e[r] = t, e;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function ownKeys(e, r) {
|
|
50
|
-
var t = Object.keys(e);
|
|
51
|
-
if (Object.getOwnPropertySymbols) {
|
|
52
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
53
|
-
r && (o = o.filter(function(r) {
|
|
54
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
55
|
-
})), t.push.apply(t, o);
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _objectSpread2(e) {
|
|
61
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
62
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
63
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
64
|
-
_defineProperty(e, r, t[r]);
|
|
65
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
66
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return e;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _objectWithoutProperties(e, t) {
|
|
73
|
-
if (null == e) return {};
|
|
74
|
-
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
75
|
-
if (Object.getOwnPropertySymbols) {
|
|
76
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
77
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
78
|
-
}
|
|
79
|
-
return i;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
83
|
-
if (null == r) return {};
|
|
7
|
+
function __rest(s, e) {
|
|
84
8
|
var t = {};
|
|
85
|
-
for (var
|
|
86
|
-
|
|
87
|
-
t[
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
10
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
11
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
88
12
|
}
|
|
89
13
|
return t;
|
|
90
14
|
}
|
|
91
15
|
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (void 0 !== e) {
|
|
96
|
-
var i = e.call(t, r || "default");
|
|
97
|
-
if ("object" != typeof i) return i;
|
|
98
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
99
|
-
}
|
|
100
|
-
return ("string" === r ? String : Number)(t);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function _toPropertyKey(t) {
|
|
104
|
-
var i = _toPrimitive(t, "string");
|
|
105
|
-
return "symbol" == typeof i ? i : i + "";
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function _wrapAsyncGenerator(e) {
|
|
109
|
-
return function() {
|
|
110
|
-
return new AsyncGenerator(e.apply(this, arguments));
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function AsyncGenerator(e) {
|
|
115
|
-
var t, n;
|
|
116
|
-
function resume(t, n) {
|
|
117
|
-
try {
|
|
118
|
-
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
119
|
-
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
120
|
-
if (u) {
|
|
121
|
-
var i = "return" === t && o.k ? t : "next";
|
|
122
|
-
if (!o.k || n.done) return resume(i, n);
|
|
123
|
-
n = e[i](n).value;
|
|
124
|
-
}
|
|
125
|
-
settle(!!r.done, n);
|
|
126
|
-
}, function(e) {
|
|
127
|
-
resume("throw", e);
|
|
128
|
-
});
|
|
129
|
-
} catch (e) {
|
|
130
|
-
settle(2, e);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function settle(e, r) {
|
|
134
|
-
2 === e ? t.reject(r) : t.resolve({
|
|
135
|
-
value: r,
|
|
136
|
-
done: e
|
|
137
|
-
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
138
|
-
}
|
|
139
|
-
this._invoke = function(e, r) {
|
|
140
|
-
return new Promise(function(o, u) {
|
|
141
|
-
var i = {
|
|
142
|
-
key: e,
|
|
143
|
-
arg: r,
|
|
144
|
-
resolve: o,
|
|
145
|
-
reject: u,
|
|
146
|
-
next: null
|
|
147
|
-
};
|
|
148
|
-
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
149
|
-
});
|
|
150
|
-
}, "function" != typeof e.return && (this.return = void 0);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
154
|
-
return this;
|
|
155
|
-
}, AsyncGenerator.prototype.next = function(e) {
|
|
156
|
-
return this._invoke("next", e);
|
|
157
|
-
}, AsyncGenerator.prototype.throw = function(e) {
|
|
158
|
-
return this._invoke("throw", e);
|
|
159
|
-
}, AsyncGenerator.prototype.return = function(e) {
|
|
160
|
-
return this._invoke("return", e);
|
|
16
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
17
|
+
var e = new Error(message);
|
|
18
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
161
19
|
};
|
|
162
20
|
|
|
163
|
-
var version = "2.
|
|
21
|
+
var version = "2.19.1";
|
|
164
22
|
|
|
165
23
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
166
24
|
|
|
@@ -301,8 +159,6 @@ function valueOrEmptyString(value) {
|
|
|
301
159
|
return value && !exclude.includes(value) ? value : "";
|
|
302
160
|
}
|
|
303
161
|
|
|
304
|
-
const _excluded$5 = [ "clientId" ];
|
|
305
|
-
|
|
306
162
|
const parseAuthenticationResult = queryString => {
|
|
307
163
|
if (queryString.indexOf("#") > -1) {
|
|
308
164
|
queryString = queryString.substring(0, queryString.indexOf("#"));
|
|
@@ -414,7 +270,7 @@ const createRandomString = () => {
|
|
|
414
270
|
|
|
415
271
|
const encode$2 = value => btoa(value);
|
|
416
272
|
|
|
417
|
-
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) =>
|
|
273
|
+
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) => Object.assign(Object.assign({}, acc), {
|
|
418
274
|
[key]: params[key]
|
|
419
275
|
}), {});
|
|
420
276
|
|
|
@@ -443,9 +299,9 @@ const stripAuth0Client = function stripAuth0Client(auth0Client) {
|
|
|
443
299
|
}, {});
|
|
444
300
|
};
|
|
445
301
|
|
|
446
|
-
const createQueryParams =
|
|
447
|
-
|
|
448
|
-
return new URLSearchParams(stripUndefined(
|
|
302
|
+
const createQueryParams = _a => {
|
|
303
|
+
var {clientId: client_id} = _a, params = __rest(_a, [ "clientId" ]);
|
|
304
|
+
return new URLSearchParams(stripUndefined(Object.assign({
|
|
449
305
|
client_id: client_id
|
|
450
306
|
}, params))).toString();
|
|
451
307
|
};
|
|
@@ -505,8 +361,8 @@ const parseNumber = value => {
|
|
|
505
361
|
return parseInt(value, 10) || undefined;
|
|
506
362
|
};
|
|
507
363
|
|
|
508
|
-
const fromEntries = iterable => [ ...iterable ].reduce((obj,
|
|
509
|
-
let [key, val] =
|
|
364
|
+
const fromEntries = iterable => [ ...iterable ].reduce((obj, _ref) => {
|
|
365
|
+
let [key, val] = _ref;
|
|
510
366
|
obj[key] = val;
|
|
511
367
|
return obj;
|
|
512
368
|
}, {});
|
|
@@ -1067,9 +923,7 @@ class WebLocksApiManager {
|
|
|
1067
923
|
|
|
1068
924
|
class LegacyLockManager {
|
|
1069
925
|
constructor() {
|
|
1070
|
-
|
|
1071
|
-
_defineProperty(this, "activeLocks", new Set);
|
|
1072
|
-
_defineProperty(this, "pagehideHandler", void 0);
|
|
926
|
+
this.activeLocks = new Set;
|
|
1073
927
|
this.lock = new _default;
|
|
1074
928
|
this.pagehideHandler = () => {
|
|
1075
929
|
this.activeLocks.forEach(key => this.lock.releaseLock(key));
|
|
@@ -1102,8 +956,8 @@ class LegacyLockManager {
|
|
|
1102
956
|
}
|
|
1103
957
|
|
|
1104
958
|
function isWebLocksSupported() {
|
|
1105
|
-
var
|
|
1106
|
-
return typeof navigator !== "undefined" && typeof ((
|
|
959
|
+
var _a;
|
|
960
|
+
return typeof navigator !== "undefined" && typeof ((_a = navigator.locks) === null || _a === void 0 ? void 0 : _a.request) === "function";
|
|
1107
961
|
}
|
|
1108
962
|
|
|
1109
963
|
function createLockManager() {
|
|
@@ -1473,24 +1327,13 @@ const sendMessage = (message, to) => new Promise(function(resolve, reject) {
|
|
|
1473
1327
|
to.postMessage(message, [ messageChannel.port2 ]);
|
|
1474
1328
|
});
|
|
1475
1329
|
|
|
1476
|
-
const _excluded$4 = [ "error", "error_description" ];
|
|
1477
|
-
|
|
1478
1330
|
const createAbortController = () => new AbortController;
|
|
1479
1331
|
|
|
1480
|
-
const
|
|
1481
|
-
const response = await fetch(fetchUrl, fetchOptions);
|
|
1482
|
-
return {
|
|
1483
|
-
ok: response.ok,
|
|
1484
|
-
json: await response.json(),
|
|
1485
|
-
headers: fromEntries(response.headers)
|
|
1486
|
-
};
|
|
1487
|
-
};
|
|
1488
|
-
|
|
1489
|
-
const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
1332
|
+
const fetchWithTimeout = (fetchUrl, fetchOptions, timeout) => {
|
|
1490
1333
|
const controller = createAbortController();
|
|
1491
1334
|
fetchOptions.signal = controller.signal;
|
|
1492
1335
|
let timeoutId;
|
|
1493
|
-
return Promise.race([
|
|
1336
|
+
return Promise.race([ fetch(fetchUrl, fetchOptions), new Promise((_, reject) => {
|
|
1494
1337
|
timeoutId = setTimeout(() => {
|
|
1495
1338
|
controller.abort();
|
|
1496
1339
|
reject(new Error("Timeout when executing 'fetch'"));
|
|
@@ -1500,7 +1343,17 @@ const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
|
1500
1343
|
});
|
|
1501
1344
|
};
|
|
1502
1345
|
|
|
1346
|
+
const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
1347
|
+
const response = await fetchWithTimeout(fetchUrl, fetchOptions, timeout);
|
|
1348
|
+
return {
|
|
1349
|
+
ok: response.ok,
|
|
1350
|
+
json: await response.json(),
|
|
1351
|
+
headers: fromEntries(response.headers)
|
|
1352
|
+
};
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1503
1355
|
const fetchWithWorker = async (fetchUrl, audience, scope, fetchOptions, timeout, worker, useFormData, useMrrt) => sendMessage({
|
|
1356
|
+
type: "refresh",
|
|
1504
1357
|
auth: {
|
|
1505
1358
|
audience: audience,
|
|
1506
1359
|
scope: scope
|
|
@@ -1529,7 +1382,7 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
|
|
|
1529
1382
|
method: options.method || "GET",
|
|
1530
1383
|
nonce: await dpop.getNonce()
|
|
1531
1384
|
});
|
|
1532
|
-
options.headers =
|
|
1385
|
+
options.headers = Object.assign(Object.assign({}, options.headers), {
|
|
1533
1386
|
dpop: dpopProof
|
|
1534
1387
|
});
|
|
1535
1388
|
}
|
|
@@ -1547,7 +1400,7 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
|
|
|
1547
1400
|
if (fetchError) {
|
|
1548
1401
|
throw fetchError;
|
|
1549
1402
|
}
|
|
1550
|
-
const
|
|
1403
|
+
const _a = response.json, {error: error, error_description: error_description} = _a, data = __rest(_a, [ "error", "error_description" ]), {headers: headers, ok: ok} = response;
|
|
1551
1404
|
let newDpopNonce;
|
|
1552
1405
|
if (dpop) {
|
|
1553
1406
|
newDpopNonce = headers[DPOP_NONCE_HEADER];
|
|
@@ -1574,13 +1427,11 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
|
|
|
1574
1427
|
return data;
|
|
1575
1428
|
}
|
|
1576
1429
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
async function oauthToken(_ref, worker) {
|
|
1580
|
-
let {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData, useMrrt: useMrrt, dpop: dpop} = _ref, options = _objectWithoutProperties(_ref, _excluded$3);
|
|
1430
|
+
async function oauthToken(_a, worker) {
|
|
1431
|
+
var {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData, useMrrt: useMrrt, dpop: dpop} = _a, options = __rest(_a, [ "baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData", "useMrrt", "dpop" ]);
|
|
1581
1432
|
const isTokenExchange = options.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
1582
1433
|
const refreshWithMrrt = options.grant_type === "refresh_token" && useMrrt;
|
|
1583
|
-
const allParams =
|
|
1434
|
+
const allParams = Object.assign(Object.assign(Object.assign(Object.assign({}, options), isTokenExchange && audience && {
|
|
1584
1435
|
audience: audience
|
|
1585
1436
|
}), isTokenExchange && scope && {
|
|
1586
1437
|
scope: scope
|
|
@@ -1600,6 +1451,64 @@ async function oauthToken(_ref, worker) {
|
|
|
1600
1451
|
}, worker, useFormData, useMrrt, isDpopSupported ? dpop : undefined);
|
|
1601
1452
|
}
|
|
1602
1453
|
|
|
1454
|
+
async function revokeToken(_ref, worker) {
|
|
1455
|
+
let {baseUrl: baseUrl, timeout: timeout, auth0Client: auth0Client, useFormData: useFormData, refreshTokens: refreshTokens, audience: audience, client_id: client_id, onRefreshTokenRevoked: onRefreshTokenRevoked} = _ref;
|
|
1456
|
+
const resolvedTimeout = timeout || DEFAULT_FETCH_TIMEOUT_MS;
|
|
1457
|
+
const token_type_hint = "refresh_token";
|
|
1458
|
+
const fetchUrl = "".concat(baseUrl, "/oauth/revoke");
|
|
1459
|
+
const headers = {
|
|
1460
|
+
"Content-Type": useFormData ? "application/x-www-form-urlencoded" : "application/json",
|
|
1461
|
+
"Auth0-Client": btoa(JSON.stringify(stripAuth0Client(auth0Client || DEFAULT_AUTH0_CLIENT)))
|
|
1462
|
+
};
|
|
1463
|
+
if (worker) {
|
|
1464
|
+
const baseParams = {
|
|
1465
|
+
client_id: client_id,
|
|
1466
|
+
token_type_hint: token_type_hint
|
|
1467
|
+
};
|
|
1468
|
+
const body = useFormData ? createQueryParams(baseParams) : JSON.stringify(baseParams);
|
|
1469
|
+
try {
|
|
1470
|
+
return await sendMessage({
|
|
1471
|
+
type: "revoke",
|
|
1472
|
+
timeout: resolvedTimeout,
|
|
1473
|
+
fetchUrl: fetchUrl,
|
|
1474
|
+
fetchOptions: {
|
|
1475
|
+
method: "POST",
|
|
1476
|
+
body: body,
|
|
1477
|
+
headers: headers
|
|
1478
|
+
},
|
|
1479
|
+
useFormData: useFormData,
|
|
1480
|
+
auth: {
|
|
1481
|
+
audience: audience !== null && audience !== void 0 ? audience : DEFAULT_AUDIENCE
|
|
1482
|
+
}
|
|
1483
|
+
}, worker);
|
|
1484
|
+
} catch (e) {
|
|
1485
|
+
throw new GenericError("revoke_error", e.message);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
for (const refreshToken of refreshTokens) {
|
|
1489
|
+
const params = {
|
|
1490
|
+
client_id: client_id,
|
|
1491
|
+
token_type_hint: token_type_hint,
|
|
1492
|
+
token: refreshToken
|
|
1493
|
+
};
|
|
1494
|
+
const body = useFormData ? createQueryParams(params) : JSON.stringify(params);
|
|
1495
|
+
const response = await fetchWithTimeout(fetchUrl, {
|
|
1496
|
+
method: "POST",
|
|
1497
|
+
body: body,
|
|
1498
|
+
headers: headers
|
|
1499
|
+
}, resolvedTimeout);
|
|
1500
|
+
if (!response.ok) {
|
|
1501
|
+
let error;
|
|
1502
|
+
let errorDescription;
|
|
1503
|
+
try {
|
|
1504
|
+
({error: error, error_description: errorDescription} = JSON.parse(await response.text()));
|
|
1505
|
+
} catch (_a) {}
|
|
1506
|
+
throw new GenericError(error || "revoke_error", errorDescription || "HTTP error ".concat(response.status));
|
|
1507
|
+
}
|
|
1508
|
+
await (onRefreshTokenRevoked === null || onRefreshTokenRevoked === void 0 ? void 0 : onRefreshTokenRevoked(refreshToken));
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1603
1512
|
const dedupe = arr => Array.from(new Set(arr));
|
|
1604
1513
|
|
|
1605
1514
|
const getUniqueScopes = function getUniqueScopes() {
|
|
@@ -1649,9 +1558,6 @@ class CacheKey {
|
|
|
1649
1558
|
let suffix = arguments.length > 2 ? arguments[2] : undefined;
|
|
1650
1559
|
this.prefix = prefix;
|
|
1651
1560
|
this.suffix = suffix;
|
|
1652
|
-
_defineProperty(this, "clientId", void 0);
|
|
1653
|
-
_defineProperty(this, "scope", void 0);
|
|
1654
|
-
_defineProperty(this, "audience", void 0);
|
|
1655
1561
|
this.clientId = data.clientId;
|
|
1656
1562
|
this.scope = data.scope;
|
|
1657
1563
|
this.audience = data.audience;
|
|
@@ -1701,7 +1607,7 @@ class LocalStorageCache {
|
|
|
1701
1607
|
|
|
1702
1608
|
class InMemoryCache {
|
|
1703
1609
|
constructor() {
|
|
1704
|
-
|
|
1610
|
+
this.enclosedCache = function() {
|
|
1705
1611
|
let cache = {};
|
|
1706
1612
|
return {
|
|
1707
1613
|
set(key, entry) {
|
|
@@ -1721,7 +1627,7 @@ class InMemoryCache {
|
|
|
1721
1627
|
return Object.keys(cache);
|
|
1722
1628
|
}
|
|
1723
1629
|
};
|
|
1724
|
-
}()
|
|
1630
|
+
}();
|
|
1725
1631
|
}
|
|
1726
1632
|
}
|
|
1727
1633
|
|
|
@@ -1731,17 +1637,16 @@ class CacheManager {
|
|
|
1731
1637
|
constructor(cache, keyManifest, nowProvider) {
|
|
1732
1638
|
this.cache = cache;
|
|
1733
1639
|
this.keyManifest = keyManifest;
|
|
1734
|
-
_defineProperty(this, "nowProvider", void 0);
|
|
1735
1640
|
this.nowProvider = nowProvider || DEFAULT_NOW_PROVIDER;
|
|
1736
1641
|
}
|
|
1737
1642
|
async setIdToken(clientId, idToken, decodedToken) {
|
|
1738
|
-
var
|
|
1643
|
+
var _a;
|
|
1739
1644
|
const cacheKey = this.getIdTokenCacheKey(clientId);
|
|
1740
1645
|
await this.cache.set(cacheKey, {
|
|
1741
1646
|
id_token: idToken,
|
|
1742
1647
|
decodedToken: decodedToken
|
|
1743
1648
|
});
|
|
1744
|
-
await ((
|
|
1649
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.add(cacheKey));
|
|
1745
1650
|
}
|
|
1746
1651
|
async getIdToken(cacheKey) {
|
|
1747
1652
|
const entry = await this.cache.get(this.getIdTokenCacheKey(cacheKey.clientId));
|
|
@@ -1770,13 +1675,16 @@ class CacheManager {
|
|
|
1770
1675
|
let expiryAdjustmentSeconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_EXPIRY_ADJUSTMENT_SECONDS;
|
|
1771
1676
|
let useMrrt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1772
1677
|
let cacheMode = arguments.length > 3 ? arguments[3] : undefined;
|
|
1678
|
+
var _a;
|
|
1773
1679
|
let wrappedEntry = await this.cache.get(cacheKey.toKey());
|
|
1680
|
+
let resolvedCacheKey = cacheKey;
|
|
1774
1681
|
if (!wrappedEntry) {
|
|
1775
1682
|
const keys = await this.getCacheKeys();
|
|
1776
1683
|
if (!keys) return;
|
|
1777
1684
|
const matchedKey = this.matchExistingCacheKey(cacheKey, keys);
|
|
1778
1685
|
if (matchedKey) {
|
|
1779
1686
|
wrappedEntry = await this.cache.get(matchedKey);
|
|
1687
|
+
resolvedCacheKey = CacheKey.fromKey(matchedKey);
|
|
1780
1688
|
}
|
|
1781
1689
|
if (!wrappedEntry && useMrrt && cacheMode !== "cache-only") {
|
|
1782
1690
|
return this.getEntryWithRefreshToken(cacheKey, keys);
|
|
@@ -1788,31 +1696,34 @@ class CacheManager {
|
|
|
1788
1696
|
const now = await this.nowProvider();
|
|
1789
1697
|
const nowSeconds = Math.floor(now / 1e3);
|
|
1790
1698
|
if (wrappedEntry.expiresAt - expiryAdjustmentSeconds < nowSeconds) {
|
|
1791
|
-
var _this$keyManifest2;
|
|
1792
1699
|
if (wrappedEntry.body.refresh_token) {
|
|
1793
|
-
return this.modifiedCachedEntry(wrappedEntry,
|
|
1700
|
+
return this.modifiedCachedEntry(wrappedEntry, resolvedCacheKey);
|
|
1794
1701
|
}
|
|
1795
|
-
await this.cache.remove(
|
|
1796
|
-
await ((
|
|
1702
|
+
await this.cache.remove(resolvedCacheKey.toKey());
|
|
1703
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.remove(resolvedCacheKey.toKey()));
|
|
1797
1704
|
return;
|
|
1798
1705
|
}
|
|
1799
1706
|
return wrappedEntry.body;
|
|
1800
1707
|
}
|
|
1801
1708
|
async modifiedCachedEntry(wrappedEntry, cacheKey) {
|
|
1802
|
-
|
|
1709
|
+
const strippedBody = {
|
|
1803
1710
|
refresh_token: wrappedEntry.body.refresh_token,
|
|
1804
1711
|
audience: wrappedEntry.body.audience,
|
|
1805
1712
|
scope: wrappedEntry.body.scope
|
|
1806
1713
|
};
|
|
1807
|
-
|
|
1714
|
+
const strippedEntry = {
|
|
1715
|
+
body: strippedBody,
|
|
1716
|
+
expiresAt: wrappedEntry.expiresAt
|
|
1717
|
+
};
|
|
1718
|
+
await this.cache.set(cacheKey.toKey(), strippedEntry);
|
|
1808
1719
|
return {
|
|
1809
|
-
refresh_token:
|
|
1810
|
-
audience:
|
|
1811
|
-
scope:
|
|
1720
|
+
refresh_token: strippedBody.refresh_token,
|
|
1721
|
+
audience: strippedBody.audience,
|
|
1722
|
+
scope: strippedBody.scope
|
|
1812
1723
|
};
|
|
1813
1724
|
}
|
|
1814
1725
|
async set(entry) {
|
|
1815
|
-
var
|
|
1726
|
+
var _a;
|
|
1816
1727
|
const cacheKey = new CacheKey({
|
|
1817
1728
|
clientId: entry.client_id,
|
|
1818
1729
|
scope: entry.scope,
|
|
@@ -1820,7 +1731,7 @@ class CacheManager {
|
|
|
1820
1731
|
});
|
|
1821
1732
|
const wrappedEntry = await this.wrapCacheEntry(entry);
|
|
1822
1733
|
await this.cache.set(cacheKey.toKey(), wrappedEntry);
|
|
1823
|
-
await ((
|
|
1734
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.add(cacheKey.toKey()));
|
|
1824
1735
|
}
|
|
1825
1736
|
async remove(client_id, audience, scope) {
|
|
1826
1737
|
const cacheKey = new CacheKey({
|
|
@@ -1830,15 +1741,27 @@ class CacheManager {
|
|
|
1830
1741
|
});
|
|
1831
1742
|
await this.cache.remove(cacheKey.toKey());
|
|
1832
1743
|
}
|
|
1744
|
+
async stripRefreshToken(refreshToken) {
|
|
1745
|
+
var _a;
|
|
1746
|
+
const keys = await this.getCacheKeys();
|
|
1747
|
+
if (!keys) return;
|
|
1748
|
+
for (const key of keys) {
|
|
1749
|
+
const entry = await this.cache.get(key);
|
|
1750
|
+
if (((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) === refreshToken) {
|
|
1751
|
+
delete entry.body.refresh_token;
|
|
1752
|
+
await this.cache.set(key, entry);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1833
1756
|
async clear(clientId) {
|
|
1834
|
-
var
|
|
1757
|
+
var _a;
|
|
1835
1758
|
const keys = await this.getCacheKeys();
|
|
1836
1759
|
if (!keys) return;
|
|
1837
1760
|
await keys.filter(key => clientId ? key.includes(clientId) : true).reduce(async (memo, key) => {
|
|
1838
1761
|
await memo;
|
|
1839
1762
|
await this.cache.remove(key);
|
|
1840
1763
|
}, Promise.resolve());
|
|
1841
|
-
await ((
|
|
1764
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.clear());
|
|
1842
1765
|
}
|
|
1843
1766
|
async wrapCacheEntry(entry) {
|
|
1844
1767
|
const now = await this.nowProvider();
|
|
@@ -1849,9 +1772,9 @@ class CacheManager {
|
|
|
1849
1772
|
};
|
|
1850
1773
|
}
|
|
1851
1774
|
async getCacheKeys() {
|
|
1775
|
+
var _a;
|
|
1852
1776
|
if (this.keyManifest) {
|
|
1853
|
-
|
|
1854
|
-
return (_await$this$keyManife = await this.keyManifest.get()) === null || _await$this$keyManife === void 0 ? void 0 : _await$this$keyManife.keys;
|
|
1777
|
+
return (_a = await this.keyManifest.get()) === null || _a === void 0 ? void 0 : _a.keys;
|
|
1855
1778
|
} else if (this.cache.allKeys) {
|
|
1856
1779
|
return this.cache.allKeys();
|
|
1857
1780
|
}
|
|
@@ -1863,34 +1786,54 @@ class CacheManager {
|
|
|
1863
1786
|
}
|
|
1864
1787
|
matchExistingCacheKey(keyToMatch, allKeys) {
|
|
1865
1788
|
return allKeys.filter(key => {
|
|
1866
|
-
var
|
|
1789
|
+
var _a;
|
|
1867
1790
|
const cacheKey = CacheKey.fromKey(key);
|
|
1868
1791
|
const scopeSet = new Set(cacheKey.scope && cacheKey.scope.split(" "));
|
|
1869
|
-
const scopesToMatch = ((
|
|
1792
|
+
const scopesToMatch = ((_a = keyToMatch.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
1870
1793
|
const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((acc, current) => acc && scopeSet.has(current), true);
|
|
1871
1794
|
return cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId && cacheKey.audience === keyToMatch.audience && hasAllScopes;
|
|
1872
1795
|
})[0];
|
|
1873
1796
|
}
|
|
1874
1797
|
async getEntryWithRefreshToken(keyToMatch, allKeys) {
|
|
1798
|
+
var _a;
|
|
1875
1799
|
for (const key of allKeys) {
|
|
1876
1800
|
const cacheKey = CacheKey.fromKey(key);
|
|
1877
1801
|
if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId) {
|
|
1878
|
-
var _cachedEntry$body;
|
|
1879
1802
|
const cachedEntry = await this.cache.get(key);
|
|
1880
|
-
if (cachedEntry
|
|
1881
|
-
return
|
|
1803
|
+
if ((_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
|
|
1804
|
+
return {
|
|
1805
|
+
refresh_token: cachedEntry.body.refresh_token,
|
|
1806
|
+
audience: cachedEntry.body.audience,
|
|
1807
|
+
scope: cachedEntry.body.scope
|
|
1808
|
+
};
|
|
1882
1809
|
}
|
|
1883
1810
|
}
|
|
1884
1811
|
}
|
|
1885
1812
|
return undefined;
|
|
1886
1813
|
}
|
|
1814
|
+
async getRefreshTokensByAudience(audience, clientId) {
|
|
1815
|
+
var _a;
|
|
1816
|
+
const keys = await this.getCacheKeys();
|
|
1817
|
+
if (!keys) return [];
|
|
1818
|
+
const tokens = new Set;
|
|
1819
|
+
for (const key of keys) {
|
|
1820
|
+
const cacheKey = CacheKey.fromKey(key);
|
|
1821
|
+
if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === clientId && cacheKey.audience === audience) {
|
|
1822
|
+
const entry = await this.cache.get(key);
|
|
1823
|
+
if ((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
|
|
1824
|
+
tokens.add(entry.body.refresh_token);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
return Array.from(tokens);
|
|
1829
|
+
}
|
|
1887
1830
|
async updateEntry(oldRefreshToken, newRefreshToken) {
|
|
1831
|
+
var _a;
|
|
1888
1832
|
const allKeys = await this.getCacheKeys();
|
|
1889
1833
|
if (!allKeys) return;
|
|
1890
1834
|
for (const key of allKeys) {
|
|
1891
|
-
var _entry$body;
|
|
1892
1835
|
const entry = await this.cache.get(key);
|
|
1893
|
-
if ((entry === null || entry === void 0
|
|
1836
|
+
if (((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) === oldRefreshToken) {
|
|
1894
1837
|
entry.body.refresh_token = newRefreshToken;
|
|
1895
1838
|
await this.cache.set(key, entry);
|
|
1896
1839
|
}
|
|
@@ -1905,7 +1848,6 @@ class TransactionManager {
|
|
|
1905
1848
|
this.storage = storage;
|
|
1906
1849
|
this.clientId = clientId;
|
|
1907
1850
|
this.cookieDomain = cookieDomain;
|
|
1908
|
-
_defineProperty(this, "storageKey", void 0);
|
|
1909
1851
|
this.storageKey = "".concat(TRANSACTION_STORAGE_KEY_PREFIX, ".").concat(this.clientId);
|
|
1910
1852
|
}
|
|
1911
1853
|
create(transaction) {
|
|
@@ -2146,17 +2088,17 @@ const CookieStorage = {
|
|
|
2146
2088
|
sameSite: "none"
|
|
2147
2089
|
};
|
|
2148
2090
|
}
|
|
2149
|
-
if (options
|
|
2091
|
+
if (options === null || options === void 0 ? void 0 : options.daysUntilExpire) {
|
|
2150
2092
|
cookieAttributes.expires = options.daysUntilExpire;
|
|
2151
2093
|
}
|
|
2152
|
-
if (options
|
|
2094
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2153
2095
|
cookieAttributes.domain = options.cookieDomain;
|
|
2154
2096
|
}
|
|
2155
2097
|
set_1(key, JSON.stringify(value), cookieAttributes);
|
|
2156
2098
|
},
|
|
2157
2099
|
remove(key, options) {
|
|
2158
2100
|
let cookieAttributes = {};
|
|
2159
|
-
if (options
|
|
2101
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2160
2102
|
cookieAttributes.domain = options.cookieDomain;
|
|
2161
2103
|
}
|
|
2162
2104
|
remove_1(key, cookieAttributes);
|
|
@@ -2180,10 +2122,10 @@ const CookieStorageWithLegacySameSite = {
|
|
|
2180
2122
|
secure: true
|
|
2181
2123
|
};
|
|
2182
2124
|
}
|
|
2183
|
-
if (options
|
|
2125
|
+
if (options === null || options === void 0 ? void 0 : options.daysUntilExpire) {
|
|
2184
2126
|
cookieAttributes.expires = options.daysUntilExpire;
|
|
2185
2127
|
}
|
|
2186
|
-
if (options
|
|
2128
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2187
2129
|
cookieAttributes.domain = options.cookieDomain;
|
|
2188
2130
|
}
|
|
2189
2131
|
set_1("".concat(LEGACY_PREFIX).concat(key), JSON.stringify(value), cookieAttributes);
|
|
@@ -2191,7 +2133,7 @@ const CookieStorageWithLegacySameSite = {
|
|
|
2191
2133
|
},
|
|
2192
2134
|
remove(key, options) {
|
|
2193
2135
|
let cookieAttributes = {};
|
|
2194
|
-
if (options
|
|
2136
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2195
2137
|
cookieAttributes.domain = options.cookieDomain;
|
|
2196
2138
|
}
|
|
2197
2139
|
remove_1(key, cookieAttributes);
|
|
@@ -2219,36 +2161,14 @@ const SessionStorage = {
|
|
|
2219
2161
|
}
|
|
2220
2162
|
};
|
|
2221
2163
|
|
|
2222
|
-
|
|
2164
|
+
exports.ResponseType = void 0;
|
|
2165
|
+
|
|
2166
|
+
(function(ResponseType) {
|
|
2223
2167
|
ResponseType["Code"] = "code";
|
|
2224
2168
|
ResponseType["ConnectCode"] = "connect_code";
|
|
2225
|
-
|
|
2226
|
-
}({});
|
|
2169
|
+
})(exports.ResponseType || (exports.ResponseType = {}));
|
|
2227
2170
|
|
|
2228
|
-
class User {
|
|
2229
|
-
constructor() {
|
|
2230
|
-
_defineProperty(this, "name", void 0);
|
|
2231
|
-
_defineProperty(this, "given_name", void 0);
|
|
2232
|
-
_defineProperty(this, "family_name", void 0);
|
|
2233
|
-
_defineProperty(this, "middle_name", void 0);
|
|
2234
|
-
_defineProperty(this, "nickname", void 0);
|
|
2235
|
-
_defineProperty(this, "preferred_username", void 0);
|
|
2236
|
-
_defineProperty(this, "profile", void 0);
|
|
2237
|
-
_defineProperty(this, "picture", void 0);
|
|
2238
|
-
_defineProperty(this, "website", void 0);
|
|
2239
|
-
_defineProperty(this, "email", void 0);
|
|
2240
|
-
_defineProperty(this, "email_verified", void 0);
|
|
2241
|
-
_defineProperty(this, "gender", void 0);
|
|
2242
|
-
_defineProperty(this, "birthdate", void 0);
|
|
2243
|
-
_defineProperty(this, "zoneinfo", void 0);
|
|
2244
|
-
_defineProperty(this, "locale", void 0);
|
|
2245
|
-
_defineProperty(this, "phone_number", void 0);
|
|
2246
|
-
_defineProperty(this, "phone_number_verified", void 0);
|
|
2247
|
-
_defineProperty(this, "address", void 0);
|
|
2248
|
-
_defineProperty(this, "updated_at", void 0);
|
|
2249
|
-
_defineProperty(this, "sub", void 0);
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2171
|
+
class User {}
|
|
2252
2172
|
|
|
2253
2173
|
function decodeBase64$1(base64, enableUnicode) {
|
|
2254
2174
|
var binaryString = atob(base64);
|
|
@@ -2282,7 +2202,7 @@ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
|
|
|
2282
2202
|
};
|
|
2283
2203
|
}
|
|
2284
2204
|
|
|
2285
|
-
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBmdW5jdGlvbiBfZGVmaW5lUHJvcGVydHkoZSwgciwgdCkgewogICAgICAgIHJldHVybiAociA9IF90b1Byb3BlcnR5S2V5KHIpKSBpbiBlID8gT2JqZWN0LmRlZmluZVByb3BlcnR5KGUsIHIsIHsKICAgICAgICAgICAgdmFsdWU6IHQsCiAgICAgICAgICAgIGVudW1lcmFibGU6ICEwLAogICAgICAgICAgICBjb25maWd1cmFibGU6ICEwLAogICAgICAgICAgICB3cml0YWJsZTogITAKICAgICAgICB9KSA6IGVbcl0gPSB0LCBlOwogICAgfQogICAgZnVuY3Rpb24gb3duS2V5cyhlLCByKSB7CiAgICAgICAgdmFyIHQgPSBPYmplY3Qua2V5cyhlKTsKICAgICAgICBpZiAoT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scykgewogICAgICAgICAgICB2YXIgbyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7CiAgICAgICAgICAgIHIgJiYgKG8gPSBvLmZpbHRlcihmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihlLCByKS5lbnVtZXJhYmxlOwogICAgICAgICAgICB9KSksIHQucHVzaC5hcHBseSh0LCBvKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHQ7CiAgICB9CiAgICBmdW5jdGlvbiBfb2JqZWN0U3ByZWFkMihlKSB7CiAgICAgICAgZm9yICh2YXIgciA9IDE7IHIgPCBhcmd1bWVudHMubGVuZ3RoOyByKyspIHsKICAgICAgICAgICAgdmFyIHQgPSBudWxsICE9IGFyZ3VtZW50c1tyXSA/IGFyZ3VtZW50c1tyXSA6IHt9OwogICAgICAgICAgICByICUgMiA/IG93bktleXMoT2JqZWN0KHQpLCAhMCkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoZSwgciwgdFtyXSk7CiAgICAgICAgICAgIH0pIDogT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnMgPyBPYmplY3QuZGVmaW5lUHJvcGVydGllcyhlLCBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyh0KSkgOiBvd25LZXlzKE9iamVjdCh0KSkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZSwgciwgT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcih0LCByKSk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllcyhlLCB0KSB7CiAgICAgICAgaWYgKG51bGwgPT0gZSkgcmV0dXJuIHt9OwogICAgICAgIHZhciBvLCByLCBpID0gX29iamVjdFdpdGhvdXRQcm9wZXJ0aWVzTG9vc2UoZSwgdCk7CiAgICAgICAgaWYgKE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMpIHsKICAgICAgICAgICAgdmFyIG4gPSBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpOwogICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgbi5sZW5ndGg7IHIrKykgbyA9IG5bcl0sIC0xID09PSB0LmluZGV4T2YobykgJiYge30ucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLCBvKSAmJiAoaVtvXSA9IGVbb10pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllc0xvb3NlKHIsIGUpIHsKICAgICAgICBpZiAobnVsbCA9PSByKSByZXR1cm4ge307CiAgICAgICAgdmFyIHQgPSB7fTsKICAgICAgICBmb3IgKHZhciBuIGluIHIpIGlmICh7fS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHIsIG4pKSB7CiAgICAgICAgICAgIGlmICgtMSAhPT0gZS5pbmRleE9mKG4pKSBjb250aW51ZTsKICAgICAgICAgICAgdFtuXSA9IHJbbl07CiAgICAgICAgfQogICAgICAgIHJldHVybiB0OwogICAgfQogICAgZnVuY3Rpb24gX3RvUHJpbWl0aXZlKHQsIHIpIHsKICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIHQgfHwgIXQpIHJldHVybiB0OwogICAgICAgIHZhciBlID0gdFtTeW1ib2wudG9QcmltaXRpdmVdOwogICAgICAgIGlmICh2b2lkIDAgIT09IGUpIHsKICAgICAgICAgICAgdmFyIGkgPSBlLmNhbGwodCwgciB8fCAiZGVmYXVsdCIpOwogICAgICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIGkpIHJldHVybiBpOwogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJAQHRvUHJpbWl0aXZlIG11c3QgcmV0dXJuIGEgcHJpbWl0aXZlIHZhbHVlLiIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gKCJzdHJpbmciID09PSByID8gU3RyaW5nIDogTnVtYmVyKSh0KTsKICAgIH0KICAgIGZ1bmN0aW9uIF90b1Byb3BlcnR5S2V5KHQpIHsKICAgICAgICB2YXIgaSA9IF90b1ByaW1pdGl2ZSh0LCAic3RyaW5nIik7CiAgICAgICAgcmV0dXJuICJzeW1ib2wiID09IHR5cGVvZiBpID8gaSA6IGkgKyAiIjsKICAgIH0KICAgIGNsYXNzIEdlbmVyaWNFcnJvciBleHRlbmRzIEVycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihlcnJvciwgZXJyb3JfZGVzY3JpcHRpb24pIHsKICAgICAgICAgICAgc3VwZXIoZXJyb3JfZ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nlQYXJhbXMuZm9yRWFjaCgodmFsLCBrZXkpID0+IHsKICAgICAgICAgICAgcGFyc2VkUXVlcnlba2V5XSA9IHZhbDsKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gcGFyc2VkUXVlcnk7CiAgICB9OwogICAgY29uc3QgdXBkYXRlUmVmcmVzaFRva2VucyA9IChvbGRSZWZyZXNoVG9rZW4sIG5ld1JlZnJlc2hUb2tlbikgPT4gewogICAgICAgIE9iamVjdC5lbnRyaWVzKHJlZnJlc2hUb2tlbnMpLmZvckVhY2goX3JlZiA9PiB7CiAgICAgICAgICAgIGxldCBba2V5LCB0b2tlbl0gPSBfcmVmOwogICAgICAgICAgICBpZiAodG9rZW4gPT09IG9sZFJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1trZXldID0gbmV3UmVmcmVzaFRva2VuOwogICAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICB9OwogICAgY29uc3QgY2hlY2tEb3duc2NvcGluZyA9IChzY29wZSwgYXVkaWVuY2UpID0+IHsKICAgICAgICBjb25zdCBmaW5kQ29pbmNpZGVuY2UgPSBPYmplY3Qua2V5cyhyZWZyZXNoVG9rZW5zKS5maW5kKGtleSA9PiB7CiAgICAgICAgICAgIGlmIChrZXkgIT09ICJsYXRlc3RfcmVmcmVzaF90b2tlbiIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGlzU2FtZUF1ZGllbmNlID0gY2FjaGVLZXlDb250YWluc0F1ZGllbmNlKGF1ZGllbmNlLCBrZXkpOwogICAgICAgICAgICAgICAgY29uc3Qgc2NvcGVzS2V5ID0ga2V5LnNwbGl0KCJ8IilbMV0uc3BsaXQoIiAiKTsKICAgICAgICAgICAgICAgIGNvbnN0IHJlcXVlc3RlZFNjb3BlcyA9IHNjb3BlLnNwbGl0KCIgIik7CiAgICAgICAgICAgICAgICBjb25zdCBzY29wZXNBcmVJbmNsdWRlZCA9IHJlcXVlc3RlZFNjb3Blcy5ldmV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ICAgICAgICAgICAgY29uc3QgbGF0ZXN0UmVmcmVzaFRva2VuID0gcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0Rvd25zY29waW5nID0gY2hlY2tEb3duc2NvcGluZyhzY29wZSwgYXVkaWVuY2UpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXRlc3RSZWZyZXNoVG9rZW4gJiYgIWlzRG93bnNjb3BpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gbGF0ZXN0UmVmcmVzaFRva2VuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvcihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLmJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKF9vYmplY3RTcHJlYWQyKF9vYmplY3RTcHJlYWQyKHt9LCBib2R5KSwge30sIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKSA6IEpTT04uc3RyaW5naWZ5KF9vYmplY3RTcHJlYWQyKF9vYmplY3RTcHJlYWQyKHt9LCBib2R5KSwge30sIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICBpZiAodHlwZW9mIEFib3J0Q29udHJvbGxlciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5zaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgUHJvbWlzZS5yYWNlKFsgd2FpdCh0aW1lb3V0KSwgZmV0Y2goZmV0Y2hVcmwsIF9vYmplY3RTcHJlYWQyKHt9LCBmZXRjaE9wdGlvbnMpKSBdKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICBpZiAoYWJvcnRDb250cm9sbGVyKSBhYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVycyA9IGZyb21FbnRyaWVzKHJlc3BvbnNlLmhlYWRlcnMpOwogICAgICAgICAgICBqc29uID0gYXdhaXQgcmVzcG9uc2UuanNvbigpOwogICAgICAgICAgICBpZiAoanNvbi5yZWZyZXNoX3Rva2VuKSB7CiAgICAgICAgICAgICAgICBpZiAodXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl0gPSBqc29uLnJlZnJlc2hfdG9rZW47CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUmVmcmVzaFRva2VucyhyZWZyZXNoVG9rZW4sIGpzb24ucmVmcmVzaF90b2tlbik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzZXRSZWZyZXNoVG9rZW4oanNvbi5yZWZyZXNoX3Rva2VuLCBhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgZGVsZXRlIGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IHJlc3BvbnNlLm9rLAogICAgICAgICAgICAgICAganNvbjoganNvbiwKICAgICAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMKICAgICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICBqc29uOiB7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLmVycm9yLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgY29uc3QgaXNBdXRob3JpemVkV29ya2VyUmVxdWVzdCA9IHdvcmtlclJlcXVlc3QgPT4gewogICAgICAgIGlmICghYWxsb3dlZEJhc2VVcmwpIHsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBhbGxvd2VkQmFzZU9yaWdpbiA9IG5ldyBVUkwoYWxsb3dlZEJhc2VVcmwpLm9yaWdpbjsKICAgICAgICAgICAgY29uc3QgcmVxdWVzdGVkVXJsID0gbmV3IFVSTCh3b3JrZXJSZXF1ZXN0LmZldGNoVXJsKTsKICAgICAgICAgICAgcmV0dXJuIHJlcXVlc3RlZFVybC5vcmlnaW4gPT09IGFsbG93ZWRCYXNlT3JpZ2luICYmIHJlcXVlc3RlZFVybC5wYXRobmFtZSA9PT0gIi9vYXV0aC90b2tlbiI7CiAgICAgICAgfSBjYXRjaCAoX3VudXNlZCkgewogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgfTsKICAgIGNvbnN0IG1lc3NhZ2VSb3V0ZXIgPSBldmVudCA9PiB7CiAgICAgICAgY29uc3Qge2RhdGE6IGRhdGEsIHBvcnRzOiBwb3J0c30gPSBldmVudDsKICAgICAgICBjb25zdCBbcG9ydF0gPSBwb3J0czsKICAgICAgICBpZiAoInR5cGUiIGluIGRhdGEgJiYgZGF0YS50eXBlID09PSAiaW5pdCIpIHsKICAgICAgICAgICAgaWYgKGFsbG93ZWRCYXNlVXJsID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgIG5ldyBVUkwoZGF0YS5hbGxvd2VkQmFzZVVybCk7CiAgICAgICAgICAgICAgICAgICAgYWxsb3dlZEJhc2VVcmwgPSBkYXRhLmFsbG93ZWRCYXNlVXJsOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoX3VudXNlZDIpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoISgiZmV0Y2hVcmwiIGluIGRhdGEpIHx8ICFpc0F1dGhvcml6ZWRXb3JrZXJSZXF1ZXN0KGRhdGEpKSB7CiAgICAgICAgICAgIHBvcnQgPT09IG51bGwgfHwgcG9ydCA9PT0gdm9pZCAwIHx8IHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IGZhbHNlLAogICAgICAgICAgICAgICAganNvbjogewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiaW52YWxpZF9mZXRjaF91cmwiLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiAiVW5hdXRob3JpemVkIGZldGNoIFVSTCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7fQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBtZXNzYWdlSGFuZGxlcihldmVudCk7CiAgICB9OwogICAgewogICAgICAgIGFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBtZXNzYWdlUm91dGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
2205
|
+
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBjbGFzcyBHZW5lcmljRXJyb3IgZXh0ZW5kcyBFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uKSB7CiAgICAgICAgICAgIHN1cGVyKGVycm9yX2Rlc2NyaXB0aW9uKTsKICAgICAgICAgICAgdGhpcy5lcnJvciA9IGVycm9yOwogICAgICAgICAgICB0aGlzLmVycm9yX2Rlc2NyaXB0aW9uID0gZXJyb3JfZGVzY3JpcHRpb247CiAgICAgICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLCBHZW5lcmljRXJyb3IucHJvdG90eXBlKTsKICAgICAgICB9CiAgICAgICAgc3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lKHJlc29sdmUgPT4gc2V0VGltZW91dChyZXNvbHZlLCB0aW1lKSk7CiAgICBjb25zdCBmb3JtRGF0YVRvT2JqZWN0ID0gZm9ybURhdGEgPT4gewogICAgICAgIGNvbnN0IHF1ZXJ5UGFyYW1zID0gbmV3IFVSTFNlYXJjaFBhcmFtcyhmb3JtRGF0YSk7CiAgICAgICAgY29uc3QgcGFyc2VkUXVlcnkgPSB7fTsKICAgICAgICBxdWVyeVBhcmFtcy5mb3JFYWNoKCh2YWwsIGtleSkgPT4gewogICAgICAgICAgICBwYXJzZWRRdWVyeVtrZXldID0gdmFsOwogICAgICAgIH0pOwogICAgICAgIHJldHVybiBwYXJzZWRRdWVyeTsKICAgIH07CiAgICBjb25zdCB1cGRhdGVSZWZyZXNoVG9rZW5zID0gKG9sZFJlZnJlc2hUb2tlbiwgbmV3UmVmcmVzaFRva2VuKSA9PiB7CiAgICAgICAgT2JqZWN0LmVudHJpZXMocmVmcmVzaFRva2VucykuZm9yRWFjaChfcmVmMyA9PiB7CiAgICAgICAgICAgIGxldCBba2V5LCB0b2tlbl0gPSBfcmVmMzsKICAgICAgICAgICAgaWYgKHRva2VuID09PSBvbGRSZWZyZXNoVG9rZW4pIHsKICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNba2V5XSA9IG5ld1JlZnJlc2hUb2tlbjsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IGNoZWNrRG93bnNjb3BpbmcgPSAoc2NvcGUsIGF1ZGllbmNlKSA9PiB7CiAgICAgICAgY29uc3QgZmluZENvaW5jaWRlbmNlID0gT2JqZWN0LmtleXMocmVmcmVzaFRva2VucykuZmluZChrZXkgPT4gewogICAgICAgICAgICBpZiAoa2V5ICE9PSAibGF0ZXN0X3JlZnJlc2hfdG9rZW4iKSB7CiAgICAgICAgICAgICAgICBjb25zdCBpc1NhbWVBdWRpZW5jZSA9IGNhY2hlS2V5Q29udGFpbnNBdWRpZW5jZShhdWRpZW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AgICAgaWYgKCFib2R5LnJlZnJlc2hfdG9rZW4gJiYgYm9keS5ncmFudF90eXBlID09PSAicmVmcmVzaF90b2tlbiIpIHsKICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGdldFJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgaWYgKCFyZWZyZXNoVG9rZW4gJiYgdXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxhdGVzdFJlZnJlc2hUb2tlbiA9IHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl07CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNEb3duc2NvcGluZyA9IGNoZWNrRG93bnNjb3Bpbmcoc2NvcGUsIGF1ZGllbmNlKTsKICAgICAgICAgICAgICAgICAgICBpZiAobGF0ZXN0UmVmcmVzaFRva2VuICYmICFpc0Rvd25zY29waW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGxhdGVzdFJlZnJlc2hUb2tlbjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBNaXNzaW5nUmVmcmVzaFRva2VuRXJyb3IoYXVkaWVuY2UsIHNjb3BlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5ib2R5ID0gdXNlRm9ybURhdGEgPyBjcmVhdGVRdWVyeVBhcmFtcyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSkgOiBKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IGFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgaWYgKHR5cGVvZiBBYm9ydENvbnRyb2xsZXIgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgIGFib3J0Q29udHJvbGxlciA9IG5ldyBBYm9ydENvbnRyb2xsZXI7CiAgICAgICAgICAgICAgICBmZXRjaE9wdGlvbnMuc2lnbmFsID0gYWJvcnRDb250cm9sbGVyLnNpZ25hbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgcmVzcG9uc2U7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICByZXNwb25zZSA9IGF3YWl0IFByb21pc2UucmFjZShbIHdhaXQodGltZW91dCksIGZldGNoKGZldGNoVXJsLCBPYmplY3QuYXNzaWduKHt9LCBmZXRjaE9wdGlvbnMpKSBdKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICBpZiAoYWJvcnRDb250cm9sbGVyKSBhYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVycyA9IGZyb21FbnRyaWVzKHJlc3BvbnNlLmhlYWRlcnMpOwogICAgICAgICAgICBqc29uID0gYXdhaXQgcmVzcG9uc2UuanNvbigpOwogICAgICAgICAgICBpZiAoanNvbi5yZWZyZXNoX3Rva2VuKSB7CiAgICAgICAgICAgICAgICBpZiAodXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl0gPSBqc29uLnJlZnJlc2hfdG9rZW47CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUmVmcmVzaFRva2VucyhyZWZyZXNoVG9rZW4sIGpzb24ucmVmcmVzaF90b2tlbik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzZXRSZWZyZXNoVG9rZW4oanNvbi5yZWZyZXNoX3Rva2VuLCBhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgZGVsZXRlIGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IHJlc3BvbnNlLm9rLAogICAgICAgICAgICAgICAganNvbjoganNvbiwKICAgICAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMKICAgICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICBqc29uOiB7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLmVycm9yLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgY29uc3QgcmV2b2tlTWVzc2FnZUhhbmRsZXIgPSBhc3luYyBfcmVmNSA9PiB7CiAgICAgICAgbGV0IHtkYXRhOiB7dGltZW91dDogdGltZW91dCwgYXV0aDogYXV0aCwgZmV0Y2hVcmw6IGZldGNoVXJsLCBmZXRjaE9wdGlvbnM6IGZldGNoT3B0aW9ucywgdXNlRm9ybURhdGE6IHVzZUZvcm1EYXRhfSwgcG9ydHM6IFtwb3J0XX0gPSBfcmVmNTsKICAgICAgICBjb25zdCB7YXVkaWVuY2U6IGF1ZGllbmNlfSA9IGF1dGggfHwge307CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgdG9rZW5zVG9SZXZva2UgPSBnZXRSZWZyZXNoVG9rZW5zQnlBdWRpZW5jZShhdWRpZW5jZSk7CiAgICAgICAgICAgIGlmICh0b2tlbnNUb1Jldm9rZS5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIG9rOiB0cnVlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBiYXNlQm9keSA9IHVzZUZvcm1EYXRhID8gZm9ybURhdGFUb09iamVjdChmZXRjaE9wdGlvbnMuYm9keSkgOiBKU09OLnBhcnNlKGZldGNoT3B0aW9ucy5ib2R5KTsKICAgICAgICAgICAgZm9yIChjb25zdCByZWZyZXNoVG9rZW4gb2YgdG9rZW5zVG9SZXZva2UpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYmFzZUJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpIDogSlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LCBiYXNlQm9keSksIHsKICAgICAgICAgICAgICAgICAgICB0b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICAgICAgbGV0IHNpZ25hbDsKICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgQWJvcnRDb250cm9sbGVyID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgICAgICBzaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGV0IHRpbWVvdXRJZDsKICAgICAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBhd2FpdCBQcm9taXNlLnJhY2UoWyBuZXcgUHJvbWlzZShyZXNvbHZlID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGltZW91dElkID0gc2V0VGltZW91dChyZXNvbHZlLCB0aW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICB9KSwgZmV0Y2goZmV0Y2hVcmwsIE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgZmV0Y2hPcHRpb25zKSwgewogICAgICAgICAgICAgICAgICAgICAgICBib2R5OiBib2R5LAogICAgICAgICAgICAgICAgICAgICAgICBzaWduYWw6IHNpZ25hbAogICAgICAgICAgICAgICAgICAgIH0pKSBdKS5maW5hbGx5KCgpID0+IGNsZWFyVGltZW91dCh0aW1lb3V0SWQpKTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFyZXNwb25zZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICBlcnJvcjogIlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyIKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXJlc3BvbnNlLm9rKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGVycm9yRGVzY3JpcHRpb247CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qge2Vycm9yX2Rlc2NyaXB0aW9uOiBlcnJvcl9kZXNjcmlwdGlvbn0gPSBKU09OLnBhcnNlKGF3YWl0IHJlc3BvbnNlLnRleHQoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yRGVzY3JpcHRpb24gPSBlcnJvcl9kZXNjcmlwdGlvbjsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChfYSkge30KICAgICAgICAgICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yRGVzY3JpcHRpb24gfHwgIkhUVFAgZXJyb3IgIi5jb25jYXQocmVzcG9uc2Uuc3RhdHVzKQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbnNCeVZhbHVlKHJlZnJlc2hUb2tlbik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogdHJ1ZQogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlIHx8ICJVbmtub3duIGVycm9yIGR1cmluZyB0b2tlbiByZXZvY2F0aW9uIgogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgY29uc3QgaXNBdXRob3JpemVkV29ya2VyUmVxdWVzdCA9ICh3b3JrZXJSZXF1ZXN0LCBleHBlY3RlZFBhdGgpID0+IHsKICAgICAgICBpZiAoIWFsbG93ZWRCYXNlVXJsKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgYWxsb3dlZEJhc2VPcmlnaW4gPSBuZXcgVVJMKGFsbG93ZWRCYXNlVXJsKS5vcmlnaW47CiAgICAgICAgICAgIGNvbnN0IHJlcXVlc3RlZFVybCA9IG5ldyBVUkwod29ya2VyUmVxdWVzdC5mZXRjaFVybCk7CiAgICAgICAgICAgIHJldHVybiByZXF1ZXN0ZWRVcmwub3JpZ2luID09PSBhbGxvd2VkQmFzZU9yaWdpbiAmJiByZXF1ZXN0ZWRVcmwucGF0aG5hbWUgPT09IGV4cGVjdGVkUGF0aDsKICAgICAgICB9IGNhdGNoIChfYSkgewogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgfTsKICAgIGNvbnN0IG1lc3NhZ2VSb3V0ZXIgPSBldmVudCA9PiB7CiAgICAgICAgY29uc3Qge2RhdGE6IGRhdGEsIHBvcnRzOiBwb3J0c30gPSBldmVudDsKICAgICAgICBjb25zdCBbcG9ydF0gPSBwb3J0czsKICAgICAgICBpZiAoInR5cGUiIGluIGRhdGEgJiYgZGF0YS50eXBlID09PSAiaW5pdCIpIHsKICAgICAgICAgICAgaWYgKGFsbG93ZWRCYXNlVXJsID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgIG5ldyBVUkwoZGF0YS5hbGxvd2VkQmFzZVVybCk7CiAgICAgICAgICAgICAgICAgICAgYWxsb3dlZEJhc2VVcmwgPSBkYXRhLmFsbG93ZWRCYXNlVXJsOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoX2EpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoInR5cGUiIGluIGRhdGEgJiYgZGF0YS50eXBlID09PSAicmV2b2tlIikgewogICAgICAgICAgICBpZiAoIWlzQXV0aG9yaXplZFdvcmtlclJlcXVlc3QoZGF0YSwgIi9vYXV0aC9yZXZva2UiKSkgewogICAgICAgICAgICAgICAgcG9ydCA9PT0gbnVsbCB8fCBwb3J0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAganNvbjogewogICAgICAgICAgICAgICAgICAgICAgICBlcnJvcjogImludmFsaWRfZmV0Y2hfdXJsIiwKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246ICJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIgogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge30KICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldm9rZU1lc3NhZ2VIYW5kbGVyKGV2ZW50KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoISgiZmV0Y2hVcmwiIGluIGRhdGEpIHx8ICFpc0F1dGhvcml6ZWRXb3JrZXJSZXF1ZXN0KGRhdGEsICIvb2F1dGgvdG9rZW4iKSkgewogICAgICAgICAgICBwb3J0ID09PSBudWxsIHx8IHBvcnQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IGZhbHNlLAogICAgICAgICAgICAgICAganNvbjogewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiaW52YWxpZF9mZXRjaF91cmwiLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiAiVW5hdXRob3JpemVkIGZldGNoIFVSTCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7fQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBtZXNzYWdlSGFuZGxlcihldmVudCk7CiAgICB9OwogICAgewogICAgICAgIGFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBtZXNzYWdlUm91dGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
2286
2206
|
|
|
2287
2207
|
const singlePromiseMap = {};
|
|
2288
2208
|
|
|
@@ -2302,12 +2222,11 @@ class CacheKeyManifest {
|
|
|
2302
2222
|
constructor(cache, clientId) {
|
|
2303
2223
|
this.cache = cache;
|
|
2304
2224
|
this.clientId = clientId;
|
|
2305
|
-
_defineProperty(this, "manifestKey", void 0);
|
|
2306
2225
|
this.manifestKey = this.createManifestKeyFrom(this.clientId);
|
|
2307
2226
|
}
|
|
2308
2227
|
async add(key) {
|
|
2309
|
-
var
|
|
2310
|
-
const keys = new Set(((
|
|
2228
|
+
var _a;
|
|
2229
|
+
const keys = new Set(((_a = await this.cache.get(this.manifestKey)) === null || _a === void 0 ? void 0 : _a.keys) || []);
|
|
2311
2230
|
keys.add(key);
|
|
2312
2231
|
await this.cache.set(this.manifestKey, {
|
|
2313
2232
|
keys: [ ...keys ]
|
|
@@ -2337,8 +2256,6 @@ class CacheKeyManifest {
|
|
|
2337
2256
|
}
|
|
2338
2257
|
}
|
|
2339
2258
|
|
|
2340
|
-
const _excluded$2 = [ "openUrl", "onRedirect" ];
|
|
2341
|
-
|
|
2342
2259
|
const GET_TOKEN_SILENTLY_LOCK_KEY = "auth0.lock.getTokenSilently";
|
|
2343
2260
|
|
|
2344
2261
|
const GET_TOKEN_FROM_IFRAME_LOCK_KEY = "auth0.lock.getTokenFromIFrame";
|
|
@@ -2360,9 +2277,9 @@ const cacheLocationBuilders = {
|
|
|
2360
2277
|
|
|
2361
2278
|
const cacheFactory = location => cacheLocationBuilders[location];
|
|
2362
2279
|
|
|
2363
|
-
const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) =>
|
|
2280
|
+
const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) => Object.assign(Object.assign(Object.assign({
|
|
2364
2281
|
client_id: clientOptions.clientId
|
|
2365
|
-
}, clientOptions.authorizationParams), authorizationParams), {
|
|
2282
|
+
}, clientOptions.authorizationParams), authorizationParams), {
|
|
2366
2283
|
scope: scopesToRequest(scope, authorizationParams.scope, authorizationParams.audience),
|
|
2367
2284
|
response_type: "code",
|
|
2368
2285
|
response_mode: response_mode || "query",
|
|
@@ -2375,8 +2292,8 @@ const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, no
|
|
|
2375
2292
|
});
|
|
2376
2293
|
|
|
2377
2294
|
const patchOpenUrlWithOnRedirect = options => {
|
|
2378
|
-
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions =
|
|
2379
|
-
const result =
|
|
2295
|
+
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions = __rest(options, [ "openUrl", "onRedirect" ]);
|
|
2296
|
+
const result = Object.assign(Object.assign({}, originalOptions), {
|
|
2380
2297
|
openUrl: openUrl === false || openUrl ? openUrl : onRedirect
|
|
2381
2298
|
});
|
|
2382
2299
|
return result;
|
|
@@ -2396,13 +2313,13 @@ const getMissingScopes = (requestedScope, respondedScope) => {
|
|
|
2396
2313
|
};
|
|
2397
2314
|
|
|
2398
2315
|
const getScopeToRequest = (useMrrt, authorizationParams, cachedAudience, cachedScope) => {
|
|
2316
|
+
var _a;
|
|
2399
2317
|
if (useMrrt && cachedAudience && cachedScope) {
|
|
2400
|
-
var _authorizationParams$;
|
|
2401
2318
|
if (authorizationParams.audience !== cachedAudience) {
|
|
2402
2319
|
return authorizationParams.scope;
|
|
2403
2320
|
}
|
|
2404
2321
|
const cachedScopes = cachedScope.split(" ");
|
|
2405
|
-
const newScopes = ((
|
|
2322
|
+
const newScopes = ((_a = authorizationParams.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
2406
2323
|
const newScopesAreIncluded = newScopes.every(scope => cachedScopes.includes(scope));
|
|
2407
2324
|
return cachedScopes.length >= newScopes.length && newScopesAreIncluded ? cachedScope : authorizationParams.scope;
|
|
2408
2325
|
}
|
|
@@ -2429,8 +2346,6 @@ const AUTH0_NONCE_ID = "auth0";
|
|
|
2429
2346
|
|
|
2430
2347
|
class DpopStorage {
|
|
2431
2348
|
constructor(clientId) {
|
|
2432
|
-
_defineProperty(this, "clientId", void 0);
|
|
2433
|
-
_defineProperty(this, "dbHandle", void 0);
|
|
2434
2349
|
this.clientId = clientId;
|
|
2435
2350
|
}
|
|
2436
2351
|
getVersion() {
|
|
@@ -2484,7 +2399,7 @@ class DpopStorage {
|
|
|
2484
2399
|
}
|
|
2485
2400
|
async deleteBy(table, predicate) {
|
|
2486
2401
|
const allKeys = await this.executeDbRequest(table, "readonly", table => table.getAllKeys());
|
|
2487
|
-
allKeys === null || allKeys === void 0
|
|
2402
|
+
allKeys === null || allKeys === void 0 ? void 0 : allKeys.filter(predicate).map(k => this.executeDbRequest(table, "readwrite", table => table.delete(k)));
|
|
2488
2403
|
}
|
|
2489
2404
|
deleteByClientId(table, clientId) {
|
|
2490
2405
|
return this.deleteBy(table, k => typeof k === "string" && k.startsWith("".concat(clientId, "::")));
|
|
@@ -2499,7 +2414,6 @@ class DpopStorage {
|
|
|
2499
2414
|
|
|
2500
2415
|
class Dpop {
|
|
2501
2416
|
constructor(clientId) {
|
|
2502
|
-
_defineProperty(this, "storage", void 0);
|
|
2503
2417
|
this.storage = new DpopStorage(clientId);
|
|
2504
2418
|
}
|
|
2505
2419
|
getNonce(id) {
|
|
@@ -2518,7 +2432,7 @@ class Dpop {
|
|
|
2518
2432
|
}
|
|
2519
2433
|
async generateProof(params) {
|
|
2520
2434
|
const keyPair = await this.getOrGenerateKeyPair();
|
|
2521
|
-
return generateProof(
|
|
2435
|
+
return generateProof(Object.assign({
|
|
2522
2436
|
keyPair: keyPair
|
|
2523
2437
|
}, params));
|
|
2524
2438
|
}
|
|
@@ -2531,18 +2445,17 @@ class Dpop {
|
|
|
2531
2445
|
}
|
|
2532
2446
|
}
|
|
2533
2447
|
|
|
2534
|
-
var TokenType
|
|
2448
|
+
var TokenType;
|
|
2449
|
+
|
|
2450
|
+
(function(TokenType) {
|
|
2535
2451
|
TokenType["Bearer"] = "Bearer";
|
|
2536
2452
|
TokenType["DPoP"] = "DPoP";
|
|
2537
|
-
|
|
2538
|
-
}(TokenType || {});
|
|
2453
|
+
})(TokenType || (TokenType = {}));
|
|
2539
2454
|
|
|
2540
2455
|
class Fetcher {
|
|
2541
2456
|
constructor(config, hooks) {
|
|
2542
|
-
_defineProperty(this, "config", void 0);
|
|
2543
|
-
_defineProperty(this, "hooks", void 0);
|
|
2544
2457
|
this.hooks = hooks;
|
|
2545
|
-
this.config =
|
|
2458
|
+
this.config = Object.assign(Object.assign({}, config), {
|
|
2546
2459
|
fetch: config.fetch || (typeof window === "undefined" ? fetch : window.fetch.bind(window))
|
|
2547
2460
|
});
|
|
2548
2461
|
}
|
|
@@ -2650,7 +2563,7 @@ class Fetcher {
|
|
|
2650
2563
|
}
|
|
2651
2564
|
fetchWithAuth(info, init, authParams) {
|
|
2652
2565
|
const callbacks = {
|
|
2653
|
-
onUseDpopNonceError: () => this.internalFetchWithAuth(info, init,
|
|
2566
|
+
onUseDpopNonceError: () => this.internalFetchWithAuth(info, init, Object.assign(Object.assign({}, callbacks), {
|
|
2654
2567
|
onUseDpopNonceError: undefined
|
|
2655
2568
|
}), authParams)
|
|
2656
2569
|
};
|
|
@@ -2708,11 +2621,6 @@ class MyAccountApiError extends Error {
|
|
|
2708
2621
|
constructor(_ref) {
|
|
2709
2622
|
let {type: type, status: status, title: title, detail: detail, validation_errors: validation_errors} = _ref;
|
|
2710
2623
|
super(detail);
|
|
2711
|
-
_defineProperty(this, "type", void 0);
|
|
2712
|
-
_defineProperty(this, "status", void 0);
|
|
2713
|
-
_defineProperty(this, "title", void 0);
|
|
2714
|
-
_defineProperty(this, "detail", void 0);
|
|
2715
|
-
_defineProperty(this, "validation_errors", void 0);
|
|
2716
2624
|
this.name = "MyAccountApiError";
|
|
2717
2625
|
this.type = type;
|
|
2718
2626
|
this.status = status;
|
|
@@ -2753,7 +2661,7 @@ const MfaGrantTypes = {
|
|
|
2753
2661
|
|
|
2754
2662
|
function getAuthJsEnrollParams(params) {
|
|
2755
2663
|
const mapping = FACTOR_MAPPING[params.factorType];
|
|
2756
|
-
return
|
|
2664
|
+
return Object.assign(Object.assign(Object.assign({
|
|
2757
2665
|
mfaToken: params.mfaToken,
|
|
2758
2666
|
authenticatorTypes: mapping.authenticatorTypes
|
|
2759
2667
|
}, mapping.oobChannels && {
|
|
@@ -2778,6 +2686,162 @@ function getGrantType(params) {
|
|
|
2778
2686
|
return undefined;
|
|
2779
2687
|
}
|
|
2780
2688
|
|
|
2689
|
+
function _OverloadYield(e, d) {
|
|
2690
|
+
this.v = e, this.k = d;
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
function _assertClassBrand(e, t, n) {
|
|
2694
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
2695
|
+
throw new TypeError("Private element is not present on this object");
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
function _awaitAsyncGenerator(e) {
|
|
2699
|
+
return new _OverloadYield(e, 0);
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
2703
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
function _classPrivateFieldGet2(s, a) {
|
|
2707
|
+
return s.get(_assertClassBrand(s, a));
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
2711
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
2715
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
2719
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
function _defineProperty(e, r, t) {
|
|
2723
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
2724
|
+
value: t,
|
|
2725
|
+
enumerable: !0,
|
|
2726
|
+
configurable: !0,
|
|
2727
|
+
writable: !0
|
|
2728
|
+
}) : e[r] = t, e;
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
function ownKeys(e, r) {
|
|
2732
|
+
var t = Object.keys(e);
|
|
2733
|
+
if (Object.getOwnPropertySymbols) {
|
|
2734
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2735
|
+
r && (o = o.filter(function(r) {
|
|
2736
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
2737
|
+
})), t.push.apply(t, o);
|
|
2738
|
+
}
|
|
2739
|
+
return t;
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
function _objectSpread2(e) {
|
|
2743
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2744
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2745
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
2746
|
+
_defineProperty(e, r, t[r]);
|
|
2747
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
2748
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
2749
|
+
});
|
|
2750
|
+
}
|
|
2751
|
+
return e;
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
function _objectWithoutProperties(e, t) {
|
|
2755
|
+
if (null == e) return {};
|
|
2756
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
2757
|
+
if (Object.getOwnPropertySymbols) {
|
|
2758
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
2759
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
2760
|
+
}
|
|
2761
|
+
return i;
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
2765
|
+
if (null == r) return {};
|
|
2766
|
+
var t = {};
|
|
2767
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
2768
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
2769
|
+
t[n] = r[n];
|
|
2770
|
+
}
|
|
2771
|
+
return t;
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
function _toPrimitive(t, r) {
|
|
2775
|
+
if ("object" != typeof t || !t) return t;
|
|
2776
|
+
var e = t[Symbol.toPrimitive];
|
|
2777
|
+
if (void 0 !== e) {
|
|
2778
|
+
var i = e.call(t, r || "default");
|
|
2779
|
+
if ("object" != typeof i) return i;
|
|
2780
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2781
|
+
}
|
|
2782
|
+
return ("string" === r ? String : Number)(t);
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
function _toPropertyKey(t) {
|
|
2786
|
+
var i = _toPrimitive(t, "string");
|
|
2787
|
+
return "symbol" == typeof i ? i : i + "";
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
function _wrapAsyncGenerator(e) {
|
|
2791
|
+
return function() {
|
|
2792
|
+
return new AsyncGenerator(e.apply(this, arguments));
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
function AsyncGenerator(e) {
|
|
2797
|
+
var t, n;
|
|
2798
|
+
function resume(t, n) {
|
|
2799
|
+
try {
|
|
2800
|
+
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
2801
|
+
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
2802
|
+
if (u) {
|
|
2803
|
+
var i = "return" === t && o.k ? t : "next";
|
|
2804
|
+
if (!o.k || n.done) return resume(i, n);
|
|
2805
|
+
n = e[i](n).value;
|
|
2806
|
+
}
|
|
2807
|
+
settle(!!r.done, n);
|
|
2808
|
+
}, function(e) {
|
|
2809
|
+
resume("throw", e);
|
|
2810
|
+
});
|
|
2811
|
+
} catch (e) {
|
|
2812
|
+
settle(2, e);
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
function settle(e, r) {
|
|
2816
|
+
2 === e ? t.reject(r) : t.resolve({
|
|
2817
|
+
value: r,
|
|
2818
|
+
done: e
|
|
2819
|
+
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
2820
|
+
}
|
|
2821
|
+
this._invoke = function(e, r) {
|
|
2822
|
+
return new Promise(function(o, u) {
|
|
2823
|
+
var i = {
|
|
2824
|
+
key: e,
|
|
2825
|
+
arg: r,
|
|
2826
|
+
resolve: o,
|
|
2827
|
+
reject: u,
|
|
2828
|
+
next: null
|
|
2829
|
+
};
|
|
2830
|
+
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
2831
|
+
});
|
|
2832
|
+
}, "function" != typeof e.return && (this.return = void 0);
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
2836
|
+
return this;
|
|
2837
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
2838
|
+
return this._invoke("next", e);
|
|
2839
|
+
}, AsyncGenerator.prototype.throw = function(e) {
|
|
2840
|
+
return this._invoke("throw", e);
|
|
2841
|
+
}, AsyncGenerator.prototype.return = function(e) {
|
|
2842
|
+
return this._invoke("return", e);
|
|
2843
|
+
};
|
|
2844
|
+
|
|
2781
2845
|
var _navigator$userAgent$2, _navigator$userAgent$$2;
|
|
2782
2846
|
|
|
2783
2847
|
let USER_AGENT$2;
|
|
@@ -7058,7 +7122,7 @@ function createRemoteJWKSet(url, options) {
|
|
|
7058
7122
|
return remoteJWKSet;
|
|
7059
7123
|
}
|
|
7060
7124
|
|
|
7061
|
-
const _excluded
|
|
7125
|
+
const _excluded = [ "mfaToken" ], _excluded2 = [ "mfaToken" ];
|
|
7062
7126
|
|
|
7063
7127
|
var _baseUrl, _clientId, _customFetch, _entries, _ttlMs, _maxEntries, _configuration, _serverMetadata, _clientAuthPromise, _options, _customFetch2, _jwks, _discoveryCache, _inFlightDiscovery, _jwksCache, _Class9_brand;
|
|
7064
7128
|
|
|
@@ -7303,7 +7367,7 @@ class MfaClient {
|
|
|
7303
7367
|
}
|
|
7304
7368
|
async enrollAuthenticator(options) {
|
|
7305
7369
|
const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/associate");
|
|
7306
|
-
const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded
|
|
7370
|
+
const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded);
|
|
7307
7371
|
const apiParams = {
|
|
7308
7372
|
authenticator_types: sdkParams.authenticatorTypes
|
|
7309
7373
|
};
|
|
@@ -7348,7 +7412,7 @@ class MfaClient {
|
|
|
7348
7412
|
}
|
|
7349
7413
|
async challengeAuthenticator(options) {
|
|
7350
7414
|
const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/challenge");
|
|
7351
|
-
const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2
|
|
7415
|
+
const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2);
|
|
7352
7416
|
const body = {
|
|
7353
7417
|
mfa_token: mfaToken,
|
|
7354
7418
|
client_id: _classPrivateFieldGet2(_clientId, this),
|
|
@@ -8103,13 +8167,12 @@ const DEFAULT_TTL_MS = 10 * 60 * 1e3;
|
|
|
8103
8167
|
class MfaContextManager {
|
|
8104
8168
|
constructor() {
|
|
8105
8169
|
let ttlMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_TTL_MS;
|
|
8106
|
-
|
|
8107
|
-
_defineProperty(this, "ttlMs", void 0);
|
|
8170
|
+
this.contexts = new Map;
|
|
8108
8171
|
this.ttlMs = ttlMs;
|
|
8109
8172
|
}
|
|
8110
8173
|
set(mfaToken, context) {
|
|
8111
8174
|
this.cleanup();
|
|
8112
|
-
this.contexts.set(mfaToken,
|
|
8175
|
+
this.contexts.set(mfaToken, Object.assign(Object.assign({}, context), {
|
|
8113
8176
|
createdAt: Date.now()
|
|
8114
8177
|
}));
|
|
8115
8178
|
}
|
|
@@ -8142,9 +8205,6 @@ class MfaContextManager {
|
|
|
8142
8205
|
|
|
8143
8206
|
class MfaApiClient {
|
|
8144
8207
|
constructor(authJsMfaClient, auth0Client) {
|
|
8145
|
-
_defineProperty(this, "authJsMfaClient", void 0);
|
|
8146
|
-
_defineProperty(this, "auth0Client", void 0);
|
|
8147
|
-
_defineProperty(this, "contextManager", void 0);
|
|
8148
8208
|
this.authJsMfaClient = authJsMfaClient;
|
|
8149
8209
|
this.auth0Client = auth0Client;
|
|
8150
8210
|
this.contextManager = new MfaContextManager;
|
|
@@ -8157,9 +8217,9 @@ class MfaApiClient {
|
|
|
8157
8217
|
});
|
|
8158
8218
|
}
|
|
8159
8219
|
async getAuthenticators(mfaToken) {
|
|
8160
|
-
var
|
|
8220
|
+
var _a, _b;
|
|
8161
8221
|
const context = this.contextManager.get(mfaToken);
|
|
8162
|
-
if (!(context
|
|
8222
|
+
if (!((_a = context === null || context === void 0 ? void 0 : context.mfaRequirements) === null || _a === void 0 ? void 0 : _a.challenge) || context.mfaRequirements.challenge.length === 0) {
|
|
8163
8223
|
throw new MfaListAuthenticatorsError("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
|
|
8164
8224
|
}
|
|
8165
8225
|
const challengeTypes = context.mfaRequirements.challenge.map(c => c.type);
|
|
@@ -8173,25 +8233,25 @@ class MfaApiClient {
|
|
|
8173
8233
|
});
|
|
8174
8234
|
} catch (error) {
|
|
8175
8235
|
if (error instanceof MfaListAuthenticatorsError$1) {
|
|
8176
|
-
|
|
8177
|
-
throw new MfaListAuthenticatorsError((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.error, error.message);
|
|
8236
|
+
throw new MfaListAuthenticatorsError((_b = error.cause) === null || _b === void 0 ? void 0 : _b.error, error.message);
|
|
8178
8237
|
}
|
|
8179
8238
|
throw error;
|
|
8180
8239
|
}
|
|
8181
8240
|
}
|
|
8182
8241
|
async enroll(params) {
|
|
8242
|
+
var _a;
|
|
8183
8243
|
const authJsParams = getAuthJsEnrollParams(params);
|
|
8184
8244
|
try {
|
|
8185
8245
|
return await this.authJsMfaClient.enrollAuthenticator(authJsParams);
|
|
8186
8246
|
} catch (error) {
|
|
8187
8247
|
if (error instanceof MfaEnrollmentError$1) {
|
|
8188
|
-
|
|
8189
|
-
throw new MfaEnrollmentError((_error$cause2 = error.cause) === null || _error$cause2 === void 0 ? void 0 : _error$cause2.error, error.message);
|
|
8248
|
+
throw new MfaEnrollmentError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
|
|
8190
8249
|
}
|
|
8191
8250
|
throw error;
|
|
8192
8251
|
}
|
|
8193
8252
|
}
|
|
8194
8253
|
async challenge(params) {
|
|
8254
|
+
var _a;
|
|
8195
8255
|
try {
|
|
8196
8256
|
const authJsParams = {
|
|
8197
8257
|
challengeType: params.challengeType,
|
|
@@ -8203,8 +8263,7 @@ class MfaApiClient {
|
|
|
8203
8263
|
return await this.authJsMfaClient.challengeAuthenticator(authJsParams);
|
|
8204
8264
|
} catch (error) {
|
|
8205
8265
|
if (error instanceof MfaChallengeError$1) {
|
|
8206
|
-
|
|
8207
|
-
throw new MfaChallengeError((_error$cause3 = error.cause) === null || _error$cause3 === void 0 ? void 0 : _error$cause3.error, error.message);
|
|
8266
|
+
throw new MfaChallengeError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
|
|
8208
8267
|
}
|
|
8209
8268
|
throw error;
|
|
8210
8269
|
}
|
|
@@ -8254,38 +8313,18 @@ class MfaApiClient {
|
|
|
8254
8313
|
}
|
|
8255
8314
|
}
|
|
8256
8315
|
|
|
8257
|
-
const _excluded = [ "openUrl", "fragment", "appState" ], _excluded2 = [ "url" ], _excluded3 = [ "cacheMode" ], _excluded4 = [ "federated" ], _excluded5 = [ "openUrl" ], _excluded6 = [ "id_token", "decodedToken" ], _excluded7 = [ "mfaToken" ];
|
|
8258
|
-
|
|
8259
8316
|
class Auth0Client {
|
|
8260
8317
|
constructor(options) {
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
_defineProperty(this, "lockManager", void 0);
|
|
8264
|
-
_defineProperty(this, "domainUrl", void 0);
|
|
8265
|
-
_defineProperty(this, "tokenIssuer", void 0);
|
|
8266
|
-
_defineProperty(this, "scope", void 0);
|
|
8267
|
-
_defineProperty(this, "cookieStorage", void 0);
|
|
8268
|
-
_defineProperty(this, "dpop", void 0);
|
|
8269
|
-
_defineProperty(this, "sessionCheckExpiryDays", void 0);
|
|
8270
|
-
_defineProperty(this, "orgHintCookieName", void 0);
|
|
8271
|
-
_defineProperty(this, "isAuthenticatedCookieName", void 0);
|
|
8272
|
-
_defineProperty(this, "nowProvider", void 0);
|
|
8273
|
-
_defineProperty(this, "httpTimeoutMs", void 0);
|
|
8274
|
-
_defineProperty(this, "options", void 0);
|
|
8275
|
-
_defineProperty(this, "userCache", (new InMemoryCache).enclosedCache);
|
|
8276
|
-
_defineProperty(this, "myAccountApi", void 0);
|
|
8277
|
-
_defineProperty(this, "mfa", void 0);
|
|
8278
|
-
_defineProperty(this, "worker", void 0);
|
|
8279
|
-
_defineProperty(this, "authJsClient", void 0);
|
|
8280
|
-
_defineProperty(this, "defaultOptions", {
|
|
8318
|
+
this.userCache = (new InMemoryCache).enclosedCache;
|
|
8319
|
+
this.defaultOptions = {
|
|
8281
8320
|
authorizationParams: {
|
|
8282
8321
|
scope: DEFAULT_SCOPE
|
|
8283
8322
|
},
|
|
8284
8323
|
useRefreshTokensFallback: false,
|
|
8285
8324
|
useFormData: true
|
|
8286
|
-
}
|
|
8287
|
-
this.options =
|
|
8288
|
-
authorizationParams:
|
|
8325
|
+
};
|
|
8326
|
+
this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), options), {
|
|
8327
|
+
authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), options.authorizationParams)
|
|
8289
8328
|
});
|
|
8290
8329
|
typeof window !== "undefined" && validateCrypto();
|
|
8291
8330
|
this.lockManager = getLockManager();
|
|
@@ -8317,9 +8356,9 @@ class Auth0Client {
|
|
|
8317
8356
|
this.domainUrl = getDomain(this.options.domain);
|
|
8318
8357
|
this.tokenIssuer = getTokenIssuer(this.options.issuer, this.domainUrl);
|
|
8319
8358
|
const myAccountApiIdentifier = "".concat(this.domainUrl, "/me/");
|
|
8320
|
-
const myAccountFetcher = this.createFetcher(
|
|
8359
|
+
const myAccountFetcher = this.createFetcher(Object.assign(Object.assign({}, this.options.useDpop && {
|
|
8321
8360
|
dpopNonceId: "__auth0_my_account_api__"
|
|
8322
|
-
}), {
|
|
8361
|
+
}), {
|
|
8323
8362
|
getAccessToken: () => this.getTokenSilently({
|
|
8324
8363
|
authorizationParams: {
|
|
8325
8364
|
scope: "create:me:connected_accounts",
|
|
@@ -8397,7 +8436,7 @@ class Auth0Client {
|
|
|
8397
8436
|
url.searchParams.delete(paramName);
|
|
8398
8437
|
window.history.replaceState({}, "", url.toString());
|
|
8399
8438
|
}
|
|
8400
|
-
} catch (
|
|
8439
|
+
} catch (_a) {}
|
|
8401
8440
|
}
|
|
8402
8441
|
_applySessionTransferToken(authorizationParams) {
|
|
8403
8442
|
const paramName = this.options.sessionTransferTokenQueryParamName;
|
|
@@ -8407,18 +8446,18 @@ class Auth0Client {
|
|
|
8407
8446
|
const token = this._extractSessionTransferToken(paramName);
|
|
8408
8447
|
if (!token) return authorizationParams;
|
|
8409
8448
|
this._clearSessionTransferTokenFromUrl(paramName);
|
|
8410
|
-
return
|
|
8449
|
+
return Object.assign(Object.assign({}, authorizationParams), {
|
|
8411
8450
|
session_transfer_token: token
|
|
8412
8451
|
});
|
|
8413
8452
|
}
|
|
8414
8453
|
async _prepareAuthorizeUrl(authorizationParams, authorizeOptions, fallbackRedirectUri) {
|
|
8415
|
-
var
|
|
8454
|
+
var _a;
|
|
8416
8455
|
const state = encode$2(createRandomString());
|
|
8417
8456
|
const nonce = encode$2(createRandomString());
|
|
8418
8457
|
const code_verifier = createRandomString();
|
|
8419
8458
|
const code_challengeBuffer = await sha256(code_verifier);
|
|
8420
8459
|
const code_challenge = bufferToBase64UrlEncoded(code_challengeBuffer);
|
|
8421
|
-
const thumbprint = await ((
|
|
8460
|
+
const thumbprint = await ((_a = this.dpop) === null || _a === void 0 ? void 0 : _a.calculateThumbprint());
|
|
8422
8461
|
const params = getAuthorizeParams(this.options, this.scope, authorizationParams, state, nonce, code_challenge, authorizationParams.redirect_uri || this.options.authorizationParams.redirect_uri || fallbackRedirectUri, authorizeOptions === null || authorizeOptions === void 0 ? void 0 : authorizeOptions.response_mode, thumbprint);
|
|
8423
8462
|
const url = this._authorizeUrl(params);
|
|
8424
8463
|
return {
|
|
@@ -8432,7 +8471,7 @@ class Auth0Client {
|
|
|
8432
8471
|
};
|
|
8433
8472
|
}
|
|
8434
8473
|
async loginWithPopup(options, config) {
|
|
8435
|
-
var
|
|
8474
|
+
var _a;
|
|
8436
8475
|
options = options || {};
|
|
8437
8476
|
config = config || {};
|
|
8438
8477
|
if (!config.popup) {
|
|
@@ -8446,13 +8485,13 @@ class Auth0Client {
|
|
|
8446
8485
|
response_mode: "web_message"
|
|
8447
8486
|
}, window.location.origin);
|
|
8448
8487
|
config.popup.location.href = params.url;
|
|
8449
|
-
const codeResult = await runPopup(
|
|
8488
|
+
const codeResult = await runPopup(Object.assign(Object.assign({}, config), {
|
|
8450
8489
|
timeoutInSeconds: config.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
8451
8490
|
}), new URL(params.url).origin);
|
|
8452
8491
|
if (params.state !== codeResult.state) {
|
|
8453
8492
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
8454
8493
|
}
|
|
8455
|
-
const organization = ((
|
|
8494
|
+
const organization = ((_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
|
|
8456
8495
|
await this._requestToken({
|
|
8457
8496
|
audience: params.audience,
|
|
8458
8497
|
scope: params.scope,
|
|
@@ -8466,26 +8505,26 @@ class Auth0Client {
|
|
|
8466
8505
|
});
|
|
8467
8506
|
}
|
|
8468
8507
|
async getUser() {
|
|
8469
|
-
var
|
|
8508
|
+
var _a;
|
|
8470
8509
|
const cache = await this._getIdTokenFromCache();
|
|
8471
|
-
return cache === null || cache === void 0
|
|
8510
|
+
return (_a = cache === null || cache === void 0 ? void 0 : cache.decodedToken) === null || _a === void 0 ? void 0 : _a.user;
|
|
8472
8511
|
}
|
|
8473
8512
|
async getIdTokenClaims() {
|
|
8474
|
-
var
|
|
8513
|
+
var _a;
|
|
8475
8514
|
const cache = await this._getIdTokenFromCache();
|
|
8476
|
-
return cache === null || cache === void 0
|
|
8515
|
+
return (_a = cache === null || cache === void 0 ? void 0 : cache.decodedToken) === null || _a === void 0 ? void 0 : _a.claims;
|
|
8477
8516
|
}
|
|
8478
8517
|
async loginWithRedirect() {
|
|
8479
|
-
var _urlOptions$authoriza;
|
|
8480
8518
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8481
|
-
|
|
8482
|
-
const
|
|
8519
|
+
var _a;
|
|
8520
|
+
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl, fragment: fragment, appState: appState} = _b, urlOptions = __rest(_b, [ "openUrl", "fragment", "appState" ]);
|
|
8521
|
+
const organization = ((_a = urlOptions.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
|
|
8483
8522
|
const authorizationParams = this._applySessionTransferToken(urlOptions.authorizationParams || {});
|
|
8484
|
-
const
|
|
8485
|
-
this.transactionManager.create(
|
|
8523
|
+
const _c = await this._prepareAuthorizeUrl(authorizationParams), {url: url} = _c, transaction = __rest(_c, [ "url" ]);
|
|
8524
|
+
this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, transaction), {
|
|
8486
8525
|
appState: appState,
|
|
8487
|
-
response_type: ResponseType.Code
|
|
8488
|
-
}, organization && {
|
|
8526
|
+
response_type: exports.ResponseType.Code
|
|
8527
|
+
}), organization && {
|
|
8489
8528
|
organization: organization
|
|
8490
8529
|
}));
|
|
8491
8530
|
const urlWithFragment = fragment ? "".concat(url, "#").concat(fragment) : url;
|
|
@@ -8507,7 +8546,7 @@ class Auth0Client {
|
|
|
8507
8546
|
}
|
|
8508
8547
|
this.transactionManager.remove();
|
|
8509
8548
|
const authenticationResult = parseAuthenticationResult(queryStringFragments.join(""));
|
|
8510
|
-
if (transaction.response_type === ResponseType.ConnectCode) {
|
|
8549
|
+
if (transaction.response_type === exports.ResponseType.ConnectCode) {
|
|
8511
8550
|
return this._handleConnectAccountRedirectCallback(authenticationResult, transaction);
|
|
8512
8551
|
}
|
|
8513
8552
|
return this._handleLoginRedirectCallback(authenticationResult, transaction);
|
|
@@ -8523,7 +8562,7 @@ class Auth0Client {
|
|
|
8523
8562
|
const organization = transaction.organization;
|
|
8524
8563
|
const nonceIn = transaction.nonce;
|
|
8525
8564
|
const redirect_uri = transaction.redirect_uri;
|
|
8526
|
-
await this._requestToken(
|
|
8565
|
+
await this._requestToken(Object.assign({
|
|
8527
8566
|
audience: transaction.audience,
|
|
8528
8567
|
scope: transaction.scope,
|
|
8529
8568
|
code_verifier: transaction.code_verifier,
|
|
@@ -8537,7 +8576,7 @@ class Auth0Client {
|
|
|
8537
8576
|
});
|
|
8538
8577
|
return {
|
|
8539
8578
|
appState: transaction.appState,
|
|
8540
|
-
response_type: ResponseType.Code
|
|
8579
|
+
response_type: exports.ResponseType.Code
|
|
8541
8580
|
};
|
|
8542
8581
|
}
|
|
8543
8582
|
async _handleConnectAccountRedirectCallback(connectResult, transaction) {
|
|
@@ -8557,9 +8596,9 @@ class Auth0Client {
|
|
|
8557
8596
|
redirect_uri: transaction.redirect_uri,
|
|
8558
8597
|
code_verifier: transaction.code_verifier
|
|
8559
8598
|
});
|
|
8560
|
-
return
|
|
8599
|
+
return Object.assign(Object.assign({}, data), {
|
|
8561
8600
|
appState: transaction.appState,
|
|
8562
|
-
response_type: ResponseType.ConnectCode
|
|
8601
|
+
response_type: exports.ResponseType.ConnectCode
|
|
8563
8602
|
});
|
|
8564
8603
|
}
|
|
8565
8604
|
async checkSession(options) {
|
|
@@ -8579,20 +8618,20 @@ class Auth0Client {
|
|
|
8579
8618
|
} catch (_) {}
|
|
8580
8619
|
}
|
|
8581
8620
|
async getTokenSilently() {
|
|
8582
|
-
var _options$authorizatio2, _options$authorizatio3;
|
|
8583
8621
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8584
|
-
|
|
8622
|
+
var _a, _b;
|
|
8623
|
+
const localOptions = Object.assign(Object.assign({
|
|
8585
8624
|
cacheMode: "on"
|
|
8586
|
-
}, options), {
|
|
8587
|
-
authorizationParams:
|
|
8588
|
-
scope: scopesToRequest(this.scope, (
|
|
8625
|
+
}, options), {
|
|
8626
|
+
authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), options.authorizationParams), {
|
|
8627
|
+
scope: scopesToRequest(this.scope, (_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.scope, ((_b = options.authorizationParams) === null || _b === void 0 ? void 0 : _b.audience) || this.options.authorizationParams.audience)
|
|
8589
8628
|
})
|
|
8590
8629
|
});
|
|
8591
8630
|
const result = await singlePromise(() => this._getTokenSilently(localOptions), "".concat(this.options.clientId, "::").concat(localOptions.authorizationParams.audience, "::").concat(localOptions.authorizationParams.scope));
|
|
8592
8631
|
return options.detailedResponse ? result : result === null || result === void 0 ? void 0 : result.access_token;
|
|
8593
8632
|
}
|
|
8594
8633
|
async _getTokenSilently(options) {
|
|
8595
|
-
const {cacheMode: cacheMode} = options, getTokenOptions =
|
|
8634
|
+
const {cacheMode: cacheMode} = options, getTokenOptions = __rest(options, [ "cacheMode" ]);
|
|
8596
8635
|
if (cacheMode !== "off") {
|
|
8597
8636
|
const entry = await this._getEntryFromCache({
|
|
8598
8637
|
scope: getTokenOptions.authorizationParams.scope,
|
|
@@ -8622,13 +8661,13 @@ class Auth0Client {
|
|
|
8622
8661
|
}
|
|
8623
8662
|
const authResult = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(getTokenOptions) : await this._getTokenFromIFrame(getTokenOptions);
|
|
8624
8663
|
const {id_token: id_token, token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = authResult;
|
|
8625
|
-
return
|
|
8664
|
+
return Object.assign(Object.assign({
|
|
8626
8665
|
id_token: id_token,
|
|
8627
8666
|
token_type: token_type,
|
|
8628
8667
|
access_token: access_token
|
|
8629
8668
|
}, oauthTokenScope ? {
|
|
8630
8669
|
scope: oauthTokenScope
|
|
8631
|
-
} : null), {
|
|
8670
|
+
} : null), {
|
|
8632
8671
|
expires_in: expires_in
|
|
8633
8672
|
});
|
|
8634
8673
|
});
|
|
@@ -8664,15 +8703,15 @@ class Auth0Client {
|
|
|
8664
8703
|
}
|
|
8665
8704
|
}
|
|
8666
8705
|
async getTokenWithPopup() {
|
|
8667
|
-
var _options$authorizatio4, _options$authorizatio5;
|
|
8668
8706
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8669
8707
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8708
|
+
var _a, _b;
|
|
8709
|
+
const localOptions = Object.assign(Object.assign({}, options), {
|
|
8710
|
+
authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), options.authorizationParams), {
|
|
8711
|
+
scope: scopesToRequest(this.scope, (_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.scope, ((_b = options.authorizationParams) === null || _b === void 0 ? void 0 : _b.audience) || this.options.authorizationParams.audience)
|
|
8673
8712
|
})
|
|
8674
8713
|
});
|
|
8675
|
-
config =
|
|
8714
|
+
config = Object.assign(Object.assign({}, DEFAULT_POPUP_CONFIG_OPTIONS), config);
|
|
8676
8715
|
await this.loginWithPopup(localOptions, config);
|
|
8677
8716
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
8678
8717
|
scope: localOptions.authorizationParams.scope,
|
|
@@ -8691,17 +8730,36 @@ class Auth0Client {
|
|
|
8691
8730
|
} else {
|
|
8692
8731
|
delete options.clientId;
|
|
8693
8732
|
}
|
|
8694
|
-
const
|
|
8733
|
+
const _a = options.logoutParams || {}, {federated: federated} = _a, logoutOptions = __rest(_a, [ "federated" ]);
|
|
8695
8734
|
const federatedQuery = federated ? "&federated" : "";
|
|
8696
|
-
const url = this._url("/v2/logout?".concat(createQueryParams(
|
|
8735
|
+
const url = this._url("/v2/logout?".concat(createQueryParams(Object.assign({
|
|
8697
8736
|
clientId: options.clientId
|
|
8698
8737
|
}, logoutOptions))));
|
|
8699
8738
|
return url + federatedQuery;
|
|
8700
8739
|
}
|
|
8740
|
+
async revokeRefreshToken() {
|
|
8741
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8742
|
+
if (!this.options.useRefreshTokens) {
|
|
8743
|
+
return;
|
|
8744
|
+
}
|
|
8745
|
+
const audience = options.audience || this.options.authorizationParams.audience;
|
|
8746
|
+
const resolvedAudience = audience || DEFAULT_AUDIENCE;
|
|
8747
|
+
const refreshTokens = await this.cacheManager.getRefreshTokensByAudience(resolvedAudience, this.options.clientId);
|
|
8748
|
+
await revokeToken({
|
|
8749
|
+
baseUrl: this.domainUrl,
|
|
8750
|
+
timeout: this.httpTimeoutMs,
|
|
8751
|
+
auth0Client: this.options.auth0Client,
|
|
8752
|
+
useFormData: this.options.useFormData,
|
|
8753
|
+
client_id: this.options.clientId,
|
|
8754
|
+
refreshTokens: refreshTokens,
|
|
8755
|
+
audience: resolvedAudience,
|
|
8756
|
+
onRefreshTokenRevoked: refreshToken => this.cacheManager.stripRefreshToken(refreshToken)
|
|
8757
|
+
}, this.worker);
|
|
8758
|
+
}
|
|
8701
8759
|
async logout() {
|
|
8702
|
-
var _this$dpop2;
|
|
8703
8760
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8704
|
-
|
|
8761
|
+
var _a;
|
|
8762
|
+
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _b, logoutOptions = __rest(_b, [ "openUrl" ]);
|
|
8705
8763
|
if (options.clientId === null) {
|
|
8706
8764
|
await this.cacheManager.clear();
|
|
8707
8765
|
} else {
|
|
@@ -8714,7 +8772,7 @@ class Auth0Client {
|
|
|
8714
8772
|
cookieDomain: this.options.cookieDomain
|
|
8715
8773
|
});
|
|
8716
8774
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
8717
|
-
await ((
|
|
8775
|
+
await ((_a = this.dpop) === null || _a === void 0 ? void 0 : _a.clear());
|
|
8718
8776
|
const url = this._buildLogoutUrl(logoutOptions);
|
|
8719
8777
|
if (openUrl) {
|
|
8720
8778
|
await openUrl(url);
|
|
@@ -8726,7 +8784,7 @@ class Auth0Client {
|
|
|
8726
8784
|
const iframeLockKey = buildIframeLockKey(this.options.clientId);
|
|
8727
8785
|
try {
|
|
8728
8786
|
return await this.lockManager.runWithLock(iframeLockKey, 5e3, async () => {
|
|
8729
|
-
const params =
|
|
8787
|
+
const params = Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8730
8788
|
prompt: "none"
|
|
8731
8789
|
});
|
|
8732
8790
|
const orgHint = this.cookieStorage.get(this.orgHintCookieName);
|
|
@@ -8743,14 +8801,14 @@ class Auth0Client {
|
|
|
8743
8801
|
let eventOrigin;
|
|
8744
8802
|
try {
|
|
8745
8803
|
eventOrigin = new URL(this.domainUrl).origin;
|
|
8746
|
-
} catch (
|
|
8804
|
+
} catch (_a) {
|
|
8747
8805
|
eventOrigin = this.domainUrl;
|
|
8748
8806
|
}
|
|
8749
8807
|
const codeResult = await runIframe(url, eventOrigin, authorizeTimeout);
|
|
8750
8808
|
if (stateIn !== codeResult.state) {
|
|
8751
8809
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
8752
8810
|
}
|
|
8753
|
-
const tokenResult = await this._requestToken(
|
|
8811
|
+
const tokenResult = await this._requestToken(Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8754
8812
|
code_verifier: code_verifier,
|
|
8755
8813
|
code: codeResult.code,
|
|
8756
8814
|
grant_type: "authorization_code",
|
|
@@ -8760,7 +8818,7 @@ class Auth0Client {
|
|
|
8760
8818
|
nonceIn: nonceIn,
|
|
8761
8819
|
organization: params.organization
|
|
8762
8820
|
});
|
|
8763
|
-
return
|
|
8821
|
+
return Object.assign(Object.assign({}, tokenResult), {
|
|
8764
8822
|
scope: scope,
|
|
8765
8823
|
oauthTokenScope: tokenResult.scope,
|
|
8766
8824
|
audience: audience
|
|
@@ -8779,6 +8837,7 @@ class Auth0Client {
|
|
|
8779
8837
|
}
|
|
8780
8838
|
}
|
|
8781
8839
|
async _getTokenUsingRefreshToken(options) {
|
|
8840
|
+
var _a, _b;
|
|
8782
8841
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
8783
8842
|
scope: options.authorizationParams.scope,
|
|
8784
8843
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
@@ -8794,16 +8853,16 @@ class Auth0Client {
|
|
|
8794
8853
|
const timeout = typeof options.timeoutInSeconds === "number" ? options.timeoutInSeconds * 1e3 : null;
|
|
8795
8854
|
const scopesToRequest = getScopeToRequest(this.options.useMrrt, options.authorizationParams, cache === null || cache === void 0 ? void 0 : cache.audience, cache === null || cache === void 0 ? void 0 : cache.scope);
|
|
8796
8855
|
try {
|
|
8797
|
-
const tokenResult = await this._requestToken(
|
|
8856
|
+
const tokenResult = await this._requestToken(Object.assign(Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8798
8857
|
grant_type: "refresh_token",
|
|
8799
8858
|
refresh_token: cache && cache.refresh_token,
|
|
8800
8859
|
redirect_uri: redirect_uri
|
|
8801
|
-
}, timeout && {
|
|
8860
|
+
}), timeout && {
|
|
8802
8861
|
timeout: timeout
|
|
8803
8862
|
}), {
|
|
8804
8863
|
scopesToRequest: scopesToRequest
|
|
8805
8864
|
});
|
|
8806
|
-
if (tokenResult.refresh_token && cache
|
|
8865
|
+
if (tokenResult.refresh_token && (cache === null || cache === void 0 ? void 0 : cache.refresh_token)) {
|
|
8807
8866
|
await this.cacheManager.updateEntry(cache.refresh_token, tokenResult.refresh_token);
|
|
8808
8867
|
}
|
|
8809
8868
|
if (this.options.useMrrt) {
|
|
@@ -8820,7 +8879,7 @@ class Auth0Client {
|
|
|
8820
8879
|
}
|
|
8821
8880
|
}
|
|
8822
8881
|
}
|
|
8823
|
-
return
|
|
8882
|
+
return Object.assign(Object.assign({}, tokenResult), {
|
|
8824
8883
|
scope: options.authorizationParams.scope,
|
|
8825
8884
|
oauthTokenScope: tokenResult.scope,
|
|
8826
8885
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE
|
|
@@ -8838,14 +8897,13 @@ class Auth0Client {
|
|
|
8838
8897
|
}
|
|
8839
8898
|
}
|
|
8840
8899
|
if (e instanceof MfaRequiredError) {
|
|
8841
|
-
|
|
8842
|
-
this.mfa.setMFAAuthDetails(e.mfa_token, (_options$authorizatio6 = options.authorizationParams) === null || _options$authorizatio6 === void 0 ? void 0 : _options$authorizatio6.scope, (_options$authorizatio7 = options.authorizationParams) === null || _options$authorizatio7 === void 0 ? void 0 : _options$authorizatio7.audience, e.mfa_requirements);
|
|
8900
|
+
this.mfa.setMFAAuthDetails(e.mfa_token, (_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.scope, (_b = options.authorizationParams) === null || _b === void 0 ? void 0 : _b.audience, e.mfa_requirements);
|
|
8843
8901
|
}
|
|
8844
8902
|
throw e;
|
|
8845
8903
|
}
|
|
8846
8904
|
}
|
|
8847
8905
|
async _saveEntryInCache(entry) {
|
|
8848
|
-
const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken =
|
|
8906
|
+
const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken = __rest(entry, [ "id_token", "decodedToken" ]);
|
|
8849
8907
|
this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, {
|
|
8850
8908
|
id_token: id_token,
|
|
8851
8909
|
decodedToken: decodedToken
|
|
@@ -8868,8 +8926,8 @@ class Auth0Client {
|
|
|
8868
8926
|
this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, cache);
|
|
8869
8927
|
return cache;
|
|
8870
8928
|
}
|
|
8871
|
-
async _getEntryFromCache(
|
|
8872
|
-
let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} =
|
|
8929
|
+
async _getEntryFromCache(_ref) {
|
|
8930
|
+
let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} = _ref;
|
|
8873
8931
|
const entry = await this.cacheManager.get(new CacheKey({
|
|
8874
8932
|
scope: scope,
|
|
8875
8933
|
audience: audience,
|
|
@@ -8878,20 +8936,21 @@ class Auth0Client {
|
|
|
8878
8936
|
if (entry && entry.access_token) {
|
|
8879
8937
|
const {token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = entry;
|
|
8880
8938
|
const cache = await this._getIdTokenFromCache();
|
|
8881
|
-
return cache &&
|
|
8939
|
+
return cache && Object.assign(Object.assign({
|
|
8882
8940
|
id_token: cache.id_token,
|
|
8883
8941
|
token_type: token_type ? token_type : "Bearer",
|
|
8884
8942
|
access_token: access_token
|
|
8885
8943
|
}, oauthTokenScope ? {
|
|
8886
8944
|
scope: oauthTokenScope
|
|
8887
|
-
} : null), {
|
|
8945
|
+
} : null), {
|
|
8888
8946
|
expires_in: expires_in
|
|
8889
8947
|
});
|
|
8890
8948
|
}
|
|
8891
8949
|
}
|
|
8892
8950
|
async _requestToken(options, additionalParameters) {
|
|
8951
|
+
var _a, _b;
|
|
8893
8952
|
const {nonceIn: nonceIn, organization: organization, scopesToRequest: scopesToRequest} = additionalParameters || {};
|
|
8894
|
-
const authResult = await oauthToken(
|
|
8953
|
+
const authResult = await oauthToken(Object.assign(Object.assign({
|
|
8895
8954
|
baseUrl: this.domainUrl,
|
|
8896
8955
|
client_id: this.options.clientId,
|
|
8897
8956
|
auth0Client: this.options.auth0Client,
|
|
@@ -8899,25 +8958,24 @@ class Auth0Client {
|
|
|
8899
8958
|
timeout: this.httpTimeoutMs,
|
|
8900
8959
|
useMrrt: this.options.useMrrt,
|
|
8901
8960
|
dpop: this.dpop
|
|
8902
|
-
}, options), {
|
|
8961
|
+
}, options), {
|
|
8903
8962
|
scope: scopesToRequest || options.scope
|
|
8904
8963
|
}), this.worker);
|
|
8905
8964
|
const decodedToken = await this._verifyIdToken(authResult.id_token, nonceIn, organization);
|
|
8906
8965
|
if (options.grant_type === "authorization_code") {
|
|
8907
|
-
var _existingIdToken$deco;
|
|
8908
8966
|
const existingIdToken = await this._getIdTokenFromCache();
|
|
8909
|
-
if (existingIdToken
|
|
8967
|
+
if (((_b = (_a = existingIdToken === null || existingIdToken === void 0 ? void 0 : existingIdToken.decodedToken) === null || _a === void 0 ? void 0 : _a.claims) === null || _b === void 0 ? void 0 : _b.sub) && existingIdToken.decodedToken.claims.sub !== decodedToken.claims.sub) {
|
|
8910
8968
|
await this.cacheManager.clear(this.options.clientId);
|
|
8911
8969
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
8912
8970
|
}
|
|
8913
8971
|
}
|
|
8914
|
-
await this._saveEntryInCache(
|
|
8972
|
+
await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, authResult), {
|
|
8915
8973
|
decodedToken: decodedToken,
|
|
8916
8974
|
scope: options.scope,
|
|
8917
8975
|
audience: options.audience || DEFAULT_AUDIENCE
|
|
8918
|
-
}, authResult.scope ? {
|
|
8976
|
+
}), authResult.scope ? {
|
|
8919
8977
|
oauthTokenScope: authResult.scope
|
|
8920
|
-
} : null), {
|
|
8978
|
+
} : null), {
|
|
8921
8979
|
client_id: this.options.clientId
|
|
8922
8980
|
}));
|
|
8923
8981
|
this.cookieStorage.save(this.isAuthenticatedCookieName, true, {
|
|
@@ -8925,12 +8983,12 @@ class Auth0Client {
|
|
|
8925
8983
|
cookieDomain: this.options.cookieDomain
|
|
8926
8984
|
});
|
|
8927
8985
|
this._processOrgHint(organization || decodedToken.claims.org_id);
|
|
8928
|
-
return
|
|
8986
|
+
return Object.assign(Object.assign({}, authResult), {
|
|
8929
8987
|
decodedToken: decodedToken
|
|
8930
8988
|
});
|
|
8931
8989
|
}
|
|
8932
8990
|
async loginWithCustomTokenExchange(options) {
|
|
8933
|
-
return this._requestToken(
|
|
8991
|
+
return this._requestToken(Object.assign(Object.assign({}, options), {
|
|
8934
8992
|
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
8935
8993
|
subject_token: options.subject_token,
|
|
8936
8994
|
subject_token_type: options.subject_token_type,
|
|
@@ -8964,10 +9022,10 @@ class Auth0Client {
|
|
|
8964
9022
|
return new Fetcher(config, {
|
|
8965
9023
|
isDpopEnabled: () => !!this.options.useDpop,
|
|
8966
9024
|
getAccessToken: authParams => {
|
|
8967
|
-
var
|
|
9025
|
+
var _a;
|
|
8968
9026
|
return this.getTokenSilently({
|
|
8969
9027
|
authorizationParams: {
|
|
8970
|
-
scope: authParams === null || authParams === void 0
|
|
9028
|
+
scope: (_a = authParams === null || authParams === void 0 ? void 0 : authParams.scope) === null || _a === void 0 ? void 0 : _a.join(" "),
|
|
8971
9029
|
audience: authParams === null || authParams === void 0 ? void 0 : authParams.audience
|
|
8972
9030
|
},
|
|
8973
9031
|
detailedResponse: true
|
|
@@ -9003,7 +9061,7 @@ class Auth0Client {
|
|
|
9003
9061
|
redirect_uri: redirectUri,
|
|
9004
9062
|
appState: appState,
|
|
9005
9063
|
connection: connection,
|
|
9006
|
-
response_type: ResponseType.ConnectCode
|
|
9064
|
+
response_type: exports.ResponseType.ConnectCode
|
|
9007
9065
|
});
|
|
9008
9066
|
const url = new URL(connect_uri);
|
|
9009
9067
|
url.searchParams.set("ticket", connect_params.ticket);
|
|
@@ -9014,8 +9072,8 @@ class Auth0Client {
|
|
|
9014
9072
|
}
|
|
9015
9073
|
}
|
|
9016
9074
|
async _requestTokenForMfa(options, additionalParameters) {
|
|
9017
|
-
const {mfaToken: mfaToken} = options, restOptions =
|
|
9018
|
-
return this._requestToken(
|
|
9075
|
+
const {mfaToken: mfaToken} = options, restOptions = __rest(options, [ "mfaToken" ]);
|
|
9076
|
+
return this._requestToken(Object.assign(Object.assign({}, restOptions), {
|
|
9019
9077
|
mfa_token: mfaToken
|
|
9020
9078
|
}), additionalParameters);
|
|
9021
9079
|
}
|
|
@@ -9067,8 +9125,6 @@ exports.PopupOpenError = PopupOpenError;
|
|
|
9067
9125
|
|
|
9068
9126
|
exports.PopupTimeoutError = PopupTimeoutError;
|
|
9069
9127
|
|
|
9070
|
-
exports.ResponseType = ResponseType;
|
|
9071
|
-
|
|
9072
9128
|
exports.TimeoutError = TimeoutError;
|
|
9073
9129
|
|
|
9074
9130
|
exports.UseDpopNonceError = UseDpopNonceError;
|