@auth0/auth0-spa-js 2.17.1 → 2.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/auth0-spa-js.development.js +430 -314
- 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 +71 -21
- 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 +453 -334
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/package.json +4 -3
- package/src/Auth0Client.ts +67 -9
- package/src/global.ts +44 -0
- package/src/index.ts +6 -3
- package/src/utils.ts +11 -5
- package/src/version.ts +1 -1
- package/dist/typings/Auth0Client.d.ts +0 -415
- package/dist/typings/Auth0Client.utils.d.ts +0 -90
- package/dist/typings/MyAccountApiClient.d.ts +0 -92
- package/dist/typings/TokenExchange.d.ts +0 -77
- package/dist/typings/api.d.ts +0 -2
- package/dist/typings/cache/cache-localstorage.d.ts +0 -7
- package/dist/typings/cache/cache-manager.d.ts +0 -56
- package/dist/typings/cache/cache-memory.d.ts +0 -4
- package/dist/typings/cache/index.d.ts +0 -4
- package/dist/typings/cache/key-manifest.d.ts +0 -12
- package/dist/typings/cache/shared.d.ts +0 -68
- package/dist/typings/constants.d.ts +0 -58
- package/dist/typings/dpop/dpop.d.ts +0 -17
- package/dist/typings/dpop/storage.d.ts +0 -27
- package/dist/typings/dpop/utils.d.ts +0 -15
- package/dist/typings/errors.d.ts +0 -96
- package/dist/typings/fetcher.d.ts +0 -54
- package/dist/typings/global.d.ts +0 -777
- package/dist/typings/http.d.ts +0 -5
- package/dist/typings/index.d.ts +0 -23
- package/dist/typings/jwt.d.ts +0 -21
- package/dist/typings/lock.d.ts +0 -32
- package/dist/typings/mfa/MfaApiClient.d.ts +0 -225
- package/dist/typings/mfa/MfaContextManager.d.ts +0 -79
- package/dist/typings/mfa/constants.d.ts +0 -23
- package/dist/typings/mfa/errors.d.ts +0 -117
- package/dist/typings/mfa/index.d.ts +0 -4
- package/dist/typings/mfa/types.d.ts +0 -181
- package/dist/typings/mfa/utils.d.ts +0 -23
- package/dist/typings/promise-utils.d.ts +0 -2
- package/dist/typings/scope.d.ts +0 -35
- package/dist/typings/storage.d.ts +0 -26
- package/dist/typings/transaction-manager.d.ts +0 -33
- package/dist/typings/utils.d.ts +0 -36
- package/dist/typings/version.d.ts +0 -2
- package/dist/typings/worker/token.worker.d.ts +0 -1
- package/dist/typings/worker/worker.types.d.ts +0 -15
- package/dist/typings/worker/worker.utils.d.ts +0 -7
|
@@ -3,19 +3,145 @@
|
|
|
3
3
|
factory(global.auth0 = {}));
|
|
4
4
|
})(this, function(exports) {
|
|
5
5
|
"use strict";
|
|
6
|
-
function
|
|
6
|
+
function _OverloadYield(e, d) {
|
|
7
|
+
this.v = e, this.k = d;
|
|
8
|
+
}
|
|
9
|
+
function _assertClassBrand(e, t, n) {
|
|
10
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
11
|
+
throw new TypeError("Private element is not present on this object");
|
|
12
|
+
}
|
|
13
|
+
function _awaitAsyncGenerator(e) {
|
|
14
|
+
return new _OverloadYield(e, 0);
|
|
15
|
+
}
|
|
16
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
17
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
18
|
+
}
|
|
19
|
+
function _classPrivateFieldGet2(s, a) {
|
|
20
|
+
return s.get(_assertClassBrand(s, a));
|
|
21
|
+
}
|
|
22
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
23
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
24
|
+
}
|
|
25
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
26
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
27
|
+
}
|
|
28
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
29
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
30
|
+
}
|
|
31
|
+
function _defineProperty(e, r, t) {
|
|
32
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
33
|
+
value: t,
|
|
34
|
+
enumerable: !0,
|
|
35
|
+
configurable: !0,
|
|
36
|
+
writable: !0
|
|
37
|
+
}) : e[r] = t, e;
|
|
38
|
+
}
|
|
39
|
+
function ownKeys(e, r) {
|
|
40
|
+
var t = Object.keys(e);
|
|
41
|
+
if (Object.getOwnPropertySymbols) {
|
|
42
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
43
|
+
r && (o = o.filter(function(r) {
|
|
44
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
45
|
+
})), t.push.apply(t, o);
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
48
|
+
}
|
|
49
|
+
function _objectSpread2(e) {
|
|
50
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
51
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
52
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
53
|
+
_defineProperty(e, r, t[r]);
|
|
54
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
55
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return e;
|
|
59
|
+
}
|
|
60
|
+
function _objectWithoutProperties(e, t) {
|
|
61
|
+
if (null == e) return {};
|
|
62
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
63
|
+
if (Object.getOwnPropertySymbols) {
|
|
64
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
65
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
66
|
+
}
|
|
67
|
+
return i;
|
|
68
|
+
}
|
|
69
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
70
|
+
if (null == r) return {};
|
|
7
71
|
var t = {};
|
|
8
|
-
for (var
|
|
9
|
-
|
|
10
|
-
|
|
72
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
73
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
74
|
+
t[n] = r[n];
|
|
11
75
|
}
|
|
12
76
|
return t;
|
|
13
77
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
78
|
+
function _toPrimitive(t, r) {
|
|
79
|
+
if ("object" != typeof t || !t) return t;
|
|
80
|
+
var e = t[Symbol.toPrimitive];
|
|
81
|
+
if (void 0 !== e) {
|
|
82
|
+
var i = e.call(t, r || "default");
|
|
83
|
+
if ("object" != typeof i) return i;
|
|
84
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
85
|
+
}
|
|
86
|
+
return ("string" === r ? String : Number)(t);
|
|
87
|
+
}
|
|
88
|
+
function _toPropertyKey(t) {
|
|
89
|
+
var i = _toPrimitive(t, "string");
|
|
90
|
+
return "symbol" == typeof i ? i : i + "";
|
|
91
|
+
}
|
|
92
|
+
function _wrapAsyncGenerator(e) {
|
|
93
|
+
return function() {
|
|
94
|
+
return new AsyncGenerator(e.apply(this, arguments));
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function AsyncGenerator(e) {
|
|
98
|
+
var t, n;
|
|
99
|
+
function resume(t, n) {
|
|
100
|
+
try {
|
|
101
|
+
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
102
|
+
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
103
|
+
if (u) {
|
|
104
|
+
var i = "return" === t && o.k ? t : "next";
|
|
105
|
+
if (!o.k || n.done) return resume(i, n);
|
|
106
|
+
n = e[i](n).value;
|
|
107
|
+
}
|
|
108
|
+
settle(!!r.done, n);
|
|
109
|
+
}, function(e) {
|
|
110
|
+
resume("throw", e);
|
|
111
|
+
});
|
|
112
|
+
} catch (e) {
|
|
113
|
+
settle(2, e);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function settle(e, r) {
|
|
117
|
+
2 === e ? t.reject(r) : t.resolve({
|
|
118
|
+
value: r,
|
|
119
|
+
done: e
|
|
120
|
+
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
121
|
+
}
|
|
122
|
+
this._invoke = function(e, r) {
|
|
123
|
+
return new Promise(function(o, u) {
|
|
124
|
+
var i = {
|
|
125
|
+
key: e,
|
|
126
|
+
arg: r,
|
|
127
|
+
resolve: o,
|
|
128
|
+
reject: u,
|
|
129
|
+
next: null
|
|
130
|
+
};
|
|
131
|
+
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
132
|
+
});
|
|
133
|
+
}, "function" != typeof e.return && (this.return = void 0);
|
|
134
|
+
}
|
|
135
|
+
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
136
|
+
return this;
|
|
137
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
138
|
+
return this._invoke("next", e);
|
|
139
|
+
}, AsyncGenerator.prototype.throw = function(e) {
|
|
140
|
+
return this._invoke("throw", e);
|
|
141
|
+
}, AsyncGenerator.prototype.return = function(e) {
|
|
142
|
+
return this._invoke("return", e);
|
|
17
143
|
};
|
|
18
|
-
var version = "2.
|
|
144
|
+
var version = "2.18.1";
|
|
19
145
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
20
146
|
const DEFAULT_POPUP_CONFIG_OPTIONS = {
|
|
21
147
|
timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
@@ -128,6 +254,7 @@
|
|
|
128
254
|
let exclude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
129
255
|
return value && !exclude.includes(value) ? value : "";
|
|
130
256
|
}
|
|
257
|
+
const _excluded$5 = [ "clientId" ];
|
|
131
258
|
const parseAuthenticationResult = queryString => {
|
|
132
259
|
if (queryString.indexOf("#") > -1) {
|
|
133
260
|
queryString = queryString.substring(0, queryString.indexOf("#"));
|
|
@@ -183,7 +310,7 @@
|
|
|
183
310
|
const top = window.screenY + (window.innerHeight - height) / 2;
|
|
184
311
|
return window.open(url, "auth0:authorize:popup", "left=".concat(left, ",top=").concat(top, ",width=").concat(width, ",height=").concat(height, ",resizable,scrollbars=yes,status=1"));
|
|
185
312
|
};
|
|
186
|
-
const runPopup = config => new Promise((resolve, reject) => {
|
|
313
|
+
const runPopup = (config, eventOrigin) => new Promise((resolve, reject) => {
|
|
187
314
|
let _popupEventListener;
|
|
188
315
|
const popupTimer = setInterval(() => {
|
|
189
316
|
if (config.popup && config.popup.closed) {
|
|
@@ -199,6 +326,7 @@
|
|
|
199
326
|
window.removeEventListener("message", _popupEventListener, false);
|
|
200
327
|
}, (config.timeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) * 1e3);
|
|
201
328
|
_popupEventListener = function popupEventListener(e) {
|
|
329
|
+
if (e.origin !== eventOrigin) return;
|
|
202
330
|
if (!e.data || e.data.type !== "authorization_response") {
|
|
203
331
|
return;
|
|
204
332
|
}
|
|
@@ -218,13 +346,20 @@
|
|
|
218
346
|
const getCrypto = () => window.crypto;
|
|
219
347
|
const createRandomString = () => {
|
|
220
348
|
const charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
|
|
349
|
+
const validMax = 256 - 256 % charset.length;
|
|
221
350
|
let random = "";
|
|
222
|
-
|
|
223
|
-
|
|
351
|
+
while (random.length < 43) {
|
|
352
|
+
const bytes = getCrypto().getRandomValues(new Uint8Array(43 - random.length));
|
|
353
|
+
for (const byte of bytes) {
|
|
354
|
+
if (random.length < 43 && byte < validMax) {
|
|
355
|
+
random += charset[byte % charset.length];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
224
359
|
return random;
|
|
225
360
|
};
|
|
226
361
|
const encode$2 = value => btoa(value);
|
|
227
|
-
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) =>
|
|
362
|
+
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) => _objectSpread2(_objectSpread2({}, acc), {}, {
|
|
228
363
|
[key]: params[key]
|
|
229
364
|
}), {});
|
|
230
365
|
const ALLOWED_AUTH0CLIENT_PROPERTIES = [ {
|
|
@@ -250,9 +385,9 @@
|
|
|
250
385
|
return acc;
|
|
251
386
|
}, {});
|
|
252
387
|
};
|
|
253
|
-
const createQueryParams =
|
|
254
|
-
|
|
255
|
-
return new URLSearchParams(stripUndefined(
|
|
388
|
+
const createQueryParams = _ref => {
|
|
389
|
+
let {clientId: client_id} = _ref, params = _objectWithoutProperties(_ref, _excluded$5);
|
|
390
|
+
return new URLSearchParams(stripUndefined(_objectSpread2({
|
|
256
391
|
client_id: client_id
|
|
257
392
|
}, params))).toString();
|
|
258
393
|
};
|
|
@@ -302,8 +437,8 @@
|
|
|
302
437
|
}
|
|
303
438
|
return parseInt(value, 10) || undefined;
|
|
304
439
|
};
|
|
305
|
-
const fromEntries = iterable => [ ...iterable ].reduce((obj,
|
|
306
|
-
let [key, val] =
|
|
440
|
+
const fromEntries = iterable => [ ...iterable ].reduce((obj, _ref2) => {
|
|
441
|
+
let [key, val] = _ref2;
|
|
307
442
|
obj[key] = val;
|
|
308
443
|
return obj;
|
|
309
444
|
}, {});
|
|
@@ -843,7 +978,9 @@
|
|
|
843
978
|
}
|
|
844
979
|
class LegacyLockManager {
|
|
845
980
|
constructor() {
|
|
846
|
-
this
|
|
981
|
+
_defineProperty(this, "lock", void 0);
|
|
982
|
+
_defineProperty(this, "activeLocks", new Set);
|
|
983
|
+
_defineProperty(this, "pagehideHandler", void 0);
|
|
847
984
|
this.lock = new _default;
|
|
848
985
|
this.pagehideHandler = () => {
|
|
849
986
|
this.activeLocks.forEach(key => this.lock.releaseLock(key));
|
|
@@ -875,8 +1012,8 @@
|
|
|
875
1012
|
}
|
|
876
1013
|
}
|
|
877
1014
|
function isWebLocksSupported() {
|
|
878
|
-
var
|
|
879
|
-
return typeof navigator !== "undefined" && typeof ((
|
|
1015
|
+
var _navigator$locks;
|
|
1016
|
+
return typeof navigator !== "undefined" && typeof ((_navigator$locks = navigator.locks) === null || _navigator$locks === void 0 ? void 0 : _navigator$locks.request) === "function";
|
|
880
1017
|
}
|
|
881
1018
|
function createLockManager() {
|
|
882
1019
|
return isWebLocksSupported() ? new WebLocksApiManager : new LegacyLockManager;
|
|
@@ -1210,6 +1347,7 @@
|
|
|
1210
1347
|
};
|
|
1211
1348
|
to.postMessage(message, [ messageChannel.port2 ]);
|
|
1212
1349
|
});
|
|
1350
|
+
const _excluded$4 = [ "error", "error_description" ];
|
|
1213
1351
|
const createAbortController = () => new AbortController;
|
|
1214
1352
|
const dofetch = async (fetchUrl, fetchOptions) => {
|
|
1215
1353
|
const response = await fetch(fetchUrl, fetchOptions);
|
|
@@ -1259,7 +1397,7 @@
|
|
|
1259
1397
|
method: options.method || "GET",
|
|
1260
1398
|
nonce: await dpop.getNonce()
|
|
1261
1399
|
});
|
|
1262
|
-
options.headers =
|
|
1400
|
+
options.headers = _objectSpread2(_objectSpread2({}, options.headers), {}, {
|
|
1263
1401
|
dpop: dpopProof
|
|
1264
1402
|
});
|
|
1265
1403
|
}
|
|
@@ -1277,7 +1415,7 @@
|
|
|
1277
1415
|
if (fetchError) {
|
|
1278
1416
|
throw fetchError;
|
|
1279
1417
|
}
|
|
1280
|
-
const
|
|
1418
|
+
const {json: {error: error, error_description: error_description}, headers: headers, ok: ok} = response, data = _objectWithoutProperties(response.json, _excluded$4);
|
|
1281
1419
|
let newDpopNonce;
|
|
1282
1420
|
if (dpop) {
|
|
1283
1421
|
newDpopNonce = headers[DPOP_NONCE_HEADER];
|
|
@@ -1303,11 +1441,12 @@
|
|
|
1303
1441
|
}
|
|
1304
1442
|
return data;
|
|
1305
1443
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1444
|
+
const _excluded$3 = [ "baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData", "useMrrt", "dpop" ];
|
|
1445
|
+
async function oauthToken(_ref, worker) {
|
|
1446
|
+
let {baseUrl: baseUrl, timeout: timeout, audience: audience, scope: scope, auth0Client: auth0Client, useFormData: useFormData, useMrrt: useMrrt, dpop: dpop} = _ref, options = _objectWithoutProperties(_ref, _excluded$3);
|
|
1308
1447
|
const isTokenExchange = options.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
1309
1448
|
const refreshWithMrrt = options.grant_type === "refresh_token" && useMrrt;
|
|
1310
|
-
const allParams =
|
|
1449
|
+
const allParams = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, options), isTokenExchange && audience && {
|
|
1311
1450
|
audience: audience
|
|
1312
1451
|
}), isTokenExchange && scope && {
|
|
1313
1452
|
scope: scope
|
|
@@ -1369,6 +1508,9 @@
|
|
|
1369
1508
|
let suffix = arguments.length > 2 ? arguments[2] : undefined;
|
|
1370
1509
|
this.prefix = prefix;
|
|
1371
1510
|
this.suffix = suffix;
|
|
1511
|
+
_defineProperty(this, "clientId", void 0);
|
|
1512
|
+
_defineProperty(this, "scope", void 0);
|
|
1513
|
+
_defineProperty(this, "audience", void 0);
|
|
1372
1514
|
this.clientId = data.clientId;
|
|
1373
1515
|
this.scope = data.scope;
|
|
1374
1516
|
this.audience = data.audience;
|
|
@@ -1416,7 +1558,7 @@
|
|
|
1416
1558
|
}
|
|
1417
1559
|
class InMemoryCache {
|
|
1418
1560
|
constructor() {
|
|
1419
|
-
this
|
|
1561
|
+
_defineProperty(this, "enclosedCache", function() {
|
|
1420
1562
|
let cache = {};
|
|
1421
1563
|
return {
|
|
1422
1564
|
set(key, entry) {
|
|
@@ -1436,7 +1578,7 @@
|
|
|
1436
1578
|
return Object.keys(cache);
|
|
1437
1579
|
}
|
|
1438
1580
|
};
|
|
1439
|
-
}();
|
|
1581
|
+
}());
|
|
1440
1582
|
}
|
|
1441
1583
|
}
|
|
1442
1584
|
const DEFAULT_EXPIRY_ADJUSTMENT_SECONDS = 0;
|
|
@@ -1444,16 +1586,17 @@
|
|
|
1444
1586
|
constructor(cache, keyManifest, nowProvider) {
|
|
1445
1587
|
this.cache = cache;
|
|
1446
1588
|
this.keyManifest = keyManifest;
|
|
1589
|
+
_defineProperty(this, "nowProvider", void 0);
|
|
1447
1590
|
this.nowProvider = nowProvider || DEFAULT_NOW_PROVIDER;
|
|
1448
1591
|
}
|
|
1449
1592
|
async setIdToken(clientId, idToken, decodedToken) {
|
|
1450
|
-
var
|
|
1593
|
+
var _this$keyManifest;
|
|
1451
1594
|
const cacheKey = this.getIdTokenCacheKey(clientId);
|
|
1452
1595
|
await this.cache.set(cacheKey, {
|
|
1453
1596
|
id_token: idToken,
|
|
1454
1597
|
decodedToken: decodedToken
|
|
1455
1598
|
});
|
|
1456
|
-
await ((
|
|
1599
|
+
await ((_this$keyManifest = this.keyManifest) === null || _this$keyManifest === void 0 ? void 0 : _this$keyManifest.add(cacheKey));
|
|
1457
1600
|
}
|
|
1458
1601
|
async getIdToken(cacheKey) {
|
|
1459
1602
|
const entry = await this.cache.get(this.getIdTokenCacheKey(cacheKey.clientId));
|
|
@@ -1482,7 +1625,6 @@
|
|
|
1482
1625
|
let expiryAdjustmentSeconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_EXPIRY_ADJUSTMENT_SECONDS;
|
|
1483
1626
|
let useMrrt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1484
1627
|
let cacheMode = arguments.length > 3 ? arguments[3] : undefined;
|
|
1485
|
-
var _a;
|
|
1486
1628
|
let wrappedEntry = await this.cache.get(cacheKey.toKey());
|
|
1487
1629
|
if (!wrappedEntry) {
|
|
1488
1630
|
const keys = await this.getCacheKeys();
|
|
@@ -1501,11 +1643,12 @@
|
|
|
1501
1643
|
const now = await this.nowProvider();
|
|
1502
1644
|
const nowSeconds = Math.floor(now / 1e3);
|
|
1503
1645
|
if (wrappedEntry.expiresAt - expiryAdjustmentSeconds < nowSeconds) {
|
|
1646
|
+
var _this$keyManifest2;
|
|
1504
1647
|
if (wrappedEntry.body.refresh_token) {
|
|
1505
1648
|
return this.modifiedCachedEntry(wrappedEntry, cacheKey);
|
|
1506
1649
|
}
|
|
1507
1650
|
await this.cache.remove(cacheKey.toKey());
|
|
1508
|
-
await ((
|
|
1651
|
+
await ((_this$keyManifest2 = this.keyManifest) === null || _this$keyManifest2 === void 0 ? void 0 : _this$keyManifest2.remove(cacheKey.toKey()));
|
|
1509
1652
|
return;
|
|
1510
1653
|
}
|
|
1511
1654
|
return wrappedEntry.body;
|
|
@@ -1524,7 +1667,7 @@
|
|
|
1524
1667
|
};
|
|
1525
1668
|
}
|
|
1526
1669
|
async set(entry) {
|
|
1527
|
-
var
|
|
1670
|
+
var _this$keyManifest3;
|
|
1528
1671
|
const cacheKey = new CacheKey({
|
|
1529
1672
|
clientId: entry.client_id,
|
|
1530
1673
|
scope: entry.scope,
|
|
@@ -1532,7 +1675,7 @@
|
|
|
1532
1675
|
});
|
|
1533
1676
|
const wrappedEntry = await this.wrapCacheEntry(entry);
|
|
1534
1677
|
await this.cache.set(cacheKey.toKey(), wrappedEntry);
|
|
1535
|
-
await ((
|
|
1678
|
+
await ((_this$keyManifest3 = this.keyManifest) === null || _this$keyManifest3 === void 0 ? void 0 : _this$keyManifest3.add(cacheKey.toKey()));
|
|
1536
1679
|
}
|
|
1537
1680
|
async remove(client_id, audience, scope) {
|
|
1538
1681
|
const cacheKey = new CacheKey({
|
|
@@ -1543,14 +1686,14 @@
|
|
|
1543
1686
|
await this.cache.remove(cacheKey.toKey());
|
|
1544
1687
|
}
|
|
1545
1688
|
async clear(clientId) {
|
|
1546
|
-
var
|
|
1689
|
+
var _this$keyManifest4;
|
|
1547
1690
|
const keys = await this.getCacheKeys();
|
|
1548
1691
|
if (!keys) return;
|
|
1549
1692
|
await keys.filter(key => clientId ? key.includes(clientId) : true).reduce(async (memo, key) => {
|
|
1550
1693
|
await memo;
|
|
1551
1694
|
await this.cache.remove(key);
|
|
1552
1695
|
}, Promise.resolve());
|
|
1553
|
-
await ((
|
|
1696
|
+
await ((_this$keyManifest4 = this.keyManifest) === null || _this$keyManifest4 === void 0 ? void 0 : _this$keyManifest4.clear());
|
|
1554
1697
|
}
|
|
1555
1698
|
async wrapCacheEntry(entry) {
|
|
1556
1699
|
const now = await this.nowProvider();
|
|
@@ -1561,9 +1704,9 @@
|
|
|
1561
1704
|
};
|
|
1562
1705
|
}
|
|
1563
1706
|
async getCacheKeys() {
|
|
1564
|
-
var _a;
|
|
1565
1707
|
if (this.keyManifest) {
|
|
1566
|
-
|
|
1708
|
+
var _await$this$keyManife;
|
|
1709
|
+
return (_await$this$keyManife = await this.keyManifest.get()) === null || _await$this$keyManife === void 0 ? void 0 : _await$this$keyManife.keys;
|
|
1567
1710
|
} else if (this.cache.allKeys) {
|
|
1568
1711
|
return this.cache.allKeys();
|
|
1569
1712
|
}
|
|
@@ -1575,21 +1718,21 @@
|
|
|
1575
1718
|
}
|
|
1576
1719
|
matchExistingCacheKey(keyToMatch, allKeys) {
|
|
1577
1720
|
return allKeys.filter(key => {
|
|
1578
|
-
var
|
|
1721
|
+
var _keyToMatch$scope;
|
|
1579
1722
|
const cacheKey = CacheKey.fromKey(key);
|
|
1580
1723
|
const scopeSet = new Set(cacheKey.scope && cacheKey.scope.split(" "));
|
|
1581
|
-
const scopesToMatch = ((
|
|
1724
|
+
const scopesToMatch = ((_keyToMatch$scope = keyToMatch.scope) === null || _keyToMatch$scope === void 0 ? void 0 : _keyToMatch$scope.split(" ")) || [];
|
|
1582
1725
|
const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((acc, current) => acc && scopeSet.has(current), true);
|
|
1583
1726
|
return cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId && cacheKey.audience === keyToMatch.audience && hasAllScopes;
|
|
1584
1727
|
})[0];
|
|
1585
1728
|
}
|
|
1586
1729
|
async getEntryWithRefreshToken(keyToMatch, allKeys) {
|
|
1587
|
-
var _a;
|
|
1588
1730
|
for (const key of allKeys) {
|
|
1589
1731
|
const cacheKey = CacheKey.fromKey(key);
|
|
1590
1732
|
if (cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId) {
|
|
1733
|
+
var _cachedEntry$body;
|
|
1591
1734
|
const cachedEntry = await this.cache.get(key);
|
|
1592
|
-
if (
|
|
1735
|
+
if (cachedEntry !== null && cachedEntry !== void 0 && (_cachedEntry$body = cachedEntry.body) !== null && _cachedEntry$body !== void 0 && _cachedEntry$body.refresh_token) {
|
|
1593
1736
|
return this.modifiedCachedEntry(cachedEntry, keyToMatch);
|
|
1594
1737
|
}
|
|
1595
1738
|
}
|
|
@@ -1597,12 +1740,12 @@
|
|
|
1597
1740
|
return undefined;
|
|
1598
1741
|
}
|
|
1599
1742
|
async updateEntry(oldRefreshToken, newRefreshToken) {
|
|
1600
|
-
var _a;
|
|
1601
1743
|
const allKeys = await this.getCacheKeys();
|
|
1602
1744
|
if (!allKeys) return;
|
|
1603
1745
|
for (const key of allKeys) {
|
|
1746
|
+
var _entry$body;
|
|
1604
1747
|
const entry = await this.cache.get(key);
|
|
1605
|
-
if ((
|
|
1748
|
+
if ((entry === null || entry === void 0 || (_entry$body = entry.body) === null || _entry$body === void 0 ? void 0 : _entry$body.refresh_token) === oldRefreshToken) {
|
|
1606
1749
|
entry.body.refresh_token = newRefreshToken;
|
|
1607
1750
|
await this.cache.set(key, entry);
|
|
1608
1751
|
}
|
|
@@ -1615,6 +1758,7 @@
|
|
|
1615
1758
|
this.storage = storage;
|
|
1616
1759
|
this.clientId = clientId;
|
|
1617
1760
|
this.cookieDomain = cookieDomain;
|
|
1761
|
+
_defineProperty(this, "storageKey", void 0);
|
|
1618
1762
|
this.storageKey = "".concat(TRANSACTION_STORAGE_KEY_PREFIX, ".").concat(this.clientId);
|
|
1619
1763
|
}
|
|
1620
1764
|
create(transaction) {
|
|
@@ -1838,17 +1982,17 @@
|
|
|
1838
1982
|
sameSite: "none"
|
|
1839
1983
|
};
|
|
1840
1984
|
}
|
|
1841
|
-
if (options
|
|
1985
|
+
if (options !== null && options !== void 0 && options.daysUntilExpire) {
|
|
1842
1986
|
cookieAttributes.expires = options.daysUntilExpire;
|
|
1843
1987
|
}
|
|
1844
|
-
if (options
|
|
1988
|
+
if (options !== null && options !== void 0 && options.cookieDomain) {
|
|
1845
1989
|
cookieAttributes.domain = options.cookieDomain;
|
|
1846
1990
|
}
|
|
1847
1991
|
set_1(key, JSON.stringify(value), cookieAttributes);
|
|
1848
1992
|
},
|
|
1849
1993
|
remove(key, options) {
|
|
1850
1994
|
let cookieAttributes = {};
|
|
1851
|
-
if (options
|
|
1995
|
+
if (options !== null && options !== void 0 && options.cookieDomain) {
|
|
1852
1996
|
cookieAttributes.domain = options.cookieDomain;
|
|
1853
1997
|
}
|
|
1854
1998
|
remove_1(key, cookieAttributes);
|
|
@@ -1870,10 +2014,10 @@
|
|
|
1870
2014
|
secure: true
|
|
1871
2015
|
};
|
|
1872
2016
|
}
|
|
1873
|
-
if (options
|
|
2017
|
+
if (options !== null && options !== void 0 && options.daysUntilExpire) {
|
|
1874
2018
|
cookieAttributes.expires = options.daysUntilExpire;
|
|
1875
2019
|
}
|
|
1876
|
-
if (options
|
|
2020
|
+
if (options !== null && options !== void 0 && options.cookieDomain) {
|
|
1877
2021
|
cookieAttributes.domain = options.cookieDomain;
|
|
1878
2022
|
}
|
|
1879
2023
|
set_1("".concat(LEGACY_PREFIX).concat(key), JSON.stringify(value), cookieAttributes);
|
|
@@ -1881,7 +2025,7 @@
|
|
|
1881
2025
|
},
|
|
1882
2026
|
remove(key, options) {
|
|
1883
2027
|
let cookieAttributes = {};
|
|
1884
|
-
if (options
|
|
2028
|
+
if (options !== null && options !== void 0 && options.cookieDomain) {
|
|
1885
2029
|
cookieAttributes.domain = options.cookieDomain;
|
|
1886
2030
|
}
|
|
1887
2031
|
remove_1(key, cookieAttributes);
|
|
@@ -1907,12 +2051,35 @@
|
|
|
1907
2051
|
sessionStorage.removeItem(key);
|
|
1908
2052
|
}
|
|
1909
2053
|
};
|
|
1910
|
-
|
|
1911
|
-
(function(ResponseType) {
|
|
2054
|
+
let ResponseType = function(ResponseType) {
|
|
1912
2055
|
ResponseType["Code"] = "code";
|
|
1913
2056
|
ResponseType["ConnectCode"] = "connect_code";
|
|
1914
|
-
|
|
1915
|
-
|
|
2057
|
+
return ResponseType;
|
|
2058
|
+
}({});
|
|
2059
|
+
class User {
|
|
2060
|
+
constructor() {
|
|
2061
|
+
_defineProperty(this, "name", void 0);
|
|
2062
|
+
_defineProperty(this, "given_name", void 0);
|
|
2063
|
+
_defineProperty(this, "family_name", void 0);
|
|
2064
|
+
_defineProperty(this, "middle_name", void 0);
|
|
2065
|
+
_defineProperty(this, "nickname", void 0);
|
|
2066
|
+
_defineProperty(this, "preferred_username", void 0);
|
|
2067
|
+
_defineProperty(this, "profile", void 0);
|
|
2068
|
+
_defineProperty(this, "picture", void 0);
|
|
2069
|
+
_defineProperty(this, "website", void 0);
|
|
2070
|
+
_defineProperty(this, "email", void 0);
|
|
2071
|
+
_defineProperty(this, "email_verified", void 0);
|
|
2072
|
+
_defineProperty(this, "gender", void 0);
|
|
2073
|
+
_defineProperty(this, "birthdate", void 0);
|
|
2074
|
+
_defineProperty(this, "zoneinfo", void 0);
|
|
2075
|
+
_defineProperty(this, "locale", void 0);
|
|
2076
|
+
_defineProperty(this, "phone_number", void 0);
|
|
2077
|
+
_defineProperty(this, "phone_number_verified", void 0);
|
|
2078
|
+
_defineProperty(this, "address", void 0);
|
|
2079
|
+
_defineProperty(this, "updated_at", void 0);
|
|
2080
|
+
_defineProperty(this, "sub", void 0);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
1916
2083
|
function decodeBase64$1(base64, enableUnicode) {
|
|
1917
2084
|
var binaryString = atob(base64);
|
|
1918
2085
|
if (enableUnicode) {
|
|
@@ -1942,7 +2109,7 @@
|
|
|
1942
2109
|
return new Worker(url, options);
|
|
1943
2110
|
};
|
|
1944
2111
|
}
|
|
1945
|
-
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBjbGFzcyBHZW5lcmljRXJyb3IgZXh0ZW5kcyBFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uKSB7CiAgICAgICAgICAgIHN1cGVyKGVycm9yX2Rlc2NyaXB0aW9uKTsKICAgICAgICAgICAgdGhpcy5lcnJvciA9IGVycm9yOwogICAgICAgICAgICB0aGlzLmVycm9yX2Rlc2NyaXB0aW9uID0gZXJyb3JfZGVzY3JpcHRpb247CiAgICAgICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLCBHZW5lcmljRXJyb3IucHJvdG90eXBlKTsKICAgICAgICB9CiAgICAgICAgc3RhdGljIGZyb21QYXlsb2FkKF9yZWYpIHsKICAgICAgICAgICAgbGV0IHtlcnJvcjogZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvcl9kZXNjcmlwdGlvbn0gPSBfcmVmOwogICAgICAgICAgICByZXR1cm4gbmV3IEdlbmVyaWNFcnJvcihlcnJvciwgZXJyb3JfZGVzY3JpcHRpb24pOwogICAgICAgIH0KICAgIH0KICAgIGNsYXNzIE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvciBleHRlbmRzIEdlbmV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IHNldFRpbWVvdXQocmVzb2x2ZSwgdGltZSkpOwogICAgY29uc3QgZm9ybURhdGFUb09iamVjdCA9IGZvcm1EYXRhID0+IHsKICAgICAgICBjb25zdCBxdWVyeVBhcmFtcyA9IG5ldyBVUkxTZWFyY2hQYXJhbXMoZm9ybURhdGEpOwogICAgICAgIGNvbnN0IHBhcnNlZFF1ZXJ5ID0ge307CiAgICAgICAgcXVlcnlQYXJhbXMuZm9yRWFjaCgodmFsLCBrZXkpID0+IHsKICAgICAgICAgICAgcGFyc2VkUXVlcnlba2V5XSA9IHZhbDsKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gcGFyc2VkUXVlcnk7CiAgICB9OwogICAgY29uc3QgdXBkYXRlUmVmcmVzaFRva2VucyA9IChvbGRSZWZyZXNoVG9rZW4sIG5ld1JlZnJlc2hUb2tlbikgPT4gewogICAgICAgIE9iamVjdC5lbnRyaWVzKHJlZnJlc2hUb2tlbnMpLmZvckVhY2goX3JlZiA9PiB7CiAgICAgICAgICAgIGxldCBba2V5LCB0b2tlbl0gPSBfcmVmOwogICAgICAgICAgICBpZiAodG9rZW4gPT09IG9sZFJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1trZXldID0gbmV3UmVmcmVzaFRva2VuOwogICAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICB9OwogICAgY29uc3QgY2hlY2tEb3duc2NvcGluZyA9IChzY29wZSwgYXVkaWVuY2UpID0+IHsKICAgICAgICBjb25zdCBmaW5kQ29pbmNpZGVuY2UgPSBPYmplY3Qua2V5cyhyZWZyZXNoVG9rZW5zKS5maW5kKGtleSA9PiB7CiAgICAgICAgICAgIGlmIChrZXkgIT09ICJsYXRlc3RfcmVmcmVzaF90b2tlbiIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGlzU2FtZUF1ZGllbmNlID0gY2FjaGVLZXlDb250YWluc0F1ZGllbmNlKGF1ZGllbmNlLCBrZXkpOwogICAgICAgICAgICA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mVmcmVzaF90b2tlbiAmJiBib2R5LmdyYW50X3R5cGUgPT09ICJyZWZyZXNoX3Rva2VuIikgewogICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gZ2V0UmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBpZiAoIXJlZnJlc2hUb2tlbiAmJiB1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF0ZXN0UmVmcmVzaFRva2VuID0gcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0Rvd25zY29waW5nID0gY2hlY2tEb3duc2NvcGluZyhzY29wZSwgYXVkaWVuY2UpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXRlc3RSZWZyZXNoVG9rZW4gJiYgIWlzRG93bnNjb3BpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gbGF0ZXN0UmVmcmVzaFRva2VuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvcihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLmJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKSA6IEpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICBpZiAodHlwZW9mIEFib3J0Q29udHJvbGxlciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5zaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgUHJvbWlzZS5yYWNlKFsgd2FpdCh0aW1lb3V0KSwgZmV0Y2goZmV0Y2hVcmwsIE9iamVjdC5hc3NpZ24oe30sIGZldGNoT3B0aW9ucykpIF0pOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6ICJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCciCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXJzID0gZnJvbUVudHJpZXMocmVzcG9uc2UuaGVhZGVycyk7CiAgICAgICAgICAgIGpzb24gPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICAgIGlmIChqc29uLnJlZnJlc2hfdG9rZW4pIHsKICAgICAgICAgICAgICAgIGlmICh1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXSA9IGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWZyZXNoVG9rZW5zKHJlZnJlc2hUb2tlbiwganNvbi5yZWZyZXNoX3Rva2VuKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHNldFJlZnJlc2hUb2tlbihqc29uLnJlZnJlc2hfdG9rZW4sIGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBkZWxldGUganNvbi5yZWZyZXNoX3Rva2VuOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZGVsZXRlUmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogcmVzcG9uc2Uub2ssCiAgICAgICAgICAgICAgICBqc29uOiBqc29uLAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIG9rOiBmYWxzZSwKICAgICAgICAgICAgICAgIGpzb246IHsKICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3IuZXJyb3IsCiAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH07CiAgICB7CiAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsIG1lc3NhZ2VIYW5kbGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
2112
|
+
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBmdW5jdGlvbiBfZGVmaW5lUHJvcGVydHkoZSwgciwgdCkgewogICAgICAgIHJldHVybiAociA9IF90b1Byb3BlcnR5S2V5KHIpKSBpbiBlID8gT2JqZWN0LmRlZmluZVByb3BlcnR5KGUsIHIsIHsKICAgICAgICAgICAgdmFsdWU6IHQsCiAgICAgICAgICAgIGVudW1lcmFibGU6ICEwLAogICAgICAgICAgICBjb25maWd1cmFibGU6ICEwLAogICAgICAgICAgICB3cml0YWJsZTogITAKICAgICAgICB9KSA6IGVbcl0gPSB0LCBlOwogICAgfQogICAgZnVuY3Rpb24gb3duS2V5cyhlLCByKSB7CiAgICAgICAgdmFyIHQgPSBPYmplY3Qua2V5cyhlKTsKICAgICAgICBpZiAoT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scykgewogICAgICAgICAgICB2YXIgbyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7CiAgICAgICAgICAgIHIgJiYgKG8gPSBvLmZpbHRlcihmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihlLCByKS5lbnVtZXJhYmxlOwogICAgICAgICAgICB9KSksIHQucHVzaC5hcHBseSh0LCBvKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHQ7CiAgICB9CiAgICBmdW5jdGlvbiBfb2JqZWN0U3ByZWFkMihlKSB7CiAgICAgICAgZm9yICh2YXIgciA9IDE7IHIgPCBhcmd1bWVudHMubGVuZ3RoOyByKyspIHsKICAgICAgICAgICAgdmFyIHQgPSBudWxsICE9IGFyZ3VtZW50c1tyXSA/IGFyZ3VtZW50c1tyXSA6IHt9OwogICAgICAgICAgICByICUgMiA/IG93bktleXMoT2JqZWN0KHQpLCAhMCkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoZSwgciwgdFtyXSk7CiAgICAgICAgICAgIH0pIDogT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnMgPyBPYmplY3QuZGVmaW5lUHJvcGVydGllcyhlLCBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyh0KSkgOiBvd25LZXlzKE9iamVjdCh0KSkuZm9yRWFjaChmdW5jdGlvbihyKSB7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZSwgciwgT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcih0LCByKSk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllcyhlLCB0KSB7CiAgICAgICAgaWYgKG51bGwgPT0gZSkgcmV0dXJuIHt9OwogICAgICAgIHZhciBvLCByLCBpID0gX29iamVjdFdpdGhvdXRQcm9wZXJ0aWVzTG9vc2UoZSwgdCk7CiAgICAgICAgaWYgKE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMpIHsKICAgICAgICAgICAgdmFyIG4gPSBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpOwogICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgbi5sZW5ndGg7IHIrKykgbyA9IG5bcl0sIC0xID09PSB0LmluZGV4T2YobykgJiYge30ucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLCBvKSAmJiAoaVtvXSA9IGVbb10pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaTsKICAgIH0KICAgIGZ1bmN0aW9uIF9vYmplY3RXaXRob3V0UHJvcGVydGllc0xvb3NlKHIsIGUpIHsKICAgICAgICBpZiAobnVsbCA9PSByKSByZXR1cm4ge307CiAgICAgICAgdmFyIHQgPSB7fTsKICAgICAgICBmb3IgKHZhciBuIGluIHIpIGlmICh7fS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHIsIG4pKSB7CiAgICAgICAgICAgIGlmICgtMSAhPT0gZS5pbmRleE9mKG4pKSBjb250aW51ZTsKICAgICAgICAgICAgdFtuXSA9IHJbbl07CiAgICAgICAgfQogICAgICAgIHJldHVybiB0OwogICAgfQogICAgZnVuY3Rpb24gX3RvUHJpbWl0aXZlKHQsIHIpIHsKICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIHQgfHwgIXQpIHJldHVybiB0OwogICAgICAgIHZhciBlID0gdFtTeW1ib2wudG9QcmltaXRpdmVdOwogICAgICAgIGlmICh2b2lkIDAgIT09IGUpIHsKICAgICAgICAgICAgdmFyIGkgPSBlLmNhbGwodCwgciB8fCAiZGVmYXVsdCIpOwogICAgICAgICAgICBpZiAoIm9iamVjdCIgIT0gdHlwZW9mIGkpIHJldHVybiBpOwogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJAQHRvUHJpbWl0aXZlIG11c3QgcmV0dXJuIGEgcHJpbWl0aXZlIHZhbHVlLiIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gKCJzdHJpbmciID09PSByID8gU3RyaW5nIDogTnVtYmVyKSh0KTsKICAgIH0KICAgIGZ1bmN0aW9uIF90b1Byb3BlcnR5S2V5KHQpIHsKICAgICAgICB2YXIgaSA9IF90b1ByaW1pdGl2ZSh0LCAic3RyaW5nIik7CiAgICAgICAgcmV0dXJuICJzeW1ib2wiID09IHR5cGVvZiBpID8ga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ogICAgICAgIGNvbnN0IHF1ZXJ5UGFyYW1zID0gbmV3IFVSTFNlYXJjaFBhcmFtcyhmb3JtRGF0YSk7CiAgICAgICAgY29uc3QgcGFyc2VkUXVlcnkgPSB7fTsKICAgICAgICBxdWVyeVBhcmFtcy5mb3JFYWNoKCh2YWwsIGtleSkgPT4gewogICAgICAgICAgICBwYXJzZWRRdWVyeVtrZXldID0gdmFsOwogICAgICAgIH0pOwogICAgICAgIHJldHVybiBwYXJzZWRRdWVyeTsKICAgIH07CiAgICBjb25zdCB1cGRhdGVSZWZyZXNoVG9rZW5zID0gKG9sZFJlZnJlc2hUb2tlbiwgbmV3UmVmcmVzaFRva2VuKSA9PiB7CiAgICAgICAgT2JqZWN0LmVudHJpZXMocmVmcmVzaFRva2VucykuZm9yRWFjaChfcmVmID0+IHsKICAgICAgICAgICAgbGV0IFtrZXksIHRva2VuXSA9IF9yZWY7CiAgICAgICAgICAgIGlmICh0b2tlbiA9PT0gb2xkUmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW5zW2tleV0gPSBuZXdSZWZyZXNoVG9rZW47CiAgICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH07CiAgICBjb25zdCBjaGVja0Rvd25zY29waW5nID0gKHNjb3BlLCBhdWRpZW5jZSkgPT4gewogICAgICAgIGNvbnN0IGZpbmRDb2luY2lkZW5jZSA9IE9iamVjdC5rZXlzKHJlZnJlc2hUb2tlbnMpLmZpbmQoa2V5ID0+IHsKICAgICAgICAgICAgaWYgKGtleSAhPT0gImxhdGVzdF9yZWZyZXNoX3Rva2VuIikgewogICAgICAgICAgICAgICAgY29uc3QgaXNTYW1lQXVkaWVuY2UgPSBjYWNoZUtleUNvbnRhaW5zQXVkaWVuY2UoYXVkaWVuY2UsIGtleSk7CiAgICAgICAgICAgICAgICBjb25zdCBzY29wZXNLZXkgPSBrZXkuc3BsaXQoInwiKVsxXS5zcGxpdCgiICIpOwogICAgICAgICAgICAgICAgY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iAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW4gPSBnZXRSZWZyZXNoVG9rZW4oYXVkaWVuY2UsIHNjb3BlKTsKICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuICYmIHVzZU1ycnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXRlc3RSZWZyZXNoVG9rZW4gPSByZWZyZXNoVG9rZW5zWyJsYXRlc3RfcmVmcmVzaF90b2tlbiJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRG93bnNjb3BpbmcgPSBjaGVja0Rvd25zY29waW5nKHNjb3BlLCBhdWRpZW5jZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxhdGVzdFJlZnJlc2hUb2tlbiAmJiAhaXNEb3duc2NvcGluZykgewogICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW4gPSBsYXRlc3RSZWZyZXNoVG9rZW47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFyZWZyZXNoVG9rZW4pIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgTWlzc2luZ1JlZnJlc2hUb2tlbkVycm9yKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmZXRjaE9wdGlvbnMuYm9keSA9IHVzZUZvcm1EYXRhID8gY3JlYXRlUXVlcnlQYXJhbXMoX29iamVjdFNwcmVhZDIoX29iamVjdFNwcmVhZDIoe30sIGJvZHkpLCB7fSwgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpIDogSlNPTi5zdHJpbmdpZnkoX29iamVjdFNwcmVhZDIoX29iamVjdFNwcmVhZDIoe30sIGJvZHkpLCB7fSwgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW46IHJlZnJlc2hUb2tlbgogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCBhYm9ydENvbnRyb2xsZXI7CiAgICAgICAgICAgIGlmICh0eXBlb2YgQWJvcnRDb250cm9sbGVyID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICBhYm9ydENvbnRyb2xsZXIgPSBuZXcgQWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLnNpZ25hbCA9IGFib3J0Q29udHJvbGxlci5zaWduYWw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IHJlc3BvbnNlOwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBhd2FpdCBQcm9taXNlLnJhY2UoWyB3YWl0KHRpbWVvdXQpLCBmZXRjaChmZXRjaFVybCwgX29iamVjdFNwcmVhZDIoe30sIGZldGNoT3B0aW9ucykpIF0pOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6ICJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCciCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXJzID0gZnJvbUVudHJpZXMocmVzcG9uc2UuaGVhZGVycyk7CiAgICAgICAgICAgIGpzb24gPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICAgIGlmIChqc29uLnJlZnJlc2hfdG9rZW4pIHsKICAgICAgICAgICAgICAgIGlmICh1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXSA9IGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWZyZXNoVG9rZW5zKHJlZnJlc2hUb2tlbiwganNvbi5yZWZyZXNoX3Rva2VuKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHNldFJlZnJlc2hUb2tlbihqc29uLnJlZnJlc2hfdG9rZW4sIGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBkZWxldGUganNvbi5yZWZyZXNoX3Rva2VuOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZGVsZXRlUmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogcmVzcG9uc2Uub2ssCiAgICAgICAgICAgICAgICBqc29uOiBqc29uLAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIG9rOiBmYWxzZSwKICAgICAgICAgICAgICAgIGpzb246IHsKICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3IuZXJyb3IsCiAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH07CiAgICB7CiAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsIG1lc3NhZ2VIYW5kbGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
1946
2113
|
const singlePromiseMap = {};
|
|
1947
2114
|
const singlePromise = (cb, key) => {
|
|
1948
2115
|
let promise = singlePromiseMap[key];
|
|
@@ -1959,11 +2126,12 @@
|
|
|
1959
2126
|
constructor(cache, clientId) {
|
|
1960
2127
|
this.cache = cache;
|
|
1961
2128
|
this.clientId = clientId;
|
|
2129
|
+
_defineProperty(this, "manifestKey", void 0);
|
|
1962
2130
|
this.manifestKey = this.createManifestKeyFrom(this.clientId);
|
|
1963
2131
|
}
|
|
1964
2132
|
async add(key) {
|
|
1965
|
-
var
|
|
1966
|
-
const keys = new Set(((
|
|
2133
|
+
var _await$this$cache$get;
|
|
2134
|
+
const keys = new Set(((_await$this$cache$get = await this.cache.get(this.manifestKey)) === null || _await$this$cache$get === void 0 ? void 0 : _await$this$cache$get.keys) || []);
|
|
1967
2135
|
keys.add(key);
|
|
1968
2136
|
await this.cache.set(this.manifestKey, {
|
|
1969
2137
|
keys: [ ...keys ]
|
|
@@ -1992,6 +2160,7 @@
|
|
|
1992
2160
|
return "".concat(CACHE_KEY_PREFIX, "::").concat(clientId);
|
|
1993
2161
|
}
|
|
1994
2162
|
}
|
|
2163
|
+
const _excluded$2 = [ "openUrl", "onRedirect" ];
|
|
1995
2164
|
const GET_TOKEN_SILENTLY_LOCK_KEY = "auth0.lock.getTokenSilently";
|
|
1996
2165
|
const GET_TOKEN_FROM_IFRAME_LOCK_KEY = "auth0.lock.getTokenFromIFrame";
|
|
1997
2166
|
const buildGetTokenSilentlyLockKey = (clientId, audience) => "".concat(GET_TOKEN_SILENTLY_LOCK_KEY, ".").concat(clientId, ".").concat(audience);
|
|
@@ -2004,9 +2173,9 @@
|
|
|
2004
2173
|
localstorage: () => new LocalStorageCache
|
|
2005
2174
|
};
|
|
2006
2175
|
const cacheFactory = location => cacheLocationBuilders[location];
|
|
2007
|
-
const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) =>
|
|
2176
|
+
const getAuthorizeParams = (clientOptions, scope, authorizationParams, state, nonce, code_challenge, redirect_uri, response_mode, thumbprint) => _objectSpread2(_objectSpread2(_objectSpread2({
|
|
2008
2177
|
client_id: clientOptions.clientId
|
|
2009
|
-
}, clientOptions.authorizationParams), authorizationParams), {
|
|
2178
|
+
}, clientOptions.authorizationParams), authorizationParams), {}, {
|
|
2010
2179
|
scope: scopesToRequest(scope, authorizationParams.scope, authorizationParams.audience),
|
|
2011
2180
|
response_type: "code",
|
|
2012
2181
|
response_mode: response_mode || "query",
|
|
@@ -2018,8 +2187,8 @@
|
|
|
2018
2187
|
dpop_jkt: thumbprint
|
|
2019
2188
|
});
|
|
2020
2189
|
const patchOpenUrlWithOnRedirect = options => {
|
|
2021
|
-
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions =
|
|
2022
|
-
const result =
|
|
2190
|
+
const {openUrl: openUrl, onRedirect: onRedirect} = options, originalOptions = _objectWithoutProperties(options, _excluded$2);
|
|
2191
|
+
const result = _objectSpread2(_objectSpread2({}, originalOptions), {}, {
|
|
2023
2192
|
openUrl: openUrl === false || openUrl ? openUrl : onRedirect
|
|
2024
2193
|
});
|
|
2025
2194
|
return result;
|
|
@@ -2036,13 +2205,13 @@
|
|
|
2036
2205
|
return missingScopes.join(",");
|
|
2037
2206
|
};
|
|
2038
2207
|
const getScopeToRequest = (useMrrt, authorizationParams, cachedAudience, cachedScope) => {
|
|
2039
|
-
var _a;
|
|
2040
2208
|
if (useMrrt && cachedAudience && cachedScope) {
|
|
2209
|
+
var _authorizationParams$;
|
|
2041
2210
|
if (authorizationParams.audience !== cachedAudience) {
|
|
2042
2211
|
return authorizationParams.scope;
|
|
2043
2212
|
}
|
|
2044
2213
|
const cachedScopes = cachedScope.split(" ");
|
|
2045
|
-
const newScopes = ((
|
|
2214
|
+
const newScopes = ((_authorizationParams$ = authorizationParams.scope) === null || _authorizationParams$ === void 0 ? void 0 : _authorizationParams$.split(" ")) || [];
|
|
2046
2215
|
const newScopesAreIncluded = newScopes.every(scope => cachedScopes.includes(scope));
|
|
2047
2216
|
return cachedScopes.length >= newScopes.length && newScopesAreIncluded ? cachedScope : authorizationParams.scope;
|
|
2048
2217
|
}
|
|
@@ -2063,6 +2232,8 @@
|
|
|
2063
2232
|
const AUTH0_NONCE_ID = "auth0";
|
|
2064
2233
|
class DpopStorage {
|
|
2065
2234
|
constructor(clientId) {
|
|
2235
|
+
_defineProperty(this, "clientId", void 0);
|
|
2236
|
+
_defineProperty(this, "dbHandle", void 0);
|
|
2066
2237
|
this.clientId = clientId;
|
|
2067
2238
|
}
|
|
2068
2239
|
getVersion() {
|
|
@@ -2116,7 +2287,7 @@
|
|
|
2116
2287
|
}
|
|
2117
2288
|
async deleteBy(table, predicate) {
|
|
2118
2289
|
const allKeys = await this.executeDbRequest(table, "readonly", table => table.getAllKeys());
|
|
2119
|
-
allKeys === null || allKeys === void 0
|
|
2290
|
+
allKeys === null || allKeys === void 0 || allKeys.filter(predicate).map(k => this.executeDbRequest(table, "readwrite", table => table.delete(k)));
|
|
2120
2291
|
}
|
|
2121
2292
|
deleteByClientId(table, clientId) {
|
|
2122
2293
|
return this.deleteBy(table, k => typeof k === "string" && k.startsWith("".concat(clientId, "::")));
|
|
@@ -2130,6 +2301,7 @@
|
|
|
2130
2301
|
}
|
|
2131
2302
|
class Dpop {
|
|
2132
2303
|
constructor(clientId) {
|
|
2304
|
+
_defineProperty(this, "storage", void 0);
|
|
2133
2305
|
this.storage = new DpopStorage(clientId);
|
|
2134
2306
|
}
|
|
2135
2307
|
getNonce(id) {
|
|
@@ -2148,7 +2320,7 @@
|
|
|
2148
2320
|
}
|
|
2149
2321
|
async generateProof(params) {
|
|
2150
2322
|
const keyPair = await this.getOrGenerateKeyPair();
|
|
2151
|
-
return generateProof(
|
|
2323
|
+
return generateProof(_objectSpread2({
|
|
2152
2324
|
keyPair: keyPair
|
|
2153
2325
|
}, params));
|
|
2154
2326
|
}
|
|
@@ -2160,15 +2332,17 @@
|
|
|
2160
2332
|
await Promise.all([ this.storage.clearNonces(), this.storage.clearKeyPairs() ]);
|
|
2161
2333
|
}
|
|
2162
2334
|
}
|
|
2163
|
-
var TokenType
|
|
2164
|
-
(function(TokenType) {
|
|
2335
|
+
var TokenType = function(TokenType) {
|
|
2165
2336
|
TokenType["Bearer"] = "Bearer";
|
|
2166
2337
|
TokenType["DPoP"] = "DPoP";
|
|
2167
|
-
|
|
2338
|
+
return TokenType;
|
|
2339
|
+
}(TokenType || {});
|
|
2168
2340
|
class Fetcher {
|
|
2169
2341
|
constructor(config, hooks) {
|
|
2342
|
+
_defineProperty(this, "config", void 0);
|
|
2343
|
+
_defineProperty(this, "hooks", void 0);
|
|
2170
2344
|
this.hooks = hooks;
|
|
2171
|
-
this.config =
|
|
2345
|
+
this.config = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
2172
2346
|
fetch: config.fetch || (typeof window === "undefined" ? fetch : window.fetch.bind(window))
|
|
2173
2347
|
});
|
|
2174
2348
|
}
|
|
@@ -2276,7 +2450,7 @@
|
|
|
2276
2450
|
}
|
|
2277
2451
|
fetchWithAuth(info, init, authParams) {
|
|
2278
2452
|
const callbacks = {
|
|
2279
|
-
onUseDpopNonceError: () => this.internalFetchWithAuth(info, init,
|
|
2453
|
+
onUseDpopNonceError: () => this.internalFetchWithAuth(info, init, _objectSpread2(_objectSpread2({}, callbacks), {}, {
|
|
2280
2454
|
onUseDpopNonceError: undefined
|
|
2281
2455
|
}), authParams)
|
|
2282
2456
|
};
|
|
@@ -2332,6 +2506,11 @@
|
|
|
2332
2506
|
constructor(_ref) {
|
|
2333
2507
|
let {type: type, status: status, title: title, detail: detail, validation_errors: validation_errors} = _ref;
|
|
2334
2508
|
super(detail);
|
|
2509
|
+
_defineProperty(this, "type", void 0);
|
|
2510
|
+
_defineProperty(this, "status", void 0);
|
|
2511
|
+
_defineProperty(this, "title", void 0);
|
|
2512
|
+
_defineProperty(this, "detail", void 0);
|
|
2513
|
+
_defineProperty(this, "validation_errors", void 0);
|
|
2335
2514
|
this.name = "MyAccountApiError";
|
|
2336
2515
|
this.type = type;
|
|
2337
2516
|
this.status = status;
|
|
@@ -2369,7 +2548,7 @@
|
|
|
2369
2548
|
};
|
|
2370
2549
|
function getAuthJsEnrollParams(params) {
|
|
2371
2550
|
const mapping = FACTOR_MAPPING[params.factorType];
|
|
2372
|
-
return
|
|
2551
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
2373
2552
|
mfaToken: params.mfaToken,
|
|
2374
2553
|
authenticatorTypes: mapping.authenticatorTypes
|
|
2375
2554
|
}, mapping.oobChannels && {
|
|
@@ -2392,159 +2571,6 @@
|
|
|
2392
2571
|
}
|
|
2393
2572
|
return undefined;
|
|
2394
2573
|
}
|
|
2395
|
-
function _OverloadYield(e, d) {
|
|
2396
|
-
this.v = e, this.k = d;
|
|
2397
|
-
}
|
|
2398
|
-
function _assertClassBrand(e, t, n) {
|
|
2399
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
2400
|
-
throw new TypeError("Private element is not present on this object");
|
|
2401
|
-
}
|
|
2402
|
-
function _awaitAsyncGenerator(e) {
|
|
2403
|
-
return new _OverloadYield(e, 0);
|
|
2404
|
-
}
|
|
2405
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
2406
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
2407
|
-
}
|
|
2408
|
-
function _classPrivateFieldGet2(s, a) {
|
|
2409
|
-
return s.get(_assertClassBrand(s, a));
|
|
2410
|
-
}
|
|
2411
|
-
function _classPrivateFieldInitSpec(e, t, a) {
|
|
2412
|
-
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
2413
|
-
}
|
|
2414
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
2415
|
-
return s.set(_assertClassBrand(s, a), r), r;
|
|
2416
|
-
}
|
|
2417
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
2418
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
2419
|
-
}
|
|
2420
|
-
function _defineProperty(e, r, t) {
|
|
2421
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
2422
|
-
value: t,
|
|
2423
|
-
enumerable: !0,
|
|
2424
|
-
configurable: !0,
|
|
2425
|
-
writable: !0
|
|
2426
|
-
}) : e[r] = t, e;
|
|
2427
|
-
}
|
|
2428
|
-
function ownKeys(e, r) {
|
|
2429
|
-
var t = Object.keys(e);
|
|
2430
|
-
if (Object.getOwnPropertySymbols) {
|
|
2431
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
2432
|
-
r && (o = o.filter(function(r) {
|
|
2433
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
2434
|
-
})), t.push.apply(t, o);
|
|
2435
|
-
}
|
|
2436
|
-
return t;
|
|
2437
|
-
}
|
|
2438
|
-
function _objectSpread2(e) {
|
|
2439
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
2440
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
2441
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
2442
|
-
_defineProperty(e, r, t[r]);
|
|
2443
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
2444
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
2445
|
-
});
|
|
2446
|
-
}
|
|
2447
|
-
return e;
|
|
2448
|
-
}
|
|
2449
|
-
function _objectWithoutProperties(e, t) {
|
|
2450
|
-
if (null == e) return {};
|
|
2451
|
-
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
2452
|
-
if (Object.getOwnPropertySymbols) {
|
|
2453
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
2454
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
2455
|
-
}
|
|
2456
|
-
return i;
|
|
2457
|
-
}
|
|
2458
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
2459
|
-
if (null == r) return {};
|
|
2460
|
-
var t = {};
|
|
2461
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
2462
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
2463
|
-
t[n] = r[n];
|
|
2464
|
-
}
|
|
2465
|
-
return t;
|
|
2466
|
-
}
|
|
2467
|
-
function _toPrimitive(t, r) {
|
|
2468
|
-
if ("object" != typeof t || !t) return t;
|
|
2469
|
-
var e = t[Symbol.toPrimitive];
|
|
2470
|
-
if (void 0 !== e) {
|
|
2471
|
-
var i = e.call(t, r || "default");
|
|
2472
|
-
if ("object" != typeof i) return i;
|
|
2473
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2474
|
-
}
|
|
2475
|
-
return ("string" === r ? String : Number)(t);
|
|
2476
|
-
}
|
|
2477
|
-
function _toPropertyKey(t) {
|
|
2478
|
-
var i = _toPrimitive(t, "string");
|
|
2479
|
-
return "symbol" == typeof i ? i : i + "";
|
|
2480
|
-
}
|
|
2481
|
-
function _wrapAsyncGenerator(e) {
|
|
2482
|
-
return function() {
|
|
2483
|
-
return new AsyncGenerator(e.apply(this, arguments));
|
|
2484
|
-
};
|
|
2485
|
-
}
|
|
2486
|
-
function AsyncGenerator(e) {
|
|
2487
|
-
var r, t;
|
|
2488
|
-
function resume(r, t) {
|
|
2489
|
-
try {
|
|
2490
|
-
var n = e[r](t), o = n.value, u = o instanceof _OverloadYield;
|
|
2491
|
-
Promise.resolve(u ? o.v : o).then(function(t) {
|
|
2492
|
-
if (u) {
|
|
2493
|
-
var i = "return" === r ? "return" : "next";
|
|
2494
|
-
if (!o.k || t.done) return resume(i, t);
|
|
2495
|
-
t = e[i](t).value;
|
|
2496
|
-
}
|
|
2497
|
-
settle(n.done ? "return" : "normal", t);
|
|
2498
|
-
}, function(e) {
|
|
2499
|
-
resume("throw", e);
|
|
2500
|
-
});
|
|
2501
|
-
} catch (e) {
|
|
2502
|
-
settle("throw", e);
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
function settle(e, n) {
|
|
2506
|
-
switch (e) {
|
|
2507
|
-
case "return":
|
|
2508
|
-
r.resolve({
|
|
2509
|
-
value: n,
|
|
2510
|
-
done: !0
|
|
2511
|
-
});
|
|
2512
|
-
break;
|
|
2513
|
-
|
|
2514
|
-
case "throw":
|
|
2515
|
-
r.reject(n);
|
|
2516
|
-
break;
|
|
2517
|
-
|
|
2518
|
-
default:
|
|
2519
|
-
r.resolve({
|
|
2520
|
-
value: n,
|
|
2521
|
-
done: !1
|
|
2522
|
-
});
|
|
2523
|
-
}
|
|
2524
|
-
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
|
2525
|
-
}
|
|
2526
|
-
this._invoke = function(e, n) {
|
|
2527
|
-
return new Promise(function(o, u) {
|
|
2528
|
-
var i = {
|
|
2529
|
-
key: e,
|
|
2530
|
-
arg: n,
|
|
2531
|
-
resolve: o,
|
|
2532
|
-
reject: u,
|
|
2533
|
-
next: null
|
|
2534
|
-
};
|
|
2535
|
-
t ? t = t.next = i : (r = t = i, resume(e, n));
|
|
2536
|
-
});
|
|
2537
|
-
}, "function" != typeof e.return && (this.return = void 0);
|
|
2538
|
-
}
|
|
2539
|
-
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
2540
|
-
return this;
|
|
2541
|
-
}, AsyncGenerator.prototype.next = function(e) {
|
|
2542
|
-
return this._invoke("next", e);
|
|
2543
|
-
}, AsyncGenerator.prototype.throw = function(e) {
|
|
2544
|
-
return this._invoke("throw", e);
|
|
2545
|
-
}, AsyncGenerator.prototype.return = function(e) {
|
|
2546
|
-
return this._invoke("return", e);
|
|
2547
|
-
};
|
|
2548
2574
|
var _navigator$userAgent$2, _navigator$userAgent$$2;
|
|
2549
2575
|
let USER_AGENT$2;
|
|
2550
2576
|
if (typeof navigator === "undefined" || !((_navigator$userAgent$2 = navigator.userAgent) !== null && _navigator$userAgent$2 !== void 0 && (_navigator$userAgent$$2 = _navigator$userAgent$2.startsWith) !== null && _navigator$userAgent$$2 !== void 0 && _navigator$userAgent$$2.call(_navigator$userAgent$2, "Mozilla/5.0 "))) {
|
|
@@ -6333,7 +6359,7 @@
|
|
|
6333
6359
|
let USER_AGENT;
|
|
6334
6360
|
if (typeof navigator === "undefined" || !((_navigator$userAgent = navigator.userAgent) !== null && _navigator$userAgent !== void 0 && (_navigator$userAgent$ = _navigator$userAgent.startsWith) !== null && _navigator$userAgent$ !== void 0 && _navigator$userAgent$.call(_navigator$userAgent, "Mozilla/5.0 "))) {
|
|
6335
6361
|
const NAME = "jose";
|
|
6336
|
-
const VERSION = "v6.2.
|
|
6362
|
+
const VERSION = "v6.2.2";
|
|
6337
6363
|
USER_AGENT = "".concat(NAME, "/").concat(VERSION);
|
|
6338
6364
|
}
|
|
6339
6365
|
const customFetch = Symbol();
|
|
@@ -6500,7 +6526,7 @@
|
|
|
6500
6526
|
});
|
|
6501
6527
|
return remoteJWKSet;
|
|
6502
6528
|
}
|
|
6503
|
-
const _excluded = [ "mfaToken" ], _excluded2 = [ "mfaToken" ];
|
|
6529
|
+
const _excluded$1 = [ "mfaToken" ], _excluded2$1 = [ "mfaToken" ];
|
|
6504
6530
|
var _baseUrl, _clientId, _customFetch, _entries, _ttlMs, _maxEntries, _configuration, _serverMetadata, _clientAuthPromise, _options, _customFetch2, _jwks, _discoveryCache, _inFlightDiscovery, _jwksCache, _Class9_brand;
|
|
6505
6531
|
var NotSupportedError = class NotSupportedError extends Error {
|
|
6506
6532
|
constructor(code, message) {
|
|
@@ -6541,6 +6567,12 @@
|
|
|
6541
6567
|
this.name = "TokenByRefreshTokenError";
|
|
6542
6568
|
}
|
|
6543
6569
|
};
|
|
6570
|
+
var TokenByPasswordError = class extends ApiError {
|
|
6571
|
+
constructor(message, cause) {
|
|
6572
|
+
super("token_by_password_error", message, cause);
|
|
6573
|
+
this.name = "TokenByPasswordError";
|
|
6574
|
+
}
|
|
6575
|
+
};
|
|
6544
6576
|
var TokenForConnectionError = class extends ApiError {
|
|
6545
6577
|
constructor(message, cause) {
|
|
6546
6578
|
super("token_for_connection_error", message, cause);
|
|
@@ -6714,7 +6746,7 @@
|
|
|
6714
6746
|
}
|
|
6715
6747
|
async enrollAuthenticator(options) {
|
|
6716
6748
|
const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/associate");
|
|
6717
|
-
const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded);
|
|
6749
|
+
const {mfaToken: mfaToken} = options, sdkParams = _objectWithoutProperties(options, _excluded$1);
|
|
6718
6750
|
const apiParams = {
|
|
6719
6751
|
authenticator_types: sdkParams.authenticatorTypes
|
|
6720
6752
|
};
|
|
@@ -6759,7 +6791,7 @@
|
|
|
6759
6791
|
}
|
|
6760
6792
|
async challengeAuthenticator(options) {
|
|
6761
6793
|
const url = "".concat(_classPrivateFieldGet2(_baseUrl, this), "/mfa/challenge");
|
|
6762
|
-
const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2);
|
|
6794
|
+
const {mfaToken: mfaToken} = options, challengeParams = _objectWithoutProperties(options, _excluded2$1);
|
|
6763
6795
|
const body = {
|
|
6764
6796
|
mfa_token: mfaToken,
|
|
6765
6797
|
client_id: _classPrivateFieldGet2(_clientId, this),
|
|
@@ -6814,7 +6846,7 @@
|
|
|
6814
6846
|
return {
|
|
6815
6847
|
enabled: true,
|
|
6816
6848
|
name: (_config$name = config === null || config === void 0 ? void 0 : config.name) !== null && _config$name !== void 0 ? _config$name : "@auth0/auth0-auth-js",
|
|
6817
|
-
version: (_config$version = config === null || config === void 0 ? void 0 : config.version) !== null && _config$version !== void 0 ? _config$version : "1.
|
|
6849
|
+
version: (_config$version = config === null || config === void 0 ? void 0 : config.version) !== null && _config$version !== void 0 ? _config$version : "1.6.0"
|
|
6818
6850
|
};
|
|
6819
6851
|
}
|
|
6820
6852
|
var TokenResponse = class _TokenResponse {
|
|
@@ -7163,6 +7195,38 @@
|
|
|
7163
7195
|
throw new TokenByRefreshTokenError("The access token has expired and there was an error while trying to refresh it.", e);
|
|
7164
7196
|
}
|
|
7165
7197
|
}
|
|
7198
|
+
async getTokenByPassword(options) {
|
|
7199
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7200
|
+
const params = new URLSearchParams({
|
|
7201
|
+
username: options.username,
|
|
7202
|
+
password: options.password
|
|
7203
|
+
});
|
|
7204
|
+
if (options.audience) {
|
|
7205
|
+
params.append("audience", options.audience);
|
|
7206
|
+
}
|
|
7207
|
+
if (options.scope) {
|
|
7208
|
+
params.append("scope", options.scope);
|
|
7209
|
+
}
|
|
7210
|
+
if (options.realm) {
|
|
7211
|
+
params.append("realm", options.realm);
|
|
7212
|
+
}
|
|
7213
|
+
let requestConfig = configuration;
|
|
7214
|
+
if (options.auth0ForwardedFor) {
|
|
7215
|
+
const clientAuth = await _assertClassBrand(_Class9_brand, this, _getClientAuth).call(this);
|
|
7216
|
+
requestConfig = new Configuration(configuration.serverMetadata(), _classPrivateFieldGet2(_options, this).clientId, _classPrivateFieldGet2(_options, this).clientSecret, clientAuth);
|
|
7217
|
+
requestConfig[customFetch$1] = (url, init) => _classPrivateFieldGet2(_customFetch2, this).call(this, url, _objectSpread2(_objectSpread2({}, init), {}, {
|
|
7218
|
+
headers: _objectSpread2(_objectSpread2({}, init.headers), {}, {
|
|
7219
|
+
"auth0-forwarded-for": options.auth0ForwardedFor
|
|
7220
|
+
})
|
|
7221
|
+
}));
|
|
7222
|
+
}
|
|
7223
|
+
try {
|
|
7224
|
+
const tokenEndpointResponse = await genericGrantRequest(requestConfig, "password", params);
|
|
7225
|
+
return TokenResponse.fromTokenEndpointResponse(tokenEndpointResponse);
|
|
7226
|
+
} catch (e) {
|
|
7227
|
+
throw new TokenByPasswordError("There was an error while trying to request a token.", e);
|
|
7228
|
+
}
|
|
7229
|
+
}
|
|
7166
7230
|
async getTokenByClientCredentials(options) {
|
|
7167
7231
|
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7168
7232
|
try {
|
|
@@ -7447,12 +7511,13 @@
|
|
|
7447
7511
|
class MfaContextManager {
|
|
7448
7512
|
constructor() {
|
|
7449
7513
|
let ttlMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_TTL_MS;
|
|
7450
|
-
this
|
|
7514
|
+
_defineProperty(this, "contexts", new Map);
|
|
7515
|
+
_defineProperty(this, "ttlMs", void 0);
|
|
7451
7516
|
this.ttlMs = ttlMs;
|
|
7452
7517
|
}
|
|
7453
7518
|
set(mfaToken, context) {
|
|
7454
7519
|
this.cleanup();
|
|
7455
|
-
this.contexts.set(mfaToken,
|
|
7520
|
+
this.contexts.set(mfaToken, _objectSpread2(_objectSpread2({}, context), {}, {
|
|
7456
7521
|
createdAt: Date.now()
|
|
7457
7522
|
}));
|
|
7458
7523
|
}
|
|
@@ -7484,6 +7549,9 @@
|
|
|
7484
7549
|
}
|
|
7485
7550
|
class MfaApiClient {
|
|
7486
7551
|
constructor(authJsMfaClient, auth0Client) {
|
|
7552
|
+
_defineProperty(this, "authJsMfaClient", void 0);
|
|
7553
|
+
_defineProperty(this, "auth0Client", void 0);
|
|
7554
|
+
_defineProperty(this, "contextManager", void 0);
|
|
7487
7555
|
this.authJsMfaClient = authJsMfaClient;
|
|
7488
7556
|
this.auth0Client = auth0Client;
|
|
7489
7557
|
this.contextManager = new MfaContextManager;
|
|
@@ -7496,9 +7564,9 @@
|
|
|
7496
7564
|
});
|
|
7497
7565
|
}
|
|
7498
7566
|
async getAuthenticators(mfaToken) {
|
|
7499
|
-
var
|
|
7567
|
+
var _context$mfaRequireme;
|
|
7500
7568
|
const context = this.contextManager.get(mfaToken);
|
|
7501
|
-
if (!(
|
|
7569
|
+
if (!(context !== null && context !== void 0 && (_context$mfaRequireme = context.mfaRequirements) !== null && _context$mfaRequireme !== void 0 && _context$mfaRequireme.challenge) || context.mfaRequirements.challenge.length === 0) {
|
|
7502
7570
|
throw new MfaListAuthenticatorsError("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
|
|
7503
7571
|
}
|
|
7504
7572
|
const challengeTypes = context.mfaRequirements.challenge.map(c => c.type);
|
|
@@ -7512,25 +7580,25 @@
|
|
|
7512
7580
|
});
|
|
7513
7581
|
} catch (error) {
|
|
7514
7582
|
if (error instanceof MfaListAuthenticatorsError$1) {
|
|
7515
|
-
|
|
7583
|
+
var _error$cause;
|
|
7584
|
+
throw new MfaListAuthenticatorsError((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.error, error.message);
|
|
7516
7585
|
}
|
|
7517
7586
|
throw error;
|
|
7518
7587
|
}
|
|
7519
7588
|
}
|
|
7520
7589
|
async enroll(params) {
|
|
7521
|
-
var _a;
|
|
7522
7590
|
const authJsParams = getAuthJsEnrollParams(params);
|
|
7523
7591
|
try {
|
|
7524
7592
|
return await this.authJsMfaClient.enrollAuthenticator(authJsParams);
|
|
7525
7593
|
} catch (error) {
|
|
7526
7594
|
if (error instanceof MfaEnrollmentError$1) {
|
|
7527
|
-
|
|
7595
|
+
var _error$cause2;
|
|
7596
|
+
throw new MfaEnrollmentError((_error$cause2 = error.cause) === null || _error$cause2 === void 0 ? void 0 : _error$cause2.error, error.message);
|
|
7528
7597
|
}
|
|
7529
7598
|
throw error;
|
|
7530
7599
|
}
|
|
7531
7600
|
}
|
|
7532
7601
|
async challenge(params) {
|
|
7533
|
-
var _a;
|
|
7534
7602
|
try {
|
|
7535
7603
|
const authJsParams = {
|
|
7536
7604
|
challengeType: params.challengeType,
|
|
@@ -7542,7 +7610,8 @@
|
|
|
7542
7610
|
return await this.authJsMfaClient.challengeAuthenticator(authJsParams);
|
|
7543
7611
|
} catch (error) {
|
|
7544
7612
|
if (error instanceof MfaChallengeError$1) {
|
|
7545
|
-
|
|
7613
|
+
var _error$cause3;
|
|
7614
|
+
throw new MfaChallengeError((_error$cause3 = error.cause) === null || _error$cause3 === void 0 ? void 0 : _error$cause3.error, error.message);
|
|
7546
7615
|
}
|
|
7547
7616
|
throw error;
|
|
7548
7617
|
}
|
|
@@ -7591,18 +7660,37 @@
|
|
|
7591
7660
|
}
|
|
7592
7661
|
}
|
|
7593
7662
|
}
|
|
7663
|
+
const _excluded = [ "openUrl", "fragment", "appState" ], _excluded2 = [ "url" ], _excluded3 = [ "cacheMode" ], _excluded4 = [ "federated" ], _excluded5 = [ "openUrl" ], _excluded6 = [ "id_token", "decodedToken" ], _excluded7 = [ "mfaToken" ];
|
|
7594
7664
|
class Auth0Client {
|
|
7595
7665
|
constructor(options) {
|
|
7596
|
-
this
|
|
7597
|
-
this
|
|
7666
|
+
_defineProperty(this, "transactionManager", void 0);
|
|
7667
|
+
_defineProperty(this, "cacheManager", void 0);
|
|
7668
|
+
_defineProperty(this, "lockManager", void 0);
|
|
7669
|
+
_defineProperty(this, "domainUrl", void 0);
|
|
7670
|
+
_defineProperty(this, "tokenIssuer", void 0);
|
|
7671
|
+
_defineProperty(this, "scope", void 0);
|
|
7672
|
+
_defineProperty(this, "cookieStorage", void 0);
|
|
7673
|
+
_defineProperty(this, "dpop", void 0);
|
|
7674
|
+
_defineProperty(this, "sessionCheckExpiryDays", void 0);
|
|
7675
|
+
_defineProperty(this, "orgHintCookieName", void 0);
|
|
7676
|
+
_defineProperty(this, "isAuthenticatedCookieName", void 0);
|
|
7677
|
+
_defineProperty(this, "nowProvider", void 0);
|
|
7678
|
+
_defineProperty(this, "httpTimeoutMs", void 0);
|
|
7679
|
+
_defineProperty(this, "options", void 0);
|
|
7680
|
+
_defineProperty(this, "userCache", (new InMemoryCache).enclosedCache);
|
|
7681
|
+
_defineProperty(this, "myAccountApi", void 0);
|
|
7682
|
+
_defineProperty(this, "mfa", void 0);
|
|
7683
|
+
_defineProperty(this, "worker", void 0);
|
|
7684
|
+
_defineProperty(this, "authJsClient", void 0);
|
|
7685
|
+
_defineProperty(this, "defaultOptions", {
|
|
7598
7686
|
authorizationParams: {
|
|
7599
7687
|
scope: DEFAULT_SCOPE
|
|
7600
7688
|
},
|
|
7601
7689
|
useRefreshTokensFallback: false,
|
|
7602
7690
|
useFormData: true
|
|
7603
|
-
};
|
|
7604
|
-
this.options =
|
|
7605
|
-
authorizationParams:
|
|
7691
|
+
});
|
|
7692
|
+
this.options = _objectSpread2(_objectSpread2(_objectSpread2({}, this.defaultOptions), options), {}, {
|
|
7693
|
+
authorizationParams: _objectSpread2(_objectSpread2({}, this.defaultOptions.authorizationParams), options.authorizationParams)
|
|
7606
7694
|
});
|
|
7607
7695
|
typeof window !== "undefined" && validateCrypto();
|
|
7608
7696
|
this.lockManager = getLockManager();
|
|
@@ -7634,9 +7722,9 @@
|
|
|
7634
7722
|
this.domainUrl = getDomain(this.options.domain);
|
|
7635
7723
|
this.tokenIssuer = getTokenIssuer(this.options.issuer, this.domainUrl);
|
|
7636
7724
|
const myAccountApiIdentifier = "".concat(this.domainUrl, "/me/");
|
|
7637
|
-
const myAccountFetcher = this.createFetcher(
|
|
7725
|
+
const myAccountFetcher = this.createFetcher(_objectSpread2(_objectSpread2({}, this.options.useDpop && {
|
|
7638
7726
|
dpopNonceId: "__auth0_my_account_api__"
|
|
7639
|
-
}), {
|
|
7727
|
+
}), {}, {
|
|
7640
7728
|
getAccessToken: () => this.getTokenSilently({
|
|
7641
7729
|
authorizationParams: {
|
|
7642
7730
|
scope: "create:me:connected_accounts",
|
|
@@ -7699,14 +7787,39 @@
|
|
|
7699
7787
|
});
|
|
7700
7788
|
}
|
|
7701
7789
|
}
|
|
7790
|
+
_extractSessionTransferToken(paramName) {
|
|
7791
|
+
const params = new URLSearchParams(window.location.search);
|
|
7792
|
+
return params.get(paramName) || undefined;
|
|
7793
|
+
}
|
|
7794
|
+
_clearSessionTransferTokenFromUrl(paramName) {
|
|
7795
|
+
try {
|
|
7796
|
+
const url = new URL(window.location.href);
|
|
7797
|
+
if (url.searchParams.has(paramName)) {
|
|
7798
|
+
url.searchParams.delete(paramName);
|
|
7799
|
+
window.history.replaceState({}, "", url.toString());
|
|
7800
|
+
}
|
|
7801
|
+
} catch (_unused) {}
|
|
7802
|
+
}
|
|
7803
|
+
_applySessionTransferToken(authorizationParams) {
|
|
7804
|
+
const paramName = this.options.sessionTransferTokenQueryParamName;
|
|
7805
|
+
if (!paramName || authorizationParams.session_transfer_token) {
|
|
7806
|
+
return authorizationParams;
|
|
7807
|
+
}
|
|
7808
|
+
const token = this._extractSessionTransferToken(paramName);
|
|
7809
|
+
if (!token) return authorizationParams;
|
|
7810
|
+
this._clearSessionTransferTokenFromUrl(paramName);
|
|
7811
|
+
return _objectSpread2(_objectSpread2({}, authorizationParams), {}, {
|
|
7812
|
+
session_transfer_token: token
|
|
7813
|
+
});
|
|
7814
|
+
}
|
|
7702
7815
|
async _prepareAuthorizeUrl(authorizationParams, authorizeOptions, fallbackRedirectUri) {
|
|
7703
|
-
var
|
|
7816
|
+
var _this$dpop;
|
|
7704
7817
|
const state = encode$2(createRandomString());
|
|
7705
7818
|
const nonce = encode$2(createRandomString());
|
|
7706
7819
|
const code_verifier = createRandomString();
|
|
7707
7820
|
const code_challengeBuffer = await sha256(code_verifier);
|
|
7708
7821
|
const code_challenge = bufferToBase64UrlEncoded(code_challengeBuffer);
|
|
7709
|
-
const thumbprint = await ((
|
|
7822
|
+
const thumbprint = await ((_this$dpop = this.dpop) === null || _this$dpop === void 0 ? void 0 : _this$dpop.calculateThumbprint());
|
|
7710
7823
|
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);
|
|
7711
7824
|
const url = this._authorizeUrl(params);
|
|
7712
7825
|
return {
|
|
@@ -7720,7 +7833,7 @@
|
|
|
7720
7833
|
};
|
|
7721
7834
|
}
|
|
7722
7835
|
async loginWithPopup(options, config) {
|
|
7723
|
-
var
|
|
7836
|
+
var _options$authorizatio;
|
|
7724
7837
|
options = options || {};
|
|
7725
7838
|
config = config || {};
|
|
7726
7839
|
if (!config.popup) {
|
|
@@ -7729,17 +7842,18 @@
|
|
|
7729
7842
|
throw new PopupOpenError;
|
|
7730
7843
|
}
|
|
7731
7844
|
}
|
|
7732
|
-
const
|
|
7845
|
+
const authorizationParams = this._applySessionTransferToken(options.authorizationParams || {});
|
|
7846
|
+
const params = await this._prepareAuthorizeUrl(authorizationParams, {
|
|
7733
7847
|
response_mode: "web_message"
|
|
7734
7848
|
}, window.location.origin);
|
|
7735
7849
|
config.popup.location.href = params.url;
|
|
7736
|
-
const codeResult = await runPopup(
|
|
7850
|
+
const codeResult = await runPopup(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
7737
7851
|
timeoutInSeconds: config.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
7738
|
-
}));
|
|
7852
|
+
}), new URL(params.url).origin);
|
|
7739
7853
|
if (params.state !== codeResult.state) {
|
|
7740
7854
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
7741
7855
|
}
|
|
7742
|
-
const organization = ((
|
|
7856
|
+
const organization = ((_options$authorizatio = options.authorizationParams) === null || _options$authorizatio === void 0 ? void 0 : _options$authorizatio.organization) || this.options.authorizationParams.organization;
|
|
7743
7857
|
await this._requestToken({
|
|
7744
7858
|
audience: params.audience,
|
|
7745
7859
|
scope: params.scope,
|
|
@@ -7753,25 +7867,26 @@
|
|
|
7753
7867
|
});
|
|
7754
7868
|
}
|
|
7755
7869
|
async getUser() {
|
|
7756
|
-
var
|
|
7870
|
+
var _cache$decodedToken;
|
|
7757
7871
|
const cache = await this._getIdTokenFromCache();
|
|
7758
|
-
return
|
|
7872
|
+
return cache === null || cache === void 0 || (_cache$decodedToken = cache.decodedToken) === null || _cache$decodedToken === void 0 ? void 0 : _cache$decodedToken.user;
|
|
7759
7873
|
}
|
|
7760
7874
|
async getIdTokenClaims() {
|
|
7761
|
-
var
|
|
7875
|
+
var _cache$decodedToken2;
|
|
7762
7876
|
const cache = await this._getIdTokenFromCache();
|
|
7763
|
-
return
|
|
7877
|
+
return cache === null || cache === void 0 || (_cache$decodedToken2 = cache.decodedToken) === null || _cache$decodedToken2 === void 0 ? void 0 : _cache$decodedToken2.claims;
|
|
7764
7878
|
}
|
|
7765
7879
|
async loginWithRedirect() {
|
|
7880
|
+
var _urlOptions$authoriza;
|
|
7766
7881
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7767
|
-
|
|
7768
|
-
const
|
|
7769
|
-
const
|
|
7770
|
-
const
|
|
7771
|
-
this.transactionManager.create(
|
|
7882
|
+
const _patchOpenUrlWithOnRe = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl, fragment: fragment, appState: appState} = _patchOpenUrlWithOnRe, urlOptions = _objectWithoutProperties(_patchOpenUrlWithOnRe, _excluded);
|
|
7883
|
+
const organization = ((_urlOptions$authoriza = urlOptions.authorizationParams) === null || _urlOptions$authoriza === void 0 ? void 0 : _urlOptions$authoriza.organization) || this.options.authorizationParams.organization;
|
|
7884
|
+
const authorizationParams = this._applySessionTransferToken(urlOptions.authorizationParams || {});
|
|
7885
|
+
const _await$this$_prepareA = await this._prepareAuthorizeUrl(authorizationParams), {url: url} = _await$this$_prepareA, transaction = _objectWithoutProperties(_await$this$_prepareA, _excluded2);
|
|
7886
|
+
this.transactionManager.create(_objectSpread2(_objectSpread2({}, transaction), {}, {
|
|
7772
7887
|
appState: appState,
|
|
7773
|
-
response_type:
|
|
7774
|
-
}
|
|
7888
|
+
response_type: ResponseType.Code
|
|
7889
|
+
}, organization && {
|
|
7775
7890
|
organization: organization
|
|
7776
7891
|
}));
|
|
7777
7892
|
const urlWithFragment = fragment ? "".concat(url, "#").concat(fragment) : url;
|
|
@@ -7793,7 +7908,7 @@
|
|
|
7793
7908
|
}
|
|
7794
7909
|
this.transactionManager.remove();
|
|
7795
7910
|
const authenticationResult = parseAuthenticationResult(queryStringFragments.join(""));
|
|
7796
|
-
if (transaction.response_type ===
|
|
7911
|
+
if (transaction.response_type === ResponseType.ConnectCode) {
|
|
7797
7912
|
return this._handleConnectAccountRedirectCallback(authenticationResult, transaction);
|
|
7798
7913
|
}
|
|
7799
7914
|
return this._handleLoginRedirectCallback(authenticationResult, transaction);
|
|
@@ -7809,7 +7924,7 @@
|
|
|
7809
7924
|
const organization = transaction.organization;
|
|
7810
7925
|
const nonceIn = transaction.nonce;
|
|
7811
7926
|
const redirect_uri = transaction.redirect_uri;
|
|
7812
|
-
await this._requestToken(
|
|
7927
|
+
await this._requestToken(_objectSpread2({
|
|
7813
7928
|
audience: transaction.audience,
|
|
7814
7929
|
scope: transaction.scope,
|
|
7815
7930
|
code_verifier: transaction.code_verifier,
|
|
@@ -7823,7 +7938,7 @@
|
|
|
7823
7938
|
});
|
|
7824
7939
|
return {
|
|
7825
7940
|
appState: transaction.appState,
|
|
7826
|
-
response_type:
|
|
7941
|
+
response_type: ResponseType.Code
|
|
7827
7942
|
};
|
|
7828
7943
|
}
|
|
7829
7944
|
async _handleConnectAccountRedirectCallback(connectResult, transaction) {
|
|
@@ -7843,9 +7958,9 @@
|
|
|
7843
7958
|
redirect_uri: transaction.redirect_uri,
|
|
7844
7959
|
code_verifier: transaction.code_verifier
|
|
7845
7960
|
});
|
|
7846
|
-
return
|
|
7961
|
+
return _objectSpread2(_objectSpread2({}, data), {}, {
|
|
7847
7962
|
appState: transaction.appState,
|
|
7848
|
-
response_type:
|
|
7963
|
+
response_type: ResponseType.ConnectCode
|
|
7849
7964
|
});
|
|
7850
7965
|
}
|
|
7851
7966
|
async checkSession(options) {
|
|
@@ -7865,20 +7980,20 @@
|
|
|
7865
7980
|
} catch (_) {}
|
|
7866
7981
|
}
|
|
7867
7982
|
async getTokenSilently() {
|
|
7983
|
+
var _options$authorizatio2, _options$authorizatio3;
|
|
7868
7984
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7869
|
-
|
|
7870
|
-
const localOptions = Object.assign(Object.assign({
|
|
7985
|
+
const localOptions = _objectSpread2(_objectSpread2({
|
|
7871
7986
|
cacheMode: "on"
|
|
7872
|
-
}, options), {
|
|
7873
|
-
authorizationParams:
|
|
7874
|
-
scope: scopesToRequest(this.scope, (
|
|
7987
|
+
}, options), {}, {
|
|
7988
|
+
authorizationParams: _objectSpread2(_objectSpread2(_objectSpread2({}, this.options.authorizationParams), options.authorizationParams), {}, {
|
|
7989
|
+
scope: scopesToRequest(this.scope, (_options$authorizatio2 = options.authorizationParams) === null || _options$authorizatio2 === void 0 ? void 0 : _options$authorizatio2.scope, ((_options$authorizatio3 = options.authorizationParams) === null || _options$authorizatio3 === void 0 ? void 0 : _options$authorizatio3.audience) || this.options.authorizationParams.audience)
|
|
7875
7990
|
})
|
|
7876
7991
|
});
|
|
7877
7992
|
const result = await singlePromise(() => this._getTokenSilently(localOptions), "".concat(this.options.clientId, "::").concat(localOptions.authorizationParams.audience, "::").concat(localOptions.authorizationParams.scope));
|
|
7878
7993
|
return options.detailedResponse ? result : result === null || result === void 0 ? void 0 : result.access_token;
|
|
7879
7994
|
}
|
|
7880
7995
|
async _getTokenSilently(options) {
|
|
7881
|
-
const {cacheMode: cacheMode} = options, getTokenOptions =
|
|
7996
|
+
const {cacheMode: cacheMode} = options, getTokenOptions = _objectWithoutProperties(options, _excluded3);
|
|
7882
7997
|
if (cacheMode !== "off") {
|
|
7883
7998
|
const entry = await this._getEntryFromCache({
|
|
7884
7999
|
scope: getTokenOptions.authorizationParams.scope,
|
|
@@ -7908,13 +8023,13 @@
|
|
|
7908
8023
|
}
|
|
7909
8024
|
const authResult = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(getTokenOptions) : await this._getTokenFromIFrame(getTokenOptions);
|
|
7910
8025
|
const {id_token: id_token, token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = authResult;
|
|
7911
|
-
return
|
|
8026
|
+
return _objectSpread2(_objectSpread2({
|
|
7912
8027
|
id_token: id_token,
|
|
7913
8028
|
token_type: token_type,
|
|
7914
8029
|
access_token: access_token
|
|
7915
8030
|
}, oauthTokenScope ? {
|
|
7916
8031
|
scope: oauthTokenScope
|
|
7917
|
-
} : null), {
|
|
8032
|
+
} : null), {}, {
|
|
7918
8033
|
expires_in: expires_in
|
|
7919
8034
|
});
|
|
7920
8035
|
});
|
|
@@ -7950,15 +8065,15 @@
|
|
|
7950
8065
|
}
|
|
7951
8066
|
}
|
|
7952
8067
|
async getTokenWithPopup() {
|
|
8068
|
+
var _options$authorizatio4, _options$authorizatio5;
|
|
7953
8069
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7954
8070
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
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)
|
|
8071
|
+
const localOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
8072
|
+
authorizationParams: _objectSpread2(_objectSpread2(_objectSpread2({}, this.options.authorizationParams), options.authorizationParams), {}, {
|
|
8073
|
+
scope: scopesToRequest(this.scope, (_options$authorizatio4 = options.authorizationParams) === null || _options$authorizatio4 === void 0 ? void 0 : _options$authorizatio4.scope, ((_options$authorizatio5 = options.authorizationParams) === null || _options$authorizatio5 === void 0 ? void 0 : _options$authorizatio5.audience) || this.options.authorizationParams.audience)
|
|
7959
8074
|
})
|
|
7960
8075
|
});
|
|
7961
|
-
config =
|
|
8076
|
+
config = _objectSpread2(_objectSpread2({}, DEFAULT_POPUP_CONFIG_OPTIONS), config);
|
|
7962
8077
|
await this.loginWithPopup(localOptions, config);
|
|
7963
8078
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
7964
8079
|
scope: localOptions.authorizationParams.scope,
|
|
@@ -7977,17 +8092,17 @@
|
|
|
7977
8092
|
} else {
|
|
7978
8093
|
delete options.clientId;
|
|
7979
8094
|
}
|
|
7980
|
-
const
|
|
8095
|
+
const _ref = options.logoutParams || {}, {federated: federated} = _ref, logoutOptions = _objectWithoutProperties(_ref, _excluded4);
|
|
7981
8096
|
const federatedQuery = federated ? "&federated" : "";
|
|
7982
|
-
const url = this._url("/v2/logout?".concat(createQueryParams(
|
|
8097
|
+
const url = this._url("/v2/logout?".concat(createQueryParams(_objectSpread2({
|
|
7983
8098
|
clientId: options.clientId
|
|
7984
8099
|
}, logoutOptions))));
|
|
7985
8100
|
return url + federatedQuery;
|
|
7986
8101
|
}
|
|
7987
8102
|
async logout() {
|
|
8103
|
+
var _this$dpop2;
|
|
7988
8104
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7989
|
-
|
|
7990
|
-
const _b = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _b, logoutOptions = __rest(_b, [ "openUrl" ]);
|
|
8105
|
+
const _patchOpenUrlWithOnRe2 = patchOpenUrlWithOnRedirect(options), {openUrl: openUrl} = _patchOpenUrlWithOnRe2, logoutOptions = _objectWithoutProperties(_patchOpenUrlWithOnRe2, _excluded5);
|
|
7991
8106
|
if (options.clientId === null) {
|
|
7992
8107
|
await this.cacheManager.clear();
|
|
7993
8108
|
} else {
|
|
@@ -8000,7 +8115,7 @@
|
|
|
8000
8115
|
cookieDomain: this.options.cookieDomain
|
|
8001
8116
|
});
|
|
8002
8117
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
8003
|
-
await ((
|
|
8118
|
+
await ((_this$dpop2 = this.dpop) === null || _this$dpop2 === void 0 ? void 0 : _this$dpop2.clear());
|
|
8004
8119
|
const url = this._buildLogoutUrl(logoutOptions);
|
|
8005
8120
|
if (openUrl) {
|
|
8006
8121
|
await openUrl(url);
|
|
@@ -8012,7 +8127,7 @@
|
|
|
8012
8127
|
const iframeLockKey = buildIframeLockKey(this.options.clientId);
|
|
8013
8128
|
try {
|
|
8014
8129
|
return await this.lockManager.runWithLock(iframeLockKey, 5e3, async () => {
|
|
8015
|
-
const params =
|
|
8130
|
+
const params = _objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
|
|
8016
8131
|
prompt: "none"
|
|
8017
8132
|
});
|
|
8018
8133
|
const orgHint = this.cookieStorage.get(this.orgHintCookieName);
|
|
@@ -8029,14 +8144,14 @@
|
|
|
8029
8144
|
let eventOrigin;
|
|
8030
8145
|
try {
|
|
8031
8146
|
eventOrigin = new URL(this.domainUrl).origin;
|
|
8032
|
-
} catch (
|
|
8147
|
+
} catch (_unused2) {
|
|
8033
8148
|
eventOrigin = this.domainUrl;
|
|
8034
8149
|
}
|
|
8035
8150
|
const codeResult = await runIframe(url, eventOrigin, authorizeTimeout);
|
|
8036
8151
|
if (stateIn !== codeResult.state) {
|
|
8037
8152
|
throw new GenericError("state_mismatch", "Invalid state");
|
|
8038
8153
|
}
|
|
8039
|
-
const tokenResult = await this._requestToken(
|
|
8154
|
+
const tokenResult = await this._requestToken(_objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
|
|
8040
8155
|
code_verifier: code_verifier,
|
|
8041
8156
|
code: codeResult.code,
|
|
8042
8157
|
grant_type: "authorization_code",
|
|
@@ -8046,7 +8161,7 @@
|
|
|
8046
8161
|
nonceIn: nonceIn,
|
|
8047
8162
|
organization: params.organization
|
|
8048
8163
|
});
|
|
8049
|
-
return
|
|
8164
|
+
return _objectSpread2(_objectSpread2({}, tokenResult), {}, {
|
|
8050
8165
|
scope: scope,
|
|
8051
8166
|
oauthTokenScope: tokenResult.scope,
|
|
8052
8167
|
audience: audience
|
|
@@ -8065,7 +8180,6 @@
|
|
|
8065
8180
|
}
|
|
8066
8181
|
}
|
|
8067
8182
|
async _getTokenUsingRefreshToken(options) {
|
|
8068
|
-
var _a, _b;
|
|
8069
8183
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
8070
8184
|
scope: options.authorizationParams.scope,
|
|
8071
8185
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
@@ -8081,16 +8195,16 @@
|
|
|
8081
8195
|
const timeout = typeof options.timeoutInSeconds === "number" ? options.timeoutInSeconds * 1e3 : null;
|
|
8082
8196
|
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);
|
|
8083
8197
|
try {
|
|
8084
|
-
const tokenResult = await this._requestToken(
|
|
8198
|
+
const tokenResult = await this._requestToken(_objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
|
|
8085
8199
|
grant_type: "refresh_token",
|
|
8086
8200
|
refresh_token: cache && cache.refresh_token,
|
|
8087
8201
|
redirect_uri: redirect_uri
|
|
8088
|
-
}
|
|
8202
|
+
}, timeout && {
|
|
8089
8203
|
timeout: timeout
|
|
8090
8204
|
}), {
|
|
8091
8205
|
scopesToRequest: scopesToRequest
|
|
8092
8206
|
});
|
|
8093
|
-
if (tokenResult.refresh_token &&
|
|
8207
|
+
if (tokenResult.refresh_token && cache !== null && cache !== void 0 && cache.refresh_token) {
|
|
8094
8208
|
await this.cacheManager.updateEntry(cache.refresh_token, tokenResult.refresh_token);
|
|
8095
8209
|
}
|
|
8096
8210
|
if (this.options.useMrrt) {
|
|
@@ -8107,7 +8221,7 @@
|
|
|
8107
8221
|
}
|
|
8108
8222
|
}
|
|
8109
8223
|
}
|
|
8110
|
-
return
|
|
8224
|
+
return _objectSpread2(_objectSpread2({}, tokenResult), {}, {
|
|
8111
8225
|
scope: options.authorizationParams.scope,
|
|
8112
8226
|
oauthTokenScope: tokenResult.scope,
|
|
8113
8227
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE
|
|
@@ -8125,13 +8239,14 @@
|
|
|
8125
8239
|
}
|
|
8126
8240
|
}
|
|
8127
8241
|
if (e instanceof MfaRequiredError) {
|
|
8128
|
-
|
|
8242
|
+
var _options$authorizatio6, _options$authorizatio7;
|
|
8243
|
+
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);
|
|
8129
8244
|
}
|
|
8130
8245
|
throw e;
|
|
8131
8246
|
}
|
|
8132
8247
|
}
|
|
8133
8248
|
async _saveEntryInCache(entry) {
|
|
8134
|
-
const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken =
|
|
8249
|
+
const {id_token: id_token, decodedToken: decodedToken} = entry, entryWithoutIdToken = _objectWithoutProperties(entry, _excluded6);
|
|
8135
8250
|
this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, {
|
|
8136
8251
|
id_token: id_token,
|
|
8137
8252
|
decodedToken: decodedToken
|
|
@@ -8154,8 +8269,8 @@
|
|
|
8154
8269
|
this.userCache.set(CACHE_KEY_ID_TOKEN_SUFFIX, cache);
|
|
8155
8270
|
return cache;
|
|
8156
8271
|
}
|
|
8157
|
-
async _getEntryFromCache(
|
|
8158
|
-
let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} =
|
|
8272
|
+
async _getEntryFromCache(_ref2) {
|
|
8273
|
+
let {scope: scope, audience: audience, clientId: clientId, cacheMode: cacheMode} = _ref2;
|
|
8159
8274
|
const entry = await this.cacheManager.get(new CacheKey({
|
|
8160
8275
|
scope: scope,
|
|
8161
8276
|
audience: audience,
|
|
@@ -8164,21 +8279,20 @@
|
|
|
8164
8279
|
if (entry && entry.access_token) {
|
|
8165
8280
|
const {token_type: token_type, access_token: access_token, oauthTokenScope: oauthTokenScope, expires_in: expires_in} = entry;
|
|
8166
8281
|
const cache = await this._getIdTokenFromCache();
|
|
8167
|
-
return cache &&
|
|
8282
|
+
return cache && _objectSpread2(_objectSpread2({
|
|
8168
8283
|
id_token: cache.id_token,
|
|
8169
8284
|
token_type: token_type ? token_type : "Bearer",
|
|
8170
8285
|
access_token: access_token
|
|
8171
8286
|
}, oauthTokenScope ? {
|
|
8172
8287
|
scope: oauthTokenScope
|
|
8173
|
-
} : null), {
|
|
8288
|
+
} : null), {}, {
|
|
8174
8289
|
expires_in: expires_in
|
|
8175
8290
|
});
|
|
8176
8291
|
}
|
|
8177
8292
|
}
|
|
8178
8293
|
async _requestToken(options, additionalParameters) {
|
|
8179
|
-
var _a, _b;
|
|
8180
8294
|
const {nonceIn: nonceIn, organization: organization, scopesToRequest: scopesToRequest} = additionalParameters || {};
|
|
8181
|
-
const authResult = await oauthToken(
|
|
8295
|
+
const authResult = await oauthToken(_objectSpread2(_objectSpread2({
|
|
8182
8296
|
baseUrl: this.domainUrl,
|
|
8183
8297
|
client_id: this.options.clientId,
|
|
8184
8298
|
auth0Client: this.options.auth0Client,
|
|
@@ -8186,24 +8300,25 @@
|
|
|
8186
8300
|
timeout: this.httpTimeoutMs,
|
|
8187
8301
|
useMrrt: this.options.useMrrt,
|
|
8188
8302
|
dpop: this.dpop
|
|
8189
|
-
}, options), {
|
|
8303
|
+
}, options), {}, {
|
|
8190
8304
|
scope: scopesToRequest || options.scope
|
|
8191
8305
|
}), this.worker);
|
|
8192
8306
|
const decodedToken = await this._verifyIdToken(authResult.id_token, nonceIn, organization);
|
|
8193
8307
|
if (options.grant_type === "authorization_code") {
|
|
8308
|
+
var _existingIdToken$deco;
|
|
8194
8309
|
const existingIdToken = await this._getIdTokenFromCache();
|
|
8195
|
-
if (
|
|
8310
|
+
if (existingIdToken !== null && existingIdToken !== void 0 && (_existingIdToken$deco = existingIdToken.decodedToken) !== null && _existingIdToken$deco !== void 0 && (_existingIdToken$deco = _existingIdToken$deco.claims) !== null && _existingIdToken$deco !== void 0 && _existingIdToken$deco.sub && existingIdToken.decodedToken.claims.sub !== decodedToken.claims.sub) {
|
|
8196
8311
|
await this.cacheManager.clear(this.options.clientId);
|
|
8197
8312
|
this.userCache.remove(CACHE_KEY_ID_TOKEN_SUFFIX);
|
|
8198
8313
|
}
|
|
8199
8314
|
}
|
|
8200
|
-
await this._saveEntryInCache(
|
|
8315
|
+
await this._saveEntryInCache(_objectSpread2(_objectSpread2(_objectSpread2({}, authResult), {}, {
|
|
8201
8316
|
decodedToken: decodedToken,
|
|
8202
8317
|
scope: options.scope,
|
|
8203
8318
|
audience: options.audience || DEFAULT_AUDIENCE
|
|
8204
|
-
}
|
|
8319
|
+
}, authResult.scope ? {
|
|
8205
8320
|
oauthTokenScope: authResult.scope
|
|
8206
|
-
} : null), {
|
|
8321
|
+
} : null), {}, {
|
|
8207
8322
|
client_id: this.options.clientId
|
|
8208
8323
|
}));
|
|
8209
8324
|
this.cookieStorage.save(this.isAuthenticatedCookieName, true, {
|
|
@@ -8211,12 +8326,12 @@
|
|
|
8211
8326
|
cookieDomain: this.options.cookieDomain
|
|
8212
8327
|
});
|
|
8213
8328
|
this._processOrgHint(organization || decodedToken.claims.org_id);
|
|
8214
|
-
return
|
|
8329
|
+
return _objectSpread2(_objectSpread2({}, authResult), {}, {
|
|
8215
8330
|
decodedToken: decodedToken
|
|
8216
8331
|
});
|
|
8217
8332
|
}
|
|
8218
8333
|
async loginWithCustomTokenExchange(options) {
|
|
8219
|
-
return this._requestToken(
|
|
8334
|
+
return this._requestToken(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8220
8335
|
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
8221
8336
|
subject_token: options.subject_token,
|
|
8222
8337
|
subject_token_type: options.subject_token_type,
|
|
@@ -8250,10 +8365,10 @@
|
|
|
8250
8365
|
return new Fetcher(config, {
|
|
8251
8366
|
isDpopEnabled: () => !!this.options.useDpop,
|
|
8252
8367
|
getAccessToken: authParams => {
|
|
8253
|
-
var
|
|
8368
|
+
var _authParams$scope;
|
|
8254
8369
|
return this.getTokenSilently({
|
|
8255
8370
|
authorizationParams: {
|
|
8256
|
-
scope:
|
|
8371
|
+
scope: authParams === null || authParams === void 0 || (_authParams$scope = authParams.scope) === null || _authParams$scope === void 0 ? void 0 : _authParams$scope.join(" "),
|
|
8257
8372
|
audience: authParams === null || authParams === void 0 ? void 0 : authParams.audience
|
|
8258
8373
|
},
|
|
8259
8374
|
detailedResponse: true
|
|
@@ -8289,7 +8404,7 @@
|
|
|
8289
8404
|
redirect_uri: redirectUri,
|
|
8290
8405
|
appState: appState,
|
|
8291
8406
|
connection: connection,
|
|
8292
|
-
response_type:
|
|
8407
|
+
response_type: ResponseType.ConnectCode
|
|
8293
8408
|
});
|
|
8294
8409
|
const url = new URL(connect_uri);
|
|
8295
8410
|
url.searchParams.set("ticket", connect_params.ticket);
|
|
@@ -8300,8 +8415,8 @@
|
|
|
8300
8415
|
}
|
|
8301
8416
|
}
|
|
8302
8417
|
async _requestTokenForMfa(options, additionalParameters) {
|
|
8303
|
-
const {mfaToken: mfaToken} = options, restOptions =
|
|
8304
|
-
return this._requestToken(
|
|
8418
|
+
const {mfaToken: mfaToken} = options, restOptions = _objectWithoutProperties(options, _excluded7);
|
|
8419
|
+
return this._requestToken(_objectSpread2(_objectSpread2({}, restOptions), {}, {
|
|
8305
8420
|
mfa_token: mfaToken
|
|
8306
8421
|
}), additionalParameters);
|
|
8307
8422
|
}
|
|
@@ -8331,6 +8446,7 @@
|
|
|
8331
8446
|
exports.PopupCancelledError = PopupCancelledError;
|
|
8332
8447
|
exports.PopupOpenError = PopupOpenError;
|
|
8333
8448
|
exports.PopupTimeoutError = PopupTimeoutError;
|
|
8449
|
+
exports.ResponseType = ResponseType;
|
|
8334
8450
|
exports.TimeoutError = TimeoutError;
|
|
8335
8451
|
exports.UseDpopNonceError = UseDpopNonceError;
|
|
8336
8452
|
exports.User = User;
|