@auth0/auth0-spa-js 2.17.0 → 2.17.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/dist/auth0-spa-js.development.js +956 -778
- 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 +14 -14
- 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 +1061 -869
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/version.d.ts +1 -1
- package/package.json +7 -8
- package/src/version.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define([ "exports" ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self,
|
|
3
3
|
factory(global.auth0 = {}));
|
|
4
|
-
})(this,
|
|
4
|
+
})(this, function(exports) {
|
|
5
5
|
"use strict";
|
|
6
6
|
function __rest(s, e) {
|
|
7
7
|
var t = {};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
var e = new Error(message);
|
|
16
16
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
17
17
|
};
|
|
18
|
-
var version = "2.17.
|
|
18
|
+
var version = "2.17.1";
|
|
19
19
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
20
20
|
const DEFAULT_POPUP_CONFIG_OPTIONS = {
|
|
21
21
|
timeoutInSeconds: DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
};
|
|
144
144
|
const runIframe = function runIframe(authorizeUrl, eventOrigin) {
|
|
145
145
|
let timeoutInSeconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS;
|
|
146
|
-
return new Promise((
|
|
146
|
+
return new Promise((res, rej) => {
|
|
147
147
|
const iframe = window.document.createElement("iframe");
|
|
148
148
|
iframe.setAttribute("width", "0");
|
|
149
149
|
iframe.setAttribute("height", "0");
|
|
@@ -155,10 +155,10 @@
|
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
157
|
let _iframeEventHandler;
|
|
158
|
-
const timeoutSetTimeoutId = setTimeout((
|
|
158
|
+
const timeoutSetTimeoutId = setTimeout(() => {
|
|
159
159
|
rej(new TimeoutError);
|
|
160
160
|
removeIframe();
|
|
161
|
-
}
|
|
161
|
+
}, timeoutInSeconds * 1e3);
|
|
162
162
|
_iframeEventHandler = function iframeEventHandler(e) {
|
|
163
163
|
if (e.origin != eventOrigin) return;
|
|
164
164
|
if (!e.data || e.data.type !== "authorization_response") return;
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
window.addEventListener("message", _iframeEventHandler, false);
|
|
175
175
|
window.document.body.appendChild(iframe);
|
|
176
176
|
iframe.setAttribute("src", authorizeUrl);
|
|
177
|
-
})
|
|
177
|
+
});
|
|
178
178
|
};
|
|
179
179
|
const openPopup = url => {
|
|
180
180
|
const width = 400;
|
|
@@ -183,21 +183,21 @@
|
|
|
183
183
|
const top = window.screenY + (window.innerHeight - height) / 2;
|
|
184
184
|
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
185
|
};
|
|
186
|
-
const runPopup = config => new Promise((
|
|
186
|
+
const runPopup = config => new Promise((resolve, reject) => {
|
|
187
187
|
let _popupEventListener;
|
|
188
|
-
const popupTimer = setInterval((
|
|
188
|
+
const popupTimer = setInterval(() => {
|
|
189
189
|
if (config.popup && config.popup.closed) {
|
|
190
190
|
clearInterval(popupTimer);
|
|
191
191
|
clearTimeout(timeoutId);
|
|
192
192
|
window.removeEventListener("message", _popupEventListener, false);
|
|
193
193
|
reject(new PopupCancelledError(config.popup));
|
|
194
194
|
}
|
|
195
|
-
}
|
|
196
|
-
const timeoutId = setTimeout((
|
|
195
|
+
}, 1e3);
|
|
196
|
+
const timeoutId = setTimeout(() => {
|
|
197
197
|
clearInterval(popupTimer);
|
|
198
198
|
reject(new PopupTimeoutError(config.popup));
|
|
199
199
|
window.removeEventListener("message", _popupEventListener, false);
|
|
200
|
-
}
|
|
200
|
+
}, (config.timeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) * 1e3);
|
|
201
201
|
_popupEventListener = function popupEventListener(e) {
|
|
202
202
|
if (!e.data || e.data.type !== "authorization_response") {
|
|
203
203
|
return;
|
|
@@ -214,19 +214,19 @@
|
|
|
214
214
|
resolve(e.data.response);
|
|
215
215
|
};
|
|
216
216
|
window.addEventListener("message", _popupEventListener);
|
|
217
|
-
})
|
|
217
|
+
});
|
|
218
218
|
const getCrypto = () => window.crypto;
|
|
219
219
|
const createRandomString = () => {
|
|
220
220
|
const charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
|
|
221
221
|
let random = "";
|
|
222
222
|
const randomValues = Array.from(getCrypto().getRandomValues(new Uint8Array(43)));
|
|
223
|
-
randomValues.forEach(
|
|
223
|
+
randomValues.forEach(v => random += charset[v % charset.length]);
|
|
224
224
|
return random;
|
|
225
225
|
};
|
|
226
226
|
const encode$2 = value => btoa(value);
|
|
227
|
-
const stripUndefined = params => Object.keys(params).filter(
|
|
227
|
+
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) => Object.assign(Object.assign({}, acc), {
|
|
228
228
|
[key]: params[key]
|
|
229
|
-
})
|
|
229
|
+
}), {});
|
|
230
230
|
const ALLOWED_AUTH0CLIENT_PROPERTIES = [ {
|
|
231
231
|
key: "name",
|
|
232
232
|
type: [ "string" ]
|
|
@@ -239,16 +239,16 @@
|
|
|
239
239
|
} ];
|
|
240
240
|
const stripAuth0Client = function stripAuth0Client(auth0Client) {
|
|
241
241
|
let excludeEnv = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
242
|
-
return Object.keys(auth0Client).reduce((
|
|
242
|
+
return Object.keys(auth0Client).reduce((acc, key) => {
|
|
243
243
|
if (excludeEnv && key === "env") {
|
|
244
244
|
return acc;
|
|
245
245
|
}
|
|
246
|
-
const allowedProperty = ALLOWED_AUTH0CLIENT_PROPERTIES.find(
|
|
246
|
+
const allowedProperty = ALLOWED_AUTH0CLIENT_PROPERTIES.find(p => p.key === key);
|
|
247
247
|
if (allowedProperty && allowedProperty.type.includes(typeof auth0Client[key])) {
|
|
248
248
|
acc[key] = auth0Client[key];
|
|
249
249
|
}
|
|
250
250
|
return acc;
|
|
251
|
-
}
|
|
251
|
+
}, {});
|
|
252
252
|
};
|
|
253
253
|
const createQueryParams = _a => {
|
|
254
254
|
var {clientId: client_id} = _a, params = __rest(_a, [ "clientId" ]);
|
|
@@ -268,9 +268,9 @@
|
|
|
268
268
|
"/": "_",
|
|
269
269
|
"=": ""
|
|
270
270
|
};
|
|
271
|
-
return input.replace(/[+/=]/g,
|
|
271
|
+
return input.replace(/[+/=]/g, m => b64Chars[m]);
|
|
272
272
|
};
|
|
273
|
-
const decodeB64 = input => decodeURIComponent(atob(input).split("").map(
|
|
273
|
+
const decodeB64 = input => decodeURIComponent(atob(input).split("").map(c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join(""));
|
|
274
274
|
const urlDecodeB64 = input => decodeB64(input.replace(/_/g, "/").replace(/-/g, "+"));
|
|
275
275
|
const bufferToBase64UrlEncoded = input => {
|
|
276
276
|
const ie11SafeInput = new Uint8Array(input);
|
|
@@ -302,11 +302,11 @@
|
|
|
302
302
|
}
|
|
303
303
|
return parseInt(value, 10) || undefined;
|
|
304
304
|
};
|
|
305
|
-
const fromEntries = iterable => [ ...iterable ].reduce((
|
|
305
|
+
const fromEntries = iterable => [ ...iterable ].reduce((obj, _ref) => {
|
|
306
306
|
let [key, val] = _ref;
|
|
307
307
|
obj[key] = val;
|
|
308
308
|
return obj;
|
|
309
|
-
}
|
|
309
|
+
}, {});
|
|
310
310
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
311
311
|
var browserTabsLock = {};
|
|
312
312
|
var processLock = {};
|
|
@@ -336,14 +336,14 @@
|
|
|
336
336
|
return _this.locked.has(key);
|
|
337
337
|
};
|
|
338
338
|
this.lock = function(key) {
|
|
339
|
-
return new Promise(
|
|
339
|
+
return new Promise(function(resolve, reject) {
|
|
340
340
|
if (_this.isLocked(key)) {
|
|
341
341
|
_this.addToLocked(key, resolve);
|
|
342
342
|
} else {
|
|
343
343
|
_this.addToLocked(key);
|
|
344
344
|
resolve();
|
|
345
345
|
}
|
|
346
|
-
})
|
|
346
|
+
});
|
|
347
347
|
};
|
|
348
348
|
this.unlock = function(key) {
|
|
349
349
|
var callbacks = _this.locked.get(key);
|
|
@@ -371,7 +371,7 @@
|
|
|
371
371
|
}
|
|
372
372
|
processLock.default = getLock;
|
|
373
373
|
var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
374
|
-
return new (P || (P = Promise))(
|
|
374
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
375
375
|
function fulfilled(value) {
|
|
376
376
|
try {
|
|
377
377
|
step(generator.next(value));
|
|
@@ -387,12 +387,12 @@
|
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
function step(result) {
|
|
390
|
-
result.done ? resolve(result.value) : new P(
|
|
390
|
+
result.done ? resolve(result.value) : new P(function(resolve) {
|
|
391
391
|
resolve(result.value);
|
|
392
|
-
})
|
|
392
|
+
}).then(fulfilled, rejected);
|
|
393
393
|
}
|
|
394
394
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
395
|
-
})
|
|
395
|
+
});
|
|
396
396
|
};
|
|
397
397
|
var __generator = commonjsGlobal && commonjsGlobal.__generator || function(thisArg, body) {
|
|
398
398
|
var _ = {
|
|
@@ -491,39 +491,39 @@
|
|
|
491
491
|
var LOCK_STORAGE_KEY = "browser-tabs-lock-key";
|
|
492
492
|
var DEFAULT_STORAGE_HANDLER = {
|
|
493
493
|
key: function(index) {
|
|
494
|
-
return __awaiter(_this, void 0, void 0,
|
|
495
|
-
return __generator(this,
|
|
494
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
495
|
+
return __generator(this, function(_a) {
|
|
496
496
|
throw new Error("Unsupported");
|
|
497
|
-
})
|
|
498
|
-
})
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
499
|
},
|
|
500
500
|
getItem: function(key) {
|
|
501
|
-
return __awaiter(_this, void 0, void 0,
|
|
502
|
-
return __generator(this,
|
|
501
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
502
|
+
return __generator(this, function(_a) {
|
|
503
503
|
throw new Error("Unsupported");
|
|
504
|
-
})
|
|
505
|
-
})
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
506
|
},
|
|
507
507
|
clear: function() {
|
|
508
|
-
return __awaiter(_this, void 0, void 0,
|
|
509
|
-
return __generator(this,
|
|
508
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
509
|
+
return __generator(this, function(_a) {
|
|
510
510
|
return [ 2, window.localStorage.clear() ];
|
|
511
|
-
})
|
|
512
|
-
})
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
513
|
},
|
|
514
514
|
removeItem: function(key) {
|
|
515
|
-
return __awaiter(_this, void 0, void 0,
|
|
516
|
-
return __generator(this,
|
|
515
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
516
|
+
return __generator(this, function(_a) {
|
|
517
517
|
throw new Error("Unsupported");
|
|
518
|
-
})
|
|
519
|
-
})
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
520
|
},
|
|
521
521
|
setItem: function(key, value) {
|
|
522
|
-
return __awaiter(_this, void 0, void 0,
|
|
523
|
-
return __generator(this,
|
|
522
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
523
|
+
return __generator(this, function(_a) {
|
|
524
524
|
throw new Error("Unsupported");
|
|
525
|
-
})
|
|
526
|
-
})
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
527
|
},
|
|
528
528
|
keySync: function(index) {
|
|
529
529
|
return window.localStorage.key(index);
|
|
@@ -542,9 +542,9 @@
|
|
|
542
542
|
}
|
|
543
543
|
};
|
|
544
544
|
function delay(milliseconds) {
|
|
545
|
-
return new Promise(
|
|
545
|
+
return new Promise(function(resolve) {
|
|
546
546
|
return setTimeout(resolve, milliseconds);
|
|
547
|
-
})
|
|
547
|
+
});
|
|
548
548
|
}
|
|
549
549
|
function generateRandomString(length) {
|
|
550
550
|
var CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
|
@@ -577,9 +577,9 @@
|
|
|
577
577
|
if (timeout === void 0) {
|
|
578
578
|
timeout = 5e3;
|
|
579
579
|
}
|
|
580
|
-
return __awaiter(this, void 0, void 0,
|
|
580
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
581
581
|
var iat, MAX_TIME, STORAGE_KEY, STORAGE, lockObj, TIMEOUT_KEY, lockObjPostDelay, parsedLockObjPostDelay;
|
|
582
|
-
return __generator(this,
|
|
582
|
+
return __generator(this, function(_a) {
|
|
583
583
|
switch (_a.label) {
|
|
584
584
|
case 0:
|
|
585
585
|
iat = Date.now() + generateRandomString(4);
|
|
@@ -638,17 +638,17 @@
|
|
|
638
638
|
case 8:
|
|
639
639
|
return [ 2, false ];
|
|
640
640
|
}
|
|
641
|
-
})
|
|
642
|
-
})
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
643
|
};
|
|
644
644
|
SuperTokensLock.prototype.refreshLockWhileAcquired = function(storageKey, iat) {
|
|
645
|
-
return __awaiter(this, void 0, void 0,
|
|
645
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
646
646
|
var _this = this;
|
|
647
|
-
return __generator(this,
|
|
648
|
-
setTimeout(
|
|
649
|
-
return __awaiter(_this, void 0, void 0,
|
|
647
|
+
return __generator(this, function(_a) {
|
|
648
|
+
setTimeout(function() {
|
|
649
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
650
650
|
var STORAGE, lockObj, parsedLockObj;
|
|
651
|
-
return __generator(this,
|
|
651
|
+
return __generator(this, function(_a) {
|
|
652
652
|
switch (_a.label) {
|
|
653
653
|
case 0:
|
|
654
654
|
return [ 4, processLock_1.default().lock(iat) ];
|
|
@@ -673,19 +673,19 @@
|
|
|
673
673
|
this.refreshLockWhileAcquired(storageKey, iat);
|
|
674
674
|
return [ 2 ];
|
|
675
675
|
}
|
|
676
|
-
})
|
|
677
|
-
})
|
|
678
|
-
}
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
}, 1e3);
|
|
679
679
|
return [ 2 ];
|
|
680
|
-
})
|
|
681
|
-
})
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
682
|
};
|
|
683
683
|
SuperTokensLock.prototype.waitForSomethingToChange = function(MAX_TIME) {
|
|
684
|
-
return __awaiter(this, void 0, void 0,
|
|
685
|
-
return __generator(this,
|
|
684
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
685
|
+
return __generator(this, function(_a) {
|
|
686
686
|
switch (_a.label) {
|
|
687
687
|
case 0:
|
|
688
|
-
return [ 4, new Promise(
|
|
688
|
+
return [ 4, new Promise(function(resolve) {
|
|
689
689
|
var resolvedCalled = false;
|
|
690
690
|
var startedAt = Date.now();
|
|
691
691
|
var MIN_TIME_TO_WAIT = 50;
|
|
@@ -710,14 +710,14 @@
|
|
|
710
710
|
window.addEventListener("storage", stopWaiting);
|
|
711
711
|
SuperTokensLock.addToWaiting(stopWaiting);
|
|
712
712
|
var timeOutId = setTimeout(stopWaiting, Math.max(0, MAX_TIME - Date.now()));
|
|
713
|
-
})
|
|
713
|
+
}) ];
|
|
714
714
|
|
|
715
715
|
case 1:
|
|
716
716
|
_a.sent();
|
|
717
717
|
return [ 2 ];
|
|
718
718
|
}
|
|
719
|
-
})
|
|
720
|
-
})
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
721
|
};
|
|
722
722
|
SuperTokensLock.addToWaiting = function(func) {
|
|
723
723
|
this.removeFromWaiting(func);
|
|
@@ -730,22 +730,22 @@
|
|
|
730
730
|
if (SuperTokensLock.waiters === undefined) {
|
|
731
731
|
return;
|
|
732
732
|
}
|
|
733
|
-
SuperTokensLock.waiters = SuperTokensLock.waiters.filter(
|
|
733
|
+
SuperTokensLock.waiters = SuperTokensLock.waiters.filter(function(i) {
|
|
734
734
|
return i !== func;
|
|
735
|
-
})
|
|
735
|
+
});
|
|
736
736
|
};
|
|
737
737
|
SuperTokensLock.notifyWaiters = function() {
|
|
738
738
|
if (SuperTokensLock.waiters === undefined) {
|
|
739
739
|
return;
|
|
740
740
|
}
|
|
741
741
|
var waiters = SuperTokensLock.waiters.slice();
|
|
742
|
-
waiters.forEach(
|
|
742
|
+
waiters.forEach(function(i) {
|
|
743
743
|
return i();
|
|
744
|
-
})
|
|
744
|
+
});
|
|
745
745
|
};
|
|
746
746
|
SuperTokensLock.prototype.releaseLock = function(lockKey) {
|
|
747
|
-
return __awaiter(this, void 0, void 0,
|
|
748
|
-
return __generator(this,
|
|
747
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
748
|
+
return __generator(this, function(_a) {
|
|
749
749
|
switch (_a.label) {
|
|
750
750
|
case 0:
|
|
751
751
|
return [ 4, this.releaseLock__private__(lockKey) ];
|
|
@@ -753,13 +753,13 @@
|
|
|
753
753
|
case 1:
|
|
754
754
|
return [ 2, _a.sent() ];
|
|
755
755
|
}
|
|
756
|
-
})
|
|
757
|
-
})
|
|
756
|
+
});
|
|
757
|
+
});
|
|
758
758
|
};
|
|
759
759
|
SuperTokensLock.prototype.releaseLock__private__ = function(lockKey) {
|
|
760
|
-
return __awaiter(this, void 0, void 0,
|
|
760
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
761
761
|
var STORAGE, STORAGE_KEY, lockObj, parsedlockObj;
|
|
762
|
-
return __generator(this,
|
|
762
|
+
return __generator(this, function(_a) {
|
|
763
763
|
switch (_a.label) {
|
|
764
764
|
case 0:
|
|
765
765
|
STORAGE = this.storageHandler === undefined ? DEFAULT_STORAGE_HANDLER : this.storageHandler;
|
|
@@ -783,8 +783,8 @@
|
|
|
783
783
|
case 2:
|
|
784
784
|
return [ 2 ];
|
|
785
785
|
}
|
|
786
|
-
})
|
|
787
|
-
})
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
788
|
};
|
|
789
789
|
SuperTokensLock.lockCorrector = function(storageHandler) {
|
|
790
790
|
var MIN_ALLOWED_TIME = Date.now() - 5e3;
|
|
@@ -824,16 +824,16 @@
|
|
|
824
824
|
class WebLocksApiManager {
|
|
825
825
|
async runWithLock(key, timeout, callback) {
|
|
826
826
|
const controller = new AbortController;
|
|
827
|
-
const timeoutId = setTimeout((
|
|
827
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
828
828
|
try {
|
|
829
829
|
return await navigator.locks.request(key, {
|
|
830
830
|
mode: "exclusive",
|
|
831
831
|
signal: controller.signal
|
|
832
|
-
},
|
|
832
|
+
}, async lock => {
|
|
833
833
|
clearTimeout(timeoutId);
|
|
834
834
|
if (!lock) throw new Error("Lock not available");
|
|
835
835
|
return await callback();
|
|
836
|
-
})
|
|
836
|
+
});
|
|
837
837
|
} catch (error) {
|
|
838
838
|
clearTimeout(timeoutId);
|
|
839
839
|
if ((error === null || error === void 0 ? void 0 : error.name) === "AbortError") throw new TimeoutError;
|
|
@@ -846,7 +846,7 @@
|
|
|
846
846
|
this.activeLocks = new Set;
|
|
847
847
|
this.lock = new _default;
|
|
848
848
|
this.pagehideHandler = () => {
|
|
849
|
-
this.activeLocks.forEach(
|
|
849
|
+
this.activeLocks.forEach(key => this.lock.releaseLock(key));
|
|
850
850
|
this.activeLocks.clear();
|
|
851
851
|
};
|
|
852
852
|
}
|
|
@@ -1198,7 +1198,7 @@
|
|
|
1198
1198
|
function isGrantTypeSupported(grantType) {
|
|
1199
1199
|
return SUPPORTED_GRANT_TYPES.includes(grantType);
|
|
1200
1200
|
}
|
|
1201
|
-
const sendMessage = (message, to) => new Promise(
|
|
1201
|
+
const sendMessage = (message, to) => new Promise(function(resolve, reject) {
|
|
1202
1202
|
const messageChannel = new MessageChannel;
|
|
1203
1203
|
messageChannel.port1.onmessage = function(event) {
|
|
1204
1204
|
if (event.data.error) {
|
|
@@ -1209,7 +1209,7 @@
|
|
|
1209
1209
|
messageChannel.port1.close();
|
|
1210
1210
|
};
|
|
1211
1211
|
to.postMessage(message, [ messageChannel.port2 ]);
|
|
1212
|
-
})
|
|
1212
|
+
});
|
|
1213
1213
|
const createAbortController = () => new AbortController;
|
|
1214
1214
|
const dofetch = async (fetchUrl, fetchOptions) => {
|
|
1215
1215
|
const response = await fetch(fetchUrl, fetchOptions);
|
|
@@ -1223,14 +1223,14 @@
|
|
|
1223
1223
|
const controller = createAbortController();
|
|
1224
1224
|
fetchOptions.signal = controller.signal;
|
|
1225
1225
|
let timeoutId;
|
|
1226
|
-
return Promise.race([ dofetch(fetchUrl, fetchOptions), new Promise((
|
|
1227
|
-
timeoutId = setTimeout((
|
|
1226
|
+
return Promise.race([ dofetch(fetchUrl, fetchOptions), new Promise((_, reject) => {
|
|
1227
|
+
timeoutId = setTimeout(() => {
|
|
1228
1228
|
controller.abort();
|
|
1229
1229
|
reject(new Error("Timeout when executing 'fetch'"));
|
|
1230
|
-
}
|
|
1231
|
-
})
|
|
1230
|
+
}, timeout);
|
|
1231
|
+
}) ]).finally(() => {
|
|
1232
1232
|
clearTimeout(timeoutId);
|
|
1233
|
-
})
|
|
1233
|
+
});
|
|
1234
1234
|
};
|
|
1235
1235
|
const fetchWithWorker = async (fetchUrl, audience, scope, fetchOptions, timeout, worker, useFormData, useMrrt) => sendMessage({
|
|
1236
1236
|
auth: {
|
|
@@ -1345,10 +1345,10 @@
|
|
|
1345
1345
|
let requestedScopes = {
|
|
1346
1346
|
[DEFAULT_AUDIENCE]: getUniqueScopes(openIdScope, ...extraScopes)
|
|
1347
1347
|
};
|
|
1348
|
-
Object.keys(authScopes).forEach(
|
|
1348
|
+
Object.keys(authScopes).forEach(key => {
|
|
1349
1349
|
const audienceScopes = authScopes[key];
|
|
1350
1350
|
requestedScopes[key] = getUniqueScopes(openIdScope, audienceScopes, ...extraScopes);
|
|
1351
|
-
})
|
|
1351
|
+
});
|
|
1352
1352
|
return requestedScopes;
|
|
1353
1353
|
};
|
|
1354
1354
|
const scopesToRequest = (authScopes, methodScopes, audience) => {
|
|
@@ -1411,7 +1411,7 @@
|
|
|
1411
1411
|
localStorage.removeItem(key);
|
|
1412
1412
|
}
|
|
1413
1413
|
allKeys() {
|
|
1414
|
-
return Object.keys(window.localStorage).filter(
|
|
1414
|
+
return Object.keys(window.localStorage).filter(key => key.startsWith(CACHE_KEY_PREFIX));
|
|
1415
1415
|
}
|
|
1416
1416
|
}
|
|
1417
1417
|
class InMemoryCache {
|
|
@@ -1546,10 +1546,10 @@
|
|
|
1546
1546
|
var _a;
|
|
1547
1547
|
const keys = await this.getCacheKeys();
|
|
1548
1548
|
if (!keys) return;
|
|
1549
|
-
await keys.filter(
|
|
1549
|
+
await keys.filter(key => clientId ? key.includes(clientId) : true).reduce(async (memo, key) => {
|
|
1550
1550
|
await memo;
|
|
1551
1551
|
await this.cache.remove(key);
|
|
1552
|
-
}
|
|
1552
|
+
}, Promise.resolve());
|
|
1553
1553
|
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.clear());
|
|
1554
1554
|
}
|
|
1555
1555
|
async wrapCacheEntry(entry) {
|
|
@@ -1574,14 +1574,14 @@
|
|
|
1574
1574
|
}, CACHE_KEY_PREFIX, CACHE_KEY_ID_TOKEN_SUFFIX).toKey();
|
|
1575
1575
|
}
|
|
1576
1576
|
matchExistingCacheKey(keyToMatch, allKeys) {
|
|
1577
|
-
return allKeys.filter(
|
|
1577
|
+
return allKeys.filter(key => {
|
|
1578
1578
|
var _a;
|
|
1579
1579
|
const cacheKey = CacheKey.fromKey(key);
|
|
1580
1580
|
const scopeSet = new Set(cacheKey.scope && cacheKey.scope.split(" "));
|
|
1581
1581
|
const scopesToMatch = ((_a = keyToMatch.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
1582
|
-
const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((
|
|
1582
|
+
const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((acc, current) => acc && scopeSet.has(current), true);
|
|
1583
1583
|
return cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId && cacheKey.audience === keyToMatch.audience && hasAllScopes;
|
|
1584
|
-
})
|
|
1584
|
+
})[0];
|
|
1585
1585
|
}
|
|
1586
1586
|
async getEntryWithRefreshToken(keyToMatch, allKeys) {
|
|
1587
1587
|
var _a;
|
|
@@ -1645,12 +1645,12 @@
|
|
|
1645
1645
|
__raw: token
|
|
1646
1646
|
};
|
|
1647
1647
|
const user = {};
|
|
1648
|
-
Object.keys(payloadJSON).forEach(
|
|
1648
|
+
Object.keys(payloadJSON).forEach(k => {
|
|
1649
1649
|
claims[k] = payloadJSON[k];
|
|
1650
1650
|
if (!idTokendecoded.includes(k)) {
|
|
1651
1651
|
user[k] = payloadJSON[k];
|
|
1652
1652
|
}
|
|
1653
|
-
})
|
|
1653
|
+
});
|
|
1654
1654
|
return {
|
|
1655
1655
|
encoded: {
|
|
1656
1656
|
header: header,
|
|
@@ -1942,15 +1942,15 @@
|
|
|
1942
1942
|
return new Worker(url, options);
|
|
1943
1943
|
};
|
|
1944
1944
|
}
|
|
1945
|
-
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBjbGFzcyBHZW5lcmljRXJyb3IgZXh0ZW5kcyBFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uKSB7CiAgICAgICAgICAgIHN1cGVyKGVycm9yX2Rlc2NyaXB0aW9uKTsKICAgICAgICAgICAgdGhpcy5lcnJvciA9IGVycm9yOwogICAgICAgICAgICB0aGlzLmVycm9yX2Rlc2NyaXB0aW9uID0gZXJyb3JfZGVzY3JpcHRpb247CiAgICAgICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLCBHZW5lcmljRXJyb3IucHJvdG90eXBlKTsKICAgICAgICB9CiAgICAgICAgc3RhdGljIGZyb21QYXlsb2FkKF9yZWYpIHsKICAgICAgICAgICAgbGV0IHtlcnJvcjogZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvcl9kZXNjcmlwdGlvbn0gPSBfcmVmOwogICAgICAgICAgICByZXR1cm4gbmV3IEdlbmVyaWNFcnJvcihlcnJvciwgZXJyb3JfZGVzY3JpcHRpb24pOwogICAgICAgIH0KICAgIH0KICAgIGNsYXNzIE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvciBleHRlbmRzIEdlbmVyaWNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoYXVkaWVuY2UsIHNjb3BlKSB7CiAgICAgICAgICAgIHN1cGVyKCJtaXNzaW5nX3JlZnJlc2hfdG9rZW4iLCAiTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyIuY29uY2F0KHZhbHVlT3JFbXB0eVN0cmluZyhhdWRpZW5jZSwgWyAiZGVmYXVsdCIgXSksICInLCBzY29wZTogJyIpLmNvbmNhdCh2YWx1ZU9yRW1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KGtleSA9PiBzY29wZXNLZXkuaW5jbHVkZXMoa2V5KSkpOwogICAgICAgICAgICAgICAgcmV0dXJuIGlzU2FtZUF1ZGllbmNlICYmIHNjb3Blc0FyZUluY2x1ZGVkOwogICAgICAgICAgICB9CiAgICAgICAgfSkpOwogICAgICAgIHJldHVybiBmaW5kQ29pbmNpZGVuY2UgPyB0cnVlIDogZmFsc2U7CiAgICB9OwogICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBhc3luYyBfcmVmMiA9PiB7CiAgICAgICAgbGV0IHtkYXRhOiB7dGltZW91dDogdGltZW91dCwgYXV0aDogYXV0aCwgZmV0Y2hVcmw6IGZldGNoVXJsLCBmZXRjaE9wdGlvbnM6IGZldGNoT3B0aW9ucywgdXNlRm9ybURhdGE6IHVzZUZvcm1EYXRhLCB1c2VNcnJ0OiB1c2VNcnJ0fSwgcG9ydHM6IFtwb3J0XX0gPSBfcmVmMjsKICAgICAgICBsZXQgaGVhZGVycyA9IHt9OwogICAgICAgIGxldCBqc29uOwogICAgICAgIGxldCByZWZyZXNoVG9rZW47CiAgICAgICAgY29uc3Qge2F1ZGllbmNlOiBhdWRpZW5jZSwgc2NvcGU6IHNjb3BlfSA9IGF1dGggfHwge307CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgYm9keSA9IHVzZUZvcm1EYXRhID8gZm9ybURhdGFUb09iamVjdChmZXRjaE9wdGlvbnMuYm9keSkgOiBKU09OLnBhcnNlKGZldGNoT3B0aW9ucy5ib2R5KTsKICAgICAgICAgICAgaWYgKCFib2R5LnJlZnJlc2hfdG9rZW4gJiYgYm9keS5ncmFudF90eXBlID09PSAicmVmcmVzaF90b2tlbiIpIHsKICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGdldFJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgaWYgKCFyZWZyZXNoVG9rZW4gJiYgdXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxhdGVzdFJlZnJlc2hUb2tlbiA9IHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl07CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNEb3duc2NvcGluZyA9IGNoZWNrRG93bnNjb3Bpbmcoc2NvcGUsIGF1ZGllbmNlKTsKICAgICAgICAgICAgICAgICAgICBpZiAobGF0ZXN0UmVmcmVzaFRva2VuICYmICFpc0Rvd25zY29waW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGxhdGVzdFJlZnJlc2hUb2tlbjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBNaXNzaW5nUmVmcmVzaFRva2VuRXJyb3IoYXVkaWVuY2UsIHNjb3BlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5ib2R5ID0gdXNlRm9ybURhdGEgPyBjcmVhdGVRdWVyeVBhcmFtcyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSkgOiBKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IGFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgaWYgKHR5cGVvZiBBYm9ydENvbnRyb2xsZXIgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgIGFib3J0Q29udHJvbGxlciA9IG5ldyBBYm9ydENvbnRyb2xsZXI7CiAgICAgICAgICAgICAgICBmZXRjaE9wdGlvbnMuc2lnbmFsID0gYWJvcnRDb250cm9sbGVyLnNpZ25hbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgcmVzcG9uc2U7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICByZXNwb25zZSA9IGF3YWl0IFByb21pc2UucmFjZShbIHdhaXQodGltZW91dCksIGZldGNoKGZldGNoVXJsLCBPYmplY3QuYXNzaWduKHt9LCBmZXRjaE9wdGlvbnMpKSBdKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICBpZiAoYWJvcnRDb250cm9sbGVyKSBhYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVycyA9IGZyb21FbnRyaWVzKHJlc3BvbnNlLmhlYWRlcnMpOwogICAgICAgICAgICBqc29uID0gYXdhaXQgcmVzcG9uc2UuanNvbigpOwogICAgICAgICAgICBpZiAoanNvbi5yZWZyZXNoX3Rva2VuKSB7CiAgICAgICAgICAgICAgICBpZiAodXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl0gPSBqc29uLnJlZnJlc2hfdG9rZW47CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUmVmcmVzaFRva2VucyhyZWZyZXNoVG9rZW4sIGpzb24ucmVmcmVzaF90b2tlbik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzZXRSZWZyZXNoVG9rZW4oanNvbi5yZWZyZXNoX3Rva2VuLCBhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgZGVsZXRlIGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IHJlc3BvbnNlLm9rLAogICAgICAgICAgICAgICAganNvbjoganNvbiwKICAgICAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMKICAgICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICBqc29uOiB7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLmVycm9yLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgewogICAgICAgIGFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBtZXNzYWdlSGFuZGxlcik7CiAgICB9Cn0pKCk7Cgo=", null, false);
|
|
1945
|
+
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXB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ICAgICAgICByZXR1cm4gcGFyc2VkUXVlcnk7CiAgICB9OwogICAgY29uc3QgdXBkYXRlUmVmcmVzaFRva2VucyA9IChvbGRSZWZyZXNoVG9rZW4sIG5ld1JlZnJlc2hUb2tlbikgPT4gewogICAgICAgIE9iamVjdC5lbnRyaWVzKHJlZnJlc2hUb2tlbnMpLmZvckVhY2goX3JlZiA9PiB7CiAgICAgICAgICAgIGxldCBba2V5LCB0b2tlbl0gPSBfcmVmOwogICAgICAgICAgICBpZiAodG9rZW4gPT09IG9sZFJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1trZXldID0gbmV3UmVmcmVzaFRva2VuOwogICAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICB9OwogICAgY29uc3QgY2hlY2tEb3duc2NvcGluZyA9IChzY29wZSwgYXVkaWVuY2UpID0+IHsKICAgICAgICBjb25zdCBmaW5kQ29pbmNpZGVuY2UgPSBPYmplY3Qua2V5cyhyZWZyZXNoVG9rZW5zKS5maW5kKGtleSA9PiB7CiAgICAgICAgICAgIGlmIChrZXkgIT09ICJsYXRlc3RfcmVmcmVzaF90b2tlbiIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGlzU2FtZUF1ZGllbmNlID0gY2FjaGVLZXlDb250YWluc0F1ZGllbmNlKGF1ZGllbmNlLCBrZXkpOwogICAgICAgICAgICAgICAgY29uc3Qgc2NvcGVzS2V5ID0ga2V5LnNwbGl0KCJ8IilbMV0uc3BsaXQoIiAiKTsKICAgICAgICAgICAgICAgIGNvbnN0IHJlcXVlc3RlZFNjb3BlcyA9IHNjb3BlLnNwbGl0KCIgIik7CiAgICAgICAgICAgICAgICBjb25zdCBzY29wZXNBcmVJbmNsdWRlZCA9IHJlcXVlc3RlZFNjb3Blcy5ldmVyeShrZXkgPT4gc2NvcGVzS2V5LmluY2x1ZGVzKGtleSkpOwogICAgICAgICAgICAgICAgcmV0dXJuIGlzU2FtZUF1ZGllbmNlICYmIHNjb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KICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0Rvd25zY29waW5nID0gY2hlY2tEb3duc2NvcGluZyhzY29wZSwgYXVkaWVuY2UpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXRlc3RSZWZyZXNoVG9rZW4gJiYgIWlzRG93bnNjb3BpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gbGF0ZXN0UmVmcmVzaFRva2VuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvcihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLmJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKSA6IEpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICBpZiAodHlwZW9mIEFib3J0Q29udHJvbGxlciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5zaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgUHJvbWlzZS5yYWNlKFsgd2FpdCh0aW1lb3V0KSwgZmV0Y2goZmV0Y2hVcmwsIE9iamVjdC5hc3NpZ24oe30sIGZldGNoT3B0aW9ucykpIF0pOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6ICJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCciCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXJzID0gZnJvbUVudHJpZXMocmVzcG9uc2UuaGVhZGVycyk7CiAgICAgICAgICAgIGpzb24gPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICAgIGlmIChqc29uLnJlZnJlc2hfdG9rZW4pIHsKICAgICAgICAgICAgICAgIGlmICh1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXSA9IGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWZyZXNoVG9rZW5zKHJlZnJlc2hUb2tlbiwganNvbi5yZWZyZXNoX3Rva2VuKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHNldFJlZnJlc2hUb2tlbihqc29uLnJlZnJlc2hfdG9rZW4sIGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBkZWxldGUganNvbi5yZWZyZXNoX3Rva2VuOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZGVsZXRlUmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogcmVzcG9uc2Uub2ssCiAgICAgICAgICAgICAgICBqc29uOiBqc29uLAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIG9rOiBmYWxzZSwKICAgICAgICAgICAgICAgIGpzb246IHsKICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3IuZXJyb3IsCiAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH07CiAgICB7CiAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsIG1lc3NhZ2VIYW5kbGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
1946
1946
|
const singlePromiseMap = {};
|
|
1947
1947
|
const singlePromise = (cb, key) => {
|
|
1948
1948
|
let promise = singlePromiseMap[key];
|
|
1949
1949
|
if (!promise) {
|
|
1950
|
-
promise = cb().finally((
|
|
1950
|
+
promise = cb().finally(() => {
|
|
1951
1951
|
delete singlePromiseMap[key];
|
|
1952
1952
|
promise = null;
|
|
1953
|
-
})
|
|
1953
|
+
});
|
|
1954
1954
|
singlePromiseMap[key] = promise;
|
|
1955
1955
|
}
|
|
1956
1956
|
return promise;
|
|
@@ -2027,12 +2027,12 @@
|
|
|
2027
2027
|
const allScopesAreIncluded = (scopeToInclude, scopes) => {
|
|
2028
2028
|
const scopeGroup = (scopes === null || scopes === void 0 ? void 0 : scopes.split(" ")) || [];
|
|
2029
2029
|
const scopesToInclude = (scopeToInclude === null || scopeToInclude === void 0 ? void 0 : scopeToInclude.split(" ")) || [];
|
|
2030
|
-
return scopesToInclude.every(
|
|
2030
|
+
return scopesToInclude.every(key => scopeGroup.includes(key));
|
|
2031
2031
|
};
|
|
2032
2032
|
const getMissingScopes = (requestedScope, respondedScope) => {
|
|
2033
2033
|
const requestedScopes = (requestedScope === null || requestedScope === void 0 ? void 0 : requestedScope.split(" ")) || [];
|
|
2034
2034
|
const respondedScopes = (respondedScope === null || respondedScope === void 0 ? void 0 : respondedScope.split(" ")) || [];
|
|
2035
|
-
const missingScopes = requestedScopes.filter(
|
|
2035
|
+
const missingScopes = requestedScopes.filter(scope => respondedScopes.indexOf(scope) == -1);
|
|
2036
2036
|
return missingScopes.join(",");
|
|
2037
2037
|
};
|
|
2038
2038
|
const getScopeToRequest = (useMrrt, authorizationParams, cachedAudience, cachedScope) => {
|
|
@@ -2043,7 +2043,7 @@
|
|
|
2043
2043
|
}
|
|
2044
2044
|
const cachedScopes = cachedScope.split(" ");
|
|
2045
2045
|
const newScopes = ((_a = authorizationParams.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
2046
|
-
const newScopesAreIncluded = newScopes.every(
|
|
2046
|
+
const newScopesAreIncluded = newScopes.every(scope => cachedScopes.includes(scope));
|
|
2047
2047
|
return cachedScopes.length >= newScopes.length && newScopesAreIncluded ? cachedScope : authorizationParams.scope;
|
|
2048
2048
|
}
|
|
2049
2049
|
return authorizationParams.scope;
|
|
@@ -2070,11 +2070,11 @@
|
|
|
2070
2070
|
}
|
|
2071
2071
|
createDbHandle() {
|
|
2072
2072
|
const req = window.indexedDB.open(NAME, this.getVersion());
|
|
2073
|
-
return new Promise((
|
|
2074
|
-
req.onupgradeneeded = () => Object.values(TABLES).forEach(
|
|
2073
|
+
return new Promise((resolve, reject) => {
|
|
2074
|
+
req.onupgradeneeded = () => Object.values(TABLES).forEach(t => req.result.createObjectStore(t));
|
|
2075
2075
|
req.onerror = () => reject(req.error);
|
|
2076
2076
|
req.onsuccess = () => resolve(req.result);
|
|
2077
|
-
})
|
|
2077
|
+
});
|
|
2078
2078
|
}
|
|
2079
2079
|
async getDbHandle() {
|
|
2080
2080
|
if (!this.dbHandle) {
|
|
@@ -2087,10 +2087,10 @@
|
|
|
2087
2087
|
const txn = db.transaction(table, mode);
|
|
2088
2088
|
const store = txn.objectStore(table);
|
|
2089
2089
|
const request = requestFactory(store);
|
|
2090
|
-
return new Promise((
|
|
2090
|
+
return new Promise((resolve, reject) => {
|
|
2091
2091
|
request.onsuccess = () => resolve(request.result);
|
|
2092
2092
|
request.onerror = () => reject(request.error);
|
|
2093
|
-
})
|
|
2093
|
+
});
|
|
2094
2094
|
}
|
|
2095
2095
|
buildKey(id) {
|
|
2096
2096
|
const finalId = id ? "_".concat(id) : AUTH0_NONCE_ID;
|
|
@@ -2103,7 +2103,7 @@
|
|
|
2103
2103
|
return this.save(TABLES.KEYPAIR, this.buildKey(), keyPair);
|
|
2104
2104
|
}
|
|
2105
2105
|
async save(table, key, obj) {
|
|
2106
|
-
return void await this.executeDbRequest(table, "readwrite",
|
|
2106
|
+
return void await this.executeDbRequest(table, "readwrite", table => table.put(obj, key));
|
|
2107
2107
|
}
|
|
2108
2108
|
findNonce(id) {
|
|
2109
2109
|
return this.find(TABLES.NONCE, this.buildKey(id));
|
|
@@ -2112,14 +2112,14 @@
|
|
|
2112
2112
|
return this.find(TABLES.KEYPAIR, this.buildKey());
|
|
2113
2113
|
}
|
|
2114
2114
|
find(table, key) {
|
|
2115
|
-
return this.executeDbRequest(table, "readonly",
|
|
2115
|
+
return this.executeDbRequest(table, "readonly", table => table.get(key));
|
|
2116
2116
|
}
|
|
2117
2117
|
async deleteBy(table, predicate) {
|
|
2118
|
-
const allKeys = await this.executeDbRequest(table, "readonly",
|
|
2119
|
-
allKeys === null || allKeys === void 0 ? void 0 : allKeys.filter(predicate).map(
|
|
2118
|
+
const allKeys = await this.executeDbRequest(table, "readonly", table => table.getAllKeys());
|
|
2119
|
+
allKeys === null || allKeys === void 0 ? void 0 : allKeys.filter(predicate).map(k => this.executeDbRequest(table, "readwrite", table => table.delete(k)));
|
|
2120
2120
|
}
|
|
2121
2121
|
deleteByClientId(table, clientId) {
|
|
2122
|
-
return this.deleteBy(table,
|
|
2122
|
+
return this.deleteBy(table, k => typeof k === "string" && k.startsWith("".concat(clientId, "::")));
|
|
2123
2123
|
}
|
|
2124
2124
|
clearNonces() {
|
|
2125
2125
|
return this.deleteByClientId(TABLES.NONCE, this.clientId);
|
|
@@ -2429,20 +2429,20 @@
|
|
|
2429
2429
|
var t = Object.keys(e);
|
|
2430
2430
|
if (Object.getOwnPropertySymbols) {
|
|
2431
2431
|
var o = Object.getOwnPropertySymbols(e);
|
|
2432
|
-
r && (o = o.filter(
|
|
2432
|
+
r && (o = o.filter(function(r) {
|
|
2433
2433
|
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
2434
|
-
}))
|
|
2434
|
+
})), t.push.apply(t, o);
|
|
2435
2435
|
}
|
|
2436
2436
|
return t;
|
|
2437
2437
|
}
|
|
2438
2438
|
function _objectSpread2(e) {
|
|
2439
2439
|
for (var r = 1; r < arguments.length; r++) {
|
|
2440
2440
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
2441
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(
|
|
2441
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
2442
2442
|
_defineProperty(e, r, t[r]);
|
|
2443
|
-
})
|
|
2443
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
2444
2444
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
2445
|
-
})
|
|
2445
|
+
});
|
|
2446
2446
|
}
|
|
2447
2447
|
return e;
|
|
2448
2448
|
}
|
|
@@ -2488,16 +2488,16 @@
|
|
|
2488
2488
|
function resume(r, t) {
|
|
2489
2489
|
try {
|
|
2490
2490
|
var n = e[r](t), o = n.value, u = o instanceof _OverloadYield;
|
|
2491
|
-
Promise.resolve(u ? o.v : o).then(
|
|
2491
|
+
Promise.resolve(u ? o.v : o).then(function(t) {
|
|
2492
2492
|
if (u) {
|
|
2493
2493
|
var i = "return" === r ? "return" : "next";
|
|
2494
2494
|
if (!o.k || t.done) return resume(i, t);
|
|
2495
2495
|
t = e[i](t).value;
|
|
2496
2496
|
}
|
|
2497
2497
|
settle(n.done ? "return" : "normal", t);
|
|
2498
|
-
}
|
|
2498
|
+
}, function(e) {
|
|
2499
2499
|
resume("throw", e);
|
|
2500
|
-
})
|
|
2500
|
+
});
|
|
2501
2501
|
} catch (e) {
|
|
2502
2502
|
settle("throw", e);
|
|
2503
2503
|
}
|
|
@@ -2524,7 +2524,7 @@
|
|
|
2524
2524
|
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
|
2525
2525
|
}
|
|
2526
2526
|
this._invoke = function(e, n) {
|
|
2527
|
-
return new Promise(
|
|
2527
|
+
return new Promise(function(o, u) {
|
|
2528
2528
|
var i = {
|
|
2529
2529
|
key: e,
|
|
2530
2530
|
arg: n,
|
|
@@ -2533,7 +2533,7 @@
|
|
|
2533
2533
|
next: null
|
|
2534
2534
|
};
|
|
2535
2535
|
t ? t = t.next = i : (r = t = i, resume(e, n));
|
|
2536
|
-
})
|
|
2536
|
+
});
|
|
2537
2537
|
}, "function" != typeof e.return && (this.return = void 0);
|
|
2538
2538
|
}
|
|
2539
2539
|
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
@@ -2549,7 +2549,7 @@
|
|
|
2549
2549
|
let USER_AGENT$2;
|
|
2550
2550
|
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 "))) {
|
|
2551
2551
|
const NAME = "oauth4webapi";
|
|
2552
|
-
const VERSION = "v3.8.
|
|
2552
|
+
const VERSION = "v3.8.5";
|
|
2553
2553
|
USER_AGENT$2 = "".concat(NAME, "/").concat(VERSION);
|
|
2554
2554
|
}
|
|
2555
2555
|
function looseInstanceOf(input, expected) {
|
|
@@ -2748,7 +2748,7 @@
|
|
|
2748
2748
|
});
|
|
2749
2749
|
}
|
|
2750
2750
|
async function discoveryRequest(issuerIdentifier, options) {
|
|
2751
|
-
return performDiscovery$1(issuerIdentifier, "issuerIdentifier",
|
|
2751
|
+
return performDiscovery$1(issuerIdentifier, "issuerIdentifier", url => {
|
|
2752
2752
|
switch (options === null || options === void 0 ? void 0 : options.algorithm) {
|
|
2753
2753
|
case undefined:
|
|
2754
2754
|
case "oidc":
|
|
@@ -2763,7 +2763,7 @@
|
|
|
2763
2763
|
throw CodedTypeError$1('"options.algorithm" must be "oidc" (default), or "oauth2"', ERR_INVALID_ARG_VALUE$1);
|
|
2764
2764
|
}
|
|
2765
2765
|
return url;
|
|
2766
|
-
}
|
|
2766
|
+
}, options);
|
|
2767
2767
|
}
|
|
2768
2768
|
function assertNumber(input, allow0, it, code, cause) {
|
|
2769
2769
|
try {
|
|
@@ -3999,10 +3999,10 @@
|
|
|
3999
3999
|
for (var _len = arguments.length, buffers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4000
4000
|
buffers[_key] = arguments[_key];
|
|
4001
4001
|
}
|
|
4002
|
-
const size = buffers.reduce((
|
|
4002
|
+
const size = buffers.reduce((acc, _ref) => {
|
|
4003
4003
|
let {length: length} = _ref;
|
|
4004
4004
|
return acc + length;
|
|
4005
|
-
}
|
|
4005
|
+
}, 0);
|
|
4006
4006
|
const buf = new Uint8Array(size);
|
|
4007
4007
|
let i = 0;
|
|
4008
4008
|
for (const buffer of buffers) {
|
|
@@ -4050,6 +4050,135 @@
|
|
|
4050
4050
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
4051
4051
|
}
|
|
4052
4052
|
}
|
|
4053
|
+
const unusable = function unusable(name) {
|
|
4054
|
+
let prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "algorithm.name";
|
|
4055
|
+
return new TypeError("CryptoKey does not support this operation, its ".concat(prop, " must be ").concat(name));
|
|
4056
|
+
};
|
|
4057
|
+
const isAlgorithm = (algorithm, name) => algorithm.name === name;
|
|
4058
|
+
function getHashLength(hash) {
|
|
4059
|
+
return parseInt(hash.name.slice(4), 10);
|
|
4060
|
+
}
|
|
4061
|
+
function checkHashLength(algorithm, expected) {
|
|
4062
|
+
const actual = getHashLength(algorithm.hash);
|
|
4063
|
+
if (actual !== expected) throw unusable("SHA-".concat(expected), "algorithm.hash");
|
|
4064
|
+
}
|
|
4065
|
+
function getNamedCurve(alg) {
|
|
4066
|
+
switch (alg) {
|
|
4067
|
+
case "ES256":
|
|
4068
|
+
return "P-256";
|
|
4069
|
+
|
|
4070
|
+
case "ES384":
|
|
4071
|
+
return "P-384";
|
|
4072
|
+
|
|
4073
|
+
case "ES512":
|
|
4074
|
+
return "P-521";
|
|
4075
|
+
|
|
4076
|
+
default:
|
|
4077
|
+
throw new Error("unreachable");
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
function checkUsage(key, usage) {
|
|
4081
|
+
if (usage && !key.usages.includes(usage)) {
|
|
4082
|
+
throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(usage, "."));
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
function checkSigCryptoKey(key, alg, usage) {
|
|
4086
|
+
switch (alg) {
|
|
4087
|
+
case "HS256":
|
|
4088
|
+
case "HS384":
|
|
4089
|
+
case "HS512":
|
|
4090
|
+
{
|
|
4091
|
+
if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
|
|
4092
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
4093
|
+
break;
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
case "RS256":
|
|
4097
|
+
case "RS384":
|
|
4098
|
+
case "RS512":
|
|
4099
|
+
{
|
|
4100
|
+
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
|
|
4101
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
4102
|
+
break;
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
case "PS256":
|
|
4106
|
+
case "PS384":
|
|
4107
|
+
case "PS512":
|
|
4108
|
+
{
|
|
4109
|
+
if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
|
|
4110
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
4111
|
+
break;
|
|
4112
|
+
}
|
|
4113
|
+
|
|
4114
|
+
case "Ed25519":
|
|
4115
|
+
case "EdDSA":
|
|
4116
|
+
{
|
|
4117
|
+
if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
|
|
4118
|
+
break;
|
|
4119
|
+
}
|
|
4120
|
+
|
|
4121
|
+
case "ML-DSA-44":
|
|
4122
|
+
case "ML-DSA-65":
|
|
4123
|
+
case "ML-DSA-87":
|
|
4124
|
+
{
|
|
4125
|
+
if (!isAlgorithm(key.algorithm, alg)) throw unusable(alg);
|
|
4126
|
+
break;
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
case "ES256":
|
|
4130
|
+
case "ES384":
|
|
4131
|
+
case "ES512":
|
|
4132
|
+
{
|
|
4133
|
+
if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
|
|
4134
|
+
const expected = getNamedCurve(alg);
|
|
4135
|
+
const actual = key.algorithm.namedCurve;
|
|
4136
|
+
if (actual !== expected) throw unusable(expected, "algorithm.namedCurve");
|
|
4137
|
+
break;
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
default:
|
|
4141
|
+
throw new TypeError("CryptoKey does not support this operation");
|
|
4142
|
+
}
|
|
4143
|
+
checkUsage(key, usage);
|
|
4144
|
+
}
|
|
4145
|
+
function message(msg, actual) {
|
|
4146
|
+
for (var _len = arguments.length, types = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
4147
|
+
types[_key - 2] = arguments[_key];
|
|
4148
|
+
}
|
|
4149
|
+
types = types.filter(Boolean);
|
|
4150
|
+
if (types.length > 2) {
|
|
4151
|
+
const last = types.pop();
|
|
4152
|
+
msg += "one of type ".concat(types.join(", "), ", or ").concat(last, ".");
|
|
4153
|
+
} else if (types.length === 2) {
|
|
4154
|
+
msg += "one of type ".concat(types[0], " or ").concat(types[1], ".");
|
|
4155
|
+
} else {
|
|
4156
|
+
msg += "of type ".concat(types[0], ".");
|
|
4157
|
+
}
|
|
4158
|
+
if (actual == null) {
|
|
4159
|
+
msg += " Received ".concat(actual);
|
|
4160
|
+
} else if (typeof actual === "function" && actual.name) {
|
|
4161
|
+
msg += " Received function ".concat(actual.name);
|
|
4162
|
+
} else if (typeof actual === "object" && actual != null) {
|
|
4163
|
+
var _actual$constructor;
|
|
4164
|
+
if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
|
|
4165
|
+
msg += " Received an instance of ".concat(actual.constructor.name);
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
return msg;
|
|
4169
|
+
}
|
|
4170
|
+
const invalidKeyInput = function invalidKeyInput(actual) {
|
|
4171
|
+
for (var _len2 = arguments.length, types = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
4172
|
+
types[_key2 - 1] = arguments[_key2];
|
|
4173
|
+
}
|
|
4174
|
+
return message("Key must be ", actual, ...types);
|
|
4175
|
+
};
|
|
4176
|
+
const withAlg = function withAlg(alg, actual) {
|
|
4177
|
+
for (var _len3 = arguments.length, types = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
4178
|
+
types[_key3 - 2] = arguments[_key3];
|
|
4179
|
+
}
|
|
4180
|
+
return message("Key for the ".concat(alg, " algorithm must be "), actual, ...types);
|
|
4181
|
+
};
|
|
4053
4182
|
class JOSEError extends Error {
|
|
4054
4183
|
constructor(message, options) {
|
|
4055
4184
|
var _Error$captureStackTr;
|
|
@@ -4197,147 +4326,37 @@
|
|
|
4197
4326
|
}
|
|
4198
4327
|
}
|
|
4199
4328
|
_defineProperty(JWSSignatureVerificationFailed, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
4200
|
-
const
|
|
4201
|
-
|
|
4202
|
-
|
|
4329
|
+
const isCryptoKey = key => {
|
|
4330
|
+
if ((key === null || key === void 0 ? void 0 : key[Symbol.toStringTag]) === "CryptoKey") return true;
|
|
4331
|
+
try {
|
|
4332
|
+
return key instanceof CryptoKey;
|
|
4333
|
+
} catch (_unused) {
|
|
4334
|
+
return false;
|
|
4335
|
+
}
|
|
4203
4336
|
};
|
|
4204
|
-
const
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
return "P-256";
|
|
4212
|
-
|
|
4213
|
-
case "ES384":
|
|
4214
|
-
return "P-384";
|
|
4215
|
-
|
|
4216
|
-
case "ES512":
|
|
4217
|
-
return "P-521";
|
|
4218
|
-
|
|
4219
|
-
default:
|
|
4220
|
-
throw new Error("unreachable");
|
|
4337
|
+
const isKeyObject = key => (key === null || key === void 0 ? void 0 : key[Symbol.toStringTag]) === "KeyObject";
|
|
4338
|
+
const isKeyLike = key => isCryptoKey(key) || isKeyObject(key);
|
|
4339
|
+
function decodeBase64url(value, label, ErrorClass) {
|
|
4340
|
+
try {
|
|
4341
|
+
return decode(value);
|
|
4342
|
+
} catch (_unused) {
|
|
4343
|
+
throw new ErrorClass("Failed to base64url decode the ".concat(label));
|
|
4221
4344
|
}
|
|
4222
4345
|
}
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4346
|
+
const isObjectLike = value => typeof value === "object" && value !== null;
|
|
4347
|
+
function isObject(input) {
|
|
4348
|
+
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
4349
|
+
return false;
|
|
4226
4350
|
}
|
|
4351
|
+
if (Object.getPrototypeOf(input) === null) {
|
|
4352
|
+
return true;
|
|
4353
|
+
}
|
|
4354
|
+
let proto = input;
|
|
4355
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
4356
|
+
proto = Object.getPrototypeOf(proto);
|
|
4357
|
+
}
|
|
4358
|
+
return Object.getPrototypeOf(input) === proto;
|
|
4227
4359
|
}
|
|
4228
|
-
function checkSigCryptoKey(key, alg, usage) {
|
|
4229
|
-
switch (alg) {
|
|
4230
|
-
case "HS256":
|
|
4231
|
-
case "HS384":
|
|
4232
|
-
case "HS512":
|
|
4233
|
-
{
|
|
4234
|
-
if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
|
|
4235
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
4236
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
4237
|
-
if (actual !== expected) throw unusable("SHA-".concat(expected), "algorithm.hash");
|
|
4238
|
-
break;
|
|
4239
|
-
}
|
|
4240
|
-
|
|
4241
|
-
case "RS256":
|
|
4242
|
-
case "RS384":
|
|
4243
|
-
case "RS512":
|
|
4244
|
-
{
|
|
4245
|
-
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
|
|
4246
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
4247
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
4248
|
-
if (actual !== expected) throw unusable("SHA-".concat(expected), "algorithm.hash");
|
|
4249
|
-
break;
|
|
4250
|
-
}
|
|
4251
|
-
|
|
4252
|
-
case "PS256":
|
|
4253
|
-
case "PS384":
|
|
4254
|
-
case "PS512":
|
|
4255
|
-
{
|
|
4256
|
-
if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
|
|
4257
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
4258
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
4259
|
-
if (actual !== expected) throw unusable("SHA-".concat(expected), "algorithm.hash");
|
|
4260
|
-
break;
|
|
4261
|
-
}
|
|
4262
|
-
|
|
4263
|
-
case "Ed25519":
|
|
4264
|
-
case "EdDSA":
|
|
4265
|
-
{
|
|
4266
|
-
if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
|
|
4267
|
-
break;
|
|
4268
|
-
}
|
|
4269
|
-
|
|
4270
|
-
case "ML-DSA-44":
|
|
4271
|
-
case "ML-DSA-65":
|
|
4272
|
-
case "ML-DSA-87":
|
|
4273
|
-
{
|
|
4274
|
-
if (!isAlgorithm(key.algorithm, alg)) throw unusable(alg);
|
|
4275
|
-
break;
|
|
4276
|
-
}
|
|
4277
|
-
|
|
4278
|
-
case "ES256":
|
|
4279
|
-
case "ES384":
|
|
4280
|
-
case "ES512":
|
|
4281
|
-
{
|
|
4282
|
-
if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
|
|
4283
|
-
const expected = getNamedCurve(alg);
|
|
4284
|
-
const actual = key.algorithm.namedCurve;
|
|
4285
|
-
if (actual !== expected) throw unusable(expected, "algorithm.namedCurve");
|
|
4286
|
-
break;
|
|
4287
|
-
}
|
|
4288
|
-
|
|
4289
|
-
default:
|
|
4290
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
4291
|
-
}
|
|
4292
|
-
checkUsage(key, usage);
|
|
4293
|
-
}
|
|
4294
|
-
function message(msg, actual) {
|
|
4295
|
-
for (var _len = arguments.length, types = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
4296
|
-
types[_key - 2] = arguments[_key];
|
|
4297
|
-
}
|
|
4298
|
-
types = types.filter(Boolean);
|
|
4299
|
-
if (types.length > 2) {
|
|
4300
|
-
const last = types.pop();
|
|
4301
|
-
msg += "one of type ".concat(types.join(", "), ", or ").concat(last, ".");
|
|
4302
|
-
} else if (types.length === 2) {
|
|
4303
|
-
msg += "one of type ".concat(types[0], " or ").concat(types[1], ".");
|
|
4304
|
-
} else {
|
|
4305
|
-
msg += "of type ".concat(types[0], ".");
|
|
4306
|
-
}
|
|
4307
|
-
if (actual == null) {
|
|
4308
|
-
msg += " Received ".concat(actual);
|
|
4309
|
-
} else if (typeof actual === "function" && actual.name) {
|
|
4310
|
-
msg += " Received function ".concat(actual.name);
|
|
4311
|
-
} else if (typeof actual === "object" && actual != null) {
|
|
4312
|
-
var _actual$constructor;
|
|
4313
|
-
if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
|
|
4314
|
-
msg += " Received an instance of ".concat(actual.constructor.name);
|
|
4315
|
-
}
|
|
4316
|
-
}
|
|
4317
|
-
return msg;
|
|
4318
|
-
}
|
|
4319
|
-
const invalidKeyInput = function invalidKeyInput(actual) {
|
|
4320
|
-
for (var _len2 = arguments.length, types = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
4321
|
-
types[_key2 - 1] = arguments[_key2];
|
|
4322
|
-
}
|
|
4323
|
-
return message("Key must be ", actual, ...types);
|
|
4324
|
-
};
|
|
4325
|
-
const withAlg = function withAlg(alg, actual) {
|
|
4326
|
-
for (var _len3 = arguments.length, types = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
4327
|
-
types[_key3 - 2] = arguments[_key3];
|
|
4328
|
-
}
|
|
4329
|
-
return message("Key for the ".concat(alg, " algorithm must be "), actual, ...types);
|
|
4330
|
-
};
|
|
4331
|
-
const isCryptoKey = key => {
|
|
4332
|
-
if ((key === null || key === void 0 ? void 0 : key[Symbol.toStringTag]) === "CryptoKey") return true;
|
|
4333
|
-
try {
|
|
4334
|
-
return key instanceof CryptoKey;
|
|
4335
|
-
} catch (_unused) {
|
|
4336
|
-
return false;
|
|
4337
|
-
}
|
|
4338
|
-
};
|
|
4339
|
-
const isKeyObject = key => (key === null || key === void 0 ? void 0 : key[Symbol.toStringTag]) === "KeyObject";
|
|
4340
|
-
const isKeyLike = key => isCryptoKey(key) || isKeyObject(key);
|
|
4341
4360
|
function isDisjoint() {
|
|
4342
4361
|
for (var _len = arguments.length, headers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4343
4362
|
headers[_key] = arguments[_key];
|
|
@@ -4362,20 +4381,10 @@
|
|
|
4362
4381
|
}
|
|
4363
4382
|
return true;
|
|
4364
4383
|
}
|
|
4365
|
-
const
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
}
|
|
4370
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
4371
|
-
return true;
|
|
4372
|
-
}
|
|
4373
|
-
let proto = input;
|
|
4374
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
4375
|
-
proto = Object.getPrototypeOf(proto);
|
|
4376
|
-
}
|
|
4377
|
-
return Object.getPrototypeOf(input) === proto;
|
|
4378
|
-
}
|
|
4384
|
+
const isJWK = key => isObject(key) && typeof key.kty === "string";
|
|
4385
|
+
const isPrivateJWK = key => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
4386
|
+
const isPublicJWK = key => key.kty !== "oct" && key.d === undefined && key.priv === undefined;
|
|
4387
|
+
const isSecretJWK = key => key.kty === "oct" && typeof key.k === "string";
|
|
4379
4388
|
function checkKeyLength(alg, key) {
|
|
4380
4389
|
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
4381
4390
|
const {modulusLength: modulusLength} = key.algorithm;
|
|
@@ -4384,198 +4393,84 @@
|
|
|
4384
4393
|
}
|
|
4385
4394
|
}
|
|
4386
4395
|
}
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
for (let i = 0; i < a.byteLength; i++) {
|
|
4390
|
-
if (a[i] !== b[i]) return false;
|
|
4391
|
-
}
|
|
4392
|
-
return true;
|
|
4393
|
-
};
|
|
4394
|
-
const createASN1State = data => ({
|
|
4395
|
-
data: data,
|
|
4396
|
-
pos: 0
|
|
4397
|
-
});
|
|
4398
|
-
const parseLength = state => {
|
|
4399
|
-
const first = state.data[state.pos++];
|
|
4400
|
-
if (first & 128) {
|
|
4401
|
-
const lengthOfLen = first & 127;
|
|
4402
|
-
let length = 0;
|
|
4403
|
-
for (let i = 0; i < lengthOfLen; i++) {
|
|
4404
|
-
length = length << 8 | state.data[state.pos++];
|
|
4405
|
-
}
|
|
4406
|
-
return length;
|
|
4407
|
-
}
|
|
4408
|
-
return first;
|
|
4409
|
-
};
|
|
4410
|
-
const expectTag = (state, expectedTag, errorMessage) => {
|
|
4411
|
-
if (state.data[state.pos++] !== expectedTag) {
|
|
4412
|
-
throw new Error(errorMessage);
|
|
4413
|
-
}
|
|
4414
|
-
};
|
|
4415
|
-
const getSubarray = (state, length) => {
|
|
4416
|
-
const result = state.data.subarray(state.pos, state.pos + length);
|
|
4417
|
-
state.pos += length;
|
|
4418
|
-
return result;
|
|
4419
|
-
};
|
|
4420
|
-
const parseAlgorithmOID = state => {
|
|
4421
|
-
expectTag(state, 6, "Expected algorithm OID");
|
|
4422
|
-
const oidLen = parseLength(state);
|
|
4423
|
-
return getSubarray(state, oidLen);
|
|
4424
|
-
};
|
|
4425
|
-
function parsePKCS8Header(state) {
|
|
4426
|
-
expectTag(state, 48, "Invalid PKCS#8 structure");
|
|
4427
|
-
parseLength(state);
|
|
4428
|
-
expectTag(state, 2, "Expected version field");
|
|
4429
|
-
const verLen = parseLength(state);
|
|
4430
|
-
state.pos += verLen;
|
|
4431
|
-
expectTag(state, 48, "Expected algorithm identifier");
|
|
4432
|
-
const algIdLen = parseLength(state);
|
|
4433
|
-
const algIdStart = state.pos;
|
|
4434
|
-
return {
|
|
4435
|
-
algIdStart: algIdStart,
|
|
4436
|
-
algIdLength: algIdLen
|
|
4437
|
-
};
|
|
4438
|
-
}
|
|
4439
|
-
const parseECAlgorithmIdentifier = state => {
|
|
4440
|
-
const algOid = parseAlgorithmOID(state);
|
|
4441
|
-
if (bytesEqual(algOid, [ 43, 101, 110 ])) {
|
|
4442
|
-
return "X25519";
|
|
4443
|
-
}
|
|
4444
|
-
if (!bytesEqual(algOid, [ 42, 134, 72, 206, 61, 2, 1 ])) {
|
|
4445
|
-
throw new Error("Unsupported key algorithm");
|
|
4446
|
-
}
|
|
4447
|
-
expectTag(state, 6, "Expected curve OID");
|
|
4448
|
-
const curveOidLen = parseLength(state);
|
|
4449
|
-
const curveOid = getSubarray(state, curveOidLen);
|
|
4450
|
-
for (const {name: name, oid: oid} of [ {
|
|
4451
|
-
name: "P-256",
|
|
4452
|
-
oid: [ 42, 134, 72, 206, 61, 3, 1, 7 ]
|
|
4453
|
-
}, {
|
|
4454
|
-
name: "P-384",
|
|
4455
|
-
oid: [ 43, 129, 4, 0, 34 ]
|
|
4456
|
-
}, {
|
|
4457
|
-
name: "P-521",
|
|
4458
|
-
oid: [ 43, 129, 4, 0, 35 ]
|
|
4459
|
-
} ]) {
|
|
4460
|
-
if (bytesEqual(curveOid, oid)) {
|
|
4461
|
-
return name;
|
|
4462
|
-
}
|
|
4463
|
-
}
|
|
4464
|
-
throw new Error("Unsupported named curve");
|
|
4465
|
-
};
|
|
4466
|
-
const genericImport = async (keyFormat, keyData, alg, options) => {
|
|
4467
|
-
var _options$extractable;
|
|
4468
|
-
let algorithm;
|
|
4469
|
-
let keyUsages;
|
|
4470
|
-
const isPublic = keyFormat === "spki";
|
|
4471
|
-
const getSigUsages = () => isPublic ? [ "verify" ] : [ "sign" ];
|
|
4472
|
-
const getEncUsages = () => isPublic ? [ "encrypt", "wrapKey" ] : [ "decrypt", "unwrapKey" ];
|
|
4396
|
+
function subtleAlgorithm(alg, algorithm) {
|
|
4397
|
+
const hash = "SHA-".concat(alg.slice(-3));
|
|
4473
4398
|
switch (alg) {
|
|
4399
|
+
case "HS256":
|
|
4400
|
+
case "HS384":
|
|
4401
|
+
case "HS512":
|
|
4402
|
+
return {
|
|
4403
|
+
hash: hash,
|
|
4404
|
+
name: "HMAC"
|
|
4405
|
+
};
|
|
4406
|
+
|
|
4474
4407
|
case "PS256":
|
|
4475
4408
|
case "PS384":
|
|
4476
4409
|
case "PS512":
|
|
4477
|
-
|
|
4410
|
+
return {
|
|
4411
|
+
hash: hash,
|
|
4478
4412
|
name: "RSA-PSS",
|
|
4479
|
-
|
|
4413
|
+
saltLength: parseInt(alg.slice(-3), 10) >> 3
|
|
4480
4414
|
};
|
|
4481
|
-
keyUsages = getSigUsages();
|
|
4482
|
-
break;
|
|
4483
4415
|
|
|
4484
4416
|
case "RS256":
|
|
4485
4417
|
case "RS384":
|
|
4486
4418
|
case "RS512":
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
};
|
|
4491
|
-
keyUsages = getSigUsages();
|
|
4492
|
-
break;
|
|
4493
|
-
|
|
4494
|
-
case "RSA-OAEP":
|
|
4495
|
-
case "RSA-OAEP-256":
|
|
4496
|
-
case "RSA-OAEP-384":
|
|
4497
|
-
case "RSA-OAEP-512":
|
|
4498
|
-
algorithm = {
|
|
4499
|
-
name: "RSA-OAEP",
|
|
4500
|
-
hash: "SHA-".concat(parseInt(alg.slice(-3), 10) || 1)
|
|
4419
|
+
return {
|
|
4420
|
+
hash: hash,
|
|
4421
|
+
name: "RSASSA-PKCS1-v1_5"
|
|
4501
4422
|
};
|
|
4502
|
-
keyUsages = getEncUsages();
|
|
4503
|
-
break;
|
|
4504
4423
|
|
|
4505
4424
|
case "ES256":
|
|
4506
4425
|
case "ES384":
|
|
4507
4426
|
case "ES512":
|
|
4508
|
-
{
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
};
|
|
4514
|
-
algorithm = {
|
|
4515
|
-
name: "ECDSA",
|
|
4516
|
-
namedCurve: curveMap[alg]
|
|
4517
|
-
};
|
|
4518
|
-
keyUsages = getSigUsages();
|
|
4519
|
-
break;
|
|
4520
|
-
}
|
|
4521
|
-
|
|
4522
|
-
case "ECDH-ES":
|
|
4523
|
-
case "ECDH-ES+A128KW":
|
|
4524
|
-
case "ECDH-ES+A192KW":
|
|
4525
|
-
case "ECDH-ES+A256KW":
|
|
4526
|
-
{
|
|
4527
|
-
try {
|
|
4528
|
-
const namedCurve = options.getNamedCurve(keyData);
|
|
4529
|
-
algorithm = namedCurve === "X25519" ? {
|
|
4530
|
-
name: "X25519"
|
|
4531
|
-
} : {
|
|
4532
|
-
name: "ECDH",
|
|
4533
|
-
namedCurve: namedCurve
|
|
4534
|
-
};
|
|
4535
|
-
} catch (cause) {
|
|
4536
|
-
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
4537
|
-
}
|
|
4538
|
-
keyUsages = isPublic ? [] : [ "deriveBits" ];
|
|
4539
|
-
break;
|
|
4540
|
-
}
|
|
4427
|
+
return {
|
|
4428
|
+
hash: hash,
|
|
4429
|
+
name: "ECDSA",
|
|
4430
|
+
namedCurve: algorithm.namedCurve
|
|
4431
|
+
};
|
|
4541
4432
|
|
|
4542
4433
|
case "Ed25519":
|
|
4543
4434
|
case "EdDSA":
|
|
4544
|
-
|
|
4435
|
+
return {
|
|
4545
4436
|
name: "Ed25519"
|
|
4546
4437
|
};
|
|
4547
|
-
keyUsages = getSigUsages();
|
|
4548
|
-
break;
|
|
4549
4438
|
|
|
4550
4439
|
case "ML-DSA-44":
|
|
4551
4440
|
case "ML-DSA-65":
|
|
4552
4441
|
case "ML-DSA-87":
|
|
4553
|
-
|
|
4442
|
+
return {
|
|
4554
4443
|
name: alg
|
|
4555
4444
|
};
|
|
4556
|
-
keyUsages = getSigUsages();
|
|
4557
|
-
break;
|
|
4558
4445
|
|
|
4559
4446
|
default:
|
|
4560
|
-
throw new JOSENotSupported(
|
|
4447
|
+
throw new JOSENotSupported("alg ".concat(alg, " is not supported either by JOSE or your javascript runtime"));
|
|
4561
4448
|
}
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
const state = createASN1State(keyData);
|
|
4573
|
-
parsePKCS8Header(state);
|
|
4574
|
-
return parseECAlgorithmIdentifier(state);
|
|
4575
|
-
};
|
|
4449
|
+
}
|
|
4450
|
+
async function getSigKey(alg, key, usage) {
|
|
4451
|
+
if (key instanceof Uint8Array) {
|
|
4452
|
+
if (!alg.startsWith("HS")) {
|
|
4453
|
+
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
4454
|
+
}
|
|
4455
|
+
return crypto.subtle.importKey("raw", key, {
|
|
4456
|
+
hash: "SHA-".concat(alg.slice(-3)),
|
|
4457
|
+
name: "HMAC"
|
|
4458
|
+
}, false, [ usage ]);
|
|
4576
4459
|
}
|
|
4577
|
-
|
|
4578
|
-
|
|
4460
|
+
checkSigCryptoKey(key, alg, usage);
|
|
4461
|
+
return key;
|
|
4462
|
+
}
|
|
4463
|
+
async function verify(alg, key, signature, data) {
|
|
4464
|
+
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
4465
|
+
checkKeyLength(alg, cryptoKey);
|
|
4466
|
+
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
4467
|
+
try {
|
|
4468
|
+
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
|
|
4469
|
+
} catch (_unused) {
|
|
4470
|
+
return false;
|
|
4471
|
+
}
|
|
4472
|
+
}
|
|
4473
|
+
const unsupportedAlg = 'Invalid or unsupported JWK "alg" (Algorithm) Parameter value';
|
|
4579
4474
|
function subtleMapping(jwk) {
|
|
4580
4475
|
let algorithm;
|
|
4581
4476
|
let keyUsages;
|
|
@@ -4593,7 +4488,7 @@
|
|
|
4593
4488
|
break;
|
|
4594
4489
|
|
|
4595
4490
|
default:
|
|
4596
|
-
throw new JOSENotSupported(
|
|
4491
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
4597
4492
|
}
|
|
4598
4493
|
break;
|
|
4599
4494
|
}
|
|
@@ -4633,7 +4528,7 @@
|
|
|
4633
4528
|
break;
|
|
4634
4529
|
|
|
4635
4530
|
default:
|
|
4636
|
-
throw new JOSENotSupported(
|
|
4531
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
4637
4532
|
}
|
|
4638
4533
|
break;
|
|
4639
4534
|
}
|
|
@@ -4642,25 +4537,15 @@
|
|
|
4642
4537
|
{
|
|
4643
4538
|
switch (jwk.alg) {
|
|
4644
4539
|
case "ES256":
|
|
4645
|
-
algorithm = {
|
|
4646
|
-
name: "ECDSA",
|
|
4647
|
-
namedCurve: "P-256"
|
|
4648
|
-
};
|
|
4649
|
-
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
4650
|
-
break;
|
|
4651
|
-
|
|
4652
4540
|
case "ES384":
|
|
4653
|
-
algorithm = {
|
|
4654
|
-
name: "ECDSA",
|
|
4655
|
-
namedCurve: "P-384"
|
|
4656
|
-
};
|
|
4657
|
-
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
4658
|
-
break;
|
|
4659
|
-
|
|
4660
4541
|
case "ES512":
|
|
4661
4542
|
algorithm = {
|
|
4662
4543
|
name: "ECDSA",
|
|
4663
|
-
namedCurve:
|
|
4544
|
+
namedCurve: {
|
|
4545
|
+
ES256: "P-256",
|
|
4546
|
+
ES384: "P-384",
|
|
4547
|
+
ES512: "P-521"
|
|
4548
|
+
}[jwk.alg]
|
|
4664
4549
|
};
|
|
4665
4550
|
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
4666
4551
|
break;
|
|
@@ -4677,7 +4562,7 @@
|
|
|
4677
4562
|
break;
|
|
4678
4563
|
|
|
4679
4564
|
default:
|
|
4680
|
-
throw new JOSENotSupported(
|
|
4565
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
4681
4566
|
}
|
|
4682
4567
|
break;
|
|
4683
4568
|
}
|
|
@@ -4704,7 +4589,7 @@
|
|
|
4704
4589
|
break;
|
|
4705
4590
|
|
|
4706
4591
|
default:
|
|
4707
|
-
throw new JOSENotSupported(
|
|
4592
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
4708
4593
|
}
|
|
4709
4594
|
break;
|
|
4710
4595
|
}
|
|
@@ -4730,102 +4615,7 @@
|
|
|
4730
4615
|
delete keyData.use;
|
|
4731
4616
|
return crypto.subtle.importKey("jwk", keyData, algorithm, (_jwk$ext = jwk.ext) !== null && _jwk$ext !== void 0 ? _jwk$ext : jwk.d || jwk.priv ? false : true, (_jwk$key_ops = jwk.key_ops) !== null && _jwk$key_ops !== void 0 ? _jwk$key_ops : keyUsages);
|
|
4732
4617
|
}
|
|
4733
|
-
|
|
4734
|
-
if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
|
|
4735
|
-
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
4736
|
-
}
|
|
4737
|
-
return fromPKCS8(pkcs8, alg, options);
|
|
4738
|
-
}
|
|
4739
|
-
async function importJWK(jwk, alg, options) {
|
|
4740
|
-
var _options$extractable;
|
|
4741
|
-
if (!isObject(jwk)) {
|
|
4742
|
-
throw new TypeError("JWK must be an object");
|
|
4743
|
-
}
|
|
4744
|
-
let ext;
|
|
4745
|
-
alg !== null && alg !== void 0 ? alg : alg = jwk.alg;
|
|
4746
|
-
ext !== null && ext !== void 0 ? ext : ext = (_options$extractable = options === null || options === void 0 ? void 0 : options.extractable) !== null && _options$extractable !== void 0 ? _options$extractable : jwk.ext;
|
|
4747
|
-
switch (jwk.kty) {
|
|
4748
|
-
case "oct":
|
|
4749
|
-
if (typeof jwk.k !== "string" || !jwk.k) {
|
|
4750
|
-
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
4751
|
-
}
|
|
4752
|
-
return decode(jwk.k);
|
|
4753
|
-
|
|
4754
|
-
case "RSA":
|
|
4755
|
-
if ("oth" in jwk && jwk.oth !== undefined) {
|
|
4756
|
-
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
4757
|
-
}
|
|
4758
|
-
return jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
4759
|
-
alg: alg,
|
|
4760
|
-
ext: ext
|
|
4761
|
-
}));
|
|
4762
|
-
|
|
4763
|
-
case "AKP":
|
|
4764
|
-
{
|
|
4765
|
-
if (typeof jwk.alg !== "string" || !jwk.alg) {
|
|
4766
|
-
throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
4767
|
-
}
|
|
4768
|
-
if (alg !== undefined && alg !== jwk.alg) {
|
|
4769
|
-
throw new TypeError("JWK alg and alg option value mismatch");
|
|
4770
|
-
}
|
|
4771
|
-
return jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
4772
|
-
ext: ext
|
|
4773
|
-
}));
|
|
4774
|
-
}
|
|
4775
|
-
|
|
4776
|
-
case "EC":
|
|
4777
|
-
case "OKP":
|
|
4778
|
-
return jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
4779
|
-
alg: alg,
|
|
4780
|
-
ext: ext
|
|
4781
|
-
}));
|
|
4782
|
-
|
|
4783
|
-
default:
|
|
4784
|
-
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
4785
|
-
}
|
|
4786
|
-
}
|
|
4787
|
-
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
4788
|
-
if (joseHeader.crit !== undefined && (protectedHeader === null || protectedHeader === void 0 ? void 0 : protectedHeader.crit) === undefined) {
|
|
4789
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
4790
|
-
}
|
|
4791
|
-
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
4792
|
-
return new Set;
|
|
4793
|
-
}
|
|
4794
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input => typeof input !== "string" || input.length === 0))) {
|
|
4795
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
4796
|
-
}
|
|
4797
|
-
let recognized;
|
|
4798
|
-
if (recognizedOption !== undefined) {
|
|
4799
|
-
recognized = new Map([ ...Object.entries(recognizedOption), ...recognizedDefault.entries() ]);
|
|
4800
|
-
} else {
|
|
4801
|
-
recognized = recognizedDefault;
|
|
4802
|
-
}
|
|
4803
|
-
for (const parameter of protectedHeader.crit) {
|
|
4804
|
-
if (!recognized.has(parameter)) {
|
|
4805
|
-
throw new JOSENotSupported('Extension Header Parameter "'.concat(parameter, '" is not recognized'));
|
|
4806
|
-
}
|
|
4807
|
-
if (joseHeader[parameter] === undefined) {
|
|
4808
|
-
throw new Err('Extension Header Parameter "'.concat(parameter, '" is missing'));
|
|
4809
|
-
}
|
|
4810
|
-
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
4811
|
-
throw new Err('Extension Header Parameter "'.concat(parameter, '" MUST be integrity protected'));
|
|
4812
|
-
}
|
|
4813
|
-
}
|
|
4814
|
-
return new Set(protectedHeader.crit);
|
|
4815
|
-
}
|
|
4816
|
-
function validateAlgorithms(option, algorithms) {
|
|
4817
|
-
if (algorithms !== undefined && (!Array.isArray(algorithms) || algorithms.some((s => typeof s !== "string")))) {
|
|
4818
|
-
throw new TypeError('"'.concat(option, '" option must be an array of strings'));
|
|
4819
|
-
}
|
|
4820
|
-
if (!algorithms) {
|
|
4821
|
-
return undefined;
|
|
4822
|
-
}
|
|
4823
|
-
return new Set(algorithms);
|
|
4824
|
-
}
|
|
4825
|
-
const isJWK = key => isObject(key) && typeof key.kty === "string";
|
|
4826
|
-
const isPrivateJWK = key => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
4827
|
-
const isPublicJWK = key => key.kty !== "oct" && key.d === undefined && key.priv === undefined;
|
|
4828
|
-
const isSecretJWK = key => key.kty === "oct" && typeof key.k === "string";
|
|
4618
|
+
const unusableForAlg = "given KeyObject instance cannot be used for this algorithm";
|
|
4829
4619
|
let cache;
|
|
4830
4620
|
const handleJWK = async function handleJWK(key, jwk, alg) {
|
|
4831
4621
|
let freeze = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
@@ -4865,13 +4655,13 @@
|
|
|
4865
4655
|
break;
|
|
4866
4656
|
|
|
4867
4657
|
default:
|
|
4868
|
-
throw new TypeError(
|
|
4658
|
+
throw new TypeError(unusableForAlg);
|
|
4869
4659
|
}
|
|
4870
4660
|
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : [ "deriveBits" ]);
|
|
4871
4661
|
}
|
|
4872
4662
|
if (keyObject.asymmetricKeyType === "ed25519") {
|
|
4873
4663
|
if (alg !== "EdDSA" && alg !== "Ed25519") {
|
|
4874
|
-
throw new TypeError(
|
|
4664
|
+
throw new TypeError(unusableForAlg);
|
|
4875
4665
|
}
|
|
4876
4666
|
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
4877
4667
|
}
|
|
@@ -4881,7 +4671,7 @@
|
|
|
4881
4671
|
case "ml-dsa-87":
|
|
4882
4672
|
{
|
|
4883
4673
|
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
|
|
4884
|
-
throw new TypeError(
|
|
4674
|
+
throw new TypeError(unusableForAlg);
|
|
4885
4675
|
}
|
|
4886
4676
|
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
4887
4677
|
}
|
|
@@ -4912,7 +4702,7 @@
|
|
|
4912
4702
|
break;
|
|
4913
4703
|
|
|
4914
4704
|
default:
|
|
4915
|
-
throw new TypeError(
|
|
4705
|
+
throw new TypeError(unusableForAlg);
|
|
4916
4706
|
}
|
|
4917
4707
|
if (alg.startsWith("RSA-OAEP")) {
|
|
4918
4708
|
return keyObject.toCryptoKey({
|
|
@@ -4930,21 +4720,14 @@
|
|
|
4930
4720
|
const nist = new Map([ [ "prime256v1", "P-256" ], [ "secp384r1", "P-384" ], [ "secp521r1", "P-521" ] ]);
|
|
4931
4721
|
const namedCurve = nist.get((_keyObject$asymmetric = keyObject.asymmetricKeyDetails) === null || _keyObject$asymmetric === void 0 ? void 0 : _keyObject$asymmetric.namedCurve);
|
|
4932
4722
|
if (!namedCurve) {
|
|
4933
|
-
throw new TypeError(
|
|
4934
|
-
}
|
|
4935
|
-
if (alg === "ES256" && namedCurve === "P-256") {
|
|
4936
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
4937
|
-
name: "ECDSA",
|
|
4938
|
-
namedCurve: namedCurve
|
|
4939
|
-
}, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
4723
|
+
throw new TypeError(unusableForAlg);
|
|
4940
4724
|
}
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
if (alg === "ES512" && namedCurve === "P-521") {
|
|
4725
|
+
const expectedCurve = {
|
|
4726
|
+
ES256: "P-256",
|
|
4727
|
+
ES384: "P-384",
|
|
4728
|
+
ES512: "P-521"
|
|
4729
|
+
};
|
|
4730
|
+
if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {
|
|
4948
4731
|
cryptoKey = keyObject.toCryptoKey({
|
|
4949
4732
|
name: "ECDSA",
|
|
4950
4733
|
namedCurve: namedCurve
|
|
@@ -4957,50 +4740,334 @@
|
|
|
4957
4740
|
}, extractable, isPublic ? [] : [ "deriveBits" ]);
|
|
4958
4741
|
}
|
|
4959
4742
|
}
|
|
4960
|
-
if (!cryptoKey) {
|
|
4961
|
-
throw new TypeError(
|
|
4743
|
+
if (!cryptoKey) {
|
|
4744
|
+
throw new TypeError(unusableForAlg);
|
|
4745
|
+
}
|
|
4746
|
+
if (!cached) {
|
|
4747
|
+
cache.set(keyObject, {
|
|
4748
|
+
[alg]: cryptoKey
|
|
4749
|
+
});
|
|
4750
|
+
} else {
|
|
4751
|
+
cached[alg] = cryptoKey;
|
|
4752
|
+
}
|
|
4753
|
+
return cryptoKey;
|
|
4754
|
+
};
|
|
4755
|
+
async function normalizeKey(key, alg) {
|
|
4756
|
+
if (key instanceof Uint8Array) {
|
|
4757
|
+
return key;
|
|
4758
|
+
}
|
|
4759
|
+
if (isCryptoKey(key)) {
|
|
4760
|
+
return key;
|
|
4761
|
+
}
|
|
4762
|
+
if (isKeyObject(key)) {
|
|
4763
|
+
if (key.type === "secret") {
|
|
4764
|
+
return key.export();
|
|
4765
|
+
}
|
|
4766
|
+
if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") {
|
|
4767
|
+
try {
|
|
4768
|
+
return handleKeyObject(key, alg);
|
|
4769
|
+
} catch (err) {
|
|
4770
|
+
if (err instanceof TypeError) {
|
|
4771
|
+
throw err;
|
|
4772
|
+
}
|
|
4773
|
+
}
|
|
4774
|
+
}
|
|
4775
|
+
let jwk = key.export({
|
|
4776
|
+
format: "jwk"
|
|
4777
|
+
});
|
|
4778
|
+
return handleJWK(key, jwk, alg);
|
|
4779
|
+
}
|
|
4780
|
+
if (isJWK(key)) {
|
|
4781
|
+
if (key.k) {
|
|
4782
|
+
return decode(key.k);
|
|
4783
|
+
}
|
|
4784
|
+
return handleJWK(key, key, alg, true);
|
|
4785
|
+
}
|
|
4786
|
+
throw new Error("unreachable");
|
|
4787
|
+
}
|
|
4788
|
+
const bytesEqual = (a, b) => {
|
|
4789
|
+
if (a.byteLength !== b.length) return false;
|
|
4790
|
+
for (let i = 0; i < a.byteLength; i++) {
|
|
4791
|
+
if (a[i] !== b[i]) return false;
|
|
4792
|
+
}
|
|
4793
|
+
return true;
|
|
4794
|
+
};
|
|
4795
|
+
const createASN1State = data => ({
|
|
4796
|
+
data: data,
|
|
4797
|
+
pos: 0
|
|
4798
|
+
});
|
|
4799
|
+
const parseLength = state => {
|
|
4800
|
+
const first = state.data[state.pos++];
|
|
4801
|
+
if (first & 128) {
|
|
4802
|
+
const lengthOfLen = first & 127;
|
|
4803
|
+
let length = 0;
|
|
4804
|
+
for (let i = 0; i < lengthOfLen; i++) {
|
|
4805
|
+
length = length << 8 | state.data[state.pos++];
|
|
4806
|
+
}
|
|
4807
|
+
return length;
|
|
4808
|
+
}
|
|
4809
|
+
return first;
|
|
4810
|
+
};
|
|
4811
|
+
const expectTag = (state, expectedTag, errorMessage) => {
|
|
4812
|
+
if (state.data[state.pos++] !== expectedTag) {
|
|
4813
|
+
throw new Error(errorMessage);
|
|
4814
|
+
}
|
|
4815
|
+
};
|
|
4816
|
+
const getSubarray = (state, length) => {
|
|
4817
|
+
const result = state.data.subarray(state.pos, state.pos + length);
|
|
4818
|
+
state.pos += length;
|
|
4819
|
+
return result;
|
|
4820
|
+
};
|
|
4821
|
+
const parseAlgorithmOID = state => {
|
|
4822
|
+
expectTag(state, 6, "Expected algorithm OID");
|
|
4823
|
+
const oidLen = parseLength(state);
|
|
4824
|
+
return getSubarray(state, oidLen);
|
|
4825
|
+
};
|
|
4826
|
+
function parsePKCS8Header(state) {
|
|
4827
|
+
expectTag(state, 48, "Invalid PKCS#8 structure");
|
|
4828
|
+
parseLength(state);
|
|
4829
|
+
expectTag(state, 2, "Expected version field");
|
|
4830
|
+
const verLen = parseLength(state);
|
|
4831
|
+
state.pos += verLen;
|
|
4832
|
+
expectTag(state, 48, "Expected algorithm identifier");
|
|
4833
|
+
const algIdLen = parseLength(state);
|
|
4834
|
+
const algIdStart = state.pos;
|
|
4835
|
+
return {
|
|
4836
|
+
algIdStart: algIdStart,
|
|
4837
|
+
algIdLength: algIdLen
|
|
4838
|
+
};
|
|
4839
|
+
}
|
|
4840
|
+
const parseECAlgorithmIdentifier = state => {
|
|
4841
|
+
const algOid = parseAlgorithmOID(state);
|
|
4842
|
+
if (bytesEqual(algOid, [ 43, 101, 110 ])) {
|
|
4843
|
+
return "X25519";
|
|
4844
|
+
}
|
|
4845
|
+
if (!bytesEqual(algOid, [ 42, 134, 72, 206, 61, 2, 1 ])) {
|
|
4846
|
+
throw new Error("Unsupported key algorithm");
|
|
4847
|
+
}
|
|
4848
|
+
expectTag(state, 6, "Expected curve OID");
|
|
4849
|
+
const curveOidLen = parseLength(state);
|
|
4850
|
+
const curveOid = getSubarray(state, curveOidLen);
|
|
4851
|
+
for (const {name: name, oid: oid} of [ {
|
|
4852
|
+
name: "P-256",
|
|
4853
|
+
oid: [ 42, 134, 72, 206, 61, 3, 1, 7 ]
|
|
4854
|
+
}, {
|
|
4855
|
+
name: "P-384",
|
|
4856
|
+
oid: [ 43, 129, 4, 0, 34 ]
|
|
4857
|
+
}, {
|
|
4858
|
+
name: "P-521",
|
|
4859
|
+
oid: [ 43, 129, 4, 0, 35 ]
|
|
4860
|
+
} ]) {
|
|
4861
|
+
if (bytesEqual(curveOid, oid)) {
|
|
4862
|
+
return name;
|
|
4863
|
+
}
|
|
4864
|
+
}
|
|
4865
|
+
throw new Error("Unsupported named curve");
|
|
4866
|
+
};
|
|
4867
|
+
const genericImport = async (keyFormat, keyData, alg, options) => {
|
|
4868
|
+
var _options$extractable;
|
|
4869
|
+
let algorithm;
|
|
4870
|
+
let keyUsages;
|
|
4871
|
+
const isPublic = keyFormat === "spki";
|
|
4872
|
+
const getSigUsages = () => isPublic ? [ "verify" ] : [ "sign" ];
|
|
4873
|
+
const getEncUsages = () => isPublic ? [ "encrypt", "wrapKey" ] : [ "decrypt", "unwrapKey" ];
|
|
4874
|
+
switch (alg) {
|
|
4875
|
+
case "PS256":
|
|
4876
|
+
case "PS384":
|
|
4877
|
+
case "PS512":
|
|
4878
|
+
algorithm = {
|
|
4879
|
+
name: "RSA-PSS",
|
|
4880
|
+
hash: "SHA-".concat(alg.slice(-3))
|
|
4881
|
+
};
|
|
4882
|
+
keyUsages = getSigUsages();
|
|
4883
|
+
break;
|
|
4884
|
+
|
|
4885
|
+
case "RS256":
|
|
4886
|
+
case "RS384":
|
|
4887
|
+
case "RS512":
|
|
4888
|
+
algorithm = {
|
|
4889
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
4890
|
+
hash: "SHA-".concat(alg.slice(-3))
|
|
4891
|
+
};
|
|
4892
|
+
keyUsages = getSigUsages();
|
|
4893
|
+
break;
|
|
4894
|
+
|
|
4895
|
+
case "RSA-OAEP":
|
|
4896
|
+
case "RSA-OAEP-256":
|
|
4897
|
+
case "RSA-OAEP-384":
|
|
4898
|
+
case "RSA-OAEP-512":
|
|
4899
|
+
algorithm = {
|
|
4900
|
+
name: "RSA-OAEP",
|
|
4901
|
+
hash: "SHA-".concat(parseInt(alg.slice(-3), 10) || 1)
|
|
4902
|
+
};
|
|
4903
|
+
keyUsages = getEncUsages();
|
|
4904
|
+
break;
|
|
4905
|
+
|
|
4906
|
+
case "ES256":
|
|
4907
|
+
case "ES384":
|
|
4908
|
+
case "ES512":
|
|
4909
|
+
{
|
|
4910
|
+
const curveMap = {
|
|
4911
|
+
ES256: "P-256",
|
|
4912
|
+
ES384: "P-384",
|
|
4913
|
+
ES512: "P-521"
|
|
4914
|
+
};
|
|
4915
|
+
algorithm = {
|
|
4916
|
+
name: "ECDSA",
|
|
4917
|
+
namedCurve: curveMap[alg]
|
|
4918
|
+
};
|
|
4919
|
+
keyUsages = getSigUsages();
|
|
4920
|
+
break;
|
|
4921
|
+
}
|
|
4922
|
+
|
|
4923
|
+
case "ECDH-ES":
|
|
4924
|
+
case "ECDH-ES+A128KW":
|
|
4925
|
+
case "ECDH-ES+A192KW":
|
|
4926
|
+
case "ECDH-ES+A256KW":
|
|
4927
|
+
{
|
|
4928
|
+
try {
|
|
4929
|
+
const namedCurve = options.getNamedCurve(keyData);
|
|
4930
|
+
algorithm = namedCurve === "X25519" ? {
|
|
4931
|
+
name: "X25519"
|
|
4932
|
+
} : {
|
|
4933
|
+
name: "ECDH",
|
|
4934
|
+
namedCurve: namedCurve
|
|
4935
|
+
};
|
|
4936
|
+
} catch (cause) {
|
|
4937
|
+
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
4938
|
+
}
|
|
4939
|
+
keyUsages = isPublic ? [] : [ "deriveBits" ];
|
|
4940
|
+
break;
|
|
4941
|
+
}
|
|
4942
|
+
|
|
4943
|
+
case "Ed25519":
|
|
4944
|
+
case "EdDSA":
|
|
4945
|
+
algorithm = {
|
|
4946
|
+
name: "Ed25519"
|
|
4947
|
+
};
|
|
4948
|
+
keyUsages = getSigUsages();
|
|
4949
|
+
break;
|
|
4950
|
+
|
|
4951
|
+
case "ML-DSA-44":
|
|
4952
|
+
case "ML-DSA-65":
|
|
4953
|
+
case "ML-DSA-87":
|
|
4954
|
+
algorithm = {
|
|
4955
|
+
name: alg
|
|
4956
|
+
};
|
|
4957
|
+
keyUsages = getSigUsages();
|
|
4958
|
+
break;
|
|
4959
|
+
|
|
4960
|
+
default:
|
|
4961
|
+
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
4962
|
+
}
|
|
4963
|
+
return crypto.subtle.importKey(keyFormat, keyData, algorithm, (_options$extractable = options === null || options === void 0 ? void 0 : options.extractable) !== null && _options$extractable !== void 0 ? _options$extractable : isPublic ? true : false, keyUsages);
|
|
4964
|
+
};
|
|
4965
|
+
const processPEMData = (pem, pattern) => decodeBase64(pem.replace(pattern, ""));
|
|
4966
|
+
const fromPKCS8 = (pem, alg, options) => {
|
|
4967
|
+
var _alg$startsWith;
|
|
4968
|
+
const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
4969
|
+
let opts = options;
|
|
4970
|
+
if (alg !== null && alg !== void 0 && (_alg$startsWith = alg.startsWith) !== null && _alg$startsWith !== void 0 && _alg$startsWith.call(alg, "ECDH-ES")) {
|
|
4971
|
+
opts || (opts = {});
|
|
4972
|
+
opts.getNamedCurve = keyData => {
|
|
4973
|
+
const state = createASN1State(keyData);
|
|
4974
|
+
parsePKCS8Header(state);
|
|
4975
|
+
return parseECAlgorithmIdentifier(state);
|
|
4976
|
+
};
|
|
4977
|
+
}
|
|
4978
|
+
return genericImport("pkcs8", keyData, alg, opts);
|
|
4979
|
+
};
|
|
4980
|
+
async function importPKCS8(pkcs8, alg, options) {
|
|
4981
|
+
if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
|
|
4982
|
+
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
4983
|
+
}
|
|
4984
|
+
return fromPKCS8(pkcs8, alg, options);
|
|
4985
|
+
}
|
|
4986
|
+
async function importJWK(jwk, alg, options) {
|
|
4987
|
+
var _options$extractable;
|
|
4988
|
+
if (!isObject(jwk)) {
|
|
4989
|
+
throw new TypeError("JWK must be an object");
|
|
4990
|
+
}
|
|
4991
|
+
let ext;
|
|
4992
|
+
alg !== null && alg !== void 0 ? alg : alg = jwk.alg;
|
|
4993
|
+
ext !== null && ext !== void 0 ? ext : ext = (_options$extractable = options === null || options === void 0 ? void 0 : options.extractable) !== null && _options$extractable !== void 0 ? _options$extractable : jwk.ext;
|
|
4994
|
+
switch (jwk.kty) {
|
|
4995
|
+
case "oct":
|
|
4996
|
+
if (typeof jwk.k !== "string" || !jwk.k) {
|
|
4997
|
+
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
4998
|
+
}
|
|
4999
|
+
return decode(jwk.k);
|
|
5000
|
+
|
|
5001
|
+
case "RSA":
|
|
5002
|
+
if ("oth" in jwk && jwk.oth !== undefined) {
|
|
5003
|
+
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
5004
|
+
}
|
|
5005
|
+
return jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
5006
|
+
alg: alg,
|
|
5007
|
+
ext: ext
|
|
5008
|
+
}));
|
|
5009
|
+
|
|
5010
|
+
case "AKP":
|
|
5011
|
+
{
|
|
5012
|
+
if (typeof jwk.alg !== "string" || !jwk.alg) {
|
|
5013
|
+
throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
5014
|
+
}
|
|
5015
|
+
if (alg !== undefined && alg !== jwk.alg) {
|
|
5016
|
+
throw new TypeError("JWK alg and alg option value mismatch");
|
|
5017
|
+
}
|
|
5018
|
+
return jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
5019
|
+
ext: ext
|
|
5020
|
+
}));
|
|
5021
|
+
}
|
|
5022
|
+
|
|
5023
|
+
case "EC":
|
|
5024
|
+
case "OKP":
|
|
5025
|
+
return jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
5026
|
+
alg: alg,
|
|
5027
|
+
ext: ext
|
|
5028
|
+
}));
|
|
5029
|
+
|
|
5030
|
+
default:
|
|
5031
|
+
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
5032
|
+
}
|
|
5033
|
+
}
|
|
5034
|
+
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
5035
|
+
if (joseHeader.crit !== undefined && (protectedHeader === null || protectedHeader === void 0 ? void 0 : protectedHeader.crit) === undefined) {
|
|
5036
|
+
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
4962
5037
|
}
|
|
4963
|
-
if (!
|
|
4964
|
-
|
|
4965
|
-
[alg]: cryptoKey
|
|
4966
|
-
});
|
|
4967
|
-
} else {
|
|
4968
|
-
cached[alg] = cryptoKey;
|
|
5038
|
+
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
5039
|
+
return new Set;
|
|
4969
5040
|
}
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
async function normalizeKey(key, alg) {
|
|
4973
|
-
if (key instanceof Uint8Array) {
|
|
4974
|
-
return key;
|
|
5041
|
+
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some(input => typeof input !== "string" || input.length === 0)) {
|
|
5042
|
+
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
4975
5043
|
}
|
|
4976
|
-
|
|
4977
|
-
|
|
5044
|
+
let recognized;
|
|
5045
|
+
if (recognizedOption !== undefined) {
|
|
5046
|
+
recognized = new Map([ ...Object.entries(recognizedOption), ...recognizedDefault.entries() ]);
|
|
5047
|
+
} else {
|
|
5048
|
+
recognized = recognizedDefault;
|
|
4978
5049
|
}
|
|
4979
|
-
|
|
4980
|
-
if (
|
|
4981
|
-
|
|
5050
|
+
for (const parameter of protectedHeader.crit) {
|
|
5051
|
+
if (!recognized.has(parameter)) {
|
|
5052
|
+
throw new JOSENotSupported('Extension Header Parameter "'.concat(parameter, '" is not recognized'));
|
|
4982
5053
|
}
|
|
4983
|
-
if (
|
|
4984
|
-
|
|
4985
|
-
return handleKeyObject(key, alg);
|
|
4986
|
-
} catch (err) {
|
|
4987
|
-
if (err instanceof TypeError) {
|
|
4988
|
-
throw err;
|
|
4989
|
-
}
|
|
4990
|
-
}
|
|
5054
|
+
if (joseHeader[parameter] === undefined) {
|
|
5055
|
+
throw new Err('Extension Header Parameter "'.concat(parameter, '" is missing'));
|
|
4991
5056
|
}
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
});
|
|
4995
|
-
return handleJWK(key, jwk, alg);
|
|
4996
|
-
}
|
|
4997
|
-
if (isJWK(key)) {
|
|
4998
|
-
if (key.k) {
|
|
4999
|
-
return decode(key.k);
|
|
5057
|
+
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
5058
|
+
throw new Err('Extension Header Parameter "'.concat(parameter, '" MUST be integrity protected'));
|
|
5000
5059
|
}
|
|
5001
|
-
return handleJWK(key, key, alg, true);
|
|
5002
5060
|
}
|
|
5003
|
-
|
|
5061
|
+
return new Set(protectedHeader.crit);
|
|
5062
|
+
}
|
|
5063
|
+
function validateAlgorithms(option, algorithms) {
|
|
5064
|
+
if (algorithms !== undefined && (!Array.isArray(algorithms) || algorithms.some(s => typeof s !== "string"))) {
|
|
5065
|
+
throw new TypeError('"'.concat(option, '" option must be an array of strings'));
|
|
5066
|
+
}
|
|
5067
|
+
if (!algorithms) {
|
|
5068
|
+
return undefined;
|
|
5069
|
+
}
|
|
5070
|
+
return new Set(algorithms);
|
|
5004
5071
|
}
|
|
5005
5072
|
const tag = key => key === null || key === void 0 ? void 0 : key[Symbol.toStringTag];
|
|
5006
5073
|
const jwkMatchesOp = (alg, key, usage) => {
|
|
@@ -5131,7 +5198,7 @@
|
|
|
5131
5198
|
let USER_AGENT$1;
|
|
5132
5199
|
if (typeof navigator === "undefined" || !((_navigator$userAgent$1 = navigator.userAgent) !== null && _navigator$userAgent$1 !== void 0 && (_navigator$userAgent$$1 = _navigator$userAgent$1.startsWith) !== null && _navigator$userAgent$$1 !== void 0 && _navigator$userAgent$$1.call(_navigator$userAgent$1, "Mozilla/5.0 "))) {
|
|
5133
5200
|
const NAME = "openid-client";
|
|
5134
|
-
const VERSION = "v6.8.
|
|
5201
|
+
const VERSION = "v6.8.2";
|
|
5135
5202
|
USER_AGENT$1 = "".concat(NAME, "/").concat(VERSION);
|
|
5136
5203
|
headers = {
|
|
5137
5204
|
"user-agent": USER_AGENT$1
|
|
@@ -5321,7 +5388,7 @@
|
|
|
5321
5388
|
method: "GET",
|
|
5322
5389
|
redirect: "manual",
|
|
5323
5390
|
signal: signal
|
|
5324
|
-
})).then(
|
|
5391
|
+
})).then(response => processDiscoveryResponse(_nodiscoverycheck, response)).catch(errorHandler);
|
|
5325
5392
|
if (resolve && new URL(as.issuer).href !== server.href) {
|
|
5326
5393
|
handleEntraId(server, as, options) || handleB2Clogin(server, options) || (() => {
|
|
5327
5394
|
throw new ClientError("discovered metadata issuer does not match the expected issuer", {
|
|
@@ -5487,7 +5554,7 @@
|
|
|
5487
5554
|
}
|
|
5488
5555
|
}
|
|
5489
5556
|
function wait(duration, signal) {
|
|
5490
|
-
return new Promise((
|
|
5557
|
+
return new Promise((resolve, reject) => {
|
|
5491
5558
|
const waitStep = remaining => {
|
|
5492
5559
|
try {
|
|
5493
5560
|
signal.throwIfAborted();
|
|
@@ -5500,10 +5567,10 @@
|
|
|
5500
5567
|
return;
|
|
5501
5568
|
}
|
|
5502
5569
|
const currentWait = Math.min(remaining, 5);
|
|
5503
|
-
setTimeout((
|
|
5570
|
+
setTimeout(() => waitStep(remaining - currentWait), currentWait * 1e3);
|
|
5504
5571
|
};
|
|
5505
5572
|
waitStep(duration);
|
|
5506
|
-
})
|
|
5573
|
+
});
|
|
5507
5574
|
}
|
|
5508
5575
|
async function initiateBackchannelAuthentication(config, parameters) {
|
|
5509
5576
|
checkConfig(config);
|
|
@@ -5513,7 +5580,7 @@
|
|
|
5513
5580
|
[allowInsecureRequests$1]: !tlsOnly,
|
|
5514
5581
|
headers: new Headers(headers),
|
|
5515
5582
|
signal: signal(timeout)
|
|
5516
|
-
}).then(
|
|
5583
|
+
}).then(response => processBackchannelAuthenticationResponse(as, c, response)).catch(errorHandler);
|
|
5517
5584
|
}
|
|
5518
5585
|
async function pollBackchannelAuthenticationGrant(config, backchannelAuthenticationResponse, parameters, options) {
|
|
5519
5586
|
var _backchannelAuthentic, _options$signal2;
|
|
@@ -5825,7 +5892,7 @@
|
|
|
5825
5892
|
DPoP: options === null || options === void 0 ? void 0 : options.DPoP,
|
|
5826
5893
|
headers: new Headers(headers),
|
|
5827
5894
|
signal: signal(timeout)
|
|
5828
|
-
}).then(
|
|
5895
|
+
}).then(response => {
|
|
5829
5896
|
let recognizedTokenTypes;
|
|
5830
5897
|
if (grantType === "urn:ietf:params:oauth:grant-type:token-exchange") {
|
|
5831
5898
|
recognizedTokenTypes = {
|
|
@@ -5836,87 +5903,10 @@
|
|
|
5836
5903
|
[jweDecrypt]: decrypt,
|
|
5837
5904
|
recognizedTokenTypes: recognizedTokenTypes
|
|
5838
5905
|
});
|
|
5839
|
-
})
|
|
5906
|
+
}).catch(errorHandler);
|
|
5840
5907
|
addHelpers(result);
|
|
5841
5908
|
return result;
|
|
5842
5909
|
}
|
|
5843
|
-
function subtleAlgorithm(alg, algorithm) {
|
|
5844
|
-
const hash = "SHA-".concat(alg.slice(-3));
|
|
5845
|
-
switch (alg) {
|
|
5846
|
-
case "HS256":
|
|
5847
|
-
case "HS384":
|
|
5848
|
-
case "HS512":
|
|
5849
|
-
return {
|
|
5850
|
-
hash: hash,
|
|
5851
|
-
name: "HMAC"
|
|
5852
|
-
};
|
|
5853
|
-
|
|
5854
|
-
case "PS256":
|
|
5855
|
-
case "PS384":
|
|
5856
|
-
case "PS512":
|
|
5857
|
-
return {
|
|
5858
|
-
hash: hash,
|
|
5859
|
-
name: "RSA-PSS",
|
|
5860
|
-
saltLength: parseInt(alg.slice(-3), 10) >> 3
|
|
5861
|
-
};
|
|
5862
|
-
|
|
5863
|
-
case "RS256":
|
|
5864
|
-
case "RS384":
|
|
5865
|
-
case "RS512":
|
|
5866
|
-
return {
|
|
5867
|
-
hash: hash,
|
|
5868
|
-
name: "RSASSA-PKCS1-v1_5"
|
|
5869
|
-
};
|
|
5870
|
-
|
|
5871
|
-
case "ES256":
|
|
5872
|
-
case "ES384":
|
|
5873
|
-
case "ES512":
|
|
5874
|
-
return {
|
|
5875
|
-
hash: hash,
|
|
5876
|
-
name: "ECDSA",
|
|
5877
|
-
namedCurve: algorithm.namedCurve
|
|
5878
|
-
};
|
|
5879
|
-
|
|
5880
|
-
case "Ed25519":
|
|
5881
|
-
case "EdDSA":
|
|
5882
|
-
return {
|
|
5883
|
-
name: "Ed25519"
|
|
5884
|
-
};
|
|
5885
|
-
|
|
5886
|
-
case "ML-DSA-44":
|
|
5887
|
-
case "ML-DSA-65":
|
|
5888
|
-
case "ML-DSA-87":
|
|
5889
|
-
return {
|
|
5890
|
-
name: alg
|
|
5891
|
-
};
|
|
5892
|
-
|
|
5893
|
-
default:
|
|
5894
|
-
throw new JOSENotSupported("alg ".concat(alg, " is not supported either by JOSE or your javascript runtime"));
|
|
5895
|
-
}
|
|
5896
|
-
}
|
|
5897
|
-
async function getSigKey(alg, key, usage) {
|
|
5898
|
-
if (key instanceof Uint8Array) {
|
|
5899
|
-
if (!alg.startsWith("HS")) {
|
|
5900
|
-
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
5901
|
-
}
|
|
5902
|
-
return crypto.subtle.importKey("raw", key, {
|
|
5903
|
-
hash: "SHA-".concat(alg.slice(-3)),
|
|
5904
|
-
name: "HMAC"
|
|
5905
|
-
}, false, [ usage ]);
|
|
5906
|
-
}
|
|
5907
|
-
checkSigCryptoKey(key, alg, usage);
|
|
5908
|
-
return key;
|
|
5909
|
-
}
|
|
5910
|
-
async function verify(alg, key, signature, data) {
|
|
5911
|
-
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
5912
|
-
checkKeyLength(alg, cryptoKey);
|
|
5913
|
-
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
5914
|
-
try {
|
|
5915
|
-
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
|
|
5916
|
-
} catch (_unused) {
|
|
5917
|
-
return false;
|
|
5918
|
-
}
|
|
5919
|
-
}
|
|
5920
5910
|
async function flattenedVerify(jws, key, options) {
|
|
5921
5911
|
if (!isObject(jws)) {
|
|
5922
5912
|
throw new JWSInvalid("Flattened JWS must be an object");
|
|
@@ -5979,12 +5969,7 @@
|
|
|
5979
5969
|
}
|
|
5980
5970
|
checkKeyType(alg, key, "verify");
|
|
5981
5971
|
const data = concat(jws.protected !== undefined ? encode(jws.protected) : new Uint8Array, encode("."), typeof jws.payload === "string" ? b64 ? encode(jws.payload) : encoder.encode(jws.payload) : jws.payload);
|
|
5982
|
-
|
|
5983
|
-
try {
|
|
5984
|
-
signature = decode(jws.signature);
|
|
5985
|
-
} catch (_unused2) {
|
|
5986
|
-
throw new JWSInvalid("Failed to base64url decode the signature");
|
|
5987
|
-
}
|
|
5972
|
+
const signature = decodeBase64url(jws.signature, "signature", JWSInvalid);
|
|
5988
5973
|
const k = await normalizeKey(key, alg);
|
|
5989
5974
|
const verified = await verify(alg, k, signature, data);
|
|
5990
5975
|
if (!verified) {
|
|
@@ -5992,11 +5977,7 @@
|
|
|
5992
5977
|
}
|
|
5993
5978
|
let payload;
|
|
5994
5979
|
if (b64) {
|
|
5995
|
-
|
|
5996
|
-
payload = decode(jws.payload);
|
|
5997
|
-
} catch (_unused3) {
|
|
5998
|
-
throw new JWSInvalid("Failed to base64url decode the payload");
|
|
5999
|
-
}
|
|
5980
|
+
payload = decodeBase64url(jws.payload, "payload", JWSInvalid);
|
|
6000
5981
|
} else if (typeof jws.payload === "string") {
|
|
6001
5982
|
payload = encoder.encode(jws.payload);
|
|
6002
5983
|
} else {
|
|
@@ -6264,7 +6245,7 @@
|
|
|
6264
6245
|
async getKey(protectedHeader, token) {
|
|
6265
6246
|
const {alg: alg, kid: kid} = _objectSpread2(_objectSpread2({}, protectedHeader), token === null || token === void 0 ? void 0 : token.header);
|
|
6266
6247
|
const kty = getKtyFromAlg(alg);
|
|
6267
|
-
const candidates = _classPrivateFieldGet2(_jwks$1, this).keys.filter(
|
|
6248
|
+
const candidates = _classPrivateFieldGet2(_jwks$1, this).keys.filter(jwk => {
|
|
6268
6249
|
let candidate = kty === jwk.kty;
|
|
6269
6250
|
if (candidate && typeof kid === "string") {
|
|
6270
6251
|
candidate = kid === jwk.kid;
|
|
@@ -6299,7 +6280,7 @@
|
|
|
6299
6280
|
}
|
|
6300
6281
|
}
|
|
6301
6282
|
return candidate;
|
|
6302
|
-
})
|
|
6283
|
+
});
|
|
6303
6284
|
const {0: jwk, length: length} = candidates;
|
|
6304
6285
|
if (length === 0) {
|
|
6305
6286
|
throw new JWKSNoMatchingKey;
|
|
@@ -6307,13 +6288,13 @@
|
|
|
6307
6288
|
if (length !== 1) {
|
|
6308
6289
|
const error = new JWKSMultipleMatchingKeys;
|
|
6309
6290
|
const _cached = _classPrivateFieldGet2(_cached2, this);
|
|
6310
|
-
error[Symbol.asyncIterator] = _wrapAsyncGenerator(
|
|
6291
|
+
error[Symbol.asyncIterator] = _wrapAsyncGenerator(function*() {
|
|
6311
6292
|
for (const jwk of candidates) {
|
|
6312
6293
|
try {
|
|
6313
6294
|
yield yield _awaitAsyncGenerator(importWithAlgCache(_cached, jwk, alg));
|
|
6314
6295
|
} catch (_unused) {}
|
|
6315
6296
|
}
|
|
6316
|
-
})
|
|
6297
|
+
});
|
|
6317
6298
|
throw error;
|
|
6318
6299
|
}
|
|
6319
6300
|
return importWithAlgCache(_classPrivateFieldGet2(_cached2, this), jwk, alg);
|
|
@@ -6352,7 +6333,7 @@
|
|
|
6352
6333
|
let USER_AGENT;
|
|
6353
6334
|
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 "))) {
|
|
6354
6335
|
const NAME = "jose";
|
|
6355
|
-
const VERSION = "v6.1
|
|
6336
|
+
const VERSION = "v6.2.1";
|
|
6356
6337
|
USER_AGENT = "".concat(NAME, "/").concat(VERSION);
|
|
6357
6338
|
}
|
|
6358
6339
|
const customFetch = Symbol();
|
|
@@ -6363,12 +6344,12 @@
|
|
|
6363
6344
|
signal: signal,
|
|
6364
6345
|
redirect: "manual",
|
|
6365
6346
|
headers: headers
|
|
6366
|
-
}).catch(
|
|
6347
|
+
}).catch(err => {
|
|
6367
6348
|
if (err.name === "TimeoutError") {
|
|
6368
6349
|
throw new JWKSTimeout;
|
|
6369
6350
|
}
|
|
6370
6351
|
throw err;
|
|
6371
|
-
})
|
|
6352
|
+
});
|
|
6372
6353
|
if (response.status !== 200) {
|
|
6373
6354
|
throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
|
|
6374
6355
|
}
|
|
@@ -6470,7 +6451,7 @@
|
|
|
6470
6451
|
if (_classPrivateFieldGet2(_pendingFetch, this) && isCloudflareWorkers()) {
|
|
6471
6452
|
_classPrivateFieldSet2(_pendingFetch, this, undefined);
|
|
6472
6453
|
}
|
|
6473
|
-
_classPrivateFieldGet2(_pendingFetch, this) || _classPrivateFieldSet2(_pendingFetch, this, fetchJwks(_classPrivateFieldGet2(_url, this).href, _classPrivateFieldGet2(_headers, this), AbortSignal.timeout(_classPrivateFieldGet2(_timeoutDuration, this)), _classPrivateFieldGet2(_customFetch$1, this)).then(
|
|
6454
|
+
_classPrivateFieldGet2(_pendingFetch, this) || _classPrivateFieldSet2(_pendingFetch, this, fetchJwks(_classPrivateFieldGet2(_url, this).href, _classPrivateFieldGet2(_headers, this), AbortSignal.timeout(_classPrivateFieldGet2(_timeoutDuration, this)), _classPrivateFieldGet2(_customFetch$1, this)).then(json => {
|
|
6474
6455
|
_classPrivateFieldSet2(_local, this, createLocalJWKSet(json));
|
|
6475
6456
|
if (_classPrivateFieldGet2(_cache, this)) {
|
|
6476
6457
|
_classPrivateFieldGet2(_cache, this).uat = Date.now();
|
|
@@ -6478,10 +6459,10 @@
|
|
|
6478
6459
|
}
|
|
6479
6460
|
_classPrivateFieldSet2(_jwksTimestamp, this, Date.now());
|
|
6480
6461
|
_classPrivateFieldSet2(_pendingFetch, this, undefined);
|
|
6481
|
-
})
|
|
6462
|
+
}).catch(err => {
|
|
6482
6463
|
_classPrivateFieldSet2(_pendingFetch, this, undefined);
|
|
6483
6464
|
throw err;
|
|
6484
|
-
}))
|
|
6465
|
+
}));
|
|
6485
6466
|
await _classPrivateFieldGet2(_pendingFetch, this);
|
|
6486
6467
|
}
|
|
6487
6468
|
}
|
|
@@ -6520,7 +6501,7 @@
|
|
|
6520
6501
|
return remoteJWKSet;
|
|
6521
6502
|
}
|
|
6522
6503
|
const _excluded = [ "mfaToken" ], _excluded2 = [ "mfaToken" ];
|
|
6523
|
-
var _baseUrl, _clientId, _customFetch, _configuration, _serverMetadata, _options, _jwks,
|
|
6504
|
+
var _baseUrl, _clientId, _customFetch, _entries, _ttlMs, _maxEntries, _configuration, _serverMetadata, _clientAuthPromise, _options, _customFetch2, _jwks, _discoveryCache, _inFlightDiscovery, _jwksCache, _Class9_brand;
|
|
6524
6505
|
var NotSupportedError = class NotSupportedError extends Error {
|
|
6525
6506
|
constructor(code, message) {
|
|
6526
6507
|
super(message);
|
|
@@ -6612,12 +6593,12 @@
|
|
|
6612
6593
|
}
|
|
6613
6594
|
};
|
|
6614
6595
|
function stripUndefinedProperties(value) {
|
|
6615
|
-
return Object.entries(value).filter(
|
|
6596
|
+
return Object.entries(value).filter(_ref => {
|
|
6616
6597
|
let [, value2] = _ref;
|
|
6617
6598
|
return typeof value2 !== "undefined";
|
|
6618
|
-
})
|
|
6599
|
+
}).reduce((acc, curr) => _objectSpread2(_objectSpread2({}, acc), {}, {
|
|
6619
6600
|
[curr[0]]: curr[1]
|
|
6620
|
-
})
|
|
6601
|
+
}), {});
|
|
6621
6602
|
}
|
|
6622
6603
|
var MfaError$1 = class MfaError extends Error {
|
|
6623
6604
|
constructor(code, message, cause) {
|
|
@@ -6682,7 +6663,9 @@
|
|
|
6682
6663
|
oobChannel: api.oob_channel,
|
|
6683
6664
|
oobCode: api.oob_code,
|
|
6684
6665
|
bindingMethod: api.binding_method,
|
|
6685
|
-
id: api.id
|
|
6666
|
+
id: api.id,
|
|
6667
|
+
barcodeUri: api.barcode_uri,
|
|
6668
|
+
recoveryCodes: api.recovery_codes
|
|
6686
6669
|
};
|
|
6687
6670
|
}
|
|
6688
6671
|
throw new Error("Unexpected authenticator type: ".concat(api.authenticator_type));
|
|
@@ -6800,6 +6783,40 @@
|
|
|
6800
6783
|
return transformChallengeResponse(apiResponse);
|
|
6801
6784
|
}
|
|
6802
6785
|
});
|
|
6786
|
+
function createTelemetryFetch(baseFetch, config) {
|
|
6787
|
+
if (config.enabled === false) {
|
|
6788
|
+
return baseFetch;
|
|
6789
|
+
}
|
|
6790
|
+
const telemetryData = {
|
|
6791
|
+
name: config.name,
|
|
6792
|
+
version: config.version
|
|
6793
|
+
};
|
|
6794
|
+
const headerValue = btoa(JSON.stringify(telemetryData));
|
|
6795
|
+
return async (input, init) => {
|
|
6796
|
+
const headers = input instanceof Request ? new Headers(input.headers) : new Headers;
|
|
6797
|
+
if (init !== null && init !== void 0 && init.headers) {
|
|
6798
|
+
const initHeaders = new Headers(init.headers);
|
|
6799
|
+
initHeaders.forEach((value, key) => {
|
|
6800
|
+
headers.set(key, value);
|
|
6801
|
+
});
|
|
6802
|
+
}
|
|
6803
|
+
headers.set("Auth0-Client", headerValue);
|
|
6804
|
+
return baseFetch(input, _objectSpread2(_objectSpread2({}, init), {}, {
|
|
6805
|
+
headers: headers
|
|
6806
|
+
}));
|
|
6807
|
+
};
|
|
6808
|
+
}
|
|
6809
|
+
function getTelemetryConfig(config) {
|
|
6810
|
+
var _config$name, _config$version;
|
|
6811
|
+
if ((config === null || config === void 0 ? void 0 : config.enabled) === false) {
|
|
6812
|
+
return config;
|
|
6813
|
+
}
|
|
6814
|
+
return {
|
|
6815
|
+
enabled: true,
|
|
6816
|
+
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.5.0"
|
|
6818
|
+
};
|
|
6819
|
+
}
|
|
6803
6820
|
var TokenResponse = class _TokenResponse {
|
|
6804
6821
|
constructor(accessToken, expiresAt, idToken, refreshToken, scope, claims, authorizationDetails) {
|
|
6805
6822
|
_defineProperty(this, "accessToken", void 0);
|
|
@@ -6827,6 +6844,75 @@
|
|
|
6827
6844
|
return tokenResponse;
|
|
6828
6845
|
}
|
|
6829
6846
|
};
|
|
6847
|
+
var LruCache = (_entries = new WeakMap, _ttlMs = new WeakMap, _maxEntries = new WeakMap,
|
|
6848
|
+
class LruCache {
|
|
6849
|
+
constructor(maxEntries, ttlMs) {
|
|
6850
|
+
_classPrivateFieldInitSpec(this, _entries, new Map);
|
|
6851
|
+
_classPrivateFieldInitSpec(this, _ttlMs, void 0);
|
|
6852
|
+
_classPrivateFieldInitSpec(this, _maxEntries, void 0);
|
|
6853
|
+
_classPrivateFieldSet2(_maxEntries, this, Math.max(1, Math.floor(maxEntries)));
|
|
6854
|
+
_classPrivateFieldSet2(_ttlMs, this, Math.max(0, Math.floor(ttlMs)));
|
|
6855
|
+
}
|
|
6856
|
+
get(key) {
|
|
6857
|
+
const entry = _classPrivateFieldGet2(_entries, this).get(key);
|
|
6858
|
+
if (!entry) {
|
|
6859
|
+
return;
|
|
6860
|
+
}
|
|
6861
|
+
if (Date.now() >= entry.expiresAt) {
|
|
6862
|
+
_classPrivateFieldGet2(_entries, this).delete(key);
|
|
6863
|
+
return;
|
|
6864
|
+
}
|
|
6865
|
+
_classPrivateFieldGet2(_entries, this).delete(key);
|
|
6866
|
+
_classPrivateFieldGet2(_entries, this).set(key, entry);
|
|
6867
|
+
return entry.value;
|
|
6868
|
+
}
|
|
6869
|
+
set(key, value) {
|
|
6870
|
+
if (_classPrivateFieldGet2(_entries, this).has(key)) {
|
|
6871
|
+
_classPrivateFieldGet2(_entries, this).delete(key);
|
|
6872
|
+
}
|
|
6873
|
+
_classPrivateFieldGet2(_entries, this).set(key, {
|
|
6874
|
+
value: value,
|
|
6875
|
+
expiresAt: Date.now() + _classPrivateFieldGet2(_ttlMs, this)
|
|
6876
|
+
});
|
|
6877
|
+
while (_classPrivateFieldGet2(_entries, this).size > _classPrivateFieldGet2(_maxEntries, this)) {
|
|
6878
|
+
const oldestKey = _classPrivateFieldGet2(_entries, this).keys().next().value;
|
|
6879
|
+
if (oldestKey === void 0) {
|
|
6880
|
+
break;
|
|
6881
|
+
}
|
|
6882
|
+
_classPrivateFieldGet2(_entries, this).delete(oldestKey);
|
|
6883
|
+
}
|
|
6884
|
+
}
|
|
6885
|
+
});
|
|
6886
|
+
var globalCaches = new Map;
|
|
6887
|
+
function getGlobalCache(key) {
|
|
6888
|
+
return globalCaches.get(key);
|
|
6889
|
+
}
|
|
6890
|
+
function getGlobalCacheKey(maxEntries, ttlMs) {
|
|
6891
|
+
return "".concat(maxEntries, ":").concat(ttlMs);
|
|
6892
|
+
}
|
|
6893
|
+
function resolveCacheConfig(options) {
|
|
6894
|
+
const ttlSeconds = typeof (options === null || options === void 0 ? void 0 : options.ttl) === "number" ? options.ttl : 600;
|
|
6895
|
+
const maxEntries = typeof (options === null || options === void 0 ? void 0 : options.maxEntries) === "number" && options.maxEntries > 0 ? options.maxEntries : 100;
|
|
6896
|
+
const ttlMs = ttlSeconds * 1e3;
|
|
6897
|
+
return {
|
|
6898
|
+
ttlMs: ttlMs,
|
|
6899
|
+
maxEntries: maxEntries
|
|
6900
|
+
};
|
|
6901
|
+
}
|
|
6902
|
+
var DiscoveryCacheFactory = class {
|
|
6903
|
+
static createDiscoveryCache(config) {
|
|
6904
|
+
const cacheKey = getGlobalCacheKey(config.maxEntries, config.ttlMs);
|
|
6905
|
+
let cache = getGlobalCache(cacheKey);
|
|
6906
|
+
if (!cache) {
|
|
6907
|
+
cache = new LruCache(config.maxEntries, config.ttlMs);
|
|
6908
|
+
globalCaches.set(cacheKey, cache);
|
|
6909
|
+
}
|
|
6910
|
+
return cache;
|
|
6911
|
+
}
|
|
6912
|
+
static createJwksCache() {
|
|
6913
|
+
return {};
|
|
6914
|
+
}
|
|
6915
|
+
};
|
|
6830
6916
|
var DEFAULT_SCOPES = "openid profile email offline_access";
|
|
6831
6917
|
var MAX_ARRAY_VALUES_PER_KEY = 20;
|
|
6832
6918
|
var PARAM_DENYLIST = Object.freeze(new Set([ "grant_type", "client_id", "client_secret", "client_assertion", "client_assertion_type", "subject_token", "subject_token_type", "requested_token_type", "actor_token", "actor_token_type", "audience", "aud", "resource", "resources", "resource_indicator", "scope", "connection", "login_hint", "organization", "assertion" ]));
|
|
@@ -6855,9 +6941,9 @@
|
|
|
6855
6941
|
if (parameterValue.length > MAX_ARRAY_VALUES_PER_KEY) {
|
|
6856
6942
|
throw new TokenExchangeError("Parameter '".concat(parameterKey, "' exceeds maximum array size of ").concat(MAX_ARRAY_VALUES_PER_KEY));
|
|
6857
6943
|
}
|
|
6858
|
-
parameterValue.forEach(
|
|
6944
|
+
parameterValue.forEach(arrayItem => {
|
|
6859
6945
|
params.append(parameterKey, arrayItem);
|
|
6860
|
-
})
|
|
6946
|
+
});
|
|
6861
6947
|
} else {
|
|
6862
6948
|
params.append(parameterKey, parameterValue);
|
|
6863
6949
|
}
|
|
@@ -6868,39 +6954,58 @@
|
|
|
6868
6954
|
var SUBJECT_TYPE_REFRESH_TOKEN = "urn:ietf:params:oauth:token-type:refresh_token";
|
|
6869
6955
|
var SUBJECT_TYPE_ACCESS_TOKEN = "urn:ietf:params:oauth:token-type:access_token";
|
|
6870
6956
|
var REQUESTED_TOKEN_TYPE_FEDERATED_CONNECTION_ACCESS_TOKEN = "http://auth0.com/oauth/token-type/federated-connection-access-token";
|
|
6871
|
-
var AuthClient = (_configuration = new WeakMap, _serverMetadata = new WeakMap,
|
|
6872
|
-
|
|
6957
|
+
var AuthClient = (_configuration = new WeakMap, _serverMetadata = new WeakMap, _clientAuthPromise = new WeakMap,
|
|
6958
|
+
_options = new WeakMap, _customFetch2 = new WeakMap, _jwks = new WeakMap, _discoveryCache = new WeakMap,
|
|
6959
|
+
_inFlightDiscovery = new WeakMap, _jwksCache = new WeakMap, _Class9_brand = new WeakSet,
|
|
6960
|
+
class AuthClient {
|
|
6873
6961
|
constructor(_options2) {
|
|
6874
|
-
|
|
6962
|
+
var _options2$customFetch;
|
|
6963
|
+
_classPrivateMethodInitSpec(this, _Class9_brand);
|
|
6875
6964
|
_classPrivateFieldInitSpec(this, _configuration, void 0);
|
|
6876
6965
|
_classPrivateFieldInitSpec(this, _serverMetadata, void 0);
|
|
6966
|
+
_classPrivateFieldInitSpec(this, _clientAuthPromise, void 0);
|
|
6877
6967
|
_classPrivateFieldInitSpec(this, _options, void 0);
|
|
6968
|
+
_classPrivateFieldInitSpec(this, _customFetch2, void 0);
|
|
6878
6969
|
_classPrivateFieldInitSpec(this, _jwks, void 0);
|
|
6970
|
+
_classPrivateFieldInitSpec(this, _discoveryCache, void 0);
|
|
6971
|
+
_classPrivateFieldInitSpec(this, _inFlightDiscovery, void 0);
|
|
6972
|
+
_classPrivateFieldInitSpec(this, _jwksCache, void 0);
|
|
6879
6973
|
_defineProperty(this, "mfa", void 0);
|
|
6880
6974
|
_classPrivateFieldSet2(_options, this, _options2);
|
|
6881
6975
|
if (_options2.useMtls && !_options2.customFetch) {
|
|
6882
6976
|
throw new NotSupportedError("mtls_without_custom_fetch_not_supported", "Using mTLS without a custom fetch implementation is not supported");
|
|
6883
6977
|
}
|
|
6978
|
+
_classPrivateFieldSet2(_customFetch2, this, createTelemetryFetch((_options2$customFetch = _options2.customFetch) !== null && _options2$customFetch !== void 0 ? _options2$customFetch : function() {
|
|
6979
|
+
return fetch(...arguments);
|
|
6980
|
+
}, getTelemetryConfig(_options2.telemetry)));
|
|
6981
|
+
const cacheConfig = resolveCacheConfig(_options2.discoveryCache);
|
|
6982
|
+
_classPrivateFieldSet2(_discoveryCache, this, DiscoveryCacheFactory.createDiscoveryCache(cacheConfig));
|
|
6983
|
+
_classPrivateFieldSet2(_inFlightDiscovery, this, new Map);
|
|
6984
|
+
_classPrivateFieldSet2(_jwksCache, this, DiscoveryCacheFactory.createJwksCache());
|
|
6884
6985
|
this.mfa = new MfaClient({
|
|
6885
6986
|
domain: _classPrivateFieldGet2(_options, this).domain,
|
|
6886
6987
|
clientId: _classPrivateFieldGet2(_options, this).clientId,
|
|
6887
|
-
customFetch: _classPrivateFieldGet2(
|
|
6988
|
+
customFetch: _classPrivateFieldGet2(_customFetch2, this)
|
|
6888
6989
|
});
|
|
6889
6990
|
}
|
|
6991
|
+
async getServerMetadata() {
|
|
6992
|
+
const {serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
6993
|
+
return serverMetadata;
|
|
6994
|
+
}
|
|
6890
6995
|
async buildAuthorizationUrl(options) {
|
|
6891
|
-
const {serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
6996
|
+
const {serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
6892
6997
|
if (options !== null && options !== void 0 && options.pushedAuthorizationRequests && !serverMetadata.pushed_authorization_request_endpoint) {
|
|
6893
6998
|
throw new NotSupportedError("par_not_supported_error", "The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par");
|
|
6894
6999
|
}
|
|
6895
7000
|
try {
|
|
6896
|
-
return await _assertClassBrand(
|
|
7001
|
+
return await _assertClassBrand(_Class9_brand, this, _buildAuthorizationUrl).call(this, options);
|
|
6897
7002
|
} catch (e) {
|
|
6898
7003
|
throw new BuildAuthorizationUrlError(e);
|
|
6899
7004
|
}
|
|
6900
7005
|
}
|
|
6901
7006
|
async buildLinkUserUrl(options) {
|
|
6902
7007
|
try {
|
|
6903
|
-
const result = await _assertClassBrand(
|
|
7008
|
+
const result = await _assertClassBrand(_Class9_brand, this, _buildAuthorizationUrl).call(this, {
|
|
6904
7009
|
authorizationParams: _objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
|
|
6905
7010
|
requested_connection: options.connection,
|
|
6906
7011
|
requested_connection_scope: options.connectionScope,
|
|
@@ -6918,7 +7023,7 @@
|
|
|
6918
7023
|
}
|
|
6919
7024
|
async buildUnlinkUserUrl(options) {
|
|
6920
7025
|
try {
|
|
6921
|
-
const result = await _assertClassBrand(
|
|
7026
|
+
const result = await _assertClassBrand(_Class9_brand, this, _buildAuthorizationUrl).call(this, {
|
|
6922
7027
|
authorizationParams: _objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
|
|
6923
7028
|
requested_connection: options.connection,
|
|
6924
7029
|
scope: "openid unlink_account",
|
|
@@ -6934,7 +7039,7 @@
|
|
|
6934
7039
|
}
|
|
6935
7040
|
}
|
|
6936
7041
|
async backchannelAuthentication(options) {
|
|
6937
|
-
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7042
|
+
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
6938
7043
|
const additionalParams = stripUndefinedProperties(_objectSpread2(_objectSpread2({}, _classPrivateFieldGet2(_options, this).authorizationParams), options === null || options === void 0 ? void 0 : options.authorizationParams));
|
|
6939
7044
|
const params = new URLSearchParams(_objectSpread2(_objectSpread2({
|
|
6940
7045
|
scope: DEFAULT_SCOPES
|
|
@@ -6962,7 +7067,7 @@
|
|
|
6962
7067
|
}
|
|
6963
7068
|
}
|
|
6964
7069
|
async initiateBackchannelAuthentication(options) {
|
|
6965
|
-
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7070
|
+
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
6966
7071
|
const additionalParams = stripUndefinedProperties(_objectSpread2(_objectSpread2({}, _classPrivateFieldGet2(_options, this).authorizationParams), options === null || options === void 0 ? void 0 : options.authorizationParams));
|
|
6967
7072
|
const params = new URLSearchParams(_objectSpread2(_objectSpread2({
|
|
6968
7073
|
scope: DEFAULT_SCOPES
|
|
@@ -6994,7 +7099,7 @@
|
|
|
6994
7099
|
}
|
|
6995
7100
|
async backchannelAuthenticationGrant(_ref2) {
|
|
6996
7101
|
let {authReqId: authReqId} = _ref2;
|
|
6997
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7102
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
6998
7103
|
const params = new URLSearchParams({
|
|
6999
7104
|
auth_req_id: authReqId
|
|
7000
7105
|
});
|
|
@@ -7029,10 +7134,10 @@
|
|
|
7029
7134
|
}
|
|
7030
7135
|
}
|
|
7031
7136
|
async exchangeToken(options) {
|
|
7032
|
-
return "connection" in options ? _assertClassBrand(
|
|
7137
|
+
return "connection" in options ? _assertClassBrand(_Class9_brand, this, _exchangeTokenVaultToken).call(this, options) : _assertClassBrand(_Class9_brand, this, _exchangeProfileToken).call(this, options);
|
|
7033
7138
|
}
|
|
7034
7139
|
async getTokenByCode(url, options) {
|
|
7035
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7140
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7036
7141
|
try {
|
|
7037
7142
|
const tokenEndpointResponse = await authorizationCodeGrant(configuration, url, {
|
|
7038
7143
|
pkceCodeVerifier: options.codeVerifier
|
|
@@ -7043,16 +7148,23 @@
|
|
|
7043
7148
|
}
|
|
7044
7149
|
}
|
|
7045
7150
|
async getTokenByRefreshToken(options) {
|
|
7046
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7151
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7152
|
+
const additionalParameters = new URLSearchParams;
|
|
7153
|
+
if (options.audience) {
|
|
7154
|
+
additionalParameters.append("audience", options.audience);
|
|
7155
|
+
}
|
|
7156
|
+
if (options.scope) {
|
|
7157
|
+
additionalParameters.append("scope", options.scope);
|
|
7158
|
+
}
|
|
7047
7159
|
try {
|
|
7048
|
-
const tokenEndpointResponse = await refreshTokenGrant(configuration, options.refreshToken);
|
|
7160
|
+
const tokenEndpointResponse = await refreshTokenGrant(configuration, options.refreshToken, additionalParameters);
|
|
7049
7161
|
return TokenResponse.fromTokenEndpointResponse(tokenEndpointResponse);
|
|
7050
7162
|
} catch (e) {
|
|
7051
7163
|
throw new TokenByRefreshTokenError("The access token has expired and there was an error while trying to refresh it.", e);
|
|
7052
7164
|
}
|
|
7053
7165
|
}
|
|
7054
7166
|
async getTokenByClientCredentials(options) {
|
|
7055
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7167
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7056
7168
|
try {
|
|
7057
7169
|
const params = new URLSearchParams({
|
|
7058
7170
|
audience: options.audience
|
|
@@ -7067,7 +7179,7 @@
|
|
|
7067
7179
|
}
|
|
7068
7180
|
}
|
|
7069
7181
|
async buildLogoutUrl(options) {
|
|
7070
|
-
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7182
|
+
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7071
7183
|
if (!serverMetadata.end_session_endpoint) {
|
|
7072
7184
|
const url = new URL("https://".concat(_classPrivateFieldGet2(_options, this).domain, "/v2/logout"));
|
|
7073
7185
|
url.searchParams.set("returnTo", options.returnTo);
|
|
@@ -7079,9 +7191,13 @@
|
|
|
7079
7191
|
});
|
|
7080
7192
|
}
|
|
7081
7193
|
async verifyLogoutToken(options) {
|
|
7082
|
-
const {serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7083
|
-
|
|
7084
|
-
|
|
7194
|
+
const {serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7195
|
+
const cacheConfig = resolveCacheConfig(_classPrivateFieldGet2(_options, this).discoveryCache);
|
|
7196
|
+
const jwksUri = serverMetadata.jwks_uri;
|
|
7197
|
+
_classPrivateFieldGet2(_jwks, this) || _classPrivateFieldSet2(_jwks, this, createRemoteJWKSet(new URL(jwksUri), {
|
|
7198
|
+
cacheMaxAge: cacheConfig.ttlMs,
|
|
7199
|
+
[customFetch]: _classPrivateFieldGet2(_customFetch2, this),
|
|
7200
|
+
[jwksCache]: _classPrivateFieldGet2(_jwksCache, this)
|
|
7085
7201
|
}));
|
|
7086
7202
|
const {payload: payload} = await jwtVerify(options.logoutToken, _classPrivateFieldGet2(_jwks, this), {
|
|
7087
7203
|
issuer: serverMetadata.issuer,
|
|
@@ -7119,6 +7235,16 @@
|
|
|
7119
7235
|
};
|
|
7120
7236
|
}
|
|
7121
7237
|
});
|
|
7238
|
+
function _getDiscoveryCacheKey() {
|
|
7239
|
+
const domain = _classPrivateFieldGet2(_options, this).domain.toLowerCase();
|
|
7240
|
+
return "".concat(domain, "|mtls:").concat(_classPrivateFieldGet2(_options, this).useMtls ? "1" : "0");
|
|
7241
|
+
}
|
|
7242
|
+
async function _createConfiguration(serverMetadata) {
|
|
7243
|
+
const clientAuth = await _assertClassBrand(_Class9_brand, this, _getClientAuth).call(this);
|
|
7244
|
+
const configuration = new Configuration(serverMetadata, _classPrivateFieldGet2(_options, this).clientId, _classPrivateFieldGet2(_options, this).clientSecret, clientAuth);
|
|
7245
|
+
configuration[customFetch$1] = _classPrivateFieldGet2(_customFetch2, this);
|
|
7246
|
+
return configuration;
|
|
7247
|
+
}
|
|
7122
7248
|
async function _discover() {
|
|
7123
7249
|
if (_classPrivateFieldGet2(_configuration, this) && _classPrivateFieldGet2(_serverMetadata, this)) {
|
|
7124
7250
|
return {
|
|
@@ -7126,14 +7252,58 @@
|
|
|
7126
7252
|
serverMetadata: _classPrivateFieldGet2(_serverMetadata, this)
|
|
7127
7253
|
};
|
|
7128
7254
|
}
|
|
7129
|
-
const
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7255
|
+
const cacheKey = _assertClassBrand(_Class9_brand, this, _getDiscoveryCacheKey).call(this);
|
|
7256
|
+
const cached = _classPrivateFieldGet2(_discoveryCache, this).get(cacheKey);
|
|
7257
|
+
if (cached) {
|
|
7258
|
+
_classPrivateFieldSet2(_serverMetadata, this, cached.serverMetadata);
|
|
7259
|
+
_classPrivateFieldSet2(_configuration, this, await _assertClassBrand(_Class9_brand, this, _createConfiguration).call(this, cached.serverMetadata));
|
|
7260
|
+
return {
|
|
7261
|
+
configuration: _classPrivateFieldGet2(_configuration, this),
|
|
7262
|
+
serverMetadata: _classPrivateFieldGet2(_serverMetadata, this)
|
|
7263
|
+
};
|
|
7264
|
+
}
|
|
7265
|
+
const inFlight = _classPrivateFieldGet2(_inFlightDiscovery, this).get(cacheKey);
|
|
7266
|
+
if (inFlight) {
|
|
7267
|
+
const entry = await inFlight;
|
|
7268
|
+
_classPrivateFieldSet2(_serverMetadata, this, entry.serverMetadata);
|
|
7269
|
+
_classPrivateFieldSet2(_configuration, this, await _assertClassBrand(_Class9_brand, this, _createConfiguration).call(this, entry.serverMetadata));
|
|
7270
|
+
return {
|
|
7271
|
+
configuration: _classPrivateFieldGet2(_configuration, this),
|
|
7272
|
+
serverMetadata: _classPrivateFieldGet2(_serverMetadata, this)
|
|
7273
|
+
};
|
|
7274
|
+
}
|
|
7275
|
+
const discoveryPromise = (async () => {
|
|
7276
|
+
const clientAuth = await _assertClassBrand(_Class9_brand, this, _getClientAuth).call(this);
|
|
7277
|
+
const configuration = await discovery(new URL("https://".concat(_classPrivateFieldGet2(_options, this).domain)), _classPrivateFieldGet2(_options, this).clientId, {
|
|
7278
|
+
use_mtls_endpoint_aliases: _classPrivateFieldGet2(_options, this).useMtls
|
|
7279
|
+
}, clientAuth, {
|
|
7280
|
+
[customFetch$1]: _classPrivateFieldGet2(_customFetch2, this)
|
|
7281
|
+
});
|
|
7282
|
+
const serverMetadata = configuration.serverMetadata();
|
|
7283
|
+
_classPrivateFieldGet2(_discoveryCache, this).set(cacheKey, {
|
|
7284
|
+
serverMetadata: serverMetadata
|
|
7285
|
+
});
|
|
7286
|
+
return {
|
|
7287
|
+
configuration: configuration,
|
|
7288
|
+
serverMetadata: serverMetadata
|
|
7289
|
+
};
|
|
7290
|
+
})();
|
|
7291
|
+
const inFlightEntry = discoveryPromise.then(_ref3 => {
|
|
7292
|
+
let {serverMetadata: serverMetadata} = _ref3;
|
|
7293
|
+
return {
|
|
7294
|
+
serverMetadata: serverMetadata
|
|
7295
|
+
};
|
|
7296
|
+
});
|
|
7297
|
+
void inFlightEntry.catch(() => void 0);
|
|
7298
|
+
_classPrivateFieldGet2(_inFlightDiscovery, this).set(cacheKey, inFlightEntry);
|
|
7299
|
+
try {
|
|
7300
|
+
const {configuration: configuration, serverMetadata: serverMetadata} = await discoveryPromise;
|
|
7301
|
+
_classPrivateFieldSet2(_configuration, this, configuration);
|
|
7302
|
+
_classPrivateFieldSet2(_serverMetadata, this, serverMetadata);
|
|
7303
|
+
_classPrivateFieldGet2(_configuration, this)[customFetch$1] = _classPrivateFieldGet2(_customFetch2, this);
|
|
7304
|
+
} finally {
|
|
7305
|
+
_classPrivateFieldGet2(_inFlightDiscovery, this).delete(cacheKey);
|
|
7306
|
+
}
|
|
7137
7307
|
return {
|
|
7138
7308
|
configuration: _classPrivateFieldGet2(_configuration, this),
|
|
7139
7309
|
serverMetadata: _classPrivateFieldGet2(_serverMetadata, this)
|
|
@@ -7141,7 +7311,7 @@
|
|
|
7141
7311
|
}
|
|
7142
7312
|
async function _exchangeTokenVaultToken(options) {
|
|
7143
7313
|
var _options$subjectToken, _options$requestedTok;
|
|
7144
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7314
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7145
7315
|
if ("audience" in options || "resource" in options) {
|
|
7146
7316
|
throw new TokenExchangeError("audience and resource parameters are not supported for Token Vault exchanges");
|
|
7147
7317
|
}
|
|
@@ -7167,7 +7337,7 @@
|
|
|
7167
7337
|
}
|
|
7168
7338
|
}
|
|
7169
7339
|
async function _exchangeProfileToken(options) {
|
|
7170
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7340
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7171
7341
|
validateSubjectToken(options.subjectToken);
|
|
7172
7342
|
const tokenRequestParams = new URLSearchParams({
|
|
7173
7343
|
subject_token_type: options.subjectTokenType,
|
|
@@ -7194,20 +7364,28 @@
|
|
|
7194
7364
|
}
|
|
7195
7365
|
}
|
|
7196
7366
|
async function _getClientAuth() {
|
|
7197
|
-
if (!_classPrivateFieldGet2(
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7367
|
+
if (!_classPrivateFieldGet2(_clientAuthPromise, this)) {
|
|
7368
|
+
_classPrivateFieldSet2(_clientAuthPromise, this, (async () => {
|
|
7369
|
+
if (!_classPrivateFieldGet2(_options, this).clientSecret && !_classPrivateFieldGet2(_options, this).clientAssertionSigningKey && !_classPrivateFieldGet2(_options, this).useMtls) {
|
|
7370
|
+
throw new MissingClientAuthError;
|
|
7371
|
+
}
|
|
7372
|
+
if (_classPrivateFieldGet2(_options, this).useMtls) {
|
|
7373
|
+
return TlsClientAuth();
|
|
7374
|
+
}
|
|
7375
|
+
let clientPrivateKey = _classPrivateFieldGet2(_options, this).clientAssertionSigningKey;
|
|
7376
|
+
if (clientPrivateKey && !(clientPrivateKey instanceof CryptoKey)) {
|
|
7377
|
+
clientPrivateKey = await importPKCS8(clientPrivateKey, _classPrivateFieldGet2(_options, this).clientAssertionSigningAlg || "RS256");
|
|
7378
|
+
}
|
|
7379
|
+
return clientPrivateKey ? PrivateKeyJwt(clientPrivateKey) : ClientSecretPost(_classPrivateFieldGet2(_options, this).clientSecret);
|
|
7380
|
+
})().catch(error => {
|
|
7381
|
+
_classPrivateFieldSet2(_clientAuthPromise, this, void 0);
|
|
7382
|
+
throw error;
|
|
7383
|
+
}));
|
|
7206
7384
|
}
|
|
7207
|
-
return
|
|
7385
|
+
return _classPrivateFieldGet2(_clientAuthPromise, this);
|
|
7208
7386
|
}
|
|
7209
7387
|
async function _buildAuthorizationUrl(options) {
|
|
7210
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7388
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7211
7389
|
const codeChallengeMethod = "S256";
|
|
7212
7390
|
const codeVerifier = randomPKCECodeVerifier();
|
|
7213
7391
|
const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);
|
|
@@ -7323,15 +7501,15 @@
|
|
|
7323
7501
|
if (!((_a = context === null || context === void 0 ? void 0 : context.mfaRequirements) === null || _a === void 0 ? void 0 : _a.challenge) || context.mfaRequirements.challenge.length === 0) {
|
|
7324
7502
|
throw new MfaListAuthenticatorsError("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
|
|
7325
7503
|
}
|
|
7326
|
-
const challengeTypes = context.mfaRequirements.challenge.map(
|
|
7504
|
+
const challengeTypes = context.mfaRequirements.challenge.map(c => c.type);
|
|
7327
7505
|
try {
|
|
7328
7506
|
const allAuthenticators = await this.authJsMfaClient.listAuthenticators({
|
|
7329
7507
|
mfaToken: mfaToken
|
|
7330
7508
|
});
|
|
7331
|
-
return allAuthenticators.filter(
|
|
7509
|
+
return allAuthenticators.filter(auth => {
|
|
7332
7510
|
if (!auth.type) return false;
|
|
7333
7511
|
return challengeTypes.includes(auth.type);
|
|
7334
|
-
})
|
|
7512
|
+
});
|
|
7335
7513
|
} catch (error) {
|
|
7336
7514
|
if (error instanceof MfaListAuthenticatorsError$1) {
|
|
7337
7515
|
throw new MfaListAuthenticatorsError((_b = error.cause) === null || _b === void 0 ? void 0 : _b.error, error.message);
|
|
@@ -7696,7 +7874,7 @@
|
|
|
7696
7874
|
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)
|
|
7697
7875
|
})
|
|
7698
7876
|
});
|
|
7699
|
-
const result = await singlePromise((
|
|
7877
|
+
const result = await singlePromise(() => this._getTokenSilently(localOptions), "".concat(this.options.clientId, "::").concat(localOptions.authorizationParams.audience, "::").concat(localOptions.authorizationParams.scope));
|
|
7700
7878
|
return options.detailedResponse ? result : result === null || result === void 0 ? void 0 : result.access_token;
|
|
7701
7879
|
}
|
|
7702
7880
|
async _getTokenSilently(options) {
|
|
@@ -7717,7 +7895,7 @@
|
|
|
7717
7895
|
}
|
|
7718
7896
|
const lockKey = buildGetTokenSilentlyLockKey(this.options.clientId, getTokenOptions.authorizationParams.audience || "default");
|
|
7719
7897
|
try {
|
|
7720
|
-
return await this.lockManager.runWithLock(lockKey, 5e3,
|
|
7898
|
+
return await this.lockManager.runWithLock(lockKey, 5e3, async () => {
|
|
7721
7899
|
if (cacheMode !== "off") {
|
|
7722
7900
|
const entry = await this._getEntryFromCache({
|
|
7723
7901
|
scope: getTokenOptions.authorizationParams.scope,
|
|
@@ -7739,7 +7917,7 @@
|
|
|
7739
7917
|
} : null), {
|
|
7740
7918
|
expires_in: expires_in
|
|
7741
7919
|
});
|
|
7742
|
-
})
|
|
7920
|
+
});
|
|
7743
7921
|
} catch (error) {
|
|
7744
7922
|
if (this._isInteractiveError(error) && this.options.interactiveErrorHandler === "popup") {
|
|
7745
7923
|
return await this._handleInteractiveErrorWithPopup(getTokenOptions);
|
|
@@ -7833,7 +8011,7 @@
|
|
|
7833
8011
|
async _getTokenFromIFrame(options) {
|
|
7834
8012
|
const iframeLockKey = buildIframeLockKey(this.options.clientId);
|
|
7835
8013
|
try {
|
|
7836
|
-
return await this.lockManager.runWithLock(iframeLockKey, 5e3,
|
|
8014
|
+
return await this.lockManager.runWithLock(iframeLockKey, 5e3, async () => {
|
|
7837
8015
|
const params = Object.assign(Object.assign({}, options.authorizationParams), {
|
|
7838
8016
|
prompt: "none"
|
|
7839
8017
|
});
|
|
@@ -7873,7 +8051,7 @@
|
|
|
7873
8051
|
oauthTokenScope: tokenResult.scope,
|
|
7874
8052
|
audience: audience
|
|
7875
8053
|
});
|
|
7876
|
-
})
|
|
8054
|
+
});
|
|
7877
8055
|
} catch (e) {
|
|
7878
8056
|
if (e.error === "login_required") {
|
|
7879
8057
|
const shouldSkipLogoutForMfaStepUp = e instanceof GenericError && this._isIframeMfaError(e) && this.options.interactiveErrorHandler === "popup";
|
|
@@ -8160,5 +8338,5 @@
|
|
|
8160
8338
|
Object.defineProperty(exports, "__esModule", {
|
|
8161
8339
|
value: true
|
|
8162
8340
|
});
|
|
8163
|
-
})
|
|
8341
|
+
});
|
|
8164
8342
|
//# sourceMappingURL=auth0-spa-js.development.js.map
|