@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
|
@@ -3,145 +3,19 @@
|
|
|
3
3
|
factory(global.auth0 = {}));
|
|
4
4
|
})(this, function(exports) {
|
|
5
5
|
"use strict";
|
|
6
|
-
function
|
|
7
|
-
this.v = e, this.k = d;
|
|
8
|
-
}
|
|
9
|
-
function _assertClassBrand(e, t, n) {
|
|
10
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
11
|
-
throw new TypeError("Private element is not present on this object");
|
|
12
|
-
}
|
|
13
|
-
function _awaitAsyncGenerator(e) {
|
|
14
|
-
return new _OverloadYield(e, 0);
|
|
15
|
-
}
|
|
16
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
17
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
18
|
-
}
|
|
19
|
-
function _classPrivateFieldGet2(s, a) {
|
|
20
|
-
return s.get(_assertClassBrand(s, a));
|
|
21
|
-
}
|
|
22
|
-
function _classPrivateFieldInitSpec(e, t, a) {
|
|
23
|
-
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
24
|
-
}
|
|
25
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
26
|
-
return s.set(_assertClassBrand(s, a), r), r;
|
|
27
|
-
}
|
|
28
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
29
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
30
|
-
}
|
|
31
|
-
function _defineProperty(e, r, t) {
|
|
32
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
33
|
-
value: t,
|
|
34
|
-
enumerable: !0,
|
|
35
|
-
configurable: !0,
|
|
36
|
-
writable: !0
|
|
37
|
-
}) : e[r] = t, e;
|
|
38
|
-
}
|
|
39
|
-
function ownKeys(e, r) {
|
|
40
|
-
var t = Object.keys(e);
|
|
41
|
-
if (Object.getOwnPropertySymbols) {
|
|
42
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
43
|
-
r && (o = o.filter(function(r) {
|
|
44
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
45
|
-
})), t.push.apply(t, o);
|
|
46
|
-
}
|
|
47
|
-
return t;
|
|
48
|
-
}
|
|
49
|
-
function _objectSpread2(e) {
|
|
50
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
51
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
52
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
53
|
-
_defineProperty(e, r, t[r]);
|
|
54
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
55
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return e;
|
|
59
|
-
}
|
|
60
|
-
function _objectWithoutProperties(e, t) {
|
|
61
|
-
if (null == e) return {};
|
|
62
|
-
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
63
|
-
if (Object.getOwnPropertySymbols) {
|
|
64
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
65
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
66
|
-
}
|
|
67
|
-
return i;
|
|
68
|
-
}
|
|
69
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
70
|
-
if (null == r) return {};
|
|
6
|
+
function __rest(s, e) {
|
|
71
7
|
var t = {};
|
|
72
|
-
for (var
|
|
73
|
-
|
|
74
|
-
t[
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
9
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
10
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
75
11
|
}
|
|
76
12
|
return t;
|
|
77
13
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (void 0 !== e) {
|
|
82
|
-
var i = e.call(t, r || "default");
|
|
83
|
-
if ("object" != typeof i) return i;
|
|
84
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
85
|
-
}
|
|
86
|
-
return ("string" === r ? String : Number)(t);
|
|
87
|
-
}
|
|
88
|
-
function _toPropertyKey(t) {
|
|
89
|
-
var i = _toPrimitive(t, "string");
|
|
90
|
-
return "symbol" == typeof i ? i : i + "";
|
|
91
|
-
}
|
|
92
|
-
function _wrapAsyncGenerator(e) {
|
|
93
|
-
return function() {
|
|
94
|
-
return new AsyncGenerator(e.apply(this, arguments));
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function AsyncGenerator(e) {
|
|
98
|
-
var t, n;
|
|
99
|
-
function resume(t, n) {
|
|
100
|
-
try {
|
|
101
|
-
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
102
|
-
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
103
|
-
if (u) {
|
|
104
|
-
var i = "return" === t && o.k ? t : "next";
|
|
105
|
-
if (!o.k || n.done) return resume(i, n);
|
|
106
|
-
n = e[i](n).value;
|
|
107
|
-
}
|
|
108
|
-
settle(!!r.done, n);
|
|
109
|
-
}, function(e) {
|
|
110
|
-
resume("throw", e);
|
|
111
|
-
});
|
|
112
|
-
} catch (e) {
|
|
113
|
-
settle(2, e);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function settle(e, r) {
|
|
117
|
-
2 === e ? t.reject(r) : t.resolve({
|
|
118
|
-
value: r,
|
|
119
|
-
done: e
|
|
120
|
-
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
121
|
-
}
|
|
122
|
-
this._invoke = function(e, r) {
|
|
123
|
-
return new Promise(function(o, u) {
|
|
124
|
-
var i = {
|
|
125
|
-
key: e,
|
|
126
|
-
arg: r,
|
|
127
|
-
resolve: o,
|
|
128
|
-
reject: u,
|
|
129
|
-
next: null
|
|
130
|
-
};
|
|
131
|
-
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
132
|
-
});
|
|
133
|
-
}, "function" != typeof e.return && (this.return = void 0);
|
|
134
|
-
}
|
|
135
|
-
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
136
|
-
return this;
|
|
137
|
-
}, AsyncGenerator.prototype.next = function(e) {
|
|
138
|
-
return this._invoke("next", e);
|
|
139
|
-
}, AsyncGenerator.prototype.throw = function(e) {
|
|
140
|
-
return this._invoke("throw", e);
|
|
141
|
-
}, AsyncGenerator.prototype.return = function(e) {
|
|
142
|
-
return this._invoke("return", e);
|
|
14
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
15
|
+
var e = new Error(message);
|
|
16
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
143
17
|
};
|
|
144
|
-
var version = "2.
|
|
18
|
+
var version = "2.19.1";
|
|
145
19
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
146
20
|
const DEFAULT_POPUP_CONFIG_OPTIONS = {
|
|
147
21
|
timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
@@ -254,7 +128,6 @@
|
|
|
254
128
|
let exclude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
255
129
|
return value && !exclude.includes(value) ? value : "";
|
|
256
130
|
}
|
|
257
|
-
const _excluded$5 = [ "clientId" ];
|
|
258
131
|
const parseAuthenticationResult = queryString => {
|
|
259
132
|
if (queryString.indexOf("#") > -1) {
|
|
260
133
|
queryString = queryString.substring(0, queryString.indexOf("#"));
|
|
@@ -359,7 +232,7 @@
|
|
|
359
232
|
return random;
|
|
360
233
|
};
|
|
361
234
|
const encode$2 = value => btoa(value);
|
|
362
|
-
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) =>
|
|
235
|
+
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) => Object.assign(Object.assign({}, acc), {
|
|
363
236
|
[key]: params[key]
|
|
364
237
|
}), {});
|
|
365
238
|
const ALLOWED_AUTH0CLIENT_PROPERTIES = [ {
|
|
@@ -385,9 +258,9 @@
|
|
|
385
258
|
return acc;
|
|
386
259
|
}, {});
|
|
387
260
|
};
|
|
388
|
-
const createQueryParams =
|
|
389
|
-
|
|
390
|
-
return new URLSearchParams(stripUndefined(
|
|
261
|
+
const createQueryParams = _a => {
|
|
262
|
+
var {clientId: client_id} = _a, params = __rest(_a, [ "clientId" ]);
|
|
263
|
+
return new URLSearchParams(stripUndefined(Object.assign({
|
|
391
264
|
client_id: client_id
|
|
392
265
|
}, params))).toString();
|
|
393
266
|
};
|
|
@@ -437,8 +310,8 @@
|
|
|
437
310
|
}
|
|
438
311
|
return parseInt(value, 10) || undefined;
|
|
439
312
|
};
|
|
440
|
-
const fromEntries = iterable => [ ...iterable ].reduce((obj,
|
|
441
|
-
let [key, val] =
|
|
313
|
+
const fromEntries = iterable => [ ...iterable ].reduce((obj, _ref) => {
|
|
314
|
+
let [key, val] = _ref;
|
|
442
315
|
obj[key] = val;
|
|
443
316
|
return obj;
|
|
444
317
|
}, {});
|
|
@@ -978,9 +851,7 @@
|
|
|
978
851
|
}
|
|
979
852
|
class LegacyLockManager {
|
|
980
853
|
constructor() {
|
|
981
|
-
|
|
982
|
-
_defineProperty(this, "activeLocks", new Set);
|
|
983
|
-
_defineProperty(this, "pagehideHandler", void 0);
|
|
854
|
+
this.activeLocks = new Set;
|
|
984
855
|
this.lock = new _default;
|
|
985
856
|
this.pagehideHandler = () => {
|
|
986
857
|
this.activeLocks.forEach(key => this.lock.releaseLock(key));
|
|
@@ -1012,8 +883,8 @@
|
|
|
1012
883
|
}
|
|
1013
884
|
}
|
|
1014
885
|
function isWebLocksSupported() {
|
|
1015
|
-
var
|
|
1016
|
-
return typeof navigator !== "undefined" && typeof ((
|
|
886
|
+
var _a;
|
|
887
|
+
return typeof navigator !== "undefined" && typeof ((_a = navigator.locks) === null || _a === void 0 ? void 0 : _a.request) === "function";
|
|
1017
888
|
}
|
|
1018
889
|
function createLockManager() {
|
|
1019
890
|
return isWebLocksSupported() ? new WebLocksApiManager : new LegacyLockManager;
|
|
@@ -1347,21 +1218,12 @@
|
|
|
1347
1218
|
};
|
|
1348
1219
|
to.postMessage(message, [ messageChannel.port2 ]);
|
|
1349
1220
|
});
|
|
1350
|
-
const _excluded$4 = [ "error", "error_description" ];
|
|
1351
1221
|
const createAbortController = () => new AbortController;
|
|
1352
|
-
const
|
|
1353
|
-
const response = await fetch(fetchUrl, fetchOptions);
|
|
1354
|
-
return {
|
|
1355
|
-
ok: response.ok,
|
|
1356
|
-
json: await response.json(),
|
|
1357
|
-
headers: fromEntries(response.headers)
|
|
1358
|
-
};
|
|
1359
|
-
};
|
|
1360
|
-
const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
1222
|
+
const fetchWithTimeout = (fetchUrl, fetchOptions, timeout) => {
|
|
1361
1223
|
const controller = createAbortController();
|
|
1362
1224
|
fetchOptions.signal = controller.signal;
|
|
1363
1225
|
let timeoutId;
|
|
1364
|
-
return Promise.race([
|
|
1226
|
+
return Promise.race([ fetch(fetchUrl, fetchOptions), new Promise((_, reject) => {
|
|
1365
1227
|
timeoutId = setTimeout(() => {
|
|
1366
1228
|
controller.abort();
|
|
1367
1229
|
reject(new Error("Timeout when executing 'fetch'"));
|
|
@@ -1370,7 +1232,16 @@
|
|
|
1370
1232
|
clearTimeout(timeoutId);
|
|
1371
1233
|
});
|
|
1372
1234
|
};
|
|
1235
|
+
const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
1236
|
+
const response = await fetchWithTimeout(fetchUrl, fetchOptions, timeout);
|
|
1237
|
+
return {
|
|
1238
|
+
ok: response.ok,
|
|
1239
|
+
json: await response.json(),
|
|
1240
|
+
headers: fromEntries(response.headers)
|
|
1241
|
+
};
|
|
1242
|
+
};
|
|
1373
1243
|
const fetchWithWorker = async (fetchUrl, audience, scope, fetchOptions, timeout, worker, useFormData, useMrrt) => sendMessage({
|
|
1244
|
+
type: "refresh",
|
|
1374
1245
|
auth: {
|
|
1375
1246
|
audience: audience,
|
|
1376
1247
|
scope: scope
|
|
@@ -1397,7 +1268,7 @@
|
|
|
1397
1268
|
method: options.method || "GET",
|
|
1398
1269
|
nonce: await dpop.getNonce()
|
|
1399
1270
|
});
|
|
1400
|
-
options.headers =
|
|
1271
|
+
options.headers = Object.assign(Object.assign({}, options.headers), {
|
|
1401
1272
|
dpop: dpopProof
|
|
1402
1273
|
});
|
|
1403
1274
|
}
|
|
@@ -1415,7 +1286,7 @@
|
|
|
1415
1286
|
if (fetchError) {
|
|
1416
1287
|
throw fetchError;
|
|
1417
1288
|
}
|
|
1418
|
-
const
|
|
1289
|
+
const _a = response.json, {error: error, error_description: error_description} = _a, data = __rest(_a, [ "error", "error_description" ]), {headers: headers, ok: ok} = response;
|
|
1419
1290
|
let newDpopNonce;
|
|
1420
1291
|
if (dpop) {
|
|
1421
1292
|
newDpopNonce = headers[DPOP_NONCE_HEADER];
|
|
@@ -1441,12 +1312,11 @@
|
|
|
1441
1312
|
}
|
|
1442
1313
|
return data;
|
|
1443
1314
|
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
let {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData, useMrrt: useMrrt, dpop: dpop} = _ref, options = _objectWithoutProperties(_ref, _excluded$3);
|
|
1315
|
+
async function oauthToken(_a, worker) {
|
|
1316
|
+
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" ]);
|
|
1447
1317
|
const isTokenExchange = options.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
1448
1318
|
const refreshWithMrrt = options.grant_type === "refresh_token" && useMrrt;
|
|
1449
|
-
const allParams =
|
|
1319
|
+
const allParams = Object.assign(Object.assign(Object.assign(Object.assign({}, options), isTokenExchange && audience && {
|
|
1450
1320
|
audience: audience
|
|
1451
1321
|
}), isTokenExchange && scope && {
|
|
1452
1322
|
scope: scope
|
|
@@ -1465,6 +1335,63 @@
|
|
|
1465
1335
|
}
|
|
1466
1336
|
}, worker, useFormData, useMrrt, isDpopSupported ? dpop : undefined);
|
|
1467
1337
|
}
|
|
1338
|
+
async function revokeToken(_ref, worker) {
|
|
1339
|
+
let {baseUrl: baseUrl, timeout: timeout, auth0Client: auth0Client, useFormData: useFormData, refreshTokens: refreshTokens, audience: audience, client_id: client_id, onRefreshTokenRevoked: onRefreshTokenRevoked} = _ref;
|
|
1340
|
+
const resolvedTimeout = timeout || DEFAULT_FETCH_TIMEOUT_MS;
|
|
1341
|
+
const token_type_hint = "refresh_token";
|
|
1342
|
+
const fetchUrl = "".concat(baseUrl, "/oauth/revoke");
|
|
1343
|
+
const headers = {
|
|
1344
|
+
"Content-Type": useFormData ? "application/x-www-form-urlencoded" : "application/json",
|
|
1345
|
+
"Auth0-Client": btoa(JSON.stringify(stripAuth0Client(auth0Client || DEFAULT_AUTH0_CLIENT)))
|
|
1346
|
+
};
|
|
1347
|
+
if (worker) {
|
|
1348
|
+
const baseParams = {
|
|
1349
|
+
client_id: client_id,
|
|
1350
|
+
token_type_hint: token_type_hint
|
|
1351
|
+
};
|
|
1352
|
+
const body = useFormData ? createQueryParams(baseParams) : JSON.stringify(baseParams);
|
|
1353
|
+
try {
|
|
1354
|
+
return await sendMessage({
|
|
1355
|
+
type: "revoke",
|
|
1356
|
+
timeout: resolvedTimeout,
|
|
1357
|
+
fetchUrl: fetchUrl,
|
|
1358
|
+
fetchOptions: {
|
|
1359
|
+
method: "POST",
|
|
1360
|
+
body: body,
|
|
1361
|
+
headers: headers
|
|
1362
|
+
},
|
|
1363
|
+
useFormData: useFormData,
|
|
1364
|
+
auth: {
|
|
1365
|
+
audience: audience !== null && audience !== void 0 ? audience : DEFAULT_AUDIENCE
|
|
1366
|
+
}
|
|
1367
|
+
}, worker);
|
|
1368
|
+
} catch (e) {
|
|
1369
|
+
throw new GenericError("revoke_error", e.message);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
for (const refreshToken of refreshTokens) {
|
|
1373
|
+
const params = {
|
|
1374
|
+
client_id: client_id,
|
|
1375
|
+
token_type_hint: token_type_hint,
|
|
1376
|
+
token: refreshToken
|
|
1377
|
+
};
|
|
1378
|
+
const body = useFormData ? createQueryParams(params) : JSON.stringify(params);
|
|
1379
|
+
const response = await fetchWithTimeout(fetchUrl, {
|
|
1380
|
+
method: "POST",
|
|
1381
|
+
body: body,
|
|
1382
|
+
headers: headers
|
|
1383
|
+
}, resolvedTimeout);
|
|
1384
|
+
if (!response.ok) {
|
|
1385
|
+
let error;
|
|
1386
|
+
let errorDescription;
|
|
1387
|
+
try {
|
|
1388
|
+
({error: error, error_description: errorDescription} = JSON.parse(await response.text()));
|
|
1389
|
+
} catch (_a) {}
|
|
1390
|
+
throw new GenericError(error || "revoke_error", errorDescription || "HTTP error ".concat(response.status));
|
|
1391
|
+
}
|
|
1392
|
+
await (onRefreshTokenRevoked === null || onRefreshTokenRevoked === void 0 ? void 0 : onRefreshTokenRevoked(refreshToken));
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1468
1395
|
const dedupe = arr => Array.from(new Set(arr));
|
|
1469
1396
|
const getUniqueScopes = function getUniqueScopes() {
|
|
1470
1397
|
for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -1508,9 +1435,6 @@
|
|
|
1508
1435
|
let suffix = arguments.length > 2 ? arguments[2] : undefined;
|
|
1509
1436
|
this.prefix = prefix;
|
|
1510
1437
|
this.suffix = suffix;
|
|
1511
|
-
_defineProperty(this, "clientId", void 0);
|
|
1512
|
-
_defineProperty(this, "scope", void 0);
|
|
1513
|
-
_defineProperty(this, "audience", void 0);
|
|
1514
1438
|
this.clientId = data.clientId;
|
|
1515
1439
|
this.scope = data.scope;
|
|
1516
1440
|
this.audience = data.audience;
|
|
@@ -1558,7 +1482,7 @@
|
|
|
1558
1482
|
}
|
|
1559
1483
|
class InMemoryCache {
|
|
1560
1484
|
constructor() {
|
|
1561
|
-
|
|
1485
|
+
this.enclosedCache = function() {
|
|
1562
1486
|
let cache = {};
|
|
1563
1487
|
return {
|
|
1564
1488
|
set(key, entry) {
|
|
@@ -1578,7 +1502,7 @@
|
|
|
1578
1502
|
return Object.keys(cache);
|
|
1579
1503
|
}
|
|
1580
1504
|
};
|
|
1581
|
-
}()
|
|
1505
|
+
}();
|
|
1582
1506
|
}
|
|
1583
1507
|
}
|
|
1584
1508
|
const DEFAULT_EXPIRY_ADJUSTMENT_SECONDS = 0;
|
|
@@ -1586,17 +1510,16 @@
|
|
|
1586
1510
|
constructor(cache, keyManifest, nowProvider) {
|
|
1587
1511
|
this.cache = cache;
|
|
1588
1512
|
this.keyManifest = keyManifest;
|
|
1589
|
-
_defineProperty(this, "nowProvider", void 0);
|
|
1590
1513
|
this.nowProvider = nowProvider || DEFAULT_NOW_PROVIDER;
|
|
1591
1514
|
}
|
|
1592
1515
|
async setIdToken(clientId, idToken, decodedToken) {
|
|
1593
|
-
var
|
|
1516
|
+
var _a;
|
|
1594
1517
|
const cacheKey = this.getIdTokenCacheKey(clientId);
|
|
1595
1518
|
await this.cache.set(cacheKey, {
|
|
1596
1519
|
id_token: idToken,
|
|
1597
1520
|
decodedToken: decodedToken
|
|
1598
1521
|
});
|
|
1599
|
-
await ((
|
|
1522
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.add(cacheKey));
|
|
1600
1523
|
}
|
|
1601
1524
|
async getIdToken(cacheKey) {
|
|
1602
1525
|
const entry = await this.cache.get(this.getIdTokenCacheKey(cacheKey.clientId));
|
|
@@ -1625,13 +1548,16 @@
|
|
|
1625
1548
|
let expiryAdjustmentSeconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_EXPIRY_ADJUSTMENT_SECONDS;
|
|
1626
1549
|
let useMrrt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1627
1550
|
let cacheMode = arguments.length > 3 ? arguments[3] : undefined;
|
|
1551
|
+
var _a;
|
|
1628
1552
|
let wrappedEntry = await this.cache.get(cacheKey.toKey());
|
|
1553
|
+
let resolvedCacheKey = cacheKey;
|
|
1629
1554
|
if (!wrappedEntry) {
|
|
1630
1555
|
const keys = await this.getCacheKeys();
|
|
1631
1556
|
if (!keys) return;
|
|
1632
1557
|
const matchedKey = this.matchExistingCacheKey(cacheKey, keys);
|
|
1633
1558
|
if (matchedKey) {
|
|
1634
1559
|
wrappedEntry = await this.cache.get(matchedKey);
|
|
1560
|
+
resolvedCacheKey = CacheKey.fromKey(matchedKey);
|
|
1635
1561
|
}
|
|
1636
1562
|
if (!wrappedEntry && useMrrt && cacheMode !== "cache-only") {
|
|
1637
1563
|
return this.getEntryWithRefreshToken(cacheKey, keys);
|
|
@@ -1643,31 +1569,34 @@
|
|
|
1643
1569
|
const now = await this.nowProvider();
|
|
1644
1570
|
const nowSeconds = Math.floor(now / 1e3);
|
|
1645
1571
|
if (wrappedEntry.expiresAt - expiryAdjustmentSeconds < nowSeconds) {
|
|
1646
|
-
var _this$keyManifest2;
|
|
1647
1572
|
if (wrappedEntry.body.refresh_token) {
|
|
1648
|
-
return this.modifiedCachedEntry(wrappedEntry,
|
|
1573
|
+
return this.modifiedCachedEntry(wrappedEntry, resolvedCacheKey);
|
|
1649
1574
|
}
|
|
1650
|
-
await this.cache.remove(
|
|
1651
|
-
await ((
|
|
1575
|
+
await this.cache.remove(resolvedCacheKey.toKey());
|
|
1576
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.remove(resolvedCacheKey.toKey()));
|
|
1652
1577
|
return;
|
|
1653
1578
|
}
|
|
1654
1579
|
return wrappedEntry.body;
|
|
1655
1580
|
}
|
|
1656
1581
|
async modifiedCachedEntry(wrappedEntry, cacheKey) {
|
|
1657
|
-
|
|
1582
|
+
const strippedBody = {
|
|
1658
1583
|
refresh_token: wrappedEntry.body.refresh_token,
|
|
1659
1584
|
audience: wrappedEntry.body.audience,
|
|
1660
1585
|
scope: wrappedEntry.body.scope
|
|
1661
1586
|
};
|
|
1662
|
-
|
|
1587
|
+
const strippedEntry = {
|
|
1588
|
+
body: strippedBody,
|
|
1589
|
+
expiresAt: wrappedEntry.expiresAt
|
|
1590
|
+
};
|
|
1591
|
+
await this.cache.set(cacheKey.toKey(), strippedEntry);
|
|
1663
1592
|
return {
|
|
1664
|
-
refresh_token:
|
|
1665
|
-
audience:
|
|
1666
|
-
scope:
|
|
1593
|
+
refresh_token: strippedBody.refresh_token,
|
|
1594
|
+
audience: strippedBody.audience,
|
|
1595
|
+
scope: strippedBody.scope
|
|
1667
1596
|
};
|
|
1668
1597
|
}
|
|
1669
1598
|
async set(entry) {
|
|
1670
|
-
var
|
|
1599
|
+
var _a;
|
|
1671
1600
|
const cacheKey = new CacheKey({
|
|
1672
1601
|
clientId: entry.client_id,
|
|
1673
1602
|
scope: entry.scope,
|
|
@@ -1675,7 +1604,7 @@
|
|
|
1675
1604
|
});
|
|
1676
1605
|
const wrappedEntry = await this.wrapCacheEntry(entry);
|
|
1677
1606
|
await this.cache.set(cacheKey.toKey(), wrappedEntry);
|
|
1678
|
-
await ((
|
|
1607
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.add(cacheKey.toKey()));
|
|
1679
1608
|
}
|
|
1680
1609
|
async remove(client_id, audience, scope) {
|
|
1681
1610
|
const cacheKey = new CacheKey({
|
|
@@ -1685,15 +1614,27 @@
|
|
|
1685
1614
|
});
|
|
1686
1615
|
await this.cache.remove(cacheKey.toKey());
|
|
1687
1616
|
}
|
|
1617
|
+
async stripRefreshToken(refreshToken) {
|
|
1618
|
+
var _a;
|
|
1619
|
+
const keys = await this.getCacheKeys();
|
|
1620
|
+
if (!keys) return;
|
|
1621
|
+
for (const key of keys) {
|
|
1622
|
+
const entry = await this.cache.get(key);
|
|
1623
|
+
if (((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) === refreshToken) {
|
|
1624
|
+
delete entry.body.refresh_token;
|
|
1625
|
+
await this.cache.set(key, entry);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1688
1629
|
async clear(clientId) {
|
|
1689
|
-
var
|
|
1630
|
+
var _a;
|
|
1690
1631
|
const keys = await this.getCacheKeys();
|
|
1691
1632
|
if (!keys) return;
|
|
1692
1633
|
await keys.filter(key => clientId ? key.includes(clientId) : true).reduce(async (memo, key) => {
|
|
1693
1634
|
await memo;
|
|
1694
1635
|
await this.cache.remove(key);
|
|
1695
1636
|
}, Promise.resolve());
|
|
1696
|
-
await ((
|
|
1637
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.clear());
|
|
1697
1638
|
}
|
|
1698
1639
|
async wrapCacheEntry(entry) {
|
|
1699
1640
|
const now = await this.nowProvider();
|
|
@@ -1704,9 +1645,9 @@
|
|
|
1704
1645
|
};
|
|
1705
1646
|
}
|
|
1706
1647
|
async getCacheKeys() {
|
|
1648
|
+
var _a;
|
|
1707
1649
|
if (this.keyManifest) {
|
|
1708
|
-
|
|
1709
|
-
return (_await$this$keyManife = await this.keyManifest.get()) === null || _await$this$keyManife === void 0 ? void 0 : _await$this$keyManife.keys;
|
|
1650
|
+
return (_a = await this.keyManifest.get()) === null || _a === void 0 ? void 0 : _a.keys;
|
|
1710
1651
|
} else if (this.cache.allKeys) {
|
|
1711
1652
|
return this.cache.allKeys();
|
|
1712
1653
|
}
|
|
@@ -1718,34 +1659,54 @@
|
|
|
1718
1659
|
}
|
|
1719
1660
|
matchExistingCacheKey(keyToMatch, allKeys) {
|
|
1720
1661
|
return allKeys.filter(key => {
|
|
1721
|
-
var
|
|
1662
|
+
var _a;
|
|
1722
1663
|
const cacheKey = CacheKey.fromKey(key);
|
|
1723
1664
|
const scopeSet = new Set(cacheKey.scope && cacheKey.scope.split(" "));
|
|
1724
|
-
const scopesToMatch = ((
|
|
1665
|
+
const scopesToMatch = ((_a = keyToMatch.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
1725
1666
|
const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((acc, current) => acc && scopeSet.has(current), true);
|
|
1726
1667
|
return cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId && cacheKey.audience === keyToMatch.audience && hasAllScopes;
|
|
1727
1668
|
})[0];
|
|
1728
1669
|
}
|
|
1729
1670
|
async getEntryWithRefreshToken(keyToMatch, allKeys) {
|
|
1671
|
+
var _a;
|
|
1730
1672
|
for (const key of allKeys) {
|
|
1731
1673
|
const cacheKey = CacheKey.fromKey(key);
|
|
1732
1674
|
if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId) {
|
|
1733
|
-
var _cachedEntry$body;
|
|
1734
1675
|
const cachedEntry = await this.cache.get(key);
|
|
1735
|
-
if (cachedEntry
|
|
1736
|
-
return
|
|
1676
|
+
if ((_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
|
|
1677
|
+
return {
|
|
1678
|
+
refresh_token: cachedEntry.body.refresh_token,
|
|
1679
|
+
audience: cachedEntry.body.audience,
|
|
1680
|
+
scope: cachedEntry.body.scope
|
|
1681
|
+
};
|
|
1737
1682
|
}
|
|
1738
1683
|
}
|
|
1739
1684
|
}
|
|
1740
1685
|
return undefined;
|
|
1741
1686
|
}
|
|
1687
|
+
async getRefreshTokensByAudience(audience, clientId) {
|
|
1688
|
+
var _a;
|
|
1689
|
+
const keys = await this.getCacheKeys();
|
|
1690
|
+
if (!keys) return [];
|
|
1691
|
+
const tokens = new Set;
|
|
1692
|
+
for (const key of keys) {
|
|
1693
|
+
const cacheKey = CacheKey.fromKey(key);
|
|
1694
|
+
if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === clientId && cacheKey.audience === audience) {
|
|
1695
|
+
const entry = await this.cache.get(key);
|
|
1696
|
+
if ((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
|
|
1697
|
+
tokens.add(entry.body.refresh_token);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
return Array.from(tokens);
|
|
1702
|
+
}
|
|
1742
1703
|
async updateEntry(oldRefreshToken, newRefreshToken) {
|
|
1704
|
+
var _a;
|
|
1743
1705
|
const allKeys = await this.getCacheKeys();
|
|
1744
1706
|
if (!allKeys) return;
|
|
1745
1707
|
for (const key of allKeys) {
|
|
1746
|
-
var _entry$body;
|
|
1747
1708
|
const entry = await this.cache.get(key);
|
|
1748
|
-
if ((entry === null || entry === void 0
|
|
1709
|
+
if (((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) === oldRefreshToken) {
|
|
1749
1710
|
entry.body.refresh_token = newRefreshToken;
|
|
1750
1711
|
await this.cache.set(key, entry);
|
|
1751
1712
|
}
|
|
@@ -1758,7 +1719,6 @@
|
|
|
1758
1719
|
this.storage = storage;
|
|
1759
1720
|
this.clientId = clientId;
|
|
1760
1721
|
this.cookieDomain = cookieDomain;
|
|
1761
|
-
_defineProperty(this, "storageKey", void 0);
|
|
1762
1722
|
this.storageKey = "".concat(TRANSACTION_STORAGE_KEY_PREFIX, ".").concat(this.clientId);
|
|
1763
1723
|
}
|
|
1764
1724
|
create(transaction) {
|
|
@@ -1982,17 +1942,17 @@
|
|
|
1982
1942
|
sameSite: "none"
|
|
1983
1943
|
};
|
|
1984
1944
|
}
|
|
1985
|
-
if (options
|
|
1945
|
+
if (options === null || options === void 0 ? void 0 : options.daysUntilExpire) {
|
|
1986
1946
|
cookieAttributes.expires = options.daysUntilExpire;
|
|
1987
1947
|
}
|
|
1988
|
-
if (options
|
|
1948
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
1989
1949
|
cookieAttributes.domain = options.cookieDomain;
|
|
1990
1950
|
}
|
|
1991
1951
|
set_1(key, JSON.stringify(value), cookieAttributes);
|
|
1992
1952
|
},
|
|
1993
1953
|
remove(key, options) {
|
|
1994
1954
|
let cookieAttributes = {};
|
|
1995
|
-
if (options
|
|
1955
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
1996
1956
|
cookieAttributes.domain = options.cookieDomain;
|
|
1997
1957
|
}
|
|
1998
1958
|
remove_1(key, cookieAttributes);
|
|
@@ -2014,10 +1974,10 @@
|
|
|
2014
1974
|
secure: true
|
|
2015
1975
|
};
|
|
2016
1976
|
}
|
|
2017
|
-
if (options
|
|
1977
|
+
if (options === null || options === void 0 ? void 0 : options.daysUntilExpire) {
|
|
2018
1978
|
cookieAttributes.expires = options.daysUntilExpire;
|
|
2019
1979
|
}
|
|
2020
|
-
if (options
|
|
1980
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2021
1981
|
cookieAttributes.domain = options.cookieDomain;
|
|
2022
1982
|
}
|
|
2023
1983
|
set_1("".concat(LEGACY_PREFIX).concat(key), JSON.stringify(value), cookieAttributes);
|
|
@@ -2025,7 +1985,7 @@
|
|
|
2025
1985
|
},
|
|
2026
1986
|
remove(key, options) {
|
|
2027
1987
|
let cookieAttributes = {};
|
|
2028
|
-
if (options
|
|
1988
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2029
1989
|
cookieAttributes.domain = options.cookieDomain;
|
|
2030
1990
|
}
|
|
2031
1991
|
remove_1(key, cookieAttributes);
|
|
@@ -2051,35 +2011,12 @@
|
|
|
2051
2011
|
sessionStorage.removeItem(key);
|
|
2052
2012
|
}
|
|
2053
2013
|
};
|
|
2054
|
-
|
|
2014
|
+
exports.ResponseType = void 0;
|
|
2015
|
+
(function(ResponseType) {
|
|
2055
2016
|
ResponseType["Code"] = "code";
|
|
2056
2017
|
ResponseType["ConnectCode"] = "connect_code";
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
class User {
|
|
2060
|
-
constructor() {
|
|
2061
|
-
_defineProperty(this, "name", void 0);
|
|
2062
|
-
_defineProperty(this, "given_name", void 0);
|
|
2063
|
-
_defineProperty(this, "family_name", void 0);
|
|
2064
|
-
_defineProperty(this, "middle_name", void 0);
|
|
2065
|
-
_defineProperty(this, "nickname", void 0);
|
|
2066
|
-
_defineProperty(this, "preferred_username", void 0);
|
|
2067
|
-
_defineProperty(this, "profile", void 0);
|
|
2068
|
-
_defineProperty(this, "picture", void 0);
|
|
2069
|
-
_defineProperty(this, "website", void 0);
|
|
2070
|
-
_defineProperty(this, "email", void 0);
|
|
2071
|
-
_defineProperty(this, "email_verified", void 0);
|
|
2072
|
-
_defineProperty(this, "gender", void 0);
|
|
2073
|
-
_defineProperty(this, "birthdate", void 0);
|
|
2074
|
-
_defineProperty(this, "zoneinfo", void 0);
|
|
2075
|
-
_defineProperty(this, "locale", void 0);
|
|
2076
|
-
_defineProperty(this, "phone_number", void 0);
|
|
2077
|
-
_defineProperty(this, "phone_number_verified", void 0);
|
|
2078
|
-
_defineProperty(this, "address", void 0);
|
|
2079
|
-
_defineProperty(this, "updated_at", void 0);
|
|
2080
|
-
_defineProperty(this, "sub", void 0);
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2018
|
+
})(exports.ResponseType || (exports.ResponseType = {}));
|
|
2019
|
+
class User {}
|
|
2083
2020
|
function decodeBase64$1(base64, enableUnicode) {
|
|
2084
2021
|
var binaryString = atob(base64);
|
|
2085
2022
|
if (enableUnicode) {
|
|
@@ -2109,7 +2046,7 @@
|
|
|
2109
2046
|
return new Worker(url, options);
|
|
2110
2047
|
};
|
|
2111
2048
|
}
|
|
2112
|
-
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBmdW5jdGlvbiBfZGVmaW5lUHJvcGVydHkoZSwgciwgdCkgewogICAgICAgIHJldHVybiAociA9IF90b1Byb3BlcnR5S2V5KHIpKSBpbiBlID8gT2JqZWN0LmRlZmluZVByb3BlcnR5KGUsIHIsIHsKICAgICAgICAgICAgdmFsdWU6IHQsCiAgICAgICAgICAgIGVudW1lcmFibGU6ICEwLAogICAgICAgICAgICBjb25maWd1cmFibGU6ICEwLAogICAgICAgICAgICB3cml0YWJsZTogITAKICAgICAgICB9KSA6IGVbcl0gPSB0LCBlOwogICAgfQogICAgZnVuY3Rpb24gb3duS2V5cyhlLCByKSB7CiAgICAgICAgdmFyIHQgPSBPYmplY3Qua2V5cyhlKTsKICAgICAgICBpZiAoT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scykgewogICAgICAgICAgICB2YXIgbyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7CiAgICAgICAgICAgIHIgJiYgKG8gPSBvLmZpbHRlcihmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihlLCByKS5lbnVtZXJhYmxlOwogICAgICAgICAgICB9KSksIHQucHVzaC5hcHBseSh0LCBvKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHQ7CiAgICB9CiAgICBmdW5jdGlvbiBfb2JqZWN0U3ByZWFkMihlKSB7CiAgICAgICAgZm9yICh2YXIgciA9IDE7IHIgPCBhcmd1bWVudHMubGVuZ3RoOyByKyspIHsKICAgICAgICAgICAgdmFyIHQgPSBudWxsICE9IGFyZ3VtZW50c1tyXSA/IGFyZ3VtZW50c1tyXSA6IHt9OwogICAgICAgICAgICByICUgMiA/IG93bktleXMoT2JqZWN0KHQpLCAhMCkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoZSwgciwgdFtyXSk7CiAgICAgICAgICAgIH0pIDogT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnMgPyBPYmplY3QuZGVmaW5lUHJvcGVydGllcyhlLCBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyh0KSkgOiBvd25LZXlzKE9iamVjdCh0KSkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZSwgciwgT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcih0LCByKSk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllcyhlLCB0KSB7CiAgICAgICAgaWYgKG51bGwgPT0gZSkgcmV0dXJuIHt9OwogICAgICAgIHZhciBvLCByLCBpID0gX29iamVjdFdpdGhvdXRQcm9wZXJ0aWVzTG9vc2UoZSwgdCk7CiAgICAgICAgaWYgKE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMpIHsKICAgICAgICAgICAgdmFyIG4gPSBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpOwogICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgbi5sZW5ndGg7IHIrKykgbyA9IG5bcl0sIC0xID09PSB0LmluZGV4T2YobykgJiYge30ucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLCBvKSAmJiAoaVtvXSA9IGVbb10pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllc0xvb3NlKHIsIGUpIHsKICAgICAgICBpZiAobnVsbCA9PSByKSByZXR1cm4ge307CiAgICAgICAgdmFyIHQgPSB7fTsKICAgICAgICBmb3IgKHZhciBuIGluIHIpIGlmICh7fS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHIsIG4pKSB7CiAgICAgICAgICAgIGlmICgtMSAhPT0gZS5pbmRleE9mKG4pKSBjb250aW51ZTsKICAgICAgICAgICAgdFtuXSA9IHJbbl07CiAgICAgICAgfQogICAgICAgIHJldHVybiB0OwogICAgfQogICAgZnVuY3Rpb24gX3RvUHJpbWl0aXZlKHQsIHIpIHsKICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIHQgfHwgIXQpIHJldHVybiB0OwogICAgICAgIHZhciBlID0gdFtTeW1ib2wudG9QcmltaXRpdmVdOwogICAgICAgIGlmICh2b2lkIDAgIT09IGUpIHsKICAgICAgICAgICAgdmFyIGkgPSBlLmNhbGwodCwgciB8fCAiZGVmYXVsdCIpOwogICAgICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIGkpIHJldHVybiBpOwogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJAQHRvUHJpbWl0aXZlIG11c3QgcmV0dXJuIGEgcHJpbWl0aXZlIHZhbHVlLiIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gKCJzdHJpbmciID09PSByID8gU3RyaW5nIDogTnVtYmVyKSh0KTsKICAgIH0KICAgIGZ1bmN0aW9uIF90b1Byb3BlcnR5S2V5KHQpIHsKICAgICAgICB2YXIgaSA9IF90b1ByaW1pdGl2ZSh0LCAic3RyaW5nIik7CiAgICAgICAgcmV0dXJuICJzeW1ib2wiID09IHR5cGVvZiBpID8gaSA6IGkgKyAiIjsKICAgIH0KICAgIGNsYXNzIEdlbmVyaWNFcnJvciBleHRlbmRzIEVycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihlcnJvciwgZXJyb3JfZGVzY3JpcHRpb24pIHsKICAgICAgICAgICAgc3VwZXIoZXJyb3JfZGVzY3JpcHRpb24pOwogICAgICAgICAgICB0aGlzLmVycm9yID0gZXJyb3I7CiAgICAgICAgICAgIHRoaXMuZXJyb3JfZGVzY3JpcHRpb24gPSBlcnJvcl9kZXNjcmlwdGlvbjsKICAgICAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsIEdlbmVyaWNFcnJvci5wcm90b3R5cGUpOwogICAgICAgIH0KICAgICAgICBzdGF0aWMgZnJvbVBheWxvYWQoX3JlZikgewogICAgICAgICAgICBsZXQge2Vycm9yOiBlcnJvciwgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yX2Rlc2NyaXB0aW9ufSA9IF9yZWY7CiAgICAgICAgICAgIHJldHVybiBuZXcgR2VuZXJpY0Vycm9yKGVycm9yLCBlcnJvcl9kZXNjcmlwdGlvbik7CiAg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U1ycnQ6IHVzZU1ycnR9LCBwb3J0czogW3BvcnRdfSA9IF9yZWYyOwogICAgICAgIGxldCBoZWFkZXJzID0ge307CiAgICAgICAgbGV0IGpzb247CiAgICAgICAgbGV0IHJlZnJlc2hUb2tlbjsKICAgICAgICBjb25zdCB7YXVkaWVuY2U6IGF1ZGllbmNlLCBzY29wZTogc2NvcGV9ID0gYXV0aCB8fCB7fTsKICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBib2R5ID0gdXNlRm9ybURhdGEgPyBmb3JtRGF0YVRvT2JqZWN0KGZldGNoT3B0aW9ucy5ib2R5KSA6IEpTT04ucGFyc2UoZmV0Y2hPcHRpb25zLmJvZHkpOwogICAgICAgICAgICBpZiAoIWJvZHkucmVmcmVzaF90b2tlbiAmJiBib2R5LmdyYW50X3R5cGUgPT09ICJyZWZyZXNoX3Rva2VuIikgewogICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gZ2V0UmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBpZiAoIXJlZnJlc2hUb2tlbiAmJiB1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF0ZXN0UmVmcmVzaFRva2VuID0gcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0Rvd25zY29waW5nID0gY2hlY2tEb3duc2NvcGluZyhzY29wZSwgYXVkaWVuY2UpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXRlc3RSZWZyZXNoVG9rZW4gJiYgIWlzRG93bnNjb3BpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gbGF0ZXN0UmVmcmVzaFRva2VuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvcihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLmJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKF9vYmplY3RTcHJlYWQyKF9vYmplY3RTcHJlYWQyKHt9LCBib2R5KSwge30sIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKSA6IEpTT04uc3RyaW5naWZ5KF9vYmplY3RTcHJlYWQyKF9vYmplY3RTcHJlYWQyKHt9LCBib2R5KSwge30sIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICBpZiAodHlwZW9mIEFib3J0Q29udHJvbGxlciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5zaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgUHJvbWlzZS5yYWNlKFsgd2FpdCh0aW1lb3V0KSwgZmV0Y2goZmV0Y2hVcmwsIF9vYmplY3RTcHJlYWQyKHt9LCBmZXRjaE9wdGlvbnMpKSBdKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICBpZiAoYWJvcnRDb250cm9sbGVyKSBhYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVycyA9IGZyb21FbnRyaWVzKHJlc3BvbnNlLmhlYWRlcnMpOwogICAgICAgICAgICBqc29uID0gYXdhaXQgcmVzcG9uc2UuanNvbigpOwogICAgICAgICAgICBpZiAoanNvbi5yZWZyZXNoX3Rva2VuKSB7CiAgICAgICAgICAgICAgICBpZiAodXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl0gPSBqc29uLnJlZnJlc2hfdG9rZW47CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUmVmcmVzaFRva2VucyhyZWZyZXNoVG9rZW4sIGpzb24ucmVmcmVzaF90b2tlbik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzZXRSZWZyZXNoVG9rZW4oanNvbi5yZWZyZXNoX3Rva2VuLCBhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgZGVsZXRlIGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IHJlc3BvbnNlLm9rLAogICAgICAgICAgICAgICAganNvbjoganNvbiwKICAgICAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMKICAgICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICBqc29uOiB7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLmVycm9yLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgY29uc3QgaXNBdXRob3JpemVkV29ya2VyUmVxdWVzdCA9IHdvcmtlclJlcXVlc3QgPT4gewogICAgICAgIGlmICghYWxsb3dlZEJhc2VVcmwpIHsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBhbGxvd2VkQmFzZU9yaWdpbiA9IG5ldyBVUkwoYWxsb3dlZEJhc2VVcmwpLm9yaWdpbjsKICAgICAgICAgICAgY29uc3QgcmVxdWVzdGVkVXJsID0gbmV3IFVSTCh3b3JrZXJSZXF1ZXN0LmZldGNoVXJsKTsKICAgICAgICAgICAgcmV0dXJuIHJlcXVlc3RlZFVybC5vcmlnaW4gPT09IGFsbG93ZWRCYXNlT3JpZ2luICYmIHJlcXVlc3RlZFVybC5wYXRobmFtZSA9PT0gIi9vYXV0aC90b2tlbiI7CiAgICAgICAgfSBjYXRjaCAoX3VudXNlZCkgewogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgfTsKICAgIGNvbnN0IG1lc3NhZ2VSb3V0ZXIgPSBldmVudCA9PiB7CiAgICAgICAgY29uc3Qge2RhdGE6IGRhdGEsIHBvcnRzOiBwb3J0c30gPSBldmVudDsKICAgICAgICBjb25zdCBbcG9ydF0gPSBwb3J0czsKICAgICAgICBpZiAoInR5cGUiIGluIGRhdGEgJiYgZGF0YS50eXBlID09PSAiaW5pdCIpIHsKICAgICAgICAgICAgaWYgKGFsbG93ZWRCYXNlVXJsID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgIG5ldyBVUkwoZGF0YS5hbGxvd2VkQmFzZVVybCk7CiAgICAgICAgICAgICAgICAgICAgYWxsb3dlZEJhc2VVcmwgPSBkYXRhLmFsbG93ZWRCYXNlVXJsOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoX3VudXNlZDIpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoISgiZmV0Y2hVcmwiIGluIGRhdGEpIHx8ICFpc0F1dGhvcml6ZWRXb3JrZXJSZXF1ZXN0KGRhdGEpKSB7CiAgICAgICAgICAgIHBvcnQgPT09IG51bGwgfHwgcG9ydCA9PT0gdm9pZCAwIHx8IHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IGZhbHNlLAogICAgICAgICAgICAgICAganNvbjogewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiaW52YWxpZF9mZXRjaF91cmwiLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiAiVW5hdXRob3JpemVkIGZldGNoIFVSTCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7fQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBtZXNzYWdlSGFuZGxlcihldmVudCk7CiAgICB9OwogICAgewogICAgICAgIGFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBtZXNzYWdlUm91dGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
2049
|
+
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBjbGFzcyBHZW5lcmljRXJyb3IgZXh0ZW5kcyBFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uKSB7CiAgICAgICAgICAgIHN1cGVyKGVycm9yX2Rlc2NyaXB0aW9uKTsKICAgICAgICAgICAgdGhpcy5lcnJvciA9IGVycm9yOwogICAgICAgICAgICB0aGlzLmVycm9yX2Rlc2NyaXB0aW9uID0gZXJyb3JfZGVzY3JpcHRpb247CiAgICAgICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLCBHZW5lcmljRXJyb3IucHJvdG90eXBlKTsKICAgICAgICB9CiAgICAgICAgc3RhdGljIGZyb21QYXlsb2FkKF9yZWYpIHsKICAgICAgICAgICAgbGV0IHtlcnJvcjogZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvcl9kZXNjcmlwdGlvbn0gPSBfcmVmOwogICAgICAgICAgICByZXR1cm4gbmV3IEdlbmVyaWNFcnJvcihlcnJvciwgZXJyb3JfZGVzY3JpcHRpb24pOwogICAgICAgIH0KICAgIH0KICAgIGNsYXNzIE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvciBleHRlbmRzIEdlbmVyaWNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoYXVkaWVuY2UsIHNjb3BlKSB7CiAgICAgICAgICAgIHN1cGVyKCJtaXNzaW5nX3JlZnJlc2hfdG9rZW4iLCAiTWlzc2luZyBSZWZyZXNoIFRva2VuI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mID0+IHsKICAgICAgICAgICAgbGV0IFtrZXksIHRva2VuXSA9IF9yZWY7CiAgICAgICAgICAgIGlmIChjYWNoZUtleUNvbnRhaW5zQXVkaWVuY2UoYXVkaWVuY2UsIGtleSkpIHsKICAgICAgICAgICAgICAgIHNlZW4uYWRkKHRva2VuKTsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgICAgIHJldHVybiBBcnJheS5mcm9tKHNlZW4pOwogICAgfTsKICAgIGNvbnN0IGRlbGV0ZVJlZnJlc2hUb2tlbnNCeVZhbHVlID0gcmVmcmVzaFRva2VuID0+IHsKICAgICAgICBPYmplY3QuZW50cmllcyhyZWZyZXNoVG9rZW5zKS5mb3JFYWNoKF9yZWYyID0+IHsKICAgICAgICAgICAgbGV0IFtrZXksIHRva2VuXSA9IF9yZWYyOwogICAgICAgICAgICBpZiAodG9rZW4gPT09IHJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgZGVsZXRlIHJlZnJlc2hUb2tlbnNba2V5XTsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHdhaXQgPSB0aW1lID0+IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gc2V0VGltZW91dChyZXNvbHZlLCB0aW1lKSk7CiAgICBjb25zdCBmb3JtRGF0YVRvT2JqZWN0ID0gZm9ybURhdGEgPT4gewogICAgICAgIGNvbnN0IHF1ZXJ5UGFyYW1zID0gbmV3IFVSTFNlYXJjaFBhcmFtcyhmb3JtRGF0YSk7CiAgICAgICAgY29uc3QgcGFyc2VkUXVlcnkgPSB7fTsKICAgICAgICBxdWVyeVBhcmFtcy5mb3JFYWNoKCh2YWwsIGtleSkgPT4gewogICAgICAgICAgICBwYXJzZWRRdWVyeVtrZXldID0gdmFsOwogICAgICAgIH0pOwogICAgICAgIHJldHVybiBwYXJzZWRRdWVyeTsKICAgIH07CiAgICBjb25zdCB1cGRhdGVSZWZyZXNoVG9rZW5zID0gKG9sZFJlZnJlc2hUb2tlbiwgbmV3UmVmcmVzaFRva2VuKSA9PiB7CiAgICAgICAgT2JqZWN0LmVudHJpZXMocmVmcmVzaFRva2VucykuZm9yRWFjaChfcmVmMyA9PiB7CiAgICAgICAgICAgIGxldCBba2V5LCB0b2tlbl0gPSBfcmVmMzsKICAgICAgICAgICAgaWYgKHRva2VuID09PSBvbGRSZWZyZXNoVG9rZW4pIHsKICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNba2V5XSA9IG5ld1JlZnJlc2hUb2tlbjsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IGNoZWNrRG93bnNjb3BpbmcgPSAoc2NvcGUsIGF1ZGllbmNlKSA9PiB7CiAgICAgICAgY29uc3QgZmluZENvaW5jaWRlbmNlID0gT2JqZWN0LmtleXMocmVmcmVzaFRva2VucykuZmluZChrZXkgPT4gewogICAgICAgICAgICBpZiAoa2V5ICE9PSAibGF0ZXN0X3JlZnJlc2hfdG9rZW4iKSB7CiAgICAgICAgICAgICAgICBjb25zdCBpc1NhbWVBdWRpZW5jZSA9IGNhY2hlS2V5Q29udGFpbnNBdWRpZW5jZShhdWRpZW5jZSwga2V5KTsKICAgICAgICAgICAgICAgIGNvbnN0IHNjb3Blc0tleSA9IGtleS5zcGxpdCgifCIpWzFdLnNwbGl0KCIgIik7CiAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ZWRTY29wZXMgPSBzY29wZS5zcGxpdCgiICIpOwogICAgICAgICAgICAgICAgY29uc3Qgc2NvcGVzQXJlSW5jbHVkZWQgPSByZXF1ZXN0ZWRTY29wZXMuZXZlcnkoa2V5ID0+IHNjb3Blc0tleS5pbmNsdWRlcyhrZXkpKTsKICAgICAgICAgICAgICAgIHJldHVybiBpc1NhbWVBdWRpZW5jZSAmJiBzY29wZXNBcmVJbmNsdWRlZDsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgICAgIHJldHVybiBmaW5kQ29pbmNpZGVuY2UgPyB0cnVlI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ICAgICAgICAgICAgICBpZiAobGF0ZXN0UmVmcmVzaFRva2VuICYmICFpc0Rvd25zY29waW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGxhdGVzdFJlZnJlc2hUb2tlbjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBNaXNzaW5nUmVmcmVzaFRva2VuRXJyb3IoYXVkaWVuY2UsIHNjb3BlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5ib2R5ID0gdXNlRm9ybURhdGEgPyBjcmVhdGVRdWVyeVBhcmFtcyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSkgOiBKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IGFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgaWYgKHR5cGVvZiBBYm9ydENvbnRyb2xsZXIgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgIGFib3J0Q29udHJvbGxlciA9IG5ldyBBYm9ydENvbnRyb2xsZXI7CiAgICAgICAgICAgICAgICBmZXRjaE9wdGlvbnMuc2lnbmFsID0gYWJvcnRDb250cm9sbGVyLnNpZ25hbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgcmVzcG9uc2U7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICByZXNwb25zZSA9IGF3YWl0IFByb21pc2UucmFjZShbIHdhaXQodGltZW91dCksIGZldGNoKGZldGNoVXJsLCBPYmplY3QuYXNzaWduKHt9LCBmZXRjaE9wdGlvbnMpKSBdKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICBpZiAoYWJvcnRDb250cm9sbGVyKSBhYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVycyA9IGZyb21FbnRyaWVzKHJlc3BvbnNlLmhlYWRlcnMpOwogICAgICAgICAgICBqc29uID0gYXdhaXQgcmVzcG9uc2UuanNvbigpOwogICAgICAgICAgICBpZiAoanNvbi5yZWZyZXNoX3Rva2VuKSB7CiAgICAgICAgICAgICAgICBpZiAodXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl0gPSBqc29uLnJlZnJlc2hfdG9rZW47CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUmVmcmVzaFRva2VucyhyZWZyZXNoVG9rZW4sIGpzb24ucmVmcmVzaF90b2tlbik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzZXRSZWZyZXNoVG9rZW4oanNvbi5yZWZyZXNoX3Rva2VuLCBhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgZGVsZXRlIGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IHJlc3BvbnNlLm9rLAogICAgICAgICAgICAgICAganNvbjoganNvbiwKICAgICAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMKICAgICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICBqc29uOiB7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLmVycm9yLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgY29uc3QgcmV2b2tlTWVzc2FnZUhhbmRsZXIgPSBhc3luYyBfcmVmNSA9PiB7CiAgICAgICAgbGV0IHtkYXRhOiB7dGltZW91dDogdGltZW91dCwgYXV0aDogYXV0aCwgZmV0Y2hVcmw6IGZldGNoVXJsLCBmZXRjaE9wdGlvbnM6IGZldGNoT3B0aW9ucywgdXNlRm9ybURhdGE6IHVzZUZvcm1EYXRhfSwgcG9ydHM6IFtwb3J0XX0gPSBfcmVmNTsKICAgICAgICBjb25zdCB7YXVkaWVuY2U6IGF1ZGllbmNlfSA9IGF1dGggfHwge307CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgdG9rZW5zVG9SZXZva2UgPSBnZXRSZWZyZXNoVG9rZW5zQnlBdWRpZW5jZShhdWRpZW5jZSk7CiAgICAgICAgICAgIGlmICh0b2tlbnNUb1Jldm9rZS5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIG9rOiB0cnVlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBiYXNlQm9keSA9IHVzZUZvcm1EYXRhID8gZm9ybURhdGFUb09iamVjdChmZXRjaE9wdGlvbnMuYm9keSkgOiBKU09OLnBhcnNlKGZldGNoT3B0aW9ucy5ib2R5KTsKICAgICAgICAgICAgZm9yIChjb25zdCByZWZyZXNoVG9rZW4gb2YgdG9rZW5zVG9SZXZva2UpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYmFzZUJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpIDogSlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LCBiYXNlQm9keSksIHsKICAgICAgICAgICAgICAgICAgICB0b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICAgICAgbGV0IHNpZ25hbDsKICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgQWJvcnRDb250cm9sbGVyID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgICAgICBzaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGV0IHRpbWVvdXRJZDsKICAgICAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBhd2FpdCBQcm9taXNlLnJhY2UoWyBuZXcgUHJvbWlzZShyZXNvbHZlID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGltZW91dElkID0gc2V0VGltZW91dChyZXNvbHZlLCB0aW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICB9KSwgZmV0Y2goZmV0Y2hVcmwsIE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgZmV0Y2hPcHRpb25zKSwgewogICAgICAgICAgICAgICAgICAgICAgICBib2R5OiBib2R5LAogICAgICAgICAgICAgICAgICAgICAgICBzaWduYWw6IHNpZ25hbAogICAgICAgICAgICAgICAgICAgIH0pKSBdKS5maW5hbGx5KCgpID0+IGNsZWFyVGltZW91dCh0aW1lb3V0SWQpKTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFyZXNwb25zZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICBlcnJvcjogIlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyIKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXJlc3BvbnNlLm9rKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGVycm9yRGVzY3JpcHRpb247CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qge2Vycm9yX2Rlc2NyaXB0aW9uOiBlcnJvcl9kZXNjcmlwdGlvbn0gPSBKU09OLnBhcnNlKGF3YWl0IHJlc3BvbnNlLnRleHQoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yRGVzY3JpcHRpb24gPSBlcnJvcl9kZXNjcmlwdGlvbjsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChfYSkge30KICAgICAgICAgICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yRGVzY3JpcHRpb24gfHwgIkhUVFAgZXJyb3IgIi5jb25jYXQocmVzcG9uc2Uuc3RhdHVzKQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbnNCeVZhbHVlKHJlZnJlc2hUb2tlbik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogdHJ1ZQogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlIHx8ICJVbmtub3duIGVycm9yIGR1cmluZyB0b2tlbiByZXZvY2F0aW9uIgogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgY29uc3QgaXNBdXRob3JpemVkV29ya2VyUmVxdWVzdCA9ICh3b3JrZXJSZXF1ZXN0LCBleHBlY3RlZFBhdGgpID0+IHsKICAgICAgICBpZiAoIWFsbG93ZWRCYXNlVXJsKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgYWxsb3dlZEJhc2VPcmlnaW4gPSBuZXcgVVJMKGFsbG93ZWRCYXNlVXJsKS5vcmlnaW47CiAgICAgICAgICAgIGNvbnN0IHJlcXVlc3RlZFVybCA9IG5ldyBVUkwod29ya2VyUmVxdWVzdC5mZXRjaFVybCk7CiAgICAgICAgICAgIHJldHVybiByZXF1ZXN0ZWRVcmwub3JpZ2luID09PSBhbGxvd2VkQmFzZU9yaWdpbiAmJiByZXF1ZXN0ZWRVcmwucGF0aG5hbWUgPT09IGV4cGVjdGVkUGF0aDsKICAgICAgICB9IGNhdGNoIChfYSkgewogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgfTsKICAgIGNvbnN0IG1lc3NhZ2VSb3V0ZXIgPSBldmVudCA9PiB7CiAgICAgICAgY29uc3Qge2RhdGE6IGRhdGEsIHBvcnRzOiBwb3J0c30gPSBldmVudDsKICAgICAgICBjb25zdCBbcG9ydF0gPSBwb3J0czsKICAgICAgICBpZiAoInR5cGUiIGluIGRhdGEgJiYgZGF0YS50eXBlID09PSAiaW5pdCIpIHsKICAgICAgICAgICAgaWYgKGFsbG93ZWRCYXNlVXJsID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgIG5ldyBVUkwoZGF0YS5hbGxvd2VkQmFzZVVybCk7CiAgICAgICAgICAgICAgICAgICAgYWxsb3dlZEJhc2VVcmwgPSBkYXRhLmFsbG93ZWRCYXNlVXJsOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoX2EpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoInR5cGUiIGluIGRhdGEgJiYgZGF0YS50eXBlID09PSAicmV2b2tlIikgewogICAgICAgICAgICBpZiAoIWlzQXV0aG9yaXplZFdvcmtlclJlcXVlc3QoZGF0YSwgIi9vYXV0aC9yZXZva2UiKSkgewogICAgICAgICAgICAgICAgcG9ydCA9PT0gbnVsbCB8fCBwb3J0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAganNvbjogewogICAgICAgICAgICAgICAgICAgICAgICBlcnJvcjogImludmFsaWRfZmV0Y2hfdXJsIiwKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246ICJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIgogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge30KICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldm9rZU1lc3NhZ2VIYW5kbGVyKGV2ZW50KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoISgiZmV0Y2hVcmwiIGluIGRhdGEpIHx8ICFpc0F1dGhvcml6ZWRXb3JrZXJSZXF1ZXN0KGRhdGEsICIvb2F1dGgvdG9rZW4iKSkgewogICAgICAgICAgICBwb3J0ID09PSBudWxsIHx8IHBvcnQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IGZhbHNlLAogICAgICAgICAgICAgICAganNvbjogewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiaW52YWxpZF9mZXRjaF91cmwiLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiAiVW5hdXRob3JpemVkIGZldGNoIFVSTCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7fQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBtZXNzYWdlSGFuZGxlcihldmVudCk7CiAgICB9OwogICAgewogICAgICAgIGFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBtZXNzYWdlUm91dGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
2113
2050
|
const singlePromiseMap = {};
|
|
2114
2051
|
const singlePromise = (cb, key) => {
|
|
2115
2052
|
let promise = singlePromiseMap[key];
|
|
@@ -2126,12 +2063,11 @@
|
|
|
2126
2063
|
constructor(cache, clientId) {
|
|
2127
2064
|
this.cache = cache;
|
|
2128
2065
|
this.clientId = clientId;
|
|
2129
|
-
_defineProperty(this, "manifestKey", void 0);
|
|
2130
2066
|
this.manifestKey = this.createManifestKeyFrom(this.clientId);
|
|
2131
2067
|
}
|
|
2132
2068
|
async add(key) {
|
|
2133
|
-
var
|
|
2134
|
-
const keys = new Set(((
|
|
2069
|
+
var _a;
|
|
2070
|
+
const keys = new Set(((_a = await this.cache.get(this.manifestKey)) === null || _a === void 0 ? void 0 : _a.keys) || []);
|
|
2135
2071
|
keys.add(key);
|
|
2136
2072
|
await this.cache.set(this.manifestKey, {
|
|
2137
2073
|
keys: [ ...keys ]
|
|
@@ -2160,7 +2096,6 @@
|
|
|
2160
2096
|
return "".concat(CACHE_KEY_PREFIX, "::").concat(clientId);
|
|
2161
2097
|
}
|
|
2162
2098
|
}
|
|
2163
|
-
const _excluded$2 = [ "openUrl", "onRedirect" ];
|
|
2164
2099
|
const GET_TOKEN_SILENTLY_LOCK_KEY = "auth0.lock.getTokenSilently";
|
|
2165
2100
|
const GET_TOKEN_FROM_IFRAME_LOCK_KEY = "auth0.lock.getTokenFromIFrame";
|
|
2166
2101
|
const buildGetTokenSilentlyLockKey = (clientId, audience) => "".concat(GET_TOKEN_SILENTLY_LOCK_KEY, ".").concat(clientId, ".").concat(audience);
|
|
@@ -2173,9 +2108,9 @@
|
|
|
2173
2108
|
localstorage: () => new LocalStorageCache
|
|
2174
2109
|
};
|
|
2175
2110
|
const cacheFactory = location => cacheLocationBuilders[location];
|
|
2176
|
-
const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) =>
|
|
2111
|
+
const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) => Object.assign(Object.assign(Object.assign({
|
|
2177
2112
|
client_id: clientOptions.clientId
|
|
2178
|
-
}, clientOptions.authorizationParams), authorizationParams), {
|
|
2113
|
+
}, clientOptions.authorizationParams), authorizationParams), {
|
|
2179
2114
|
scope: scopesToRequest(scope, authorizationParams.scope, authorizationParams.audience),
|
|
2180
2115
|
response_type: "code",
|
|
2181
2116
|
response_mode: response_mode || "query",
|
|
@@ -2187,8 +2122,8 @@
|
|
|
2187
2122
|
dpop_jkt: thumbprint
|
|
2188
2123
|
});
|
|
2189
2124
|
const patchOpenUrlWithOnRedirect = options => {
|
|
2190
|
-
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions =
|
|
2191
|
-
const result =
|
|
2125
|
+
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions = __rest(options, [ "openUrl", "onRedirect" ]);
|
|
2126
|
+
const result = Object.assign(Object.assign({}, originalOptions), {
|
|
2192
2127
|
openUrl: openUrl === false || openUrl ? openUrl : onRedirect
|
|
2193
2128
|
});
|
|
2194
2129
|
return result;
|
|
@@ -2205,13 +2140,13 @@
|
|
|
2205
2140
|
return missingScopes.join(",");
|
|
2206
2141
|
};
|
|
2207
2142
|
const getScopeToRequest = (useMrrt, authorizationParams, cachedAudience, cachedScope) => {
|
|
2143
|
+
var _a;
|
|
2208
2144
|
if (useMrrt && cachedAudience && cachedScope) {
|
|
2209
|
-
var _authorizationParams$;
|
|
2210
2145
|
if (authorizationParams.audience !== cachedAudience) {
|
|
2211
2146
|
return authorizationParams.scope;
|
|
2212
2147
|
}
|
|
2213
2148
|
const cachedScopes = cachedScope.split(" ");
|
|
2214
|
-
const newScopes = ((
|
|
2149
|
+
const newScopes = ((_a = authorizationParams.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
2215
2150
|
const newScopesAreIncluded = newScopes.every(scope => cachedScopes.includes(scope));
|
|
2216
2151
|
return cachedScopes.length >= newScopes.length && newScopesAreIncluded ? cachedScope : authorizationParams.scope;
|
|
2217
2152
|
}
|
|
@@ -2232,8 +2167,6 @@
|
|
|
2232
2167
|
const AUTH0_NONCE_ID = "auth0";
|
|
2233
2168
|
class DpopStorage {
|
|
2234
2169
|
constructor(clientId) {
|
|
2235
|
-
_defineProperty(this, "clientId", void 0);
|
|
2236
|
-
_defineProperty(this, "dbHandle", void 0);
|
|
2237
2170
|
this.clientId = clientId;
|
|
2238
2171
|
}
|
|
2239
2172
|
getVersion() {
|
|
@@ -2287,7 +2220,7 @@
|
|
|
2287
2220
|
}
|
|
2288
2221
|
async deleteBy(table, predicate) {
|
|
2289
2222
|
const allKeys = await this.executeDbRequest(table, "readonly", table => table.getAllKeys());
|
|
2290
|
-
allKeys === null || allKeys === void 0
|
|
2223
|
+
allKeys === null || allKeys === void 0 ? void 0 : allKeys.filter(predicate).map(k => this.executeDbRequest(table, "readwrite", table => table.delete(k)));
|
|
2291
2224
|
}
|
|
2292
2225
|
deleteByClientId(table, clientId) {
|
|
2293
2226
|
return this.deleteBy(table, k => typeof k === "string" && k.startsWith("".concat(clientId, "::")));
|
|
@@ -2301,7 +2234,6 @@
|
|
|
2301
2234
|
}
|
|
2302
2235
|
class Dpop {
|
|
2303
2236
|
constructor(clientId) {
|
|
2304
|
-
_defineProperty(this, "storage", void 0);
|
|
2305
2237
|
this.storage = new DpopStorage(clientId);
|
|
2306
2238
|
}
|
|
2307
2239
|
getNonce(id) {
|
|
@@ -2320,7 +2252,7 @@
|
|
|
2320
2252
|
}
|
|
2321
2253
|
async generateProof(params) {
|
|
2322
2254
|
const keyPair = await this.getOrGenerateKeyPair();
|
|
2323
|
-
return generateProof(
|
|
2255
|
+
return generateProof(Object.assign({
|
|
2324
2256
|
keyPair: keyPair
|
|
2325
2257
|
}, params));
|
|
2326
2258
|
}
|
|
@@ -2332,17 +2264,15 @@
|
|
|
2332
2264
|
await Promise.all([ this.storage.clearNonces(), this.storage.clearKeyPairs() ]);
|
|
2333
2265
|
}
|
|
2334
2266
|
}
|
|
2335
|
-
var TokenType
|
|
2267
|
+
var TokenType;
|
|
2268
|
+
(function(TokenType) {
|
|
2336
2269
|
TokenType["Bearer"] = "Bearer";
|
|
2337
2270
|
TokenType["DPoP"] = "DPoP";
|
|
2338
|
-
|
|
2339
|
-
}(TokenType || {});
|
|
2271
|
+
})(TokenType || (TokenType = {}));
|
|
2340
2272
|
class Fetcher {
|
|
2341
2273
|
constructor(config, hooks) {
|
|
2342
|
-
_defineProperty(this, "config", void 0);
|
|
2343
|
-
_defineProperty(this, "hooks", void 0);
|
|
2344
2274
|
this.hooks = hooks;
|
|
2345
|
-
this.config =
|
|
2275
|
+
this.config = Object.assign(Object.assign({}, config), {
|
|
2346
2276
|
fetch: config.fetch || (typeof window === "undefined" ? fetch : window.fetch.bind(window))
|
|
2347
2277
|
});
|
|
2348
2278
|
}
|
|
@@ -2450,7 +2380,7 @@
|
|
|
2450
2380
|
}
|
|
2451
2381
|
fetchWithAuth(info, init, authParams) {
|
|
2452
2382
|
const callbacks = {
|
|
2453
|
-
onUseDpopNonceError: () => this.internalFetchWithAuth(info, init,
|
|
2383
|
+
onUseDpopNonceError: () => this.internalFetchWithAuth(info, init, Object.assign(Object.assign({}, callbacks), {
|
|
2454
2384
|
onUseDpopNonceError: undefined
|
|
2455
2385
|
}), authParams)
|
|
2456
2386
|
};
|
|
@@ -2506,11 +2436,6 @@
|
|
|
2506
2436
|
constructor(_ref) {
|
|
2507
2437
|
let {type: type, status: status, title: title, detail: detail, validation_errors: validation_errors} = _ref;
|
|
2508
2438
|
super(detail);
|
|
2509
|
-
_defineProperty(this, "type", void 0);
|
|
2510
|
-
_defineProperty(this, "status", void 0);
|
|
2511
|
-
_defineProperty(this, "title", void 0);
|
|
2512
|
-
_defineProperty(this, "detail", void 0);
|
|
2513
|
-
_defineProperty(this, "validation_errors", void 0);
|
|
2514
2439
|
this.name = "MyAccountApiError";
|
|
2515
2440
|
this.type = type;
|
|
2516
2441
|
this.status = status;
|
|
@@ -2548,7 +2473,7 @@
|
|
|
2548
2473
|
};
|
|
2549
2474
|
function getAuthJsEnrollParams(params) {
|
|
2550
2475
|
const mapping = FACTOR_MAPPING[params.factorType];
|
|
2551
|
-
return
|
|
2476
|
+
return Object.assign(Object.assign(Object.assign({
|
|
2552
2477
|
mfaToken: params.mfaToken,
|
|
2553
2478
|
authenticatorTypes: mapping.authenticatorTypes
|
|
2554
2479
|
}, mapping.oobChannels && {
|
|
@@ -2571,6 +2496,144 @@
|
|
|
2571
2496
|
}
|
|
2572
2497
|
return undefined;
|
|
2573
2498
|
}
|
|
2499
|
+
function _OverloadYield(e, d) {
|
|
2500
|
+
this.v = e, this.k = d;
|
|
2501
|
+
}
|
|
2502
|
+
function _assertClassBrand(e, t, n) {
|
|
2503
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
2504
|
+
throw new TypeError("Private element is not present on this object");
|
|
2505
|
+
}
|
|
2506
|
+
function _awaitAsyncGenerator(e) {
|
|
2507
|
+
return new _OverloadYield(e, 0);
|
|
2508
|
+
}
|
|
2509
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
2510
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
2511
|
+
}
|
|
2512
|
+
function _classPrivateFieldGet2(s, a) {
|
|
2513
|
+
return s.get(_assertClassBrand(s, a));
|
|
2514
|
+
}
|
|
2515
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
2516
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
2517
|
+
}
|
|
2518
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
2519
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
2520
|
+
}
|
|
2521
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
2522
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
2523
|
+
}
|
|
2524
|
+
function _defineProperty(e, r, t) {
|
|
2525
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
2526
|
+
value: t,
|
|
2527
|
+
enumerable: !0,
|
|
2528
|
+
configurable: !0,
|
|
2529
|
+
writable: !0
|
|
2530
|
+
}) : e[r] = t, e;
|
|
2531
|
+
}
|
|
2532
|
+
function ownKeys(e, r) {
|
|
2533
|
+
var t = Object.keys(e);
|
|
2534
|
+
if (Object.getOwnPropertySymbols) {
|
|
2535
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2536
|
+
r && (o = o.filter(function(r) {
|
|
2537
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
2538
|
+
})), t.push.apply(t, o);
|
|
2539
|
+
}
|
|
2540
|
+
return t;
|
|
2541
|
+
}
|
|
2542
|
+
function _objectSpread2(e) {
|
|
2543
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2544
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2545
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
2546
|
+
_defineProperty(e, r, t[r]);
|
|
2547
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
2548
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
return e;
|
|
2552
|
+
}
|
|
2553
|
+
function _objectWithoutProperties(e, t) {
|
|
2554
|
+
if (null == e) return {};
|
|
2555
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
2556
|
+
if (Object.getOwnPropertySymbols) {
|
|
2557
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
2558
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
2559
|
+
}
|
|
2560
|
+
return i;
|
|
2561
|
+
}
|
|
2562
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
2563
|
+
if (null == r) return {};
|
|
2564
|
+
var t = {};
|
|
2565
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
2566
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
2567
|
+
t[n] = r[n];
|
|
2568
|
+
}
|
|
2569
|
+
return t;
|
|
2570
|
+
}
|
|
2571
|
+
function _toPrimitive(t, r) {
|
|
2572
|
+
if ("object" != typeof t || !t) return t;
|
|
2573
|
+
var e = t[Symbol.toPrimitive];
|
|
2574
|
+
if (void 0 !== e) {
|
|
2575
|
+
var i = e.call(t, r || "default");
|
|
2576
|
+
if ("object" != typeof i) return i;
|
|
2577
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2578
|
+
}
|
|
2579
|
+
return ("string" === r ? String : Number)(t);
|
|
2580
|
+
}
|
|
2581
|
+
function _toPropertyKey(t) {
|
|
2582
|
+
var i = _toPrimitive(t, "string");
|
|
2583
|
+
return "symbol" == typeof i ? i : i + "";
|
|
2584
|
+
}
|
|
2585
|
+
function _wrapAsyncGenerator(e) {
|
|
2586
|
+
return function() {
|
|
2587
|
+
return new AsyncGenerator(e.apply(this, arguments));
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
function AsyncGenerator(e) {
|
|
2591
|
+
var t, n;
|
|
2592
|
+
function resume(t, n) {
|
|
2593
|
+
try {
|
|
2594
|
+
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
2595
|
+
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
2596
|
+
if (u) {
|
|
2597
|
+
var i = "return" === t && o.k ? t : "next";
|
|
2598
|
+
if (!o.k || n.done) return resume(i, n);
|
|
2599
|
+
n = e[i](n).value;
|
|
2600
|
+
}
|
|
2601
|
+
settle(!!r.done, n);
|
|
2602
|
+
}, function(e) {
|
|
2603
|
+
resume("throw", e);
|
|
2604
|
+
});
|
|
2605
|
+
} catch (e) {
|
|
2606
|
+
settle(2, e);
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
function settle(e, r) {
|
|
2610
|
+
2 === e ? t.reject(r) : t.resolve({
|
|
2611
|
+
value: r,
|
|
2612
|
+
done: e
|
|
2613
|
+
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
2614
|
+
}
|
|
2615
|
+
this._invoke = function(e, r) {
|
|
2616
|
+
return new Promise(function(o, u) {
|
|
2617
|
+
var i = {
|
|
2618
|
+
key: e,
|
|
2619
|
+
arg: r,
|
|
2620
|
+
resolve: o,
|
|
2621
|
+
reject: u,
|
|
2622
|
+
next: null
|
|
2623
|
+
};
|
|
2624
|
+
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
2625
|
+
});
|
|
2626
|
+
}, "function" != typeof e.return && (this.return = void 0);
|
|
2627
|
+
}
|
|
2628
|
+
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
2629
|
+
return this;
|
|
2630
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
2631
|
+
return this._invoke("next", e);
|
|
2632
|
+
}, AsyncGenerator.prototype.throw = function(e) {
|
|
2633
|
+
return this._invoke("throw", e);
|
|
2634
|
+
}, AsyncGenerator.prototype.return = function(e) {
|
|
2635
|
+
return this._invoke("return", e);
|
|
2636
|
+
};
|
|
2574
2637
|
var _navigator$userAgent$2, _navigator$userAgent$$2;
|
|
2575
2638
|
let USER_AGENT$2;
|
|
2576
2639
|
if (typeof navigator === "undefined" || !((_navigator$userAgent$2 = navigator.userAgent) !== null && _navigator$userAgent$2 !== void 0 && (_navigator$userAgent$$2 = _navigator$userAgent$2.startsWith) !== null && _navigator$userAgent$$2 !== void 0 && _navigator$userAgent$$2.call(_navigator$userAgent$2, "Mozilla/5.0 "))) {
|
|
@@ -6526,7 +6589,7 @@
|
|
|
6526
6589
|
});
|
|
6527
6590
|
return remoteJWKSet;
|
|
6528
6591
|
}
|
|
6529
|
-
const _excluded
|
|
6592
|
+
const _excluded = [ "mfaToken" ], _excluded2 = [ "mfaToken" ];
|
|
6530
6593
|
var _baseUrl, _clientId, _customFetch, _entries, _ttlMs, _maxEntries, _configuration, _serverMetadata, _clientAuthPromise, _options, _customFetch2, _jwks, _discoveryCache, _inFlightDiscovery, _jwksCache, _Class9_brand;
|
|
6531
6594
|
var NotSupportedError = class NotSupportedError extends Error {
|
|
6532
6595
|
constructor(code, message) {
|
|
@@ -6746,7 +6809,7 @@
|
|
|
6746
6809
|
}
|
|
6747
6810
|
async enrollAuthenticator(options) {
|
|
6748
6811
|
const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/associate");
|
|
6749
|
-
const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded
|
|
6812
|
+
const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded);
|
|
6750
6813
|
const apiParams = {
|
|
6751
6814
|
authenticator_types: sdkParams.authenticatorTypes
|
|
6752
6815
|
};
|
|
@@ -6791,7 +6854,7 @@
|
|
|
6791
6854
|
}
|
|
6792
6855
|
async challengeAuthenticator(options) {
|
|
6793
6856
|
const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/challenge");
|
|
6794
|
-
const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2
|
|
6857
|
+
const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2);
|
|
6795
6858
|
const body = {
|
|
6796
6859
|
mfa_token: mfaToken,
|
|
6797
6860
|
client_id: _classPrivateFieldGet2(_clientId, this),
|
|
@@ -7511,13 +7574,12 @@
|
|
|
7511
7574
|
class MfaContextManager {
|
|
7512
7575
|
constructor() {
|
|
7513
7576
|
let ttlMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_TTL_MS;
|
|
7514
|
-
|
|
7515
|
-
_defineProperty(this, "ttlMs", void 0);
|
|
7577
|
+
this.contexts = new Map;
|
|
7516
7578
|
this.ttlMs = ttlMs;
|
|
7517
7579
|
}
|
|
7518
7580
|
set(mfaToken, context) {
|
|
7519
7581
|
this.cleanup();
|
|
7520
|
-
this.contexts.set(mfaToken,
|
|
7582
|
+
this.contexts.set(mfaToken, Object.assign(Object.assign({}, context), {
|
|
7521
7583
|
createdAt: Date.now()
|
|
7522
7584
|
}));
|
|
7523
7585
|
}
|
|
@@ -7549,9 +7611,6 @@
|
|
|
7549
7611
|
}
|
|
7550
7612
|
class MfaApiClient {
|
|
7551
7613
|
constructor(authJsMfaClient, auth0Client) {
|
|
7552
|
-
_defineProperty(this, "authJsMfaClient", void 0);
|
|
7553
|
-
_defineProperty(this, "auth0Client", void 0);
|
|
7554
|
-
_defineProperty(this, "contextManager", void 0);
|
|
7555
7614
|
this.authJsMfaClient = authJsMfaClient;
|
|
7556
7615
|
this.auth0Client = auth0Client;
|
|
7557
7616
|
this.contextManager = new MfaContextManager;
|
|
@@ -7564,9 +7623,9 @@
|
|
|
7564
7623
|
});
|
|
7565
7624
|
}
|
|
7566
7625
|
async getAuthenticators(mfaToken) {
|
|
7567
|
-
var
|
|
7626
|
+
var _a, _b;
|
|
7568
7627
|
const context = this.contextManager.get(mfaToken);
|
|
7569
|
-
if (!(context
|
|
7628
|
+
if (!((_a = context === null || context === void 0 ? void 0 : context.mfaRequirements) === null || _a === void 0 ? void 0 : _a.challenge) || context.mfaRequirements.challenge.length === 0) {
|
|
7570
7629
|
throw new MfaListAuthenticatorsError("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
|
|
7571
7630
|
}
|
|
7572
7631
|
const challengeTypes = context.mfaRequirements.challenge.map(c => c.type);
|
|
@@ -7580,25 +7639,25 @@
|
|
|
7580
7639
|
});
|
|
7581
7640
|
} catch (error) {
|
|
7582
7641
|
if (error instanceof MfaListAuthenticatorsError$1) {
|
|
7583
|
-
|
|
7584
|
-
throw new MfaListAuthenticatorsError((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.error, error.message);
|
|
7642
|
+
throw new MfaListAuthenticatorsError((_b = error.cause) === null || _b === void 0 ? void 0 : _b.error, error.message);
|
|
7585
7643
|
}
|
|
7586
7644
|
throw error;
|
|
7587
7645
|
}
|
|
7588
7646
|
}
|
|
7589
7647
|
async enroll(params) {
|
|
7648
|
+
var _a;
|
|
7590
7649
|
const authJsParams = getAuthJsEnrollParams(params);
|
|
7591
7650
|
try {
|
|
7592
7651
|
return await this.authJsMfaClient.enrollAuthenticator(authJsParams);
|
|
7593
7652
|
} catch (error) {
|
|
7594
7653
|
if (error instanceof MfaEnrollmentError$1) {
|
|
7595
|
-
|
|
7596
|
-
throw new MfaEnrollmentError((_error$cause2 = error.cause) === null || _error$cause2 === void 0 ? void 0 : _error$cause2.error, error.message);
|
|
7654
|
+
throw new MfaEnrollmentError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
|
|
7597
7655
|
}
|
|
7598
7656
|
throw error;
|
|
7599
7657
|
}
|
|
7600
7658
|
}
|
|
7601
7659
|
async challenge(params) {
|
|
7660
|
+
var _a;
|
|
7602
7661
|
try {
|
|
7603
7662
|
const authJsParams = {
|
|
7604
7663
|
challengeType: params.challengeType,
|
|
@@ -7610,8 +7669,7 @@
|
|
|
7610
7669
|
return await this.authJsMfaClient.challengeAuthenticator(authJsParams);
|
|
7611
7670
|
} catch (error) {
|
|
7612
7671
|
if (error instanceof MfaChallengeError$1) {
|
|
7613
|
-
|
|
7614
|
-
throw new MfaChallengeError((_error$cause3 = error.cause) === null || _error$cause3 === void 0 ? void 0 : _error$cause3.error, error.message);
|
|
7672
|
+
throw new MfaChallengeError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
|
|
7615
7673
|
}
|
|
7616
7674
|
throw error;
|
|
7617
7675
|
}
|
|
@@ -7660,37 +7718,18 @@
|
|
|
7660
7718
|
}
|
|
7661
7719
|
}
|
|
7662
7720
|
}
|
|
7663
|
-
const _excluded = [ "openUrl", "fragment", "appState" ], _excluded2 = [ "url" ], _excluded3 = [ "cacheMode" ], _excluded4 = [ "federated" ], _excluded5 = [ "openUrl" ], _excluded6 = [ "id_token", "decodedToken" ], _excluded7 = [ "mfaToken" ];
|
|
7664
7721
|
class Auth0Client {
|
|
7665
7722
|
constructor(options) {
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
_defineProperty(this, "lockManager", void 0);
|
|
7669
|
-
_defineProperty(this, "domainUrl", void 0);
|
|
7670
|
-
_defineProperty(this, "tokenIssuer", void 0);
|
|
7671
|
-
_defineProperty(this, "scope", void 0);
|
|
7672
|
-
_defineProperty(this, "cookieStorage", void 0);
|
|
7673
|
-
_defineProperty(this, "dpop", void 0);
|
|
7674
|
-
_defineProperty(this, "sessionCheckExpiryDays", void 0);
|
|
7675
|
-
_defineProperty(this, "orgHintCookieName", void 0);
|
|
7676
|
-
_defineProperty(this, "isAuthenticatedCookieName", void 0);
|
|
7677
|
-
_defineProperty(this, "nowProvider", void 0);
|
|
7678
|
-
_defineProperty(this, "httpTimeoutMs", void 0);
|
|
7679
|
-
_defineProperty(this, "options", void 0);
|
|
7680
|
-
_defineProperty(this, "userCache", (new InMemoryCache).enclosedCache);
|
|
7681
|
-
_defineProperty(this, "myAccountApi", void 0);
|
|
7682
|
-
_defineProperty(this, "mfa", void 0);
|
|
7683
|
-
_defineProperty(this, "worker", void 0);
|
|
7684
|
-
_defineProperty(this, "authJsClient", void 0);
|
|
7685
|
-
_defineProperty(this, "defaultOptions", {
|
|
7723
|
+
this.userCache = (new InMemoryCache).enclosedCache;
|
|
7724
|
+
this.defaultOptions = {
|
|
7686
7725
|
authorizationParams: {
|
|
7687
7726
|
scope: DEFAULT_SCOPE
|
|
7688
7727
|
},
|
|
7689
7728
|
useRefreshTokensFallback: false,
|
|
7690
7729
|
useFormData: true
|
|
7691
|
-
}
|
|
7692
|
-
this.options =
|
|
7693
|
-
authorizationParams:
|
|
7730
|
+
};
|
|
7731
|
+
this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), options), {
|
|
7732
|
+
authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), options.authorizationParams)
|
|
7694
7733
|
});
|
|
7695
7734
|
typeof window !== "undefined" && validateCrypto();
|
|
7696
7735
|
this.lockManager = getLockManager();
|
|
@@ -7722,9 +7761,9 @@
|
|
|
7722
7761
|
this.domainUrl = getDomain(this.options.domain);
|
|
7723
7762
|
this.tokenIssuer = getTokenIssuer(this.options.issuer, this.domainUrl);
|
|
7724
7763
|
const myAccountApiIdentifier = "".concat(this.domainUrl, "/me/");
|
|
7725
|
-
const myAccountFetcher = this.createFetcher(
|
|
7764
|
+
const myAccountFetcher = this.createFetcher(Object.assign(Object.assign({}, this.options.useDpop && {
|
|
7726
7765
|
dpopNonceId: "__auth0_my_account_api__"
|
|
7727
|
-
}), {
|
|
7766
|
+
}), {
|
|
7728
7767
|
getAccessToken: () => this.getTokenSilently({
|
|
7729
7768
|
authorizationParams: {
|
|
7730
7769
|
scope: "create:me:connected_accounts",
|
|
@@ -7802,7 +7841,7 @@
|
|
|
7802
7841
|
url.searchParams.delete(paramName);
|
|
7803
7842
|
window.history.replaceState({}, "", url.toString());
|
|
7804
7843
|
}
|
|
7805
|
-
} catch (
|
|
7844
|
+
} catch (_a) {}
|
|
7806
7845
|
}
|
|
7807
7846
|
_applySessionTransferToken(authorizationParams) {
|
|
7808
7847
|
const paramName = this.options.sessionTransferTokenQueryParamName;
|
|
@@ -7812,18 +7851,18 @@
|
|
|
7812
7851
|
const token = this._extractSessionTransferToken(paramName);
|
|
7813
7852
|
if (!token) return authorizationParams;
|
|
7814
7853
|
this._clearSessionTransferTokenFromUrl(paramName);
|
|
7815
|
-
return
|
|
7854
|
+
return Object.assign(Object.assign({}, authorizationParams), {
|
|
7816
7855
|
session_transfer_token: token
|
|
7817
7856
|
});
|
|
7818
7857
|
}
|
|
7819
7858
|
async _prepareAuthorizeUrl(authorizationParams, authorizeOptions, fallbackRedirectUri) {
|
|
7820
|
-
var
|
|
7859
|
+
var _a;
|
|
7821
7860
|
const state = encode$2(createRandomString());
|
|
7822
7861
|
const nonce = encode$2(createRandomString());
|
|
7823
7862
|
const code_verifier = createRandomString();
|
|
7824
7863
|
const code_challengeBuffer = await sha256(code_verifier);
|
|
7825
7864
|
const code_challenge = bufferToBase64UrlEncoded(code_challengeBuffer);
|
|
7826
|
-
const thumbprint = await ((
|
|
7865
|
+
const thumbprint = await ((_a = this.dpop) === null || _a === void 0 ? void 0 : _a.calculateThumbprint());
|
|
7827
7866
|
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);
|
|
7828
7867
|
const url = this._authorizeUrl(params);
|
|
7829
7868
|
return {
|
|
@@ -7837,7 +7876,7 @@
|
|
|
7837
7876
|
};
|
|
7838
7877
|
}
|
|
7839
7878
|
async loginWithPopup(options, config) {
|
|
7840
|
-
var
|
|
7879
|
+
var _a;
|
|
7841
7880
|
options = options || {};
|
|
7842
7881
|
config = config || {};
|
|
7843
7882
|
if (!config.popup) {
|
|
@@ -7851,13 +7890,13 @@
|
|
|
7851
7890
|
response_mode: "web_message"
|
|
7852
7891
|
}, window.location.origin);
|
|
7853
7892
|
config.popup.location.href = params.url;
|
|
7854
|
-
const codeResult = await runPopup(
|
|
7893
|
+
const codeResult = await runPopup(Object.assign(Object.assign({}, config), {
|
|
7855
7894
|
timeoutInSeconds: config.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
7856
7895
|
}), new URL(params.url).origin);
|
|
7857
7896
|
if (params.state !== codeResult.state) {
|
|
7858
7897
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
7859
7898
|
}
|
|
7860
|
-
const organization = ((
|
|
7899
|
+
const organization = ((_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
|
|
7861
7900
|
await this._requestToken({
|
|
7862
7901
|
audience: params.audience,
|
|
7863
7902
|
scope: params.scope,
|
|
@@ -7871,26 +7910,26 @@
|
|
|
7871
7910
|
});
|
|
7872
7911
|
}
|
|
7873
7912
|
async getUser() {
|
|
7874
|
-
var
|
|
7913
|
+
var _a;
|
|
7875
7914
|
const cache = await this._getIdTokenFromCache();
|
|
7876
|
-
return cache === null || cache === void 0
|
|
7915
|
+
return (_a = cache === null || cache === void 0 ? void 0 : cache.decodedToken) === null || _a === void 0 ? void 0 : _a.user;
|
|
7877
7916
|
}
|
|
7878
7917
|
async getIdTokenClaims() {
|
|
7879
|
-
var
|
|
7918
|
+
var _a;
|
|
7880
7919
|
const cache = await this._getIdTokenFromCache();
|
|
7881
|
-
return cache === null || cache === void 0
|
|
7920
|
+
return (_a = cache === null || cache === void 0 ? void 0 : cache.decodedToken) === null || _a === void 0 ? void 0 : _a.claims;
|
|
7882
7921
|
}
|
|
7883
7922
|
async loginWithRedirect() {
|
|
7884
|
-
var _urlOptions$authoriza;
|
|
7885
7923
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7886
|
-
|
|
7887
|
-
const
|
|
7924
|
+
var _a;
|
|
7925
|
+
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl, fragment: fragment, appState: appState} = _b, urlOptions = __rest(_b, [ "openUrl", "fragment", "appState" ]);
|
|
7926
|
+
const organization = ((_a = urlOptions.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
|
|
7888
7927
|
const authorizationParams = this._applySessionTransferToken(urlOptions.authorizationParams || {});
|
|
7889
|
-
const
|
|
7890
|
-
this.transactionManager.create(
|
|
7928
|
+
const _c = await this._prepareAuthorizeUrl(authorizationParams), {url: url} = _c, transaction = __rest(_c, [ "url" ]);
|
|
7929
|
+
this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, transaction), {
|
|
7891
7930
|
appState: appState,
|
|
7892
|
-
response_type: ResponseType.Code
|
|
7893
|
-
}, organization && {
|
|
7931
|
+
response_type: exports.ResponseType.Code
|
|
7932
|
+
}), organization && {
|
|
7894
7933
|
organization: organization
|
|
7895
7934
|
}));
|
|
7896
7935
|
const urlWithFragment = fragment ? "".concat(url, "#").concat(fragment) : url;
|
|
@@ -7912,7 +7951,7 @@
|
|
|
7912
7951
|
}
|
|
7913
7952
|
this.transactionManager.remove();
|
|
7914
7953
|
const authenticationResult = parseAuthenticationResult(queryStringFragments.join(""));
|
|
7915
|
-
if (transaction.response_type === ResponseType.ConnectCode) {
|
|
7954
|
+
if (transaction.response_type === exports.ResponseType.ConnectCode) {
|
|
7916
7955
|
return this._handleConnectAccountRedirectCallback(authenticationResult, transaction);
|
|
7917
7956
|
}
|
|
7918
7957
|
return this._handleLoginRedirectCallback(authenticationResult, transaction);
|
|
@@ -7928,7 +7967,7 @@
|
|
|
7928
7967
|
const organization = transaction.organization;
|
|
7929
7968
|
const nonceIn = transaction.nonce;
|
|
7930
7969
|
const redirect_uri = transaction.redirect_uri;
|
|
7931
|
-
await this._requestToken(
|
|
7970
|
+
await this._requestToken(Object.assign({
|
|
7932
7971
|
audience: transaction.audience,
|
|
7933
7972
|
scope: transaction.scope,
|
|
7934
7973
|
code_verifier: transaction.code_verifier,
|
|
@@ -7942,7 +7981,7 @@
|
|
|
7942
7981
|
});
|
|
7943
7982
|
return {
|
|
7944
7983
|
appState: transaction.appState,
|
|
7945
|
-
response_type: ResponseType.Code
|
|
7984
|
+
response_type: exports.ResponseType.Code
|
|
7946
7985
|
};
|
|
7947
7986
|
}
|
|
7948
7987
|
async _handleConnectAccountRedirectCallback(connectResult, transaction) {
|
|
@@ -7962,9 +8001,9 @@
|
|
|
7962
8001
|
redirect_uri: transaction.redirect_uri,
|
|
7963
8002
|
code_verifier: transaction.code_verifier
|
|
7964
8003
|
});
|
|
7965
|
-
return
|
|
8004
|
+
return Object.assign(Object.assign({}, data), {
|
|
7966
8005
|
appState: transaction.appState,
|
|
7967
|
-
response_type: ResponseType.ConnectCode
|
|
8006
|
+
response_type: exports.ResponseType.ConnectCode
|
|
7968
8007
|
});
|
|
7969
8008
|
}
|
|
7970
8009
|
async checkSession(options) {
|
|
@@ -7984,20 +8023,20 @@
|
|
|
7984
8023
|
} catch (_) {}
|
|
7985
8024
|
}
|
|
7986
8025
|
async getTokenSilently() {
|
|
7987
|
-
var _options$authorizatio2, _options$authorizatio3;
|
|
7988
8026
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7989
|
-
|
|
8027
|
+
var _a, _b;
|
|
8028
|
+
const localOptions = Object.assign(Object.assign({
|
|
7990
8029
|
cacheMode: "on"
|
|
7991
|
-
}, options), {
|
|
7992
|
-
authorizationParams:
|
|
7993
|
-
scope: scopesToRequest(this.scope, (
|
|
8030
|
+
}, options), {
|
|
8031
|
+
authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), options.authorizationParams), {
|
|
8032
|
+
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)
|
|
7994
8033
|
})
|
|
7995
8034
|
});
|
|
7996
8035
|
const result = await singlePromise(() => this._getTokenSilently(localOptions), "".concat(this.options.clientId, "::").concat(localOptions.authorizationParams.audience, "::").concat(localOptions.authorizationParams.scope));
|
|
7997
8036
|
return options.detailedResponse ? result : result === null || result === void 0 ? void 0 : result.access_token;
|
|
7998
8037
|
}
|
|
7999
8038
|
async _getTokenSilently(options) {
|
|
8000
|
-
const {cacheMode: cacheMode} = options, getTokenOptions =
|
|
8039
|
+
const {cacheMode: cacheMode} = options, getTokenOptions = __rest(options, [ "cacheMode" ]);
|
|
8001
8040
|
if (cacheMode !== "off") {
|
|
8002
8041
|
const entry = await this._getEntryFromCache({
|
|
8003
8042
|
scope: getTokenOptions.authorizationParams.scope,
|
|
@@ -8027,13 +8066,13 @@
|
|
|
8027
8066
|
}
|
|
8028
8067
|
const authResult = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(getTokenOptions) : await this._getTokenFromIFrame(getTokenOptions);
|
|
8029
8068
|
const {id_token: id_token, token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = authResult;
|
|
8030
|
-
return
|
|
8069
|
+
return Object.assign(Object.assign({
|
|
8031
8070
|
id_token: id_token,
|
|
8032
8071
|
token_type: token_type,
|
|
8033
8072
|
access_token: access_token
|
|
8034
8073
|
}, oauthTokenScope ? {
|
|
8035
8074
|
scope: oauthTokenScope
|
|
8036
|
-
} : null), {
|
|
8075
|
+
} : null), {
|
|
8037
8076
|
expires_in: expires_in
|
|
8038
8077
|
});
|
|
8039
8078
|
});
|
|
@@ -8069,15 +8108,15 @@
|
|
|
8069
8108
|
}
|
|
8070
8109
|
}
|
|
8071
8110
|
async getTokenWithPopup() {
|
|
8072
|
-
var _options$authorizatio4, _options$authorizatio5;
|
|
8073
8111
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8074
8112
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8113
|
+
var _a, _b;
|
|
8114
|
+
const localOptions = Object.assign(Object.assign({}, options), {
|
|
8115
|
+
authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), options.authorizationParams), {
|
|
8116
|
+
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)
|
|
8078
8117
|
})
|
|
8079
8118
|
});
|
|
8080
|
-
config =
|
|
8119
|
+
config = Object.assign(Object.assign({}, DEFAULT_POPUP_CONFIG_OPTIONS), config);
|
|
8081
8120
|
await this.loginWithPopup(localOptions, config);
|
|
8082
8121
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
8083
8122
|
scope: localOptions.authorizationParams.scope,
|
|
@@ -8096,17 +8135,36 @@
|
|
|
8096
8135
|
} else {
|
|
8097
8136
|
delete options.clientId;
|
|
8098
8137
|
}
|
|
8099
|
-
const
|
|
8138
|
+
const _a = options.logoutParams || {}, {federated: federated} = _a, logoutOptions = __rest(_a, [ "federated" ]);
|
|
8100
8139
|
const federatedQuery = federated ? "&federated" : "";
|
|
8101
|
-
const url = this._url("/v2/logout?".concat(createQueryParams(
|
|
8140
|
+
const url = this._url("/v2/logout?".concat(createQueryParams(Object.assign({
|
|
8102
8141
|
clientId: options.clientId
|
|
8103
8142
|
}, logoutOptions))));
|
|
8104
8143
|
return url + federatedQuery;
|
|
8105
8144
|
}
|
|
8145
|
+
async revokeRefreshToken() {
|
|
8146
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8147
|
+
if (!this.options.useRefreshTokens) {
|
|
8148
|
+
return;
|
|
8149
|
+
}
|
|
8150
|
+
const audience = options.audience || this.options.authorizationParams.audience;
|
|
8151
|
+
const resolvedAudience = audience || DEFAULT_AUDIENCE;
|
|
8152
|
+
const refreshTokens = await this.cacheManager.getRefreshTokensByAudience(resolvedAudience, this.options.clientId);
|
|
8153
|
+
await revokeToken({
|
|
8154
|
+
baseUrl: this.domainUrl,
|
|
8155
|
+
timeout: this.httpTimeoutMs,
|
|
8156
|
+
auth0Client: this.options.auth0Client,
|
|
8157
|
+
useFormData: this.options.useFormData,
|
|
8158
|
+
client_id: this.options.clientId,
|
|
8159
|
+
refreshTokens: refreshTokens,
|
|
8160
|
+
audience: resolvedAudience,
|
|
8161
|
+
onRefreshTokenRevoked: refreshToken => this.cacheManager.stripRefreshToken(refreshToken)
|
|
8162
|
+
}, this.worker);
|
|
8163
|
+
}
|
|
8106
8164
|
async logout() {
|
|
8107
|
-
var _this$dpop2;
|
|
8108
8165
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8109
|
-
|
|
8166
|
+
var _a;
|
|
8167
|
+
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _b, logoutOptions = __rest(_b, [ "openUrl" ]);
|
|
8110
8168
|
if (options.clientId === null) {
|
|
8111
8169
|
await this.cacheManager.clear();
|
|
8112
8170
|
} else {
|
|
@@ -8119,7 +8177,7 @@
|
|
|
8119
8177
|
cookieDomain: this.options.cookieDomain
|
|
8120
8178
|
});
|
|
8121
8179
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
8122
|
-
await ((
|
|
8180
|
+
await ((_a = this.dpop) === null || _a === void 0 ? void 0 : _a.clear());
|
|
8123
8181
|
const url = this._buildLogoutUrl(logoutOptions);
|
|
8124
8182
|
if (openUrl) {
|
|
8125
8183
|
await openUrl(url);
|
|
@@ -8131,7 +8189,7 @@
|
|
|
8131
8189
|
const iframeLockKey = buildIframeLockKey(this.options.clientId);
|
|
8132
8190
|
try {
|
|
8133
8191
|
return await this.lockManager.runWithLock(iframeLockKey, 5e3, async () => {
|
|
8134
|
-
const params =
|
|
8192
|
+
const params = Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8135
8193
|
prompt: "none"
|
|
8136
8194
|
});
|
|
8137
8195
|
const orgHint = this.cookieStorage.get(this.orgHintCookieName);
|
|
@@ -8148,14 +8206,14 @@
|
|
|
8148
8206
|
let eventOrigin;
|
|
8149
8207
|
try {
|
|
8150
8208
|
eventOrigin = new URL(this.domainUrl).origin;
|
|
8151
|
-
} catch (
|
|
8209
|
+
} catch (_a) {
|
|
8152
8210
|
eventOrigin = this.domainUrl;
|
|
8153
8211
|
}
|
|
8154
8212
|
const codeResult = await runIframe(url, eventOrigin, authorizeTimeout);
|
|
8155
8213
|
if (stateIn !== codeResult.state) {
|
|
8156
8214
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
8157
8215
|
}
|
|
8158
|
-
const tokenResult = await this._requestToken(
|
|
8216
|
+
const tokenResult = await this._requestToken(Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8159
8217
|
code_verifier: code_verifier,
|
|
8160
8218
|
code: codeResult.code,
|
|
8161
8219
|
grant_type: "authorization_code",
|
|
@@ -8165,7 +8223,7 @@
|
|
|
8165
8223
|
nonceIn: nonceIn,
|
|
8166
8224
|
organization: params.organization
|
|
8167
8225
|
});
|
|
8168
|
-
return
|
|
8226
|
+
return Object.assign(Object.assign({}, tokenResult), {
|
|
8169
8227
|
scope: scope,
|
|
8170
8228
|
oauthTokenScope: tokenResult.scope,
|
|
8171
8229
|
audience: audience
|
|
@@ -8184,6 +8242,7 @@
|
|
|
8184
8242
|
}
|
|
8185
8243
|
}
|
|
8186
8244
|
async _getTokenUsingRefreshToken(options) {
|
|
8245
|
+
var _a, _b;
|
|
8187
8246
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
8188
8247
|
scope: options.authorizationParams.scope,
|
|
8189
8248
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
@@ -8199,16 +8258,16 @@
|
|
|
8199
8258
|
const timeout = typeof options.timeoutInSeconds === "number" ? options.timeoutInSeconds * 1e3 : null;
|
|
8200
8259
|
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);
|
|
8201
8260
|
try {
|
|
8202
|
-
const tokenResult = await this._requestToken(
|
|
8261
|
+
const tokenResult = await this._requestToken(Object.assign(Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8203
8262
|
grant_type: "refresh_token",
|
|
8204
8263
|
refresh_token: cache && cache.refresh_token,
|
|
8205
8264
|
redirect_uri: redirect_uri
|
|
8206
|
-
}, timeout && {
|
|
8265
|
+
}), timeout && {
|
|
8207
8266
|
timeout: timeout
|
|
8208
8267
|
}), {
|
|
8209
8268
|
scopesToRequest: scopesToRequest
|
|
8210
8269
|
});
|
|
8211
|
-
if (tokenResult.refresh_token && cache
|
|
8270
|
+
if (tokenResult.refresh_token && (cache === null || cache === void 0 ? void 0 : cache.refresh_token)) {
|
|
8212
8271
|
await this.cacheManager.updateEntry(cache.refresh_token, tokenResult.refresh_token);
|
|
8213
8272
|
}
|
|
8214
8273
|
if (this.options.useMrrt) {
|
|
@@ -8225,7 +8284,7 @@
|
|
|
8225
8284
|
}
|
|
8226
8285
|
}
|
|
8227
8286
|
}
|
|
8228
|
-
return
|
|
8287
|
+
return Object.assign(Object.assign({}, tokenResult), {
|
|
8229
8288
|
scope: options.authorizationParams.scope,
|
|
8230
8289
|
oauthTokenScope: tokenResult.scope,
|
|
8231
8290
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE
|
|
@@ -8243,14 +8302,13 @@
|
|
|
8243
8302
|
}
|
|
8244
8303
|
}
|
|
8245
8304
|
if (e instanceof MfaRequiredError) {
|
|
8246
|
-
|
|
8247
|
-
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);
|
|
8305
|
+
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);
|
|
8248
8306
|
}
|
|
8249
8307
|
throw e;
|
|
8250
8308
|
}
|
|
8251
8309
|
}
|
|
8252
8310
|
async _saveEntryInCache(entry) {
|
|
8253
|
-
const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken =
|
|
8311
|
+
const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken = __rest(entry, [ "id_token", "decodedToken" ]);
|
|
8254
8312
|
this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, {
|
|
8255
8313
|
id_token: id_token,
|
|
8256
8314
|
decodedToken: decodedToken
|
|
@@ -8273,8 +8331,8 @@
|
|
|
8273
8331
|
this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, cache);
|
|
8274
8332
|
return cache;
|
|
8275
8333
|
}
|
|
8276
|
-
async _getEntryFromCache(
|
|
8277
|
-
let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} =
|
|
8334
|
+
async _getEntryFromCache(_ref) {
|
|
8335
|
+
let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} = _ref;
|
|
8278
8336
|
const entry = await this.cacheManager.get(new CacheKey({
|
|
8279
8337
|
scope: scope,
|
|
8280
8338
|
audience: audience,
|
|
@@ -8283,20 +8341,21 @@
|
|
|
8283
8341
|
if (entry && entry.access_token) {
|
|
8284
8342
|
const {token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = entry;
|
|
8285
8343
|
const cache = await this._getIdTokenFromCache();
|
|
8286
|
-
return cache &&
|
|
8344
|
+
return cache && Object.assign(Object.assign({
|
|
8287
8345
|
id_token: cache.id_token,
|
|
8288
8346
|
token_type: token_type ? token_type : "Bearer",
|
|
8289
8347
|
access_token: access_token
|
|
8290
8348
|
}, oauthTokenScope ? {
|
|
8291
8349
|
scope: oauthTokenScope
|
|
8292
|
-
} : null), {
|
|
8350
|
+
} : null), {
|
|
8293
8351
|
expires_in: expires_in
|
|
8294
8352
|
});
|
|
8295
8353
|
}
|
|
8296
8354
|
}
|
|
8297
8355
|
async _requestToken(options, additionalParameters) {
|
|
8356
|
+
var _a, _b;
|
|
8298
8357
|
const {nonceIn: nonceIn, organization: organization, scopesToRequest: scopesToRequest} = additionalParameters || {};
|
|
8299
|
-
const authResult = await oauthToken(
|
|
8358
|
+
const authResult = await oauthToken(Object.assign(Object.assign({
|
|
8300
8359
|
baseUrl: this.domainUrl,
|
|
8301
8360
|
client_id: this.options.clientId,
|
|
8302
8361
|
auth0Client: this.options.auth0Client,
|
|
@@ -8304,25 +8363,24 @@
|
|
|
8304
8363
|
timeout: this.httpTimeoutMs,
|
|
8305
8364
|
useMrrt: this.options.useMrrt,
|
|
8306
8365
|
dpop: this.dpop
|
|
8307
|
-
}, options), {
|
|
8366
|
+
}, options), {
|
|
8308
8367
|
scope: scopesToRequest || options.scope
|
|
8309
8368
|
}), this.worker);
|
|
8310
8369
|
const decodedToken = await this._verifyIdToken(authResult.id_token, nonceIn, organization);
|
|
8311
8370
|
if (options.grant_type === "authorization_code") {
|
|
8312
|
-
var _existingIdToken$deco;
|
|
8313
8371
|
const existingIdToken = await this._getIdTokenFromCache();
|
|
8314
|
-
if (existingIdToken
|
|
8372
|
+
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) {
|
|
8315
8373
|
await this.cacheManager.clear(this.options.clientId);
|
|
8316
8374
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
8317
8375
|
}
|
|
8318
8376
|
}
|
|
8319
|
-
await this._saveEntryInCache(
|
|
8377
|
+
await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, authResult), {
|
|
8320
8378
|
decodedToken: decodedToken,
|
|
8321
8379
|
scope: options.scope,
|
|
8322
8380
|
audience: options.audience || DEFAULT_AUDIENCE
|
|
8323
|
-
}, authResult.scope ? {
|
|
8381
|
+
}), authResult.scope ? {
|
|
8324
8382
|
oauthTokenScope: authResult.scope
|
|
8325
|
-
} : null), {
|
|
8383
|
+
} : null), {
|
|
8326
8384
|
client_id: this.options.clientId
|
|
8327
8385
|
}));
|
|
8328
8386
|
this.cookieStorage.save(this.isAuthenticatedCookieName, true, {
|
|
@@ -8330,12 +8388,12 @@
|
|
|
8330
8388
|
cookieDomain: this.options.cookieDomain
|
|
8331
8389
|
});
|
|
8332
8390
|
this._processOrgHint(organization || decodedToken.claims.org_id);
|
|
8333
|
-
return
|
|
8391
|
+
return Object.assign(Object.assign({}, authResult), {
|
|
8334
8392
|
decodedToken: decodedToken
|
|
8335
8393
|
});
|
|
8336
8394
|
}
|
|
8337
8395
|
async loginWithCustomTokenExchange(options) {
|
|
8338
|
-
return this._requestToken(
|
|
8396
|
+
return this._requestToken(Object.assign(Object.assign({}, options), {
|
|
8339
8397
|
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
8340
8398
|
subject_token: options.subject_token,
|
|
8341
8399
|
subject_token_type: options.subject_token_type,
|
|
@@ -8369,10 +8427,10 @@
|
|
|
8369
8427
|
return new Fetcher(config, {
|
|
8370
8428
|
isDpopEnabled: () => !!this.options.useDpop,
|
|
8371
8429
|
getAccessToken: authParams => {
|
|
8372
|
-
var
|
|
8430
|
+
var _a;
|
|
8373
8431
|
return this.getTokenSilently({
|
|
8374
8432
|
authorizationParams: {
|
|
8375
|
-
scope: authParams === null || authParams === void 0
|
|
8433
|
+
scope: (_a = authParams === null || authParams === void 0 ? void 0 : authParams.scope) === null || _a === void 0 ? void 0 : _a.join(" "),
|
|
8376
8434
|
audience: authParams === null || authParams === void 0 ? void 0 : authParams.audience
|
|
8377
8435
|
},
|
|
8378
8436
|
detailedResponse: true
|
|
@@ -8408,7 +8466,7 @@
|
|
|
8408
8466
|
redirect_uri: redirectUri,
|
|
8409
8467
|
appState: appState,
|
|
8410
8468
|
connection: connection,
|
|
8411
|
-
response_type: ResponseType.ConnectCode
|
|
8469
|
+
response_type: exports.ResponseType.ConnectCode
|
|
8412
8470
|
});
|
|
8413
8471
|
const url = new URL(connect_uri);
|
|
8414
8472
|
url.searchParams.set("ticket", connect_params.ticket);
|
|
@@ -8419,8 +8477,8 @@
|
|
|
8419
8477
|
}
|
|
8420
8478
|
}
|
|
8421
8479
|
async _requestTokenForMfa(options, additionalParameters) {
|
|
8422
|
-
const {mfaToken: mfaToken} = options, restOptions =
|
|
8423
|
-
return this._requestToken(
|
|
8480
|
+
const {mfaToken: mfaToken} = options, restOptions = __rest(options, [ "mfaToken" ]);
|
|
8481
|
+
return this._requestToken(Object.assign(Object.assign({}, restOptions), {
|
|
8424
8482
|
mfa_token: mfaToken
|
|
8425
8483
|
}), additionalParameters);
|
|
8426
8484
|
}
|
|
@@ -8450,7 +8508,6 @@
|
|
|
8450
8508
|
exports.PopupCancelledError = PopupCancelledError;
|
|
8451
8509
|
exports.PopupOpenError = PopupOpenError;
|
|
8452
8510
|
exports.PopupTimeoutError = PopupTimeoutError;
|
|
8453
|
-
exports.ResponseType = ResponseType;
|
|
8454
8511
|
exports.TimeoutError = TimeoutError;
|
|
8455
8512
|
exports.UseDpopNonceError = UseDpopNonceError;
|
|
8456
8513
|
exports.User = User;
|