@auth0/auth0-spa-js 2.18.2 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/auth0-spa-js.development.js +408 -298
- 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 +167 -76
- 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 +430 -321
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/Auth0Client.d.ts +38 -1
- package/dist/typings/api.d.ts +31 -0
- package/dist/typings/cache/cache-manager.d.ts +13 -0
- package/dist/typings/global.d.ts +7 -0
- package/dist/typings/http.d.ts +6 -0
- package/dist/typings/version.d.ts +1 -1
- package/dist/typings/worker/worker.types.d.ts +17 -5
- package/dist/typings/worker/worker.utils.d.ts +11 -5
- package/package.json +3 -3
- package/src/Auth0Client.ts +78 -2
- package/src/api.ts +112 -2
- package/src/cache/cache-manager.ts +57 -0
- package/src/global.ts +8 -0
- package/src/http.ts +28 -21
- package/src/version.ts +1 -1
- package/src/worker/__mocks__/token.worker.ts +3 -3
- package/src/worker/token.worker.ts +174 -3
- package/src/worker/worker.types.ts +23 -5
- package/src/worker/worker.utils.ts +18 -7
|
@@ -4,163 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
this.v = e, this.k = d;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function _assertClassBrand(e, t, n) {
|
|
12
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
13
|
-
throw new TypeError("Private element is not present on this object");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function _awaitAsyncGenerator(e) {
|
|
17
|
-
return new _OverloadYield(e, 0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
21
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function _classPrivateFieldGet2(s, a) {
|
|
25
|
-
return s.get(_assertClassBrand(s, a));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _classPrivateFieldInitSpec(e, t, a) {
|
|
29
|
-
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
33
|
-
return s.set(_assertClassBrand(s, a), r), r;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
37
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _defineProperty(e, r, t) {
|
|
41
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
|
-
value: t,
|
|
43
|
-
enumerable: !0,
|
|
44
|
-
configurable: !0,
|
|
45
|
-
writable: !0
|
|
46
|
-
}) : e[r] = t, e;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function ownKeys(e, r) {
|
|
50
|
-
var t = Object.keys(e);
|
|
51
|
-
if (Object.getOwnPropertySymbols) {
|
|
52
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
53
|
-
r && (o = o.filter(function(r) {
|
|
54
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
55
|
-
})), t.push.apply(t, o);
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _objectSpread2(e) {
|
|
61
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
62
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
63
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
64
|
-
_defineProperty(e, r, t[r]);
|
|
65
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
66
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return e;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _objectWithoutProperties(e, t) {
|
|
73
|
-
if (null == e) return {};
|
|
74
|
-
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
75
|
-
if (Object.getOwnPropertySymbols) {
|
|
76
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
77
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
78
|
-
}
|
|
79
|
-
return i;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
83
|
-
if (null == r) return {};
|
|
7
|
+
function __rest(s, e) {
|
|
84
8
|
var t = {};
|
|
85
|
-
for (var
|
|
86
|
-
|
|
87
|
-
t[
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
10
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
11
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
88
12
|
}
|
|
89
13
|
return t;
|
|
90
14
|
}
|
|
91
15
|
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (void 0 !== e) {
|
|
96
|
-
var i = e.call(t, r || "default");
|
|
97
|
-
if ("object" != typeof i) return i;
|
|
98
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
99
|
-
}
|
|
100
|
-
return ("string" === r ? String : Number)(t);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function _toPropertyKey(t) {
|
|
104
|
-
var i = _toPrimitive(t, "string");
|
|
105
|
-
return "symbol" == typeof i ? i : i + "";
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function _wrapAsyncGenerator(e) {
|
|
109
|
-
return function() {
|
|
110
|
-
return new AsyncGenerator(e.apply(this, arguments));
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function AsyncGenerator(e) {
|
|
115
|
-
var t, n;
|
|
116
|
-
function resume(t, n) {
|
|
117
|
-
try {
|
|
118
|
-
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
119
|
-
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
120
|
-
if (u) {
|
|
121
|
-
var i = "return" === t && o.k ? t : "next";
|
|
122
|
-
if (!o.k || n.done) return resume(i, n);
|
|
123
|
-
n = e[i](n).value;
|
|
124
|
-
}
|
|
125
|
-
settle(!!r.done, n);
|
|
126
|
-
}, function(e) {
|
|
127
|
-
resume("throw", e);
|
|
128
|
-
});
|
|
129
|
-
} catch (e) {
|
|
130
|
-
settle(2, e);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function settle(e, r) {
|
|
134
|
-
2 === e ? t.reject(r) : t.resolve({
|
|
135
|
-
value: r,
|
|
136
|
-
done: e
|
|
137
|
-
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
138
|
-
}
|
|
139
|
-
this._invoke = function(e, r) {
|
|
140
|
-
return new Promise(function(o, u) {
|
|
141
|
-
var i = {
|
|
142
|
-
key: e,
|
|
143
|
-
arg: r,
|
|
144
|
-
resolve: o,
|
|
145
|
-
reject: u,
|
|
146
|
-
next: null
|
|
147
|
-
};
|
|
148
|
-
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
149
|
-
});
|
|
150
|
-
}, "function" != typeof e.return && (this.return = void 0);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
154
|
-
return this;
|
|
155
|
-
}, AsyncGenerator.prototype.next = function(e) {
|
|
156
|
-
return this._invoke("next", e);
|
|
157
|
-
}, AsyncGenerator.prototype.throw = function(e) {
|
|
158
|
-
return this._invoke("throw", e);
|
|
159
|
-
}, AsyncGenerator.prototype.return = function(e) {
|
|
160
|
-
return this._invoke("return", e);
|
|
16
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
17
|
+
var e = new Error(message);
|
|
18
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
161
19
|
};
|
|
162
20
|
|
|
163
|
-
var version = "2.
|
|
21
|
+
var version = "2.19.0";
|
|
164
22
|
|
|
165
23
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
166
24
|
|
|
@@ -301,8 +159,6 @@ function valueOrEmptyString(value) {
|
|
|
301
159
|
return value && !exclude.includes(value) ? value : "";
|
|
302
160
|
}
|
|
303
161
|
|
|
304
|
-
const _excluded$5 = [ "clientId" ];
|
|
305
|
-
|
|
306
162
|
const parseAuthenticationResult = queryString => {
|
|
307
163
|
if (queryString.indexOf("#") > -1) {
|
|
308
164
|
queryString = queryString.substring(0, queryString.indexOf("#"));
|
|
@@ -414,7 +270,7 @@ const createRandomString = () => {
|
|
|
414
270
|
|
|
415
271
|
const encode$2 = value => btoa(value);
|
|
416
272
|
|
|
417
|
-
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) =>
|
|
273
|
+
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) => Object.assign(Object.assign({}, acc), {
|
|
418
274
|
[key]: params[key]
|
|
419
275
|
}), {});
|
|
420
276
|
|
|
@@ -443,9 +299,9 @@ const stripAuth0Client = function stripAuth0Client(auth0Client) {
|
|
|
443
299
|
}, {});
|
|
444
300
|
};
|
|
445
301
|
|
|
446
|
-
const createQueryParams =
|
|
447
|
-
|
|
448
|
-
return new URLSearchParams(stripUndefined(
|
|
302
|
+
const createQueryParams = _a => {
|
|
303
|
+
var {clientId: client_id} = _a, params = __rest(_a, [ "clientId" ]);
|
|
304
|
+
return new URLSearchParams(stripUndefined(Object.assign({
|
|
449
305
|
client_id: client_id
|
|
450
306
|
}, params))).toString();
|
|
451
307
|
};
|
|
@@ -505,8 +361,8 @@ const parseNumber = value => {
|
|
|
505
361
|
return parseInt(value, 10) || undefined;
|
|
506
362
|
};
|
|
507
363
|
|
|
508
|
-
const fromEntries = iterable => [ ...iterable ].reduce((obj,
|
|
509
|
-
let [key, val] =
|
|
364
|
+
const fromEntries = iterable => [ ...iterable ].reduce((obj, _ref) => {
|
|
365
|
+
let [key, val] = _ref;
|
|
510
366
|
obj[key] = val;
|
|
511
367
|
return obj;
|
|
512
368
|
}, {});
|
|
@@ -1067,7 +923,7 @@ class WebLocksApiManager {
|
|
|
1067
923
|
|
|
1068
924
|
class LegacyLockManager {
|
|
1069
925
|
constructor() {
|
|
1070
|
-
|
|
926
|
+
this.activeLocks = new Set;
|
|
1071
927
|
this.lock = new _default;
|
|
1072
928
|
this.pagehideHandler = () => {
|
|
1073
929
|
this.activeLocks.forEach(key => this.lock.releaseLock(key));
|
|
@@ -1100,8 +956,8 @@ class LegacyLockManager {
|
|
|
1100
956
|
}
|
|
1101
957
|
|
|
1102
958
|
function isWebLocksSupported() {
|
|
1103
|
-
var
|
|
1104
|
-
return typeof navigator !== "undefined" && typeof ((
|
|
959
|
+
var _a;
|
|
960
|
+
return typeof navigator !== "undefined" && typeof ((_a = navigator.locks) === null || _a === void 0 ? void 0 : _a.request) === "function";
|
|
1105
961
|
}
|
|
1106
962
|
|
|
1107
963
|
function createLockManager() {
|
|
@@ -1471,24 +1327,13 @@ const sendMessage = (message, to) => new Promise(function(resolve, reject) {
|
|
|
1471
1327
|
to.postMessage(message, [ messageChannel.port2 ]);
|
|
1472
1328
|
});
|
|
1473
1329
|
|
|
1474
|
-
const _excluded$4 = [ "error", "error_description" ];
|
|
1475
|
-
|
|
1476
1330
|
const createAbortController = () => new AbortController;
|
|
1477
1331
|
|
|
1478
|
-
const
|
|
1479
|
-
const response = await fetch(fetchUrl, fetchOptions);
|
|
1480
|
-
return {
|
|
1481
|
-
ok: response.ok,
|
|
1482
|
-
json: await response.json(),
|
|
1483
|
-
headers: fromEntries(response.headers)
|
|
1484
|
-
};
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
1332
|
+
const fetchWithTimeout = (fetchUrl, fetchOptions, timeout) => {
|
|
1488
1333
|
const controller = createAbortController();
|
|
1489
1334
|
fetchOptions.signal = controller.signal;
|
|
1490
1335
|
let timeoutId;
|
|
1491
|
-
return Promise.race([
|
|
1336
|
+
return Promise.race([ fetch(fetchUrl, fetchOptions), new Promise((_, reject) => {
|
|
1492
1337
|
timeoutId = setTimeout(() => {
|
|
1493
1338
|
controller.abort();
|
|
1494
1339
|
reject(new Error("Timeout when executing 'fetch'"));
|
|
@@ -1498,7 +1343,17 @@ const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
|
1498
1343
|
});
|
|
1499
1344
|
};
|
|
1500
1345
|
|
|
1346
|
+
const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
1347
|
+
const response = await fetchWithTimeout(fetchUrl, fetchOptions, timeout);
|
|
1348
|
+
return {
|
|
1349
|
+
ok: response.ok,
|
|
1350
|
+
json: await response.json(),
|
|
1351
|
+
headers: fromEntries(response.headers)
|
|
1352
|
+
};
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1501
1355
|
const fetchWithWorker = async (fetchUrl, audience, scope, fetchOptions, timeout, worker, useFormData, useMrrt) => sendMessage({
|
|
1356
|
+
type: "refresh",
|
|
1502
1357
|
auth: {
|
|
1503
1358
|
audience: audience,
|
|
1504
1359
|
scope: scope
|
|
@@ -1527,7 +1382,7 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
|
|
|
1527
1382
|
method: options.method || "GET",
|
|
1528
1383
|
nonce: await dpop.getNonce()
|
|
1529
1384
|
});
|
|
1530
|
-
options.headers =
|
|
1385
|
+
options.headers = Object.assign(Object.assign({}, options.headers), {
|
|
1531
1386
|
dpop: dpopProof
|
|
1532
1387
|
});
|
|
1533
1388
|
}
|
|
@@ -1545,7 +1400,7 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
|
|
|
1545
1400
|
if (fetchError) {
|
|
1546
1401
|
throw fetchError;
|
|
1547
1402
|
}
|
|
1548
|
-
const
|
|
1403
|
+
const _a = response.json, {error: error, error_description: error_description} = _a, data = __rest(_a, [ "error", "error_description" ]), {headers: headers, ok: ok} = response;
|
|
1549
1404
|
let newDpopNonce;
|
|
1550
1405
|
if (dpop) {
|
|
1551
1406
|
newDpopNonce = headers[DPOP_NONCE_HEADER];
|
|
@@ -1572,13 +1427,11 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
|
|
|
1572
1427
|
return data;
|
|
1573
1428
|
}
|
|
1574
1429
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
async function oauthToken(_ref, worker) {
|
|
1578
|
-
let {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData, useMrrt: useMrrt, dpop: dpop} = _ref, options = _objectWithoutProperties(_ref, _excluded$3);
|
|
1430
|
+
async function oauthToken(_a, worker) {
|
|
1431
|
+
var {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData, useMrrt: useMrrt, dpop: dpop} = _a, options = __rest(_a, [ "baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData", "useMrrt", "dpop" ]);
|
|
1579
1432
|
const isTokenExchange = options.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
1580
1433
|
const refreshWithMrrt = options.grant_type === "refresh_token" && useMrrt;
|
|
1581
|
-
const allParams =
|
|
1434
|
+
const allParams = Object.assign(Object.assign(Object.assign(Object.assign({}, options), isTokenExchange && audience && {
|
|
1582
1435
|
audience: audience
|
|
1583
1436
|
}), isTokenExchange && scope && {
|
|
1584
1437
|
scope: scope
|
|
@@ -1598,6 +1451,60 @@ async function oauthToken(_ref, worker) {
|
|
|
1598
1451
|
}, worker, useFormData, useMrrt, isDpopSupported ? dpop : undefined);
|
|
1599
1452
|
}
|
|
1600
1453
|
|
|
1454
|
+
async function revokeToken(_ref, worker) {
|
|
1455
|
+
let {baseUrl: baseUrl, timeout: timeout, auth0Client: auth0Client, useFormData: useFormData, refreshTokens: refreshTokens, audience: audience, client_id: client_id, onRefreshTokenRevoked: onRefreshTokenRevoked} = _ref;
|
|
1456
|
+
const resolvedTimeout = timeout || DEFAULT_FETCH_TIMEOUT_MS;
|
|
1457
|
+
const token_type_hint = "refresh_token";
|
|
1458
|
+
const fetchUrl = "".concat(baseUrl, "/oauth/revoke");
|
|
1459
|
+
const headers = {
|
|
1460
|
+
"Content-Type": useFormData ? "application/x-www-form-urlencoded" : "application/json",
|
|
1461
|
+
"Auth0-Client": btoa(JSON.stringify(stripAuth0Client(auth0Client || DEFAULT_AUTH0_CLIENT)))
|
|
1462
|
+
};
|
|
1463
|
+
if (worker) {
|
|
1464
|
+
const baseParams = {
|
|
1465
|
+
client_id: client_id,
|
|
1466
|
+
token_type_hint: token_type_hint
|
|
1467
|
+
};
|
|
1468
|
+
const body = useFormData ? createQueryParams(baseParams) : JSON.stringify(baseParams);
|
|
1469
|
+
return sendMessage({
|
|
1470
|
+
type: "revoke",
|
|
1471
|
+
timeout: resolvedTimeout,
|
|
1472
|
+
fetchUrl: fetchUrl,
|
|
1473
|
+
fetchOptions: {
|
|
1474
|
+
method: "POST",
|
|
1475
|
+
body: body,
|
|
1476
|
+
headers: headers
|
|
1477
|
+
},
|
|
1478
|
+
useFormData: useFormData,
|
|
1479
|
+
auth: {
|
|
1480
|
+
audience: audience !== null && audience !== void 0 ? audience : DEFAULT_AUDIENCE
|
|
1481
|
+
}
|
|
1482
|
+
}, worker);
|
|
1483
|
+
}
|
|
1484
|
+
for (const refreshToken of refreshTokens) {
|
|
1485
|
+
const params = {
|
|
1486
|
+
client_id: client_id,
|
|
1487
|
+
token_type_hint: token_type_hint,
|
|
1488
|
+
token: refreshToken
|
|
1489
|
+
};
|
|
1490
|
+
const body = useFormData ? createQueryParams(params) : JSON.stringify(params);
|
|
1491
|
+
const response = await fetchWithTimeout(fetchUrl, {
|
|
1492
|
+
method: "POST",
|
|
1493
|
+
body: body,
|
|
1494
|
+
headers: headers
|
|
1495
|
+
}, resolvedTimeout);
|
|
1496
|
+
if (!response.ok) {
|
|
1497
|
+
let error;
|
|
1498
|
+
let errorDescription;
|
|
1499
|
+
try {
|
|
1500
|
+
({error: error, error_description: errorDescription} = JSON.parse(await response.text()));
|
|
1501
|
+
} catch (_a) {}
|
|
1502
|
+
throw new GenericError(error || "revoke_error", errorDescription || "HTTP error ".concat(response.status));
|
|
1503
|
+
}
|
|
1504
|
+
await (onRefreshTokenRevoked === null || onRefreshTokenRevoked === void 0 ? void 0 : onRefreshTokenRevoked(refreshToken));
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1601
1508
|
const dedupe = arr => Array.from(new Set(arr));
|
|
1602
1509
|
|
|
1603
1510
|
const getUniqueScopes = function getUniqueScopes() {
|
|
@@ -1696,7 +1603,7 @@ class LocalStorageCache {
|
|
|
1696
1603
|
|
|
1697
1604
|
class InMemoryCache {
|
|
1698
1605
|
constructor() {
|
|
1699
|
-
|
|
1606
|
+
this.enclosedCache = function() {
|
|
1700
1607
|
let cache = {};
|
|
1701
1608
|
return {
|
|
1702
1609
|
set(key, entry) {
|
|
@@ -1716,7 +1623,7 @@ class InMemoryCache {
|
|
|
1716
1623
|
return Object.keys(cache);
|
|
1717
1624
|
}
|
|
1718
1625
|
};
|
|
1719
|
-
}()
|
|
1626
|
+
}();
|
|
1720
1627
|
}
|
|
1721
1628
|
}
|
|
1722
1629
|
|
|
@@ -1729,13 +1636,13 @@ class CacheManager {
|
|
|
1729
1636
|
this.nowProvider = nowProvider || DEFAULT_NOW_PROVIDER;
|
|
1730
1637
|
}
|
|
1731
1638
|
async setIdToken(clientId, idToken, decodedToken) {
|
|
1732
|
-
var
|
|
1639
|
+
var _a;
|
|
1733
1640
|
const cacheKey = this.getIdTokenCacheKey(clientId);
|
|
1734
1641
|
await this.cache.set(cacheKey, {
|
|
1735
1642
|
id_token: idToken,
|
|
1736
1643
|
decodedToken: decodedToken
|
|
1737
1644
|
});
|
|
1738
|
-
await ((
|
|
1645
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.add(cacheKey));
|
|
1739
1646
|
}
|
|
1740
1647
|
async getIdToken(cacheKey) {
|
|
1741
1648
|
const entry = await this.cache.get(this.getIdTokenCacheKey(cacheKey.clientId));
|
|
@@ -1764,6 +1671,7 @@ class CacheManager {
|
|
|
1764
1671
|
let expiryAdjustmentSeconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_EXPIRY_ADJUSTMENT_SECONDS;
|
|
1765
1672
|
let useMrrt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1766
1673
|
let cacheMode = arguments.length > 3 ? arguments[3] : undefined;
|
|
1674
|
+
var _a;
|
|
1767
1675
|
let wrappedEntry = await this.cache.get(cacheKey.toKey());
|
|
1768
1676
|
if (!wrappedEntry) {
|
|
1769
1677
|
const keys = await this.getCacheKeys();
|
|
@@ -1782,12 +1690,11 @@ class CacheManager {
|
|
|
1782
1690
|
const now = await this.nowProvider();
|
|
1783
1691
|
const nowSeconds = Math.floor(now / 1e3);
|
|
1784
1692
|
if (wrappedEntry.expiresAt - expiryAdjustmentSeconds < nowSeconds) {
|
|
1785
|
-
var _this$keyManifest2;
|
|
1786
1693
|
if (wrappedEntry.body.refresh_token) {
|
|
1787
1694
|
return this.modifiedCachedEntry(wrappedEntry, cacheKey);
|
|
1788
1695
|
}
|
|
1789
1696
|
await this.cache.remove(cacheKey.toKey());
|
|
1790
|
-
await ((
|
|
1697
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.remove(cacheKey.toKey()));
|
|
1791
1698
|
return;
|
|
1792
1699
|
}
|
|
1793
1700
|
return wrappedEntry.body;
|
|
@@ -1806,7 +1713,7 @@ class CacheManager {
|
|
|
1806
1713
|
};
|
|
1807
1714
|
}
|
|
1808
1715
|
async set(entry) {
|
|
1809
|
-
var
|
|
1716
|
+
var _a;
|
|
1810
1717
|
const cacheKey = new CacheKey({
|
|
1811
1718
|
clientId: entry.client_id,
|
|
1812
1719
|
scope: entry.scope,
|
|
@@ -1814,7 +1721,7 @@ class CacheManager {
|
|
|
1814
1721
|
});
|
|
1815
1722
|
const wrappedEntry = await this.wrapCacheEntry(entry);
|
|
1816
1723
|
await this.cache.set(cacheKey.toKey(), wrappedEntry);
|
|
1817
|
-
await ((
|
|
1724
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.add(cacheKey.toKey()));
|
|
1818
1725
|
}
|
|
1819
1726
|
async remove(client_id, audience, scope) {
|
|
1820
1727
|
const cacheKey = new CacheKey({
|
|
@@ -1824,15 +1731,27 @@ class CacheManager {
|
|
|
1824
1731
|
});
|
|
1825
1732
|
await this.cache.remove(cacheKey.toKey());
|
|
1826
1733
|
}
|
|
1734
|
+
async stripRefreshToken(refreshToken) {
|
|
1735
|
+
var _a;
|
|
1736
|
+
const keys = await this.getCacheKeys();
|
|
1737
|
+
if (!keys) return;
|
|
1738
|
+
for (const key of keys) {
|
|
1739
|
+
const entry = await this.cache.get(key);
|
|
1740
|
+
if (((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) === refreshToken) {
|
|
1741
|
+
delete entry.body.refresh_token;
|
|
1742
|
+
await this.cache.set(key, entry);
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1827
1746
|
async clear(clientId) {
|
|
1828
|
-
var
|
|
1747
|
+
var _a;
|
|
1829
1748
|
const keys = await this.getCacheKeys();
|
|
1830
1749
|
if (!keys) return;
|
|
1831
1750
|
await keys.filter(key => clientId ? key.includes(clientId) : true).reduce(async (memo, key) => {
|
|
1832
1751
|
await memo;
|
|
1833
1752
|
await this.cache.remove(key);
|
|
1834
1753
|
}, Promise.resolve());
|
|
1835
|
-
await ((
|
|
1754
|
+
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.clear());
|
|
1836
1755
|
}
|
|
1837
1756
|
async wrapCacheEntry(entry) {
|
|
1838
1757
|
const now = await this.nowProvider();
|
|
@@ -1843,9 +1762,9 @@ class CacheManager {
|
|
|
1843
1762
|
};
|
|
1844
1763
|
}
|
|
1845
1764
|
async getCacheKeys() {
|
|
1765
|
+
var _a;
|
|
1846
1766
|
if (this.keyManifest) {
|
|
1847
|
-
|
|
1848
|
-
return (_await$this$keyManife = await this.keyManifest.get()) === null || _await$this$keyManife === void 0 ? void 0 : _await$this$keyManife.keys;
|
|
1767
|
+
return (_a = await this.keyManifest.get()) === null || _a === void 0 ? void 0 : _a.keys;
|
|
1849
1768
|
} else if (this.cache.allKeys) {
|
|
1850
1769
|
return this.cache.allKeys();
|
|
1851
1770
|
}
|
|
@@ -1857,34 +1776,50 @@ class CacheManager {
|
|
|
1857
1776
|
}
|
|
1858
1777
|
matchExistingCacheKey(keyToMatch, allKeys) {
|
|
1859
1778
|
return allKeys.filter(key => {
|
|
1860
|
-
var
|
|
1779
|
+
var _a;
|
|
1861
1780
|
const cacheKey = CacheKey.fromKey(key);
|
|
1862
1781
|
const scopeSet = new Set(cacheKey.scope && cacheKey.scope.split(" "));
|
|
1863
|
-
const scopesToMatch = ((
|
|
1782
|
+
const scopesToMatch = ((_a = keyToMatch.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
1864
1783
|
const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((acc, current) => acc && scopeSet.has(current), true);
|
|
1865
1784
|
return cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId && cacheKey.audience === keyToMatch.audience && hasAllScopes;
|
|
1866
1785
|
})[0];
|
|
1867
1786
|
}
|
|
1868
1787
|
async getEntryWithRefreshToken(keyToMatch, allKeys) {
|
|
1788
|
+
var _a;
|
|
1869
1789
|
for (const key of allKeys) {
|
|
1870
1790
|
const cacheKey = CacheKey.fromKey(key);
|
|
1871
1791
|
if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId) {
|
|
1872
|
-
var _cachedEntry$body;
|
|
1873
1792
|
const cachedEntry = await this.cache.get(key);
|
|
1874
|
-
if (cachedEntry
|
|
1793
|
+
if ((_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
|
|
1875
1794
|
return this.modifiedCachedEntry(cachedEntry, keyToMatch);
|
|
1876
1795
|
}
|
|
1877
1796
|
}
|
|
1878
1797
|
}
|
|
1879
1798
|
return undefined;
|
|
1880
1799
|
}
|
|
1800
|
+
async getRefreshTokensByAudience(audience, clientId) {
|
|
1801
|
+
var _a;
|
|
1802
|
+
const keys = await this.getCacheKeys();
|
|
1803
|
+
if (!keys) return [];
|
|
1804
|
+
const tokens = new Set;
|
|
1805
|
+
for (const key of keys) {
|
|
1806
|
+
const cacheKey = CacheKey.fromKey(key);
|
|
1807
|
+
if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === clientId && cacheKey.audience === audience) {
|
|
1808
|
+
const entry = await this.cache.get(key);
|
|
1809
|
+
if ((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) {
|
|
1810
|
+
tokens.add(entry.body.refresh_token);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
return Array.from(tokens);
|
|
1815
|
+
}
|
|
1881
1816
|
async updateEntry(oldRefreshToken, newRefreshToken) {
|
|
1817
|
+
var _a;
|
|
1882
1818
|
const allKeys = await this.getCacheKeys();
|
|
1883
1819
|
if (!allKeys) return;
|
|
1884
1820
|
for (const key of allKeys) {
|
|
1885
|
-
var _entry$body;
|
|
1886
1821
|
const entry = await this.cache.get(key);
|
|
1887
|
-
if ((entry === null || entry === void 0
|
|
1822
|
+
if (((_a = entry === null || entry === void 0 ? void 0 : entry.body) === null || _a === void 0 ? void 0 : _a.refresh_token) === oldRefreshToken) {
|
|
1888
1823
|
entry.body.refresh_token = newRefreshToken;
|
|
1889
1824
|
await this.cache.set(key, entry);
|
|
1890
1825
|
}
|
|
@@ -2139,17 +2074,17 @@ const CookieStorage = {
|
|
|
2139
2074
|
sameSite: "none"
|
|
2140
2075
|
};
|
|
2141
2076
|
}
|
|
2142
|
-
if (options
|
|
2077
|
+
if (options === null || options === void 0 ? void 0 : options.daysUntilExpire) {
|
|
2143
2078
|
cookieAttributes.expires = options.daysUntilExpire;
|
|
2144
2079
|
}
|
|
2145
|
-
if (options
|
|
2080
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2146
2081
|
cookieAttributes.domain = options.cookieDomain;
|
|
2147
2082
|
}
|
|
2148
2083
|
set_1(key, JSON.stringify(value), cookieAttributes);
|
|
2149
2084
|
},
|
|
2150
2085
|
remove(key, options) {
|
|
2151
2086
|
let cookieAttributes = {};
|
|
2152
|
-
if (options
|
|
2087
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2153
2088
|
cookieAttributes.domain = options.cookieDomain;
|
|
2154
2089
|
}
|
|
2155
2090
|
remove_1(key, cookieAttributes);
|
|
@@ -2173,10 +2108,10 @@ const CookieStorageWithLegacySameSite = {
|
|
|
2173
2108
|
secure: true
|
|
2174
2109
|
};
|
|
2175
2110
|
}
|
|
2176
|
-
if (options
|
|
2111
|
+
if (options === null || options === void 0 ? void 0 : options.daysUntilExpire) {
|
|
2177
2112
|
cookieAttributes.expires = options.daysUntilExpire;
|
|
2178
2113
|
}
|
|
2179
|
-
if (options
|
|
2114
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2180
2115
|
cookieAttributes.domain = options.cookieDomain;
|
|
2181
2116
|
}
|
|
2182
2117
|
set_1("".concat(LEGACY_PREFIX).concat(key), JSON.stringify(value), cookieAttributes);
|
|
@@ -2184,7 +2119,7 @@ const CookieStorageWithLegacySameSite = {
|
|
|
2184
2119
|
},
|
|
2185
2120
|
remove(key, options) {
|
|
2186
2121
|
let cookieAttributes = {};
|
|
2187
|
-
if (options
|
|
2122
|
+
if (options === null || options === void 0 ? void 0 : options.cookieDomain) {
|
|
2188
2123
|
cookieAttributes.domain = options.cookieDomain;
|
|
2189
2124
|
}
|
|
2190
2125
|
remove_1(key, cookieAttributes);
|
|
@@ -2212,11 +2147,12 @@ const SessionStorage = {
|
|
|
2212
2147
|
}
|
|
2213
2148
|
};
|
|
2214
2149
|
|
|
2215
|
-
|
|
2150
|
+
exports.ResponseType = void 0;
|
|
2151
|
+
|
|
2152
|
+
(function(ResponseType) {
|
|
2216
2153
|
ResponseType["Code"] = "code";
|
|
2217
2154
|
ResponseType["ConnectCode"] = "connect_code";
|
|
2218
|
-
|
|
2219
|
-
}({});
|
|
2155
|
+
})(exports.ResponseType || (exports.ResponseType = {}));
|
|
2220
2156
|
|
|
2221
2157
|
class User {}
|
|
2222
2158
|
|
|
@@ -2252,7 +2188,7 @@ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
|
|
|
2252
2188
|
};
|
|
2253
2189
|
}
|
|
2254
2190
|
|
|
2255
|
-
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBmdW5jdGlvbiBfZGVmaW5lUHJvcGVydHkoZSwgciwgdCkgewogICAgICAgIHJldHVybiAociA9IF90b1Byb3BlcnR5S2V5KHIpKSBpbiBlID8gT2JqZWN0LmRlZmluZVByb3BlcnR5KGUsIHIsIHsKICAgICAgICAgICAgdmFsdWU6IHQsCiAgICAgICAgICAgIGVudW1lcmFibGU6ICEwLAogICAgICAgICAgICBjb25maWd1cmFibGU6ICEwLAogICAgICAgICAgICB3cml0YWJsZTogITAKICAgICAgICB9KSA6IGVbcl0gPSB0LCBlOwogICAgfQogICAgZnVuY3Rpb24gb3duS2V5cyhlLCByKSB7CiAgICAgICAgdmFyIHQgPSBPYmplY3Qua2V5cyhlKTsKICAgICAgICBpZiAoT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scykgewogICAgICAgICAgICB2YXIgbyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7CiAgICAgICAgICAgIHIgJiYgKG8gPSBvLmZpbHRlcihmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihlLCByKS5lbnVtZXJhYmxlOwogICAgICAgICAgICB9KSksIHQucHVzaC5hcHBseSh0LCBvKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHQ7CiAgICB9CiAgICBmdW5jdGlvbiBfb2JqZWN0U3ByZWFkMihlKSB7CiAgICAgICAgZm9yICh2YXIgciA9IDE7IHIgPCBhcmd1bWVudHMubGVuZ3RoOyByKyspIHsKICAgICAgICAgICAgdmFyIHQgPSBudWxsICE9IGFyZ3VtZW50c1tyXSA/IGFyZ3VtZW50c1tyXSA6IHt9OwogICAgICAgICAgICByICUgMiA/IG93bktleXMoT2JqZWN0KHQpLCAhMCkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoZSwgciwgdFtyXSk7CiAgICAgICAgICAgIH0pIDogT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnMgPyBPYmplY3QuZGVmaW5lUHJvcGVydGllcyhlLCBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyh0KSkgOiBvd25LZXlzKE9iamVjdCh0KSkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZSwgciwgT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcih0LCByKSk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllcyhlLCB0KSB7CiAgICAgICAgaWYgKG51bGwgPT0gZSkgcmV0dXJuIHt9OwogICAgICAgIHZhciBvLCByLCBpID0gX29iamVjdFdpdGhvdXRQcm9wZXJ0aWVzTG9vc2UoZSwgdCk7CiAgICAgICAgaWYgKE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMpIHsKICAgICAgICAgICAgdmFyIG4gPSBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpOwogICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgbi5sZW5ndGg7IHIrKykgbyA9IG5bcl0sIC0xID09PSB0LmluZGV4T2YobykgJiYge30ucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLCBvKSAmJiAoaVtvXSA9IGVbb10pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllc0xvb3NlKHIsIGUpIHsKICAgICAgICBpZiAobnVsbCA9PSByKSByZXR1cm4ge307CiAgICAgICAgdmFyIHQgPSB7fTsKICAgICAgICBmb3IgKHZhciBuIGluIHIpIGlmICh7fS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHIsIG4pKSB7CiAgICAgICAgICAgIGlmICgtMSAhPT0gZS5pbmRleE9mKG4pKSBjb250aW51ZTsKICAgICAgICAgICAgdFtuXSA9IHJbbl07CiAgICAgICAgfQogICAgICAgIHJldHVybiB0OwogICAgfQogICAgZnVuY3Rpb24gX3RvUHJpbWl0aXZlKHQsIHIpIHsKICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIHQgfHwgIXQpIHJldHVybiB0OwogICAgICAgIHZhciBlID0gdFtTeW1ib2wudG9QcmltaXRpdmVdOwogICAgICAgIGlmICh2b2lkIDAgIT09IGUpIHsKICAgICAgICAgICAgdmFyIGkgPSBlLmNhbGwodCwgciB8fCAiZGVmYXVsdCIpOwogICAgICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIGkpIHJldHVybiBpOwogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJAQHRvUHJpbWl0aXZlIG11c3QgcmV0dXJuIGEgcHJpbWl0aXZlIHZhbHVlLiIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gKCJzdHJpbmciID09PSByID8gU3RyaW5nIDogTnVtYmVyKSh0KTsKICAgIH0KICAgIGZ1bmN0aW9uIF90b1Byb3BlcnR5S2V5KHQpIHsKICAgICAgICB2YXIgaSA9IF90b1ByaW1pdGl2ZSh0LCAic3RyaW5nIik7CiAgICAgICAgcmV0dXJuICJzeW1ib2wiID09IHR5cGVvZiBpID8gaSA6IGkgKyAiIjsKICAgIH0KICAgIGNsYXNzIEdlbmVyaWNFcnJvciBleHRlbmRzIEVycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihlcnJvciwgZXJyb3JfZGVzY3JpcHRpb24pIHsKICAgICAgICAgICAgc3VwZXIoZXJyb3JfZGVzY3JpcHRpb24pOw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ICAgICAgICBwYXJzZWRRdWVyeVtrZXldID0gdmFsOwogICAgICAgIH0pOwogICAgICAgIHJldHVybiBwYXJzZWRRdWVyeTsKICAgIH07CiAgICBjb25zdCB1cGRhdGVSZWZyZXNoVG9rZW5zID0gKG9sZFJlZnJlc2hUb2tlbiwgbmV3UmVmcmVzaFRva2VuKSA9PiB7CiAgICAgICAgT2JqZWN0LmVudHJpZXMocmVmcmVzaFRva2VucykuZm9yRWFjaChfcmVmID0+IHsKICAgICAgICAgICAgbGV0IFtrZXksIHRva2VuXSA9IF9yZWY7CiAgICAgICAgICAgIGlmICh0b2tlbiA9PT0gb2xkUmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW5zW2tleV0gPSBuZXdSZWZyZXNoVG9rZW47CiAgICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH07CiAgICBjb25zdCBjaGVja0Rvd25zY29waW5nID0gKHNjb3BlLCBhdWRpZW5jZSkgPT4gewogICAgICAgIGNvbnN0IGZpbmRDb2luY2lkZW5jZSA9IE9iamVjdC5rZXlzKHJlZnJlc2hUb2tlbnMpLmZpbmQoa2V5ID0+IHsKICAgICAgICAgICAgaWYgKGtleSAhPT0gImxhdGVzdF9yZWZyZXNoX3Rva2VuIikgewogICAgICAgICAgICAgICAgY29uc3QgaXNTYW1lQXVkaWVuY2UgPSBjYWNoZUtleUNvbnRhaW5zQXVkaWVuY2UoYXVkaWVuY2UsIGtleSk7CiAgICAgICAgICAgICAgICBjb25zdCBzY29wZXNLZXkgPSBrZXkuc3BsaXQoInwiKVsxXS5zcGxpdCgiICIpOwogICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdGVkU2NvcGVzID0gc2NvcGUuc3BsaXQoIiAiKTsKICAgICAgICAgICAgICAgIGNvbnN0IHNjb3Blc0FyZUluY2x1ZGVkID0gcmVxdWVzdGVkU2NvcGVzLmV2ZXJ5KGtleSA9PiBzY29wZXNLZXkuaW5jbHVkZXMoa2V5KSk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ZyZXNoVG9rZW4gPSByZWZyZXNoVG9rZW5zWyJsYXRlc3RfcmVmcmVzaF90b2tlbiJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRG93bnNjb3BpbmcgPSBjaGVja0Rvd25zY29waW5nKHNjb3BlLCBhdWRpZW5jZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxhdGVzdFJlZnJlc2hUb2tlbiAmJiAhaXNEb3duc2NvcGluZykgewogICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW4gPSBsYXRlc3RSZWZyZXNoVG9rZW47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFyZWZyZXNoVG9rZW4pIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgTWlzc2luZ1JlZnJlc2hUb2tlbkVycm9yKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmZXRjaE9wdGlvbnMuYm9keSA9IHVzZUZvcm1EYXRhID8gY3JlYXRlUXVlcnlQYXJhbXMoX29iamVjdFNwcmVhZDIoX29iamVjdFNwcmVhZDIoe30sIGJvZHkpLCB7fSwgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpIDogSlNPTi5zdHJpbmdpZnkoX29iamVjdFNwcmVhZDIoX29iamVjdFNwcmVhZDIoe30sIGJvZHkpLCB7fSwgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCBhYm9ydENvbnRyb2xsZXI7CiAgICAgICAgICAgIGlmICh0eXBlb2YgQWJvcnRDb250cm9sbGVyID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICBhYm9ydENvbnRyb2xsZXIgPSBuZXcgQWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLnNpZ25hbCA9IGFib3J0Q29udHJvbGxlci5zaWduYWw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IHJlc3BvbnNlOwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBhd2FpdCBQcm9taXNlLnJhY2UoWyB3YWl0KHRpbWVvdXQpLCBmZXRjaChmZXRjaFVybCwgX29iamVjdFNwcmVhZDIoe30sIGZldGNoT3B0aW9ucykpIF0pOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6ICJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCciCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXJzID0gZnJvbUVudHJpZXMocmVzcG9uc2UuaGVhZGVycyk7CiAgICAgICAgICAgIGpzb24gPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICAgIGlmIChqc29uLnJlZnJlc2hfdG9rZW4pIHsKICAgICAgICAgICAgICAgIGlmICh1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXSA9IGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWZyZXNoVG9rZW5zKHJlZnJlc2hUb2tlbiwganNvbi5yZWZyZXNoX3Rva2VuKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHNldFJlZnJlc2hUb2tlbihqc29uLnJlZnJlc2hfdG9rZW4sIGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBkZWxldGUganNvbi5yZWZyZXNoX3Rva2VuOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZGVsZXRlUmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogcmVzcG9uc2Uub2ssCiAgICAgICAgICAgICAgICBqc29uOiBqc29uLAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIG9rOiBmYWxzZSwKICAgICAgICAgICAgICAgIGpzb246IHsKICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3IuZXJyb3IsCiAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH07CiAgICB7CiAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsIG1lc3NhZ2VIYW5kbGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
2191
|
+
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29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gIH0pOwogICAgICAgIHJldHVybiBBcnJheS5mcm9tKHNlZW4pOwogICAgfTsKICAgIGNvbnN0IGRlbGV0ZVJlZnJlc2hUb2tlbnNCeVZhbHVlID0gcmVmcmVzaFRva2VuID0+IHsKICAgICAgICBPYmplY3QuZW50cmllcyhyZWZyZXNoVG9rZW5zKS5mb3JFYWNoKF9yZWYyID0+IHsKICAgICAgICAgICAgbGV0IFtrZXksIHRva2VuXSA9IF9yZWYyOwogICAgICAgICAgICBpZiAodG9rZW4gPT09IHJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgZGVsZXRlIHJlZnJlc2hUb2tlbnNba2V5XTsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHdhaXQgPSB0aW1lID0+IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gc2V0VGltZW91dChyZXNvbHZlLCB0aW1lKSk7CiAgICBjb25zdCBmb3JtRGF0YVRvT2JqZWN0ID0gZm9ybURhdGEgPT4gewogICAgICAgIGNvbnN0IHF1ZXJ5UGFyYW1zID0gbmV3IFVSTFNlYXJjaFBhcmFtcyhmb3JtRGF0YSk7CiAgICAgICAgY29uc3QgcGFyc2VkUXVlcnkgPSB7fTsKICAgICAgICBxdWVyeVBhcmFtcy5mb3JFYWNoKCh2YWwsIGtleSkgPT4gewogICAgICAgICAgICBwYXJzZWRRdWVyeVtrZXldID0gdmFsOwogICAgICAgIH0pOwogICAgICAgIHJldHVybiBwYXJzZWRRdWVyeTsKICAgIH07CiAgICBjb25zdCB1cGRhdGVSZWZyZXNoVG9rZW5zID0gKG9sZFJlZnJlc2hUb2tlbiwgbmV3UmVmcmVzaFRva2VuKSA9PiB7CiAgICAgICAgT2JqZWN0LmVudHJpZXMocmVmcmVzaFRva2VucykuZm9yRWFjaChfcmVmMyA9PiB7CiAgICAgICAgICAgIGxldCBba2V5LCB0b2tlbl0gPSBfcmVmMzsKICAgICAgICAgICAgaWYgKHRva2VuID09PSBvbGRSZWZyZXNoVG9rZW4pIHsKICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNba2V5XSA9IG5ld1JlZnJlc2hUb2tlbjsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IGNoZWNrRG93bnNjb3BpbmcgPSAoc2NvcGUsIGF1ZGllbmNlKSA9PiB7CiAgICAgICAgY29uc3QgZmluZENvaW5jaWRlbmNlID0gT2JqZWN0LmtleXMocmVmcmVzaFRva2VucykuZmluZChrZXkgPT4gewogICAgICAgICAgICBpZiAoa2V5ICE9PSAibGF0ZXN0X3JlZnJlc2hfdG9rZW4iKSB7CiAgICAgICAgICAgICAgICBjb25zdCBpc1NhbWVBdWRpZW5jZSA9IGNhY2hlS2V5Q29udGFpbnNBdWRpZW5jZShhdWRpZW5jZSwga2V5KTsKICAgICAgICAgICAgICAgIGNvbnN0IHNjb3Blc0tleSA9IGtleS5zcGxpdCgifCIpWzFdLnNwbGl0KCIgIik7CiAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ZWRTY29wZXMgPSBzY29wZS5zcGxpdCgiICIpOwogICAgICAgICAgICAgICAgY29uc3Qgc2NvcGVzQXJlSW5jbHVkZWQgPSByZXF1ZXN0ZWRTY29wZXMuZXZlcnkoa2V5ID0+IHNjb3Blc0tleS5pbmNsdWRlcyhrZXkpKTsKICAgICAgICAgICAgICAgIHJldHVybiBpc1NhbWVBdWRpZW5jZSAmJiBzY29wZXNBcmVJbmNsdWRlZDsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgICAgIHJldHVybiBmaW5kQ29pbmNpZGVuY2UgPyB0cnVlIDogZmFsc2U7CiAgICB9OwogICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBhc3luYyBfcmVmNCA9PiB7CiAgICAgICAgbGV0IHtkYXRhOiB7dGltZW91dDogdGltZW91dCwgYXV0aDogYXV0aCwgZmV0Y2hVcmw6IGZldGNoVXJsLCBmZXRjaE9wdGlvbnM6IGZldGNoT3B0aW9ucywgdXNlRm9ybURhdGE6IHVzZUZvcm1EYXRhLCB1c2VNcnJ0OiB1c2VNcnJ0fSwgcG9ydHM6IFtwb3J0XX0gPSBfcmVmNDsKICAgICAgICBsZXQgaGVhZGVycyA9IHt9OwogICAgICAgIGxldCBqc29uOwogICAgICAgIGxldCByZWZyZXNoVG9rZW47CiAgICAgICAgY29uc3Qge2F1ZGllbmNlOiBhdWRpZW5jZSwgc2NvcGU6IHNjb3BlfSA9IGF1dGggfHwge307CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgYm9keSA9IHVzZUZvcm1EYXRhID8gZm9ybURhdGFUb09iamVjdChmZXRjaE9wdGlvbnMuYm9keSkgOiBKU09OLnBhcnNlKGZldGNoT3B0aW9ucy5ib2R5KTsKICAgICAgICAgICAgaWYgKCFib2R5LnJlZnJlc2hfdG9rZW4gJiYgYm9keS5ncmFudF90eXBlID09PSAicmVmcmVzaF90b2tlbiIpIHsKICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGdldFJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgaWYgKCFyZWZyZXNoVG9rZW4gJiYgdXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxhdGVzdFJlZnJlc2hUb2tlbiA9IHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl07CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNEb3duc2NvcGluZyA9IGNoZWNrRG93bnNjb3Bpbmcoc2NvcGUsIGF1ZGllbmNlKTsKICAgICAgICAgICAgICAgICAgICBpZiAobGF0ZXN0UmVmcmVzaFRva2VuICYmICFpc0Rvd25zY29waW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGxhdGVzdFJlZnJlc2hUb2tlbjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBNaXNzaW5nUmVmcmVzaFRva2VuRXJyb3IoYXVkaWVuY2UsIHNjb3BlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5ib2R5ID0gdXNlRm9ybURhdGEgPyBjcmVhdGVRdWVyeVBhcmFtcyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSkgOiBKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IGFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgaWYgKHR5cGVvZiBBYm9ydENvbnRyb2xsZXIgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgIGFib3J0Q29udHJvbGxlciA9IG5ldyBBYm9ydENvbnRyb2xsZXI7CiAgICAgICAgICAgICAgICBmZXRjaE9wdGlvbnMuc2lnbmFsID0gYWJvcnRDb250cm9sbGVyLnNpZ25hbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgcmVzcG9uc2U7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICByZXNwb25zZSA9IGF3YWl0IFByb21pc2UucmFjZShbIHdhaXQodGltZW91dCksIGZldGNoKGZldGNoVXJsLCBPYmplY3QuYXNzaWduKHt9LCBmZXRjaE9wdGlvbnMpKSBdKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICBpZiAoYWJvcnRDb250cm9sbGVyKSBhYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVycyA9IGZyb21FbnRyaWVzKHJlc3BvbnNlLmhlYWRlcnMpOwogICAgICAgICAgICBqc29uID0gYXdhaXQgcmVzcG9uc2UuanNvbigpOwogICAgICAgICAgICBpZiAoanNvbi5yZWZyZXNoX3Rva2VuKSB7CiAgICAgICAgICAgICAgICBpZiAodXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl0gPSBqc29uLnJlZnJlc2hfdG9rZW47CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUmVmcmVzaFRva2VucyhyZWZyZXNoVG9rZW4sIGpzb24ucmVmcmVzaF90b2tlbik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzZXRSZWZyZXNoVG9rZW4oanNvbi5yZWZyZXNoX3Rva2VuLCBhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgZGVsZXRlIGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IHJlc3BvbnNlLm9rLAogICAgICAgICAgICAgICAganNvbjoganNvbiwKICAgICAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMKICAgICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICBqc29uOiB7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLmVycm9yLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgY29uc3QgcmV2b2tlTWVzc2FnZUhhbmRsZXIgPSBhc3luYyBfcmVmNSA9PiB7CiAgICAgICAgbGV0IHtkYXRhOiB7dGltZW91dDogdGltZW91dCwgYXV0aDogYXV0aCwgZmV0Y2hVcmw6IGZldGNoVXJsLCBmZXRjaE9wdGlvbnM6IGZldGNoT3B0aW9ucywgdXNlRm9ybURhdGE6IHVzZUZvcm1EYXRhfSwgcG9ydHM6IFtwb3J0XX0gPSBfcmVmNTsKICAgICAgICBjb25zdCB7YXVkaWVuY2U6IGF1ZGllbmNlfSA9IGF1dGggfHwge307CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgdG9rZW5zVG9SZXZva2UgPSBnZXRSZWZyZXNoVG9rZW5zQnlBdWRpZW5jZShhdWRpZW5jZSk7CiAgICAgICAgICAgIGlmICh0b2tlbnNUb1Jldm9rZS5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIG9rOiB0cnVlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBiYXNlQm9keSA9IHVzZUZvcm1EYXRhID8gZm9ybURhdGFUb09iamVjdChmZXRjaE9wdGlvbnMuYm9keSkgOiBKU09OLnBhcnNlKGZldGNoT3B0aW9ucy5ib2R5KTsKICAgICAgICAgICAgZm9yIChjb25zdCByZWZyZXNoVG9rZW4gb2YgdG9rZW5zVG9SZXZva2UpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYmFzZUJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpIDogSlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LCBiYXNlQm9keSksIHsKICAgICAgICAgICAgICAgICAgICB0b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICAgICAgbGV0IHNpZ25hbDsKICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgQWJvcnRDb250cm9sbGVyID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgICAgICBzaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGV0IHRpbWVvdXRJZDsKICAgICAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBhd2FpdCBQcm9taXNlLnJhY2UoWyBuZXcgUHJvbWlzZShyZXNvbHZlID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGltZW91dElkID0gc2V0VGltZW91dChyZXNvbHZlLCB0aW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICB9KSwgZmV0Y2goZmV0Y2hVcmwsIE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgZmV0Y2hPcHRpb25zKSwgewogICAgICAgICAgICAgICAgICAgICAgICBib2R5OiBib2R5LAogICAgICAgICAgICAgICAgICAgICAgICBzaWduYWw6IHNpZ25hbAogICAgICAgICAgICAgICAgICAgIH0pKSBdKS5maW5hbGx5KCgpID0+IGNsZWFyVGltZW91dCh0aW1lb3V0SWQpKTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFyZXNwb25zZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICBlcnJvcjogIlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyIKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXJlc3BvbnNlLm9rKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGVycm9yRGVzY3JpcHRpb247CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qge2Vycm9yX2Rlc2NyaXB0aW9uOiBlcnJvcl9kZXNjcmlwdGlvbn0gPSBKU09OLnBhcnNlKGF3YWl0IHJlc3BvbnNlLnRleHQoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yRGVzY3JpcHRpb24gPSBlcnJvcl9kZXNjcmlwdGlvbjsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChfYSkge30KICAgICAgICAgICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yRGVzY3JpcHRpb24gfHwgIkhUVFAgZXJyb3IgIi5jb25jYXQocmVzcG9uc2Uuc3RhdHVzKQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbnNCeVZhbHVlKHJlZnJlc2hUb2tlbik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogdHJ1ZQogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlIHx8ICJVbmtub3duIGVycm9yIGR1cmluZyB0b2tlbiByZXZvY2F0aW9uIgogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgY29uc3QgaXNBdXRob3JpemVkV29ya2VyUmVxdWVzdCA9ICh3b3JrZXJSZXF1ZXN0LCBleHBlY3RlZFBhdGgpID0+IHsKICAgICAgICBpZiAoIWFsbG93ZWRCYXNlVXJsKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgYWxsb3dlZEJhc2VPcmlnaW4gPSBuZXcgVVJMKGFsbG93ZWRCYXNlVXJsKS5vcmlnaW47CiAgICAgICAgICAgIGNvbnN0IHJlcXVlc3RlZFVybCA9IG5ldyBVUkwod29ya2VyUmVxdWVzdC5mZXRjaFVybCk7CiAgICAgICAgICAgIHJldHVybiByZXF1ZXN0ZWRVcmwub3JpZ2luID09PSBhbGxvd2VkQmFzZU9yaWdpbiAmJiByZXF1ZXN0ZWRVcmwucGF0aG5hbWUgPT09IGV4cGVjdGVkUGF0aDsKICAgICAgICB9IGNhdGNoIChfYSkgewogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgfTsKICAgIGNvbnN0IG1lc3NhZ2VSb3V0ZXIgPSBldmVudCA9PiB7CiAgICAgICAgY29uc3Qge2RhdGE6IGRhdGEsIHBvcnRzOiBwb3J0c30gPSBldmVudDsKICAgICAgICBjb25zdCBbcG9ydF0gPSBwb3J0czsKICAgICAgICBpZiAoInR5cGUiIGluIGRhdGEgJiYgZGF0YS50eXBlID09PSAiaW5pdCIpIHsKICAgICAgICAgICAgaWYgKGFsbG93ZWRCYXNlVXJsID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgIG5ldyBVUkwoZGF0YS5hbGxvd2VkQmFzZVVybCk7CiAgICAgICAgICAgICAgICAgICAgYWxsb3dlZEJhc2VVcmwgPSBkYXRhLmFsbG93ZWRCYXNlVXJsOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoX2EpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoInR5cGUiIGluIGRhdGEgJiYgZGF0YS50eXBlID09PSAicmV2b2tlIikgewogICAgICAgICAgICBpZiAoIWlzQXV0aG9yaXplZFdvcmtlclJlcXVlc3QoZGF0YSwgIi9vYXV0aC9yZXZva2UiKSkgewogICAgICAgICAgICAgICAgcG9ydCA9PT0gbnVsbCB8fCBwb3J0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAganNvbjogewogICAgICAgICAgICAgICAgICAgICAgICBlcnJvcjogImludmFsaWRfZmV0Y2hfdXJsIiwKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246ICJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIgogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge30KICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldm9rZU1lc3NhZ2VIYW5kbGVyKGV2ZW50KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoISgiZmV0Y2hVcmwiIGluIGRhdGEpIHx8ICFpc0F1dGhvcml6ZWRXb3JrZXJSZXF1ZXN0KGRhdGEsICIvb2F1dGgvdG9rZW4iKSkgewogICAgICAgICAgICBwb3J0ID09PSBudWxsIHx8IHBvcnQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IGZhbHNlLAogICAgICAgICAgICAgICAganNvbjogewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiaW52YWxpZF9mZXRjaF91cmwiLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiAiVW5hdXRob3JpemVkIGZldGNoIFVSTCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7fQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBtZXNzYWdlSGFuZGxlcihldmVudCk7CiAgICB9OwogICAgewogICAgICAgIGFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBtZXNzYWdlUm91dGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
2256
2192
|
|
|
2257
2193
|
const singlePromiseMap = {};
|
|
2258
2194
|
|
|
@@ -2275,8 +2211,8 @@ class CacheKeyManifest {
|
|
|
2275
2211
|
this.manifestKey = this.createManifestKeyFrom(this.clientId);
|
|
2276
2212
|
}
|
|
2277
2213
|
async add(key) {
|
|
2278
|
-
var
|
|
2279
|
-
const keys = new Set(((
|
|
2214
|
+
var _a;
|
|
2215
|
+
const keys = new Set(((_a = await this.cache.get(this.manifestKey)) === null || _a === void 0 ? void 0 : _a.keys) || []);
|
|
2280
2216
|
keys.add(key);
|
|
2281
2217
|
await this.cache.set(this.manifestKey, {
|
|
2282
2218
|
keys: [ ...keys ]
|
|
@@ -2306,8 +2242,6 @@ class CacheKeyManifest {
|
|
|
2306
2242
|
}
|
|
2307
2243
|
}
|
|
2308
2244
|
|
|
2309
|
-
const _excluded$2 = [ "openUrl", "onRedirect" ];
|
|
2310
|
-
|
|
2311
2245
|
const GET_TOKEN_SILENTLY_LOCK_KEY = "auth0.lock.getTokenSilently";
|
|
2312
2246
|
|
|
2313
2247
|
const GET_TOKEN_FROM_IFRAME_LOCK_KEY = "auth0.lock.getTokenFromIFrame";
|
|
@@ -2329,9 +2263,9 @@ const cacheLocationBuilders = {
|
|
|
2329
2263
|
|
|
2330
2264
|
const cacheFactory = location => cacheLocationBuilders[location];
|
|
2331
2265
|
|
|
2332
|
-
const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) =>
|
|
2266
|
+
const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) => Object.assign(Object.assign(Object.assign({
|
|
2333
2267
|
client_id: clientOptions.clientId
|
|
2334
|
-
}, clientOptions.authorizationParams), authorizationParams), {
|
|
2268
|
+
}, clientOptions.authorizationParams), authorizationParams), {
|
|
2335
2269
|
scope: scopesToRequest(scope, authorizationParams.scope, authorizationParams.audience),
|
|
2336
2270
|
response_type: "code",
|
|
2337
2271
|
response_mode: response_mode || "query",
|
|
@@ -2344,8 +2278,8 @@ const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, no
|
|
|
2344
2278
|
});
|
|
2345
2279
|
|
|
2346
2280
|
const patchOpenUrlWithOnRedirect = options => {
|
|
2347
|
-
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions =
|
|
2348
|
-
const result =
|
|
2281
|
+
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions = __rest(options, [ "openUrl", "onRedirect" ]);
|
|
2282
|
+
const result = Object.assign(Object.assign({}, originalOptions), {
|
|
2349
2283
|
openUrl: openUrl === false || openUrl ? openUrl : onRedirect
|
|
2350
2284
|
});
|
|
2351
2285
|
return result;
|
|
@@ -2365,13 +2299,13 @@ const getMissingScopes = (requestedScope, respondedScope) => {
|
|
|
2365
2299
|
};
|
|
2366
2300
|
|
|
2367
2301
|
const getScopeToRequest = (useMrrt, authorizationParams, cachedAudience, cachedScope) => {
|
|
2302
|
+
var _a;
|
|
2368
2303
|
if (useMrrt && cachedAudience && cachedScope) {
|
|
2369
|
-
var _authorizationParams$;
|
|
2370
2304
|
if (authorizationParams.audience !== cachedAudience) {
|
|
2371
2305
|
return authorizationParams.scope;
|
|
2372
2306
|
}
|
|
2373
2307
|
const cachedScopes = cachedScope.split(" ");
|
|
2374
|
-
const newScopes = ((
|
|
2308
|
+
const newScopes = ((_a = authorizationParams.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
2375
2309
|
const newScopesAreIncluded = newScopes.every(scope => cachedScopes.includes(scope));
|
|
2376
2310
|
return cachedScopes.length >= newScopes.length && newScopesAreIncluded ? cachedScope : authorizationParams.scope;
|
|
2377
2311
|
}
|
|
@@ -2451,7 +2385,7 @@ class DpopStorage {
|
|
|
2451
2385
|
}
|
|
2452
2386
|
async deleteBy(table, predicate) {
|
|
2453
2387
|
const allKeys = await this.executeDbRequest(table, "readonly", table => table.getAllKeys());
|
|
2454
|
-
allKeys === null || allKeys === void 0
|
|
2388
|
+
allKeys === null || allKeys === void 0 ? void 0 : allKeys.filter(predicate).map(k => this.executeDbRequest(table, "readwrite", table => table.delete(k)));
|
|
2455
2389
|
}
|
|
2456
2390
|
deleteByClientId(table, clientId) {
|
|
2457
2391
|
return this.deleteBy(table, k => typeof k === "string" && k.startsWith("".concat(clientId, "::")));
|
|
@@ -2484,7 +2418,7 @@ class Dpop {
|
|
|
2484
2418
|
}
|
|
2485
2419
|
async generateProof(params) {
|
|
2486
2420
|
const keyPair = await this.getOrGenerateKeyPair();
|
|
2487
|
-
return generateProof(
|
|
2421
|
+
return generateProof(Object.assign({
|
|
2488
2422
|
keyPair: keyPair
|
|
2489
2423
|
}, params));
|
|
2490
2424
|
}
|
|
@@ -2497,16 +2431,17 @@ class Dpop {
|
|
|
2497
2431
|
}
|
|
2498
2432
|
}
|
|
2499
2433
|
|
|
2500
|
-
var TokenType
|
|
2434
|
+
var TokenType;
|
|
2435
|
+
|
|
2436
|
+
(function(TokenType) {
|
|
2501
2437
|
TokenType["Bearer"] = "Bearer";
|
|
2502
2438
|
TokenType["DPoP"] = "DPoP";
|
|
2503
|
-
|
|
2504
|
-
}(TokenType || {});
|
|
2439
|
+
})(TokenType || (TokenType = {}));
|
|
2505
2440
|
|
|
2506
2441
|
class Fetcher {
|
|
2507
2442
|
constructor(config, hooks) {
|
|
2508
2443
|
this.hooks = hooks;
|
|
2509
|
-
this.config =
|
|
2444
|
+
this.config = Object.assign(Object.assign({}, config), {
|
|
2510
2445
|
fetch: config.fetch || (typeof window === "undefined" ? fetch : window.fetch.bind(window))
|
|
2511
2446
|
});
|
|
2512
2447
|
}
|
|
@@ -2614,7 +2549,7 @@ class Fetcher {
|
|
|
2614
2549
|
}
|
|
2615
2550
|
fetchWithAuth(info, init, authParams) {
|
|
2616
2551
|
const callbacks = {
|
|
2617
|
-
onUseDpopNonceError: () => this.internalFetchWithAuth(info, init,
|
|
2552
|
+
onUseDpopNonceError: () => this.internalFetchWithAuth(info, init, Object.assign(Object.assign({}, callbacks), {
|
|
2618
2553
|
onUseDpopNonceError: undefined
|
|
2619
2554
|
}), authParams)
|
|
2620
2555
|
};
|
|
@@ -2712,7 +2647,7 @@ const MfaGrantTypes = {
|
|
|
2712
2647
|
|
|
2713
2648
|
function getAuthJsEnrollParams(params) {
|
|
2714
2649
|
const mapping = FACTOR_MAPPING[params.factorType];
|
|
2715
|
-
return
|
|
2650
|
+
return Object.assign(Object.assign(Object.assign({
|
|
2716
2651
|
mfaToken: params.mfaToken,
|
|
2717
2652
|
authenticatorTypes: mapping.authenticatorTypes
|
|
2718
2653
|
}, mapping.oobChannels && {
|
|
@@ -2737,6 +2672,162 @@ function getGrantType(params) {
|
|
|
2737
2672
|
return undefined;
|
|
2738
2673
|
}
|
|
2739
2674
|
|
|
2675
|
+
function _OverloadYield(e, d) {
|
|
2676
|
+
this.v = e, this.k = d;
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
function _assertClassBrand(e, t, n) {
|
|
2680
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
2681
|
+
throw new TypeError("Private element is not present on this object");
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
function _awaitAsyncGenerator(e) {
|
|
2685
|
+
return new _OverloadYield(e, 0);
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
2689
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
function _classPrivateFieldGet2(s, a) {
|
|
2693
|
+
return s.get(_assertClassBrand(s, a));
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
2697
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
2701
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
2705
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
function _defineProperty(e, r, t) {
|
|
2709
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
2710
|
+
value: t,
|
|
2711
|
+
enumerable: !0,
|
|
2712
|
+
configurable: !0,
|
|
2713
|
+
writable: !0
|
|
2714
|
+
}) : e[r] = t, e;
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
function ownKeys(e, r) {
|
|
2718
|
+
var t = Object.keys(e);
|
|
2719
|
+
if (Object.getOwnPropertySymbols) {
|
|
2720
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2721
|
+
r && (o = o.filter(function(r) {
|
|
2722
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
2723
|
+
})), t.push.apply(t, o);
|
|
2724
|
+
}
|
|
2725
|
+
return t;
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
function _objectSpread2(e) {
|
|
2729
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2730
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2731
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
2732
|
+
_defineProperty(e, r, t[r]);
|
|
2733
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
2734
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2737
|
+
return e;
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
function _objectWithoutProperties(e, t) {
|
|
2741
|
+
if (null == e) return {};
|
|
2742
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
2743
|
+
if (Object.getOwnPropertySymbols) {
|
|
2744
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
2745
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
2746
|
+
}
|
|
2747
|
+
return i;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
2751
|
+
if (null == r) return {};
|
|
2752
|
+
var t = {};
|
|
2753
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
2754
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
2755
|
+
t[n] = r[n];
|
|
2756
|
+
}
|
|
2757
|
+
return t;
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
function _toPrimitive(t, r) {
|
|
2761
|
+
if ("object" != typeof t || !t) return t;
|
|
2762
|
+
var e = t[Symbol.toPrimitive];
|
|
2763
|
+
if (void 0 !== e) {
|
|
2764
|
+
var i = e.call(t, r || "default");
|
|
2765
|
+
if ("object" != typeof i) return i;
|
|
2766
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2767
|
+
}
|
|
2768
|
+
return ("string" === r ? String : Number)(t);
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
function _toPropertyKey(t) {
|
|
2772
|
+
var i = _toPrimitive(t, "string");
|
|
2773
|
+
return "symbol" == typeof i ? i : i + "";
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
function _wrapAsyncGenerator(e) {
|
|
2777
|
+
return function() {
|
|
2778
|
+
return new AsyncGenerator(e.apply(this, arguments));
|
|
2779
|
+
};
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
function AsyncGenerator(e) {
|
|
2783
|
+
var t, n;
|
|
2784
|
+
function resume(t, n) {
|
|
2785
|
+
try {
|
|
2786
|
+
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
2787
|
+
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
2788
|
+
if (u) {
|
|
2789
|
+
var i = "return" === t && o.k ? t : "next";
|
|
2790
|
+
if (!o.k || n.done) return resume(i, n);
|
|
2791
|
+
n = e[i](n).value;
|
|
2792
|
+
}
|
|
2793
|
+
settle(!!r.done, n);
|
|
2794
|
+
}, function(e) {
|
|
2795
|
+
resume("throw", e);
|
|
2796
|
+
});
|
|
2797
|
+
} catch (e) {
|
|
2798
|
+
settle(2, e);
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
function settle(e, r) {
|
|
2802
|
+
2 === e ? t.reject(r) : t.resolve({
|
|
2803
|
+
value: r,
|
|
2804
|
+
done: e
|
|
2805
|
+
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
2806
|
+
}
|
|
2807
|
+
this._invoke = function(e, r) {
|
|
2808
|
+
return new Promise(function(o, u) {
|
|
2809
|
+
var i = {
|
|
2810
|
+
key: e,
|
|
2811
|
+
arg: r,
|
|
2812
|
+
resolve: o,
|
|
2813
|
+
reject: u,
|
|
2814
|
+
next: null
|
|
2815
|
+
};
|
|
2816
|
+
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
2817
|
+
});
|
|
2818
|
+
}, "function" != typeof e.return && (this.return = void 0);
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
2822
|
+
return this;
|
|
2823
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
2824
|
+
return this._invoke("next", e);
|
|
2825
|
+
}, AsyncGenerator.prototype.throw = function(e) {
|
|
2826
|
+
return this._invoke("throw", e);
|
|
2827
|
+
}, AsyncGenerator.prototype.return = function(e) {
|
|
2828
|
+
return this._invoke("return", e);
|
|
2829
|
+
};
|
|
2830
|
+
|
|
2740
2831
|
var _navigator$userAgent$2, _navigator$userAgent$$2;
|
|
2741
2832
|
|
|
2742
2833
|
let USER_AGENT$2;
|
|
@@ -7017,7 +7108,7 @@ function createRemoteJWKSet(url, options) {
|
|
|
7017
7108
|
return remoteJWKSet;
|
|
7018
7109
|
}
|
|
7019
7110
|
|
|
7020
|
-
const _excluded
|
|
7111
|
+
const _excluded = [ "mfaToken" ], _excluded2 = [ "mfaToken" ];
|
|
7021
7112
|
|
|
7022
7113
|
var _baseUrl, _clientId, _customFetch, _entries, _ttlMs, _maxEntries, _configuration, _serverMetadata, _clientAuthPromise, _options, _customFetch2, _jwks, _discoveryCache, _inFlightDiscovery, _jwksCache, _Class9_brand;
|
|
7023
7114
|
|
|
@@ -7262,7 +7353,7 @@ class MfaClient {
|
|
|
7262
7353
|
}
|
|
7263
7354
|
async enrollAuthenticator(options) {
|
|
7264
7355
|
const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/associate");
|
|
7265
|
-
const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded
|
|
7356
|
+
const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded);
|
|
7266
7357
|
const apiParams = {
|
|
7267
7358
|
authenticator_types: sdkParams.authenticatorTypes
|
|
7268
7359
|
};
|
|
@@ -7307,7 +7398,7 @@ class MfaClient {
|
|
|
7307
7398
|
}
|
|
7308
7399
|
async challengeAuthenticator(options) {
|
|
7309
7400
|
const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/challenge");
|
|
7310
|
-
const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2
|
|
7401
|
+
const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2);
|
|
7311
7402
|
const body = {
|
|
7312
7403
|
mfa_token: mfaToken,
|
|
7313
7404
|
client_id: _classPrivateFieldGet2(_clientId, this),
|
|
@@ -8062,12 +8153,12 @@ const DEFAULT_TTL_MS = 10 * 60 * 1e3;
|
|
|
8062
8153
|
class MfaContextManager {
|
|
8063
8154
|
constructor() {
|
|
8064
8155
|
let ttlMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_TTL_MS;
|
|
8065
|
-
|
|
8156
|
+
this.contexts = new Map;
|
|
8066
8157
|
this.ttlMs = ttlMs;
|
|
8067
8158
|
}
|
|
8068
8159
|
set(mfaToken, context) {
|
|
8069
8160
|
this.cleanup();
|
|
8070
|
-
this.contexts.set(mfaToken,
|
|
8161
|
+
this.contexts.set(mfaToken, Object.assign(Object.assign({}, context), {
|
|
8071
8162
|
createdAt: Date.now()
|
|
8072
8163
|
}));
|
|
8073
8164
|
}
|
|
@@ -8112,9 +8203,9 @@ class MfaApiClient {
|
|
|
8112
8203
|
});
|
|
8113
8204
|
}
|
|
8114
8205
|
async getAuthenticators(mfaToken) {
|
|
8115
|
-
var
|
|
8206
|
+
var _a, _b;
|
|
8116
8207
|
const context = this.contextManager.get(mfaToken);
|
|
8117
|
-
if (!(context
|
|
8208
|
+
if (!((_a = context === null || context === void 0 ? void 0 : context.mfaRequirements) === null || _a === void 0 ? void 0 : _a.challenge) || context.mfaRequirements.challenge.length === 0) {
|
|
8118
8209
|
throw new MfaListAuthenticatorsError("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
|
|
8119
8210
|
}
|
|
8120
8211
|
const challengeTypes = context.mfaRequirements.challenge.map(c => c.type);
|
|
@@ -8128,25 +8219,25 @@ class MfaApiClient {
|
|
|
8128
8219
|
});
|
|
8129
8220
|
} catch (error) {
|
|
8130
8221
|
if (error instanceof MfaListAuthenticatorsError$1) {
|
|
8131
|
-
|
|
8132
|
-
throw new MfaListAuthenticatorsError((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.error, error.message);
|
|
8222
|
+
throw new MfaListAuthenticatorsError((_b = error.cause) === null || _b === void 0 ? void 0 : _b.error, error.message);
|
|
8133
8223
|
}
|
|
8134
8224
|
throw error;
|
|
8135
8225
|
}
|
|
8136
8226
|
}
|
|
8137
8227
|
async enroll(params) {
|
|
8228
|
+
var _a;
|
|
8138
8229
|
const authJsParams = getAuthJsEnrollParams(params);
|
|
8139
8230
|
try {
|
|
8140
8231
|
return await this.authJsMfaClient.enrollAuthenticator(authJsParams);
|
|
8141
8232
|
} catch (error) {
|
|
8142
8233
|
if (error instanceof MfaEnrollmentError$1) {
|
|
8143
|
-
|
|
8144
|
-
throw new MfaEnrollmentError((_error$cause2 = error.cause) === null || _error$cause2 === void 0 ? void 0 : _error$cause2.error, error.message);
|
|
8234
|
+
throw new MfaEnrollmentError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
|
|
8145
8235
|
}
|
|
8146
8236
|
throw error;
|
|
8147
8237
|
}
|
|
8148
8238
|
}
|
|
8149
8239
|
async challenge(params) {
|
|
8240
|
+
var _a;
|
|
8150
8241
|
try {
|
|
8151
8242
|
const authJsParams = {
|
|
8152
8243
|
challengeType: params.challengeType,
|
|
@@ -8158,8 +8249,7 @@ class MfaApiClient {
|
|
|
8158
8249
|
return await this.authJsMfaClient.challengeAuthenticator(authJsParams);
|
|
8159
8250
|
} catch (error) {
|
|
8160
8251
|
if (error instanceof MfaChallengeError$1) {
|
|
8161
|
-
|
|
8162
|
-
throw new MfaChallengeError((_error$cause3 = error.cause) === null || _error$cause3 === void 0 ? void 0 : _error$cause3.error, error.message);
|
|
8252
|
+
throw new MfaChallengeError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
|
|
8163
8253
|
}
|
|
8164
8254
|
throw error;
|
|
8165
8255
|
}
|
|
@@ -8209,20 +8299,18 @@ class MfaApiClient {
|
|
|
8209
8299
|
}
|
|
8210
8300
|
}
|
|
8211
8301
|
|
|
8212
|
-
const _excluded = [ "openUrl", "fragment", "appState" ], _excluded2 = [ "url" ], _excluded3 = [ "cacheMode" ], _excluded4 = [ "federated" ], _excluded5 = [ "openUrl" ], _excluded6 = [ "id_token", "decodedToken" ], _excluded7 = [ "mfaToken" ];
|
|
8213
|
-
|
|
8214
8302
|
class Auth0Client {
|
|
8215
8303
|
constructor(options) {
|
|
8216
|
-
|
|
8217
|
-
|
|
8304
|
+
this.userCache = (new InMemoryCache).enclosedCache;
|
|
8305
|
+
this.defaultOptions = {
|
|
8218
8306
|
authorizationParams: {
|
|
8219
8307
|
scope: DEFAULT_SCOPE
|
|
8220
8308
|
},
|
|
8221
8309
|
useRefreshTokensFallback: false,
|
|
8222
8310
|
useFormData: true
|
|
8223
|
-
}
|
|
8224
|
-
this.options =
|
|
8225
|
-
authorizationParams:
|
|
8311
|
+
};
|
|
8312
|
+
this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), options), {
|
|
8313
|
+
authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), options.authorizationParams)
|
|
8226
8314
|
});
|
|
8227
8315
|
typeof window !== "undefined" && validateCrypto();
|
|
8228
8316
|
this.lockManager = getLockManager();
|
|
@@ -8254,9 +8342,9 @@ class Auth0Client {
|
|
|
8254
8342
|
this.domainUrl = getDomain(this.options.domain);
|
|
8255
8343
|
this.tokenIssuer = getTokenIssuer(this.options.issuer, this.domainUrl);
|
|
8256
8344
|
const myAccountApiIdentifier = "".concat(this.domainUrl, "/me/");
|
|
8257
|
-
const myAccountFetcher = this.createFetcher(
|
|
8345
|
+
const myAccountFetcher = this.createFetcher(Object.assign(Object.assign({}, this.options.useDpop && {
|
|
8258
8346
|
dpopNonceId: "__auth0_my_account_api__"
|
|
8259
|
-
}), {
|
|
8347
|
+
}), {
|
|
8260
8348
|
getAccessToken: () => this.getTokenSilently({
|
|
8261
8349
|
authorizationParams: {
|
|
8262
8350
|
scope: "create:me:connected_accounts",
|
|
@@ -8277,6 +8365,10 @@ class Auth0Client {
|
|
|
8277
8365
|
} else {
|
|
8278
8366
|
this.worker = new WorkerFactory;
|
|
8279
8367
|
}
|
|
8368
|
+
this.worker.postMessage({
|
|
8369
|
+
type: "init",
|
|
8370
|
+
allowedBaseUrl: this.domainUrl
|
|
8371
|
+
});
|
|
8280
8372
|
}
|
|
8281
8373
|
}
|
|
8282
8374
|
getConfiguration() {
|
|
@@ -8330,7 +8422,7 @@ class Auth0Client {
|
|
|
8330
8422
|
url.searchParams.delete(paramName);
|
|
8331
8423
|
window.history.replaceState({}, "", url.toString());
|
|
8332
8424
|
}
|
|
8333
|
-
} catch (
|
|
8425
|
+
} catch (_a) {}
|
|
8334
8426
|
}
|
|
8335
8427
|
_applySessionTransferToken(authorizationParams) {
|
|
8336
8428
|
const paramName = this.options.sessionTransferTokenQueryParamName;
|
|
@@ -8340,18 +8432,18 @@ class Auth0Client {
|
|
|
8340
8432
|
const token = this._extractSessionTransferToken(paramName);
|
|
8341
8433
|
if (!token) return authorizationParams;
|
|
8342
8434
|
this._clearSessionTransferTokenFromUrl(paramName);
|
|
8343
|
-
return
|
|
8435
|
+
return Object.assign(Object.assign({}, authorizationParams), {
|
|
8344
8436
|
session_transfer_token: token
|
|
8345
8437
|
});
|
|
8346
8438
|
}
|
|
8347
8439
|
async _prepareAuthorizeUrl(authorizationParams, authorizeOptions, fallbackRedirectUri) {
|
|
8348
|
-
var
|
|
8440
|
+
var _a;
|
|
8349
8441
|
const state = encode$2(createRandomString());
|
|
8350
8442
|
const nonce = encode$2(createRandomString());
|
|
8351
8443
|
const code_verifier = createRandomString();
|
|
8352
8444
|
const code_challengeBuffer = await sha256(code_verifier);
|
|
8353
8445
|
const code_challenge = bufferToBase64UrlEncoded(code_challengeBuffer);
|
|
8354
|
-
const thumbprint = await ((
|
|
8446
|
+
const thumbprint = await ((_a = this.dpop) === null || _a === void 0 ? void 0 : _a.calculateThumbprint());
|
|
8355
8447
|
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);
|
|
8356
8448
|
const url = this._authorizeUrl(params);
|
|
8357
8449
|
return {
|
|
@@ -8365,7 +8457,7 @@ class Auth0Client {
|
|
|
8365
8457
|
};
|
|
8366
8458
|
}
|
|
8367
8459
|
async loginWithPopup(options, config) {
|
|
8368
|
-
var
|
|
8460
|
+
var _a;
|
|
8369
8461
|
options = options || {};
|
|
8370
8462
|
config = config || {};
|
|
8371
8463
|
if (!config.popup) {
|
|
@@ -8379,13 +8471,13 @@ class Auth0Client {
|
|
|
8379
8471
|
response_mode: "web_message"
|
|
8380
8472
|
}, window.location.origin);
|
|
8381
8473
|
config.popup.location.href = params.url;
|
|
8382
|
-
const codeResult = await runPopup(
|
|
8474
|
+
const codeResult = await runPopup(Object.assign(Object.assign({}, config), {
|
|
8383
8475
|
timeoutInSeconds: config.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
8384
8476
|
}), new URL(params.url).origin);
|
|
8385
8477
|
if (params.state !== codeResult.state) {
|
|
8386
8478
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
8387
8479
|
}
|
|
8388
|
-
const organization = ((
|
|
8480
|
+
const organization = ((_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
|
|
8389
8481
|
await this._requestToken({
|
|
8390
8482
|
audience: params.audience,
|
|
8391
8483
|
scope: params.scope,
|
|
@@ -8399,26 +8491,26 @@ class Auth0Client {
|
|
|
8399
8491
|
});
|
|
8400
8492
|
}
|
|
8401
8493
|
async getUser() {
|
|
8402
|
-
var
|
|
8494
|
+
var _a;
|
|
8403
8495
|
const cache = await this._getIdTokenFromCache();
|
|
8404
|
-
return cache === null || cache === void 0
|
|
8496
|
+
return (_a = cache === null || cache === void 0 ? void 0 : cache.decodedToken) === null || _a === void 0 ? void 0 : _a.user;
|
|
8405
8497
|
}
|
|
8406
8498
|
async getIdTokenClaims() {
|
|
8407
|
-
var
|
|
8499
|
+
var _a;
|
|
8408
8500
|
const cache = await this._getIdTokenFromCache();
|
|
8409
|
-
return cache === null || cache === void 0
|
|
8501
|
+
return (_a = cache === null || cache === void 0 ? void 0 : cache.decodedToken) === null || _a === void 0 ? void 0 : _a.claims;
|
|
8410
8502
|
}
|
|
8411
8503
|
async loginWithRedirect() {
|
|
8412
|
-
var _urlOptions$authoriza;
|
|
8413
8504
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8414
|
-
|
|
8415
|
-
const
|
|
8505
|
+
var _a;
|
|
8506
|
+
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl, fragment: fragment, appState: appState} = _b, urlOptions = __rest(_b, [ "openUrl", "fragment", "appState" ]);
|
|
8507
|
+
const organization = ((_a = urlOptions.authorizationParams) === null || _a === void 0 ? void 0 : _a.organization) || this.options.authorizationParams.organization;
|
|
8416
8508
|
const authorizationParams = this._applySessionTransferToken(urlOptions.authorizationParams || {});
|
|
8417
|
-
const
|
|
8418
|
-
this.transactionManager.create(
|
|
8509
|
+
const _c = await this._prepareAuthorizeUrl(authorizationParams), {url: url} = _c, transaction = __rest(_c, [ "url" ]);
|
|
8510
|
+
this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, transaction), {
|
|
8419
8511
|
appState: appState,
|
|
8420
|
-
response_type: ResponseType.Code
|
|
8421
|
-
}, organization && {
|
|
8512
|
+
response_type: exports.ResponseType.Code
|
|
8513
|
+
}), organization && {
|
|
8422
8514
|
organization: organization
|
|
8423
8515
|
}));
|
|
8424
8516
|
const urlWithFragment = fragment ? "".concat(url, "#").concat(fragment) : url;
|
|
@@ -8440,7 +8532,7 @@ class Auth0Client {
|
|
|
8440
8532
|
}
|
|
8441
8533
|
this.transactionManager.remove();
|
|
8442
8534
|
const authenticationResult = parseAuthenticationResult(queryStringFragments.join(""));
|
|
8443
|
-
if (transaction.response_type === ResponseType.ConnectCode) {
|
|
8535
|
+
if (transaction.response_type === exports.ResponseType.ConnectCode) {
|
|
8444
8536
|
return this._handleConnectAccountRedirectCallback(authenticationResult, transaction);
|
|
8445
8537
|
}
|
|
8446
8538
|
return this._handleLoginRedirectCallback(authenticationResult, transaction);
|
|
@@ -8456,7 +8548,7 @@ class Auth0Client {
|
|
|
8456
8548
|
const organization = transaction.organization;
|
|
8457
8549
|
const nonceIn = transaction.nonce;
|
|
8458
8550
|
const redirect_uri = transaction.redirect_uri;
|
|
8459
|
-
await this._requestToken(
|
|
8551
|
+
await this._requestToken(Object.assign({
|
|
8460
8552
|
audience: transaction.audience,
|
|
8461
8553
|
scope: transaction.scope,
|
|
8462
8554
|
code_verifier: transaction.code_verifier,
|
|
@@ -8470,7 +8562,7 @@ class Auth0Client {
|
|
|
8470
8562
|
});
|
|
8471
8563
|
return {
|
|
8472
8564
|
appState: transaction.appState,
|
|
8473
|
-
response_type: ResponseType.Code
|
|
8565
|
+
response_type: exports.ResponseType.Code
|
|
8474
8566
|
};
|
|
8475
8567
|
}
|
|
8476
8568
|
async _handleConnectAccountRedirectCallback(connectResult, transaction) {
|
|
@@ -8490,9 +8582,9 @@ class Auth0Client {
|
|
|
8490
8582
|
redirect_uri: transaction.redirect_uri,
|
|
8491
8583
|
code_verifier: transaction.code_verifier
|
|
8492
8584
|
});
|
|
8493
|
-
return
|
|
8585
|
+
return Object.assign(Object.assign({}, data), {
|
|
8494
8586
|
appState: transaction.appState,
|
|
8495
|
-
response_type: ResponseType.ConnectCode
|
|
8587
|
+
response_type: exports.ResponseType.ConnectCode
|
|
8496
8588
|
});
|
|
8497
8589
|
}
|
|
8498
8590
|
async checkSession(options) {
|
|
@@ -8512,20 +8604,20 @@ class Auth0Client {
|
|
|
8512
8604
|
} catch (_) {}
|
|
8513
8605
|
}
|
|
8514
8606
|
async getTokenSilently() {
|
|
8515
|
-
var _options$authorizatio2, _options$authorizatio3;
|
|
8516
8607
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8517
|
-
|
|
8608
|
+
var _a, _b;
|
|
8609
|
+
const localOptions = Object.assign(Object.assign({
|
|
8518
8610
|
cacheMode: "on"
|
|
8519
|
-
}, options), {
|
|
8520
|
-
authorizationParams:
|
|
8521
|
-
scope: scopesToRequest(this.scope, (
|
|
8611
|
+
}, options), {
|
|
8612
|
+
authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), options.authorizationParams), {
|
|
8613
|
+
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)
|
|
8522
8614
|
})
|
|
8523
8615
|
});
|
|
8524
8616
|
const result = await singlePromise(() => this._getTokenSilently(localOptions), "".concat(this.options.clientId, "::").concat(localOptions.authorizationParams.audience, "::").concat(localOptions.authorizationParams.scope));
|
|
8525
8617
|
return options.detailedResponse ? result : result === null || result === void 0 ? void 0 : result.access_token;
|
|
8526
8618
|
}
|
|
8527
8619
|
async _getTokenSilently(options) {
|
|
8528
|
-
const {cacheMode: cacheMode} = options, getTokenOptions =
|
|
8620
|
+
const {cacheMode: cacheMode} = options, getTokenOptions = __rest(options, [ "cacheMode" ]);
|
|
8529
8621
|
if (cacheMode !== "off") {
|
|
8530
8622
|
const entry = await this._getEntryFromCache({
|
|
8531
8623
|
scope: getTokenOptions.authorizationParams.scope,
|
|
@@ -8555,13 +8647,13 @@ class Auth0Client {
|
|
|
8555
8647
|
}
|
|
8556
8648
|
const authResult = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(getTokenOptions) : await this._getTokenFromIFrame(getTokenOptions);
|
|
8557
8649
|
const {id_token: id_token, token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = authResult;
|
|
8558
|
-
return
|
|
8650
|
+
return Object.assign(Object.assign({
|
|
8559
8651
|
id_token: id_token,
|
|
8560
8652
|
token_type: token_type,
|
|
8561
8653
|
access_token: access_token
|
|
8562
8654
|
}, oauthTokenScope ? {
|
|
8563
8655
|
scope: oauthTokenScope
|
|
8564
|
-
} : null), {
|
|
8656
|
+
} : null), {
|
|
8565
8657
|
expires_in: expires_in
|
|
8566
8658
|
});
|
|
8567
8659
|
});
|
|
@@ -8597,15 +8689,15 @@ class Auth0Client {
|
|
|
8597
8689
|
}
|
|
8598
8690
|
}
|
|
8599
8691
|
async getTokenWithPopup() {
|
|
8600
|
-
var _options$authorizatio4, _options$authorizatio5;
|
|
8601
8692
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8602
8693
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8694
|
+
var _a, _b;
|
|
8695
|
+
const localOptions = Object.assign(Object.assign({}, options), {
|
|
8696
|
+
authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), options.authorizationParams), {
|
|
8697
|
+
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)
|
|
8606
8698
|
})
|
|
8607
8699
|
});
|
|
8608
|
-
config =
|
|
8700
|
+
config = Object.assign(Object.assign({}, DEFAULT_POPUP_CONFIG_OPTIONS), config);
|
|
8609
8701
|
await this.loginWithPopup(localOptions, config);
|
|
8610
8702
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
8611
8703
|
scope: localOptions.authorizationParams.scope,
|
|
@@ -8624,17 +8716,36 @@ class Auth0Client {
|
|
|
8624
8716
|
} else {
|
|
8625
8717
|
delete options.clientId;
|
|
8626
8718
|
}
|
|
8627
|
-
const
|
|
8719
|
+
const _a = options.logoutParams || {}, {federated: federated} = _a, logoutOptions = __rest(_a, [ "federated" ]);
|
|
8628
8720
|
const federatedQuery = federated ? "&federated" : "";
|
|
8629
|
-
const url = this._url("/v2/logout?".concat(createQueryParams(
|
|
8721
|
+
const url = this._url("/v2/logout?".concat(createQueryParams(Object.assign({
|
|
8630
8722
|
clientId: options.clientId
|
|
8631
8723
|
}, logoutOptions))));
|
|
8632
8724
|
return url + federatedQuery;
|
|
8633
8725
|
}
|
|
8726
|
+
async revokeRefreshToken() {
|
|
8727
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8728
|
+
if (!this.options.useRefreshTokens) {
|
|
8729
|
+
return;
|
|
8730
|
+
}
|
|
8731
|
+
const audience = options.audience || this.options.authorizationParams.audience;
|
|
8732
|
+
const resolvedAudience = audience || DEFAULT_AUDIENCE;
|
|
8733
|
+
const refreshTokens = await this.cacheManager.getRefreshTokensByAudience(resolvedAudience, this.options.clientId);
|
|
8734
|
+
await revokeToken({
|
|
8735
|
+
baseUrl: this.domainUrl,
|
|
8736
|
+
timeout: this.httpTimeoutMs,
|
|
8737
|
+
auth0Client: this.options.auth0Client,
|
|
8738
|
+
useFormData: this.options.useFormData,
|
|
8739
|
+
client_id: this.options.clientId,
|
|
8740
|
+
refreshTokens: refreshTokens,
|
|
8741
|
+
audience: resolvedAudience,
|
|
8742
|
+
onRefreshTokenRevoked: refreshToken => this.cacheManager.stripRefreshToken(refreshToken)
|
|
8743
|
+
}, this.worker);
|
|
8744
|
+
}
|
|
8634
8745
|
async logout() {
|
|
8635
|
-
var _this$dpop2;
|
|
8636
8746
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8637
|
-
|
|
8747
|
+
var _a;
|
|
8748
|
+
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _b, logoutOptions = __rest(_b, [ "openUrl" ]);
|
|
8638
8749
|
if (options.clientId === null) {
|
|
8639
8750
|
await this.cacheManager.clear();
|
|
8640
8751
|
} else {
|
|
@@ -8647,7 +8758,7 @@ class Auth0Client {
|
|
|
8647
8758
|
cookieDomain: this.options.cookieDomain
|
|
8648
8759
|
});
|
|
8649
8760
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
8650
|
-
await ((
|
|
8761
|
+
await ((_a = this.dpop) === null || _a === void 0 ? void 0 : _a.clear());
|
|
8651
8762
|
const url = this._buildLogoutUrl(logoutOptions);
|
|
8652
8763
|
if (openUrl) {
|
|
8653
8764
|
await openUrl(url);
|
|
@@ -8659,7 +8770,7 @@ class Auth0Client {
|
|
|
8659
8770
|
const iframeLockKey = buildIframeLockKey(this.options.clientId);
|
|
8660
8771
|
try {
|
|
8661
8772
|
return await this.lockManager.runWithLock(iframeLockKey, 5e3, async () => {
|
|
8662
|
-
const params =
|
|
8773
|
+
const params = Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8663
8774
|
prompt: "none"
|
|
8664
8775
|
});
|
|
8665
8776
|
const orgHint = this.cookieStorage.get(this.orgHintCookieName);
|
|
@@ -8676,14 +8787,14 @@ class Auth0Client {
|
|
|
8676
8787
|
let eventOrigin;
|
|
8677
8788
|
try {
|
|
8678
8789
|
eventOrigin = new URL(this.domainUrl).origin;
|
|
8679
|
-
} catch (
|
|
8790
|
+
} catch (_a) {
|
|
8680
8791
|
eventOrigin = this.domainUrl;
|
|
8681
8792
|
}
|
|
8682
8793
|
const codeResult = await runIframe(url, eventOrigin, authorizeTimeout);
|
|
8683
8794
|
if (stateIn !== codeResult.state) {
|
|
8684
8795
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
8685
8796
|
}
|
|
8686
|
-
const tokenResult = await this._requestToken(
|
|
8797
|
+
const tokenResult = await this._requestToken(Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8687
8798
|
code_verifier: code_verifier,
|
|
8688
8799
|
code: codeResult.code,
|
|
8689
8800
|
grant_type: "authorization_code",
|
|
@@ -8693,7 +8804,7 @@ class Auth0Client {
|
|
|
8693
8804
|
nonceIn: nonceIn,
|
|
8694
8805
|
organization: params.organization
|
|
8695
8806
|
});
|
|
8696
|
-
return
|
|
8807
|
+
return Object.assign(Object.assign({}, tokenResult), {
|
|
8697
8808
|
scope: scope,
|
|
8698
8809
|
oauthTokenScope: tokenResult.scope,
|
|
8699
8810
|
audience: audience
|
|
@@ -8712,6 +8823,7 @@ class Auth0Client {
|
|
|
8712
8823
|
}
|
|
8713
8824
|
}
|
|
8714
8825
|
async _getTokenUsingRefreshToken(options) {
|
|
8826
|
+
var _a, _b;
|
|
8715
8827
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
8716
8828
|
scope: options.authorizationParams.scope,
|
|
8717
8829
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
@@ -8727,16 +8839,16 @@ class Auth0Client {
|
|
|
8727
8839
|
const timeout = typeof options.timeoutInSeconds === "number" ? options.timeoutInSeconds * 1e3 : null;
|
|
8728
8840
|
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);
|
|
8729
8841
|
try {
|
|
8730
|
-
const tokenResult = await this._requestToken(
|
|
8842
|
+
const tokenResult = await this._requestToken(Object.assign(Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8731
8843
|
grant_type: "refresh_token",
|
|
8732
8844
|
refresh_token: cache && cache.refresh_token,
|
|
8733
8845
|
redirect_uri: redirect_uri
|
|
8734
|
-
}, timeout && {
|
|
8846
|
+
}), timeout && {
|
|
8735
8847
|
timeout: timeout
|
|
8736
8848
|
}), {
|
|
8737
8849
|
scopesToRequest: scopesToRequest
|
|
8738
8850
|
});
|
|
8739
|
-
if (tokenResult.refresh_token && cache
|
|
8851
|
+
if (tokenResult.refresh_token && (cache === null || cache === void 0 ? void 0 : cache.refresh_token)) {
|
|
8740
8852
|
await this.cacheManager.updateEntry(cache.refresh_token, tokenResult.refresh_token);
|
|
8741
8853
|
}
|
|
8742
8854
|
if (this.options.useMrrt) {
|
|
@@ -8753,7 +8865,7 @@ class Auth0Client {
|
|
|
8753
8865
|
}
|
|
8754
8866
|
}
|
|
8755
8867
|
}
|
|
8756
|
-
return
|
|
8868
|
+
return Object.assign(Object.assign({}, tokenResult), {
|
|
8757
8869
|
scope: options.authorizationParams.scope,
|
|
8758
8870
|
oauthTokenScope: tokenResult.scope,
|
|
8759
8871
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE
|
|
@@ -8771,14 +8883,13 @@ class Auth0Client {
|
|
|
8771
8883
|
}
|
|
8772
8884
|
}
|
|
8773
8885
|
if (e instanceof MfaRequiredError) {
|
|
8774
|
-
|
|
8775
|
-
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);
|
|
8886
|
+
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);
|
|
8776
8887
|
}
|
|
8777
8888
|
throw e;
|
|
8778
8889
|
}
|
|
8779
8890
|
}
|
|
8780
8891
|
async _saveEntryInCache(entry) {
|
|
8781
|
-
const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken =
|
|
8892
|
+
const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken = __rest(entry, [ "id_token", "decodedToken" ]);
|
|
8782
8893
|
this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, {
|
|
8783
8894
|
id_token: id_token,
|
|
8784
8895
|
decodedToken: decodedToken
|
|
@@ -8801,8 +8912,8 @@ class Auth0Client {
|
|
|
8801
8912
|
this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, cache);
|
|
8802
8913
|
return cache;
|
|
8803
8914
|
}
|
|
8804
|
-
async _getEntryFromCache(
|
|
8805
|
-
let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} =
|
|
8915
|
+
async _getEntryFromCache(_ref) {
|
|
8916
|
+
let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} = _ref;
|
|
8806
8917
|
const entry = await this.cacheManager.get(new CacheKey({
|
|
8807
8918
|
scope: scope,
|
|
8808
8919
|
audience: audience,
|
|
@@ -8811,20 +8922,21 @@ class Auth0Client {
|
|
|
8811
8922
|
if (entry && entry.access_token) {
|
|
8812
8923
|
const {token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = entry;
|
|
8813
8924
|
const cache = await this._getIdTokenFromCache();
|
|
8814
|
-
return cache &&
|
|
8925
|
+
return cache && Object.assign(Object.assign({
|
|
8815
8926
|
id_token: cache.id_token,
|
|
8816
8927
|
token_type: token_type ? token_type : "Bearer",
|
|
8817
8928
|
access_token: access_token
|
|
8818
8929
|
}, oauthTokenScope ? {
|
|
8819
8930
|
scope: oauthTokenScope
|
|
8820
|
-
} : null), {
|
|
8931
|
+
} : null), {
|
|
8821
8932
|
expires_in: expires_in
|
|
8822
8933
|
});
|
|
8823
8934
|
}
|
|
8824
8935
|
}
|
|
8825
8936
|
async _requestToken(options, additionalParameters) {
|
|
8937
|
+
var _a, _b;
|
|
8826
8938
|
const {nonceIn: nonceIn, organization: organization, scopesToRequest: scopesToRequest} = additionalParameters || {};
|
|
8827
|
-
const authResult = await oauthToken(
|
|
8939
|
+
const authResult = await oauthToken(Object.assign(Object.assign({
|
|
8828
8940
|
baseUrl: this.domainUrl,
|
|
8829
8941
|
client_id: this.options.clientId,
|
|
8830
8942
|
auth0Client: this.options.auth0Client,
|
|
@@ -8832,25 +8944,24 @@ class Auth0Client {
|
|
|
8832
8944
|
timeout: this.httpTimeoutMs,
|
|
8833
8945
|
useMrrt: this.options.useMrrt,
|
|
8834
8946
|
dpop: this.dpop
|
|
8835
|
-
}, options), {
|
|
8947
|
+
}, options), {
|
|
8836
8948
|
scope: scopesToRequest || options.scope
|
|
8837
8949
|
}), this.worker);
|
|
8838
8950
|
const decodedToken = await this._verifyIdToken(authResult.id_token, nonceIn, organization);
|
|
8839
8951
|
if (options.grant_type === "authorization_code") {
|
|
8840
|
-
var _existingIdToken$deco;
|
|
8841
8952
|
const existingIdToken = await this._getIdTokenFromCache();
|
|
8842
|
-
if (existingIdToken
|
|
8953
|
+
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) {
|
|
8843
8954
|
await this.cacheManager.clear(this.options.clientId);
|
|
8844
8955
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
8845
8956
|
}
|
|
8846
8957
|
}
|
|
8847
|
-
await this._saveEntryInCache(
|
|
8958
|
+
await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, authResult), {
|
|
8848
8959
|
decodedToken: decodedToken,
|
|
8849
8960
|
scope: options.scope,
|
|
8850
8961
|
audience: options.audience || DEFAULT_AUDIENCE
|
|
8851
|
-
}, authResult.scope ? {
|
|
8962
|
+
}), authResult.scope ? {
|
|
8852
8963
|
oauthTokenScope: authResult.scope
|
|
8853
|
-
} : null), {
|
|
8964
|
+
} : null), {
|
|
8854
8965
|
client_id: this.options.clientId
|
|
8855
8966
|
}));
|
|
8856
8967
|
this.cookieStorage.save(this.isAuthenticatedCookieName, true, {
|
|
@@ -8858,12 +8969,12 @@ class Auth0Client {
|
|
|
8858
8969
|
cookieDomain: this.options.cookieDomain
|
|
8859
8970
|
});
|
|
8860
8971
|
this._processOrgHint(organization || decodedToken.claims.org_id);
|
|
8861
|
-
return
|
|
8972
|
+
return Object.assign(Object.assign({}, authResult), {
|
|
8862
8973
|
decodedToken: decodedToken
|
|
8863
8974
|
});
|
|
8864
8975
|
}
|
|
8865
8976
|
async loginWithCustomTokenExchange(options) {
|
|
8866
|
-
return this._requestToken(
|
|
8977
|
+
return this._requestToken(Object.assign(Object.assign({}, options), {
|
|
8867
8978
|
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
8868
8979
|
subject_token: options.subject_token,
|
|
8869
8980
|
subject_token_type: options.subject_token_type,
|
|
@@ -8897,10 +9008,10 @@ class Auth0Client {
|
|
|
8897
9008
|
return new Fetcher(config, {
|
|
8898
9009
|
isDpopEnabled: () => !!this.options.useDpop,
|
|
8899
9010
|
getAccessToken: authParams => {
|
|
8900
|
-
var
|
|
9011
|
+
var _a;
|
|
8901
9012
|
return this.getTokenSilently({
|
|
8902
9013
|
authorizationParams: {
|
|
8903
|
-
scope: authParams === null || authParams === void 0
|
|
9014
|
+
scope: (_a = authParams === null || authParams === void 0 ? void 0 : authParams.scope) === null || _a === void 0 ? void 0 : _a.join(" "),
|
|
8904
9015
|
audience: authParams === null || authParams === void 0 ? void 0 : authParams.audience
|
|
8905
9016
|
},
|
|
8906
9017
|
detailedResponse: true
|
|
@@ -8936,7 +9047,7 @@ class Auth0Client {
|
|
|
8936
9047
|
redirect_uri: redirectUri,
|
|
8937
9048
|
appState: appState,
|
|
8938
9049
|
connection: connection,
|
|
8939
|
-
response_type: ResponseType.ConnectCode
|
|
9050
|
+
response_type: exports.ResponseType.ConnectCode
|
|
8940
9051
|
});
|
|
8941
9052
|
const url = new URL(connect_uri);
|
|
8942
9053
|
url.searchParams.set("ticket", connect_params.ticket);
|
|
@@ -8947,8 +9058,8 @@ class Auth0Client {
|
|
|
8947
9058
|
}
|
|
8948
9059
|
}
|
|
8949
9060
|
async _requestTokenForMfa(options, additionalParameters) {
|
|
8950
|
-
const {mfaToken: mfaToken} = options, restOptions =
|
|
8951
|
-
return this._requestToken(
|
|
9061
|
+
const {mfaToken: mfaToken} = options, restOptions = __rest(options, [ "mfaToken" ]);
|
|
9062
|
+
return this._requestToken(Object.assign(Object.assign({}, restOptions), {
|
|
8952
9063
|
mfa_token: mfaToken
|
|
8953
9064
|
}), additionalParameters);
|
|
8954
9065
|
}
|
|
@@ -9000,8 +9111,6 @@ exports.PopupOpenError = PopupOpenError;
|
|
|
9000
9111
|
|
|
9001
9112
|
exports.PopupTimeoutError = PopupTimeoutError;
|
|
9002
9113
|
|
|
9003
|
-
exports.ResponseType = ResponseType;
|
|
9004
|
-
|
|
9005
9114
|
exports.TimeoutError = TimeoutError;
|
|
9006
9115
|
|
|
9007
9116
|
exports.UseDpopNonceError = UseDpopNonceError;
|