@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
|
@@ -18,7 +18,7 @@ typeof SuppressedError === "function" ? SuppressedError : function(error, suppre
|
|
|
18
18
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
var version = "2.17.
|
|
21
|
+
var version = "2.17.1";
|
|
22
22
|
|
|
23
23
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
24
24
|
|
|
@@ -175,7 +175,7 @@ const parseAuthenticationResult = queryString => {
|
|
|
175
175
|
|
|
176
176
|
const runIframe = function runIframe(authorizeUrl, eventOrigin) {
|
|
177
177
|
let timeoutInSeconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS;
|
|
178
|
-
return new Promise((
|
|
178
|
+
return new Promise((res, rej) => {
|
|
179
179
|
const iframe = window.document.createElement("iframe");
|
|
180
180
|
iframe.setAttribute("width", "0");
|
|
181
181
|
iframe.setAttribute("height", "0");
|
|
@@ -187,10 +187,10 @@ const runIframe = function runIframe(authorizeUrl, eventOrigin) {
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
let _iframeEventHandler;
|
|
190
|
-
const timeoutSetTimeoutId = setTimeout((
|
|
190
|
+
const timeoutSetTimeoutId = setTimeout(() => {
|
|
191
191
|
rej(new TimeoutError);
|
|
192
192
|
removeIframe();
|
|
193
|
-
}
|
|
193
|
+
}, timeoutInSeconds * 1e3);
|
|
194
194
|
_iframeEventHandler = function iframeEventHandler(e) {
|
|
195
195
|
if (e.origin != eventOrigin) return;
|
|
196
196
|
if (!e.data || e.data.type !== "authorization_response") return;
|
|
@@ -206,7 +206,7 @@ const runIframe = function runIframe(authorizeUrl, eventOrigin) {
|
|
|
206
206
|
window.addEventListener("message", _iframeEventHandler, false);
|
|
207
207
|
window.document.body.appendChild(iframe);
|
|
208
208
|
iframe.setAttribute("src", authorizeUrl);
|
|
209
|
-
})
|
|
209
|
+
});
|
|
210
210
|
};
|
|
211
211
|
|
|
212
212
|
const openPopup = url => {
|
|
@@ -217,21 +217,21 @@ const openPopup = url => {
|
|
|
217
217
|
return window.open(url, "auth0:authorize:popup", "left=".concat(left, ",top=").concat(top, ",width=").concat(width, ",height=").concat(height, ",resizable,scrollbars=yes,status=1"));
|
|
218
218
|
};
|
|
219
219
|
|
|
220
|
-
const runPopup = config => new Promise((
|
|
220
|
+
const runPopup = config => new Promise((resolve, reject) => {
|
|
221
221
|
let _popupEventListener;
|
|
222
|
-
const popupTimer = setInterval((
|
|
222
|
+
const popupTimer = setInterval(() => {
|
|
223
223
|
if (config.popup && config.popup.closed) {
|
|
224
224
|
clearInterval(popupTimer);
|
|
225
225
|
clearTimeout(timeoutId);
|
|
226
226
|
window.removeEventListener("message", _popupEventListener, false);
|
|
227
227
|
reject(new PopupCancelledError(config.popup));
|
|
228
228
|
}
|
|
229
|
-
}
|
|
230
|
-
const timeoutId = setTimeout((
|
|
229
|
+
}, 1e3);
|
|
230
|
+
const timeoutId = setTimeout(() => {
|
|
231
231
|
clearInterval(popupTimer);
|
|
232
232
|
reject(new PopupTimeoutError(config.popup));
|
|
233
233
|
window.removeEventListener("message", _popupEventListener, false);
|
|
234
|
-
}
|
|
234
|
+
}, (config.timeoutInSeconds || DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) * 1e3);
|
|
235
235
|
_popupEventListener = function popupEventListener(e) {
|
|
236
236
|
if (!e.data || e.data.type !== "authorization_response") {
|
|
237
237
|
return;
|
|
@@ -248,7 +248,7 @@ const runPopup = config => new Promise(((resolve, reject) => {
|
|
|
248
248
|
resolve(e.data.response);
|
|
249
249
|
};
|
|
250
250
|
window.addEventListener("message", _popupEventListener);
|
|
251
|
-
})
|
|
251
|
+
});
|
|
252
252
|
|
|
253
253
|
const getCrypto = () => window.crypto;
|
|
254
254
|
|
|
@@ -256,15 +256,15 @@ const createRandomString = () => {
|
|
|
256
256
|
const charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
|
|
257
257
|
let random = "";
|
|
258
258
|
const randomValues = Array.from(getCrypto().getRandomValues(new Uint8Array(43)));
|
|
259
|
-
randomValues.forEach(
|
|
259
|
+
randomValues.forEach(v => random += charset[v % charset.length]);
|
|
260
260
|
return random;
|
|
261
261
|
};
|
|
262
262
|
|
|
263
263
|
const encode$2 = value => btoa(value);
|
|
264
264
|
|
|
265
|
-
const stripUndefined = params => Object.keys(params).filter(
|
|
265
|
+
const stripUndefined = params => Object.keys(params).filter(k => typeof params[k] !== "undefined").reduce((acc, key) => Object.assign(Object.assign({}, acc), {
|
|
266
266
|
[key]: params[key]
|
|
267
|
-
})
|
|
267
|
+
}), {});
|
|
268
268
|
|
|
269
269
|
const ALLOWED_AUTH0CLIENT_PROPERTIES = [ {
|
|
270
270
|
key: "name",
|
|
@@ -279,16 +279,16 @@ const ALLOWED_AUTH0CLIENT_PROPERTIES = [ {
|
|
|
279
279
|
|
|
280
280
|
const stripAuth0Client = function stripAuth0Client(auth0Client) {
|
|
281
281
|
let excludeEnv = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
282
|
-
return Object.keys(auth0Client).reduce((
|
|
282
|
+
return Object.keys(auth0Client).reduce((acc, key) => {
|
|
283
283
|
if (excludeEnv && key === "env") {
|
|
284
284
|
return acc;
|
|
285
285
|
}
|
|
286
|
-
const allowedProperty = ALLOWED_AUTH0CLIENT_PROPERTIES.find(
|
|
286
|
+
const allowedProperty = ALLOWED_AUTH0CLIENT_PROPERTIES.find(p => p.key === key);
|
|
287
287
|
if (allowedProperty && allowedProperty.type.includes(typeof auth0Client[key])) {
|
|
288
288
|
acc[key] = auth0Client[key];
|
|
289
289
|
}
|
|
290
290
|
return acc;
|
|
291
|
-
}
|
|
291
|
+
}, {});
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
const createQueryParams = _a => {
|
|
@@ -311,10 +311,10 @@ const urlEncodeB64 = input => {
|
|
|
311
311
|
"/": "_",
|
|
312
312
|
"=": ""
|
|
313
313
|
};
|
|
314
|
-
return input.replace(/[+/=]/g,
|
|
314
|
+
return input.replace(/[+/=]/g, m => b64Chars[m]);
|
|
315
315
|
};
|
|
316
316
|
|
|
317
|
-
const decodeB64 = input => decodeURIComponent(atob(input).split("").map(
|
|
317
|
+
const decodeB64 = input => decodeURIComponent(atob(input).split("").map(c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join(""));
|
|
318
318
|
|
|
319
319
|
const urlDecodeB64 = input => decodeB64(input.replace(/_/g, "/").replace(/-/g, "+"));
|
|
320
320
|
|
|
@@ -353,11 +353,11 @@ const parseNumber = value => {
|
|
|
353
353
|
return parseInt(value, 10) || undefined;
|
|
354
354
|
};
|
|
355
355
|
|
|
356
|
-
const fromEntries = iterable => [ ...iterable ].reduce((
|
|
356
|
+
const fromEntries = iterable => [ ...iterable ].reduce((obj, _ref) => {
|
|
357
357
|
let [key, val] = _ref;
|
|
358
358
|
obj[key] = val;
|
|
359
359
|
return obj;
|
|
360
|
-
}
|
|
360
|
+
}, {});
|
|
361
361
|
|
|
362
362
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
363
363
|
|
|
@@ -392,14 +392,14 @@ var ProcessLocking = function() {
|
|
|
392
392
|
return _this.locked.has(key);
|
|
393
393
|
};
|
|
394
394
|
this.lock = function(key) {
|
|
395
|
-
return new Promise(
|
|
395
|
+
return new Promise(function(resolve, reject) {
|
|
396
396
|
if (_this.isLocked(key)) {
|
|
397
397
|
_this.addToLocked(key, resolve);
|
|
398
398
|
} else {
|
|
399
399
|
_this.addToLocked(key);
|
|
400
400
|
resolve();
|
|
401
401
|
}
|
|
402
|
-
})
|
|
402
|
+
});
|
|
403
403
|
};
|
|
404
404
|
this.unlock = function(key) {
|
|
405
405
|
var callbacks = _this.locked.get(key);
|
|
@@ -430,7 +430,7 @@ function getLock() {
|
|
|
430
430
|
processLock.default = getLock;
|
|
431
431
|
|
|
432
432
|
var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
433
|
-
return new (P || (P = Promise))(
|
|
433
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
434
434
|
function fulfilled(value) {
|
|
435
435
|
try {
|
|
436
436
|
step(generator.next(value));
|
|
@@ -446,12 +446,12 @@ var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg,
|
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
function step(result) {
|
|
449
|
-
result.done ? resolve(result.value) : new P(
|
|
449
|
+
result.done ? resolve(result.value) : new P(function(resolve) {
|
|
450
450
|
resolve(result.value);
|
|
451
|
-
})
|
|
451
|
+
}).then(fulfilled, rejected);
|
|
452
452
|
}
|
|
453
453
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
454
|
-
})
|
|
454
|
+
});
|
|
455
455
|
};
|
|
456
456
|
|
|
457
457
|
var __generator = commonjsGlobal && commonjsGlobal.__generator || function(thisArg, body) {
|
|
@@ -556,39 +556,39 @@ var LOCK_STORAGE_KEY = "browser-tabs-lock-key";
|
|
|
556
556
|
|
|
557
557
|
var DEFAULT_STORAGE_HANDLER = {
|
|
558
558
|
key: function(index) {
|
|
559
|
-
return __awaiter(_this, void 0, void 0,
|
|
560
|
-
return __generator(this,
|
|
559
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
560
|
+
return __generator(this, function(_a) {
|
|
561
561
|
throw new Error("Unsupported");
|
|
562
|
-
})
|
|
563
|
-
})
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
564
|
},
|
|
565
565
|
getItem: function(key) {
|
|
566
|
-
return __awaiter(_this, void 0, void 0,
|
|
567
|
-
return __generator(this,
|
|
566
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
567
|
+
return __generator(this, function(_a) {
|
|
568
568
|
throw new Error("Unsupported");
|
|
569
|
-
})
|
|
570
|
-
})
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
571
|
},
|
|
572
572
|
clear: function() {
|
|
573
|
-
return __awaiter(_this, void 0, void 0,
|
|
574
|
-
return __generator(this,
|
|
573
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
574
|
+
return __generator(this, function(_a) {
|
|
575
575
|
return [ 2, window.localStorage.clear() ];
|
|
576
|
-
})
|
|
577
|
-
})
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
578
|
},
|
|
579
579
|
removeItem: function(key) {
|
|
580
|
-
return __awaiter(_this, void 0, void 0,
|
|
581
|
-
return __generator(this,
|
|
580
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
581
|
+
return __generator(this, function(_a) {
|
|
582
582
|
throw new Error("Unsupported");
|
|
583
|
-
})
|
|
584
|
-
})
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
585
|
},
|
|
586
586
|
setItem: function(key, value) {
|
|
587
|
-
return __awaiter(_this, void 0, void 0,
|
|
588
|
-
return __generator(this,
|
|
587
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
588
|
+
return __generator(this, function(_a) {
|
|
589
589
|
throw new Error("Unsupported");
|
|
590
|
-
})
|
|
591
|
-
})
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
592
|
},
|
|
593
593
|
keySync: function(index) {
|
|
594
594
|
return window.localStorage.key(index);
|
|
@@ -608,9 +608,9 @@ var DEFAULT_STORAGE_HANDLER = {
|
|
|
608
608
|
};
|
|
609
609
|
|
|
610
610
|
function delay(milliseconds) {
|
|
611
|
-
return new Promise(
|
|
611
|
+
return new Promise(function(resolve) {
|
|
612
612
|
return setTimeout(resolve, milliseconds);
|
|
613
|
-
})
|
|
613
|
+
});
|
|
614
614
|
}
|
|
615
615
|
|
|
616
616
|
function generateRandomString(length) {
|
|
@@ -646,9 +646,9 @@ var SuperTokensLock = function() {
|
|
|
646
646
|
if (timeout === void 0) {
|
|
647
647
|
timeout = 5e3;
|
|
648
648
|
}
|
|
649
|
-
return __awaiter(this, void 0, void 0,
|
|
649
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
650
650
|
var iat, MAX_TIME, STORAGE_KEY, STORAGE, lockObj, TIMEOUT_KEY, lockObjPostDelay, parsedLockObjPostDelay;
|
|
651
|
-
return __generator(this,
|
|
651
|
+
return __generator(this, function(_a) {
|
|
652
652
|
switch (_a.label) {
|
|
653
653
|
case 0:
|
|
654
654
|
iat = Date.now() + generateRandomString(4);
|
|
@@ -707,17 +707,17 @@ var SuperTokensLock = function() {
|
|
|
707
707
|
case 8:
|
|
708
708
|
return [ 2, false ];
|
|
709
709
|
}
|
|
710
|
-
})
|
|
711
|
-
})
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
712
|
};
|
|
713
713
|
SuperTokensLock.prototype.refreshLockWhileAcquired = function(storageKey, iat) {
|
|
714
|
-
return __awaiter(this, void 0, void 0,
|
|
714
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
715
715
|
var _this = this;
|
|
716
|
-
return __generator(this,
|
|
717
|
-
setTimeout(
|
|
718
|
-
return __awaiter(_this, void 0, void 0,
|
|
716
|
+
return __generator(this, function(_a) {
|
|
717
|
+
setTimeout(function() {
|
|
718
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
719
719
|
var STORAGE, lockObj, parsedLockObj;
|
|
720
|
-
return __generator(this,
|
|
720
|
+
return __generator(this, function(_a) {
|
|
721
721
|
switch (_a.label) {
|
|
722
722
|
case 0:
|
|
723
723
|
return [ 4, processLock_1.default().lock(iat) ];
|
|
@@ -742,19 +742,19 @@ var SuperTokensLock = function() {
|
|
|
742
742
|
this.refreshLockWhileAcquired(storageKey, iat);
|
|
743
743
|
return [ 2 ];
|
|
744
744
|
}
|
|
745
|
-
})
|
|
746
|
-
})
|
|
747
|
-
}
|
|
745
|
+
});
|
|
746
|
+
});
|
|
747
|
+
}, 1e3);
|
|
748
748
|
return [ 2 ];
|
|
749
|
-
})
|
|
750
|
-
})
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
751
|
};
|
|
752
752
|
SuperTokensLock.prototype.waitForSomethingToChange = function(MAX_TIME) {
|
|
753
|
-
return __awaiter(this, void 0, void 0,
|
|
754
|
-
return __generator(this,
|
|
753
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
754
|
+
return __generator(this, function(_a) {
|
|
755
755
|
switch (_a.label) {
|
|
756
756
|
case 0:
|
|
757
|
-
return [ 4, new Promise(
|
|
757
|
+
return [ 4, new Promise(function(resolve) {
|
|
758
758
|
var resolvedCalled = false;
|
|
759
759
|
var startedAt = Date.now();
|
|
760
760
|
var MIN_TIME_TO_WAIT = 50;
|
|
@@ -779,14 +779,14 @@ var SuperTokensLock = function() {
|
|
|
779
779
|
window.addEventListener("storage", stopWaiting);
|
|
780
780
|
SuperTokensLock.addToWaiting(stopWaiting);
|
|
781
781
|
var timeOutId = setTimeout(stopWaiting, Math.max(0, MAX_TIME - Date.now()));
|
|
782
|
-
})
|
|
782
|
+
}) ];
|
|
783
783
|
|
|
784
784
|
case 1:
|
|
785
785
|
_a.sent();
|
|
786
786
|
return [ 2 ];
|
|
787
787
|
}
|
|
788
|
-
})
|
|
789
|
-
})
|
|
788
|
+
});
|
|
789
|
+
});
|
|
790
790
|
};
|
|
791
791
|
SuperTokensLock.addToWaiting = function(func) {
|
|
792
792
|
this.removeFromWaiting(func);
|
|
@@ -799,22 +799,22 @@ var SuperTokensLock = function() {
|
|
|
799
799
|
if (SuperTokensLock.waiters === undefined) {
|
|
800
800
|
return;
|
|
801
801
|
}
|
|
802
|
-
SuperTokensLock.waiters = SuperTokensLock.waiters.filter(
|
|
802
|
+
SuperTokensLock.waiters = SuperTokensLock.waiters.filter(function(i) {
|
|
803
803
|
return i !== func;
|
|
804
|
-
})
|
|
804
|
+
});
|
|
805
805
|
};
|
|
806
806
|
SuperTokensLock.notifyWaiters = function() {
|
|
807
807
|
if (SuperTokensLock.waiters === undefined) {
|
|
808
808
|
return;
|
|
809
809
|
}
|
|
810
810
|
var waiters = SuperTokensLock.waiters.slice();
|
|
811
|
-
waiters.forEach(
|
|
811
|
+
waiters.forEach(function(i) {
|
|
812
812
|
return i();
|
|
813
|
-
})
|
|
813
|
+
});
|
|
814
814
|
};
|
|
815
815
|
SuperTokensLock.prototype.releaseLock = function(lockKey) {
|
|
816
|
-
return __awaiter(this, void 0, void 0,
|
|
817
|
-
return __generator(this,
|
|
816
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
817
|
+
return __generator(this, function(_a) {
|
|
818
818
|
switch (_a.label) {
|
|
819
819
|
case 0:
|
|
820
820
|
return [ 4, this.releaseLock__private__(lockKey) ];
|
|
@@ -822,13 +822,13 @@ var SuperTokensLock = function() {
|
|
|
822
822
|
case 1:
|
|
823
823
|
return [ 2, _a.sent() ];
|
|
824
824
|
}
|
|
825
|
-
})
|
|
826
|
-
})
|
|
825
|
+
});
|
|
826
|
+
});
|
|
827
827
|
};
|
|
828
828
|
SuperTokensLock.prototype.releaseLock__private__ = function(lockKey) {
|
|
829
|
-
return __awaiter(this, void 0, void 0,
|
|
829
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
830
830
|
var STORAGE, STORAGE_KEY, lockObj, parsedlockObj;
|
|
831
|
-
return __generator(this,
|
|
831
|
+
return __generator(this, function(_a) {
|
|
832
832
|
switch (_a.label) {
|
|
833
833
|
case 0:
|
|
834
834
|
STORAGE = this.storageHandler === undefined ? DEFAULT_STORAGE_HANDLER : this.storageHandler;
|
|
@@ -852,8 +852,8 @@ var SuperTokensLock = function() {
|
|
|
852
852
|
case 2:
|
|
853
853
|
return [ 2 ];
|
|
854
854
|
}
|
|
855
|
-
})
|
|
856
|
-
})
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
857
|
};
|
|
858
858
|
SuperTokensLock.lockCorrector = function(storageHandler) {
|
|
859
859
|
var MIN_ALLOWED_TIME = Date.now() - 5e3;
|
|
@@ -895,16 +895,16 @@ var _default = browserTabsLock.default = SuperTokensLock;
|
|
|
895
895
|
class WebLocksApiManager {
|
|
896
896
|
async runWithLock(key, timeout, callback) {
|
|
897
897
|
const controller = new AbortController;
|
|
898
|
-
const timeoutId = setTimeout((
|
|
898
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
899
899
|
try {
|
|
900
900
|
return await navigator.locks.request(key, {
|
|
901
901
|
mode: "exclusive",
|
|
902
902
|
signal: controller.signal
|
|
903
|
-
},
|
|
903
|
+
}, async lock => {
|
|
904
904
|
clearTimeout(timeoutId);
|
|
905
905
|
if (!lock) throw new Error("Lock not available");
|
|
906
906
|
return await callback();
|
|
907
|
-
})
|
|
907
|
+
});
|
|
908
908
|
} catch (error) {
|
|
909
909
|
clearTimeout(timeoutId);
|
|
910
910
|
if ((error === null || error === void 0 ? void 0 : error.name) === "AbortError") throw new TimeoutError;
|
|
@@ -918,7 +918,7 @@ class LegacyLockManager {
|
|
|
918
918
|
this.activeLocks = new Set;
|
|
919
919
|
this.lock = new _default;
|
|
920
920
|
this.pagehideHandler = () => {
|
|
921
|
-
this.activeLocks.forEach(
|
|
921
|
+
this.activeLocks.forEach(key => this.lock.releaseLock(key));
|
|
922
922
|
this.activeLocks.clear();
|
|
923
923
|
};
|
|
924
924
|
}
|
|
@@ -1306,7 +1306,7 @@ function isGrantTypeSupported(grantType) {
|
|
|
1306
1306
|
return SUPPORTED_GRANT_TYPES.includes(grantType);
|
|
1307
1307
|
}
|
|
1308
1308
|
|
|
1309
|
-
const sendMessage = (message, to) => new Promise(
|
|
1309
|
+
const sendMessage = (message, to) => new Promise(function(resolve, reject) {
|
|
1310
1310
|
const messageChannel = new MessageChannel;
|
|
1311
1311
|
messageChannel.port1.onmessage = function(event) {
|
|
1312
1312
|
if (event.data.error) {
|
|
@@ -1317,7 +1317,7 @@ const sendMessage = (message, to) => new Promise((function(resolve, reject) {
|
|
|
1317
1317
|
messageChannel.port1.close();
|
|
1318
1318
|
};
|
|
1319
1319
|
to.postMessage(message, [ messageChannel.port2 ]);
|
|
1320
|
-
})
|
|
1320
|
+
});
|
|
1321
1321
|
|
|
1322
1322
|
const createAbortController = () => new AbortController;
|
|
1323
1323
|
|
|
@@ -1334,14 +1334,14 @@ const fetchWithoutWorker = async (fetchUrl, fetchOptions, timeout) => {
|
|
|
1334
1334
|
const controller = createAbortController();
|
|
1335
1335
|
fetchOptions.signal = controller.signal;
|
|
1336
1336
|
let timeoutId;
|
|
1337
|
-
return Promise.race([ dofetch(fetchUrl, fetchOptions), new Promise((
|
|
1338
|
-
timeoutId = setTimeout((
|
|
1337
|
+
return Promise.race([ dofetch(fetchUrl, fetchOptions), new Promise((_, reject) => {
|
|
1338
|
+
timeoutId = setTimeout(() => {
|
|
1339
1339
|
controller.abort();
|
|
1340
1340
|
reject(new Error("Timeout when executing 'fetch'"));
|
|
1341
|
-
}
|
|
1342
|
-
})
|
|
1341
|
+
}, timeout);
|
|
1342
|
+
}) ]).finally(() => {
|
|
1343
1343
|
clearTimeout(timeoutId);
|
|
1344
|
-
})
|
|
1344
|
+
});
|
|
1345
1345
|
};
|
|
1346
1346
|
|
|
1347
1347
|
const fetchWithWorker = async (fetchUrl, audience, scope, fetchOptions, timeout, worker, useFormData, useMrrt) => sendMessage({
|
|
@@ -1463,10 +1463,10 @@ const injectDefaultScopes = function injectDefaultScopes(authScopes, openIdScope
|
|
|
1463
1463
|
let requestedScopes = {
|
|
1464
1464
|
[DEFAULT_AUDIENCE]: getUniqueScopes(openIdScope, ...extraScopes)
|
|
1465
1465
|
};
|
|
1466
|
-
Object.keys(authScopes).forEach(
|
|
1466
|
+
Object.keys(authScopes).forEach(key => {
|
|
1467
1467
|
const audienceScopes = authScopes[key];
|
|
1468
1468
|
requestedScopes[key] = getUniqueScopes(openIdScope, audienceScopes, ...extraScopes);
|
|
1469
|
-
})
|
|
1469
|
+
});
|
|
1470
1470
|
return requestedScopes;
|
|
1471
1471
|
};
|
|
1472
1472
|
|
|
@@ -1534,7 +1534,7 @@ class LocalStorageCache {
|
|
|
1534
1534
|
localStorage.removeItem(key);
|
|
1535
1535
|
}
|
|
1536
1536
|
allKeys() {
|
|
1537
|
-
return Object.keys(window.localStorage).filter(
|
|
1537
|
+
return Object.keys(window.localStorage).filter(key => key.startsWith(CACHE_KEY_PREFIX));
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
1540
|
|
|
@@ -1672,10 +1672,10 @@ class CacheManager {
|
|
|
1672
1672
|
var _a;
|
|
1673
1673
|
const keys = await this.getCacheKeys();
|
|
1674
1674
|
if (!keys) return;
|
|
1675
|
-
await keys.filter(
|
|
1675
|
+
await keys.filter(key => clientId ? key.includes(clientId) : true).reduce(async (memo, key) => {
|
|
1676
1676
|
await memo;
|
|
1677
1677
|
await this.cache.remove(key);
|
|
1678
|
-
}
|
|
1678
|
+
}, Promise.resolve());
|
|
1679
1679
|
await ((_a = this.keyManifest) === null || _a === void 0 ? void 0 : _a.clear());
|
|
1680
1680
|
}
|
|
1681
1681
|
async wrapCacheEntry(entry) {
|
|
@@ -1700,14 +1700,14 @@ class CacheManager {
|
|
|
1700
1700
|
}, CACHE_KEY_PREFIX, CACHE_KEY_ID_TOKEN_SUFFIX).toKey();
|
|
1701
1701
|
}
|
|
1702
1702
|
matchExistingCacheKey(keyToMatch, allKeys) {
|
|
1703
|
-
return allKeys.filter(
|
|
1703
|
+
return allKeys.filter(key => {
|
|
1704
1704
|
var _a;
|
|
1705
1705
|
const cacheKey = CacheKey.fromKey(key);
|
|
1706
1706
|
const scopeSet = new Set(cacheKey.scope && cacheKey.scope.split(" "));
|
|
1707
1707
|
const scopesToMatch = ((_a = keyToMatch.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
1708
|
-
const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((
|
|
1708
|
+
const hasAllScopes = cacheKey.scope && scopesToMatch.reduce((acc, current) => acc && scopeSet.has(current), true);
|
|
1709
1709
|
return cacheKey.prefix === CACHE_KEY_PREFIX && cacheKey.clientId === keyToMatch.clientId && cacheKey.audience === keyToMatch.audience && hasAllScopes;
|
|
1710
|
-
})
|
|
1710
|
+
})[0];
|
|
1711
1711
|
}
|
|
1712
1712
|
async getEntryWithRefreshToken(keyToMatch, allKeys) {
|
|
1713
1713
|
var _a;
|
|
@@ -1776,12 +1776,12 @@ const decode$1 = token => {
|
|
|
1776
1776
|
__raw: token
|
|
1777
1777
|
};
|
|
1778
1778
|
const user = {};
|
|
1779
|
-
Object.keys(payloadJSON).forEach(
|
|
1779
|
+
Object.keys(payloadJSON).forEach(k => {
|
|
1780
1780
|
claims[k] = payloadJSON[k];
|
|
1781
1781
|
if (!idTokendecoded.includes(k)) {
|
|
1782
1782
|
user[k] = payloadJSON[k];
|
|
1783
1783
|
}
|
|
1784
|
-
})
|
|
1784
|
+
});
|
|
1785
1785
|
return {
|
|
1786
1786
|
encoded: {
|
|
1787
1787
|
header: header,
|
|
@@ -2097,17 +2097,17 @@ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
|
|
|
2097
2097
|
};
|
|
2098
2098
|
}
|
|
2099
2099
|
|
|
2100
|
-
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBjbGFzcyBHZW5lcmljRXJyb3IgZXh0ZW5kcyBFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uKSB7CiAgICAgICAgICAgIHN1cGVyKGVycm9yX2Rlc2NyaXB0aW9uKTsKICAgICAgICAgICAgdGhpcy5lcnJvciA9IGVycm9yOwogICAgICAgICAgICB0aGlzLmVycm9yX2Rlc2NyaXB0aW9uID0gZXJyb3JfZGVzY3JpcHRpb247CiAgICAgICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLCBHZW5lcmljRXJyb3IucHJvdG90eXBlKTsKICAgICAgICB9CiAgICAgICAgc3RhdGljIGZyb21QYXlsb2FkKF9yZWYpIHsKICAgICAgICAgICAgbGV0IHtlcnJvcjogZXJyb3IsIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvcl9kZXNjcmlwdGlvbn0gPSBfcmVmOwogICAgICAgICAgICByZXR1cm4gbmV3IEdlbmVyaWNFcnJvcihlcnJvciwgZXJyb3JfZGVzY3JpcHRpb24pOwogICAgICAgIH0KICAgIH0KICAgIGNsYXNzIE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvciBleHRlbmRzIEdlbmVyaWNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoYXVkaWVuY2UsIHNjb3BlKSB7CiAgICAgICAgICAgIHN1cGVyKCJtaXNzaW5nX3JlZnJlc2hfdG9rZW4iLCAiTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyIuY29uY2F0KHZhbHVlT3JFbXB0eVN0cmluZyhhdWRpZW5jZSwgWyAiZGVmYXVsdCIgXSksICInLCBzY29wZTogJyIpLmNvbmNhdCh2YWx1ZU9yRW1wdH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leSA9PiBzY29wZXNLZXkuaW5jbHVkZXMoa2V5KSkpOwogICAgICAgICAgICAgICAgcmV0dXJuIGlzU2FtZUF1ZGllbmNlICYmIHNjb3Blc0FyZUluY2x1ZGVkOwogICAgICAgICAgICB9CiAgICAgICAgfSkpOwogICAgICAgIHJldHVybiBmaW5kQ29pbmNpZGVuY2UgPyB0cnVlIDogZmFsc2U7CiAgICB9OwogICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBhc3luYyBfcmVmMiA9PiB7CiAgICAgICAgbGV0IHtkYXRhOiB7dGltZW91dDogdGltZW91dCwgYXV0aDogYXV0aCwgZmV0Y2hVcmw6IGZldGNoVXJsLCBmZXRjaE9wdGlvbnM6IGZldGNoT3B0aW9ucywgdXNlRm9ybURhdGE6IHVzZUZvcm1EYXRhLCB1c2VNcnJ0OiB1c2VNcnJ0fSwgcG9ydHM6IFtwb3J0XX0gPSBfcmVmMjsKICAgICAgICBsZXQgaGVhZGVycyA9IHt9OwogICAgICAgIGxldCBqc29uOwogICAgICAgIGxldCByZWZyZXNoVG9rZW47CiAgICAgICAgY29uc3Qge2F1ZGllbmNlOiBhdWRpZW5jZSwgc2NvcGU6IHNjb3BlfSA9IGF1dGggfHwge307CiAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgYm9keSA9IHVzZUZvcm1EYXRhID8gZm9ybURhdGFUb09iamVjdChmZXRjaE9wdGlvbnMuYm9keSkgOiBKU09OLnBhcnNlKGZldGNoT3B0aW9ucy5ib2R5KTsKICAgICAgICAgICAgaWYgKCFib2R5LnJlZnJlc2hfdG9rZW4gJiYgYm9keS5ncmFudF90eXBlID09PSAicmVmcmVzaF90b2tlbiIpIHsKICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGdldFJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgaWYgKCFyZWZyZXNoVG9rZW4gJiYgdXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxhdGVzdFJlZnJlc2hUb2tlbiA9IHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl07CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNEb3duc2NvcGluZyA9IGNoZWNrRG93bnNjb3Bpbmcoc2NvcGUsIGF1ZGllbmNlKTsKICAgICAgICAgICAgICAgICAgICBpZiAobGF0ZXN0UmVmcmVzaFRva2VuICYmICFpc0Rvd25zY29waW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbiA9IGxhdGVzdFJlZnJlc2hUb2tlbjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBNaXNzaW5nUmVmcmVzaFRva2VuRXJyb3IoYXVkaWVuY2UsIHNjb3BlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5ib2R5ID0gdXNlRm9ybURhdGEgPyBjcmVhdGVRdWVyeVBhcmFtcyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSkgOiBKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIGJvZHkpLCB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogcmVmcmVzaFRva2VuCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IGFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgaWYgKHR5cGVvZiBBYm9ydENvbnRyb2xsZXIgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgIGFib3J0Q29udHJvbGxlciA9IG5ldyBBYm9ydENvbnRyb2xsZXI7CiAgICAgICAgICAgICAgICBmZXRjaE9wdGlvbnMuc2lnbmFsID0gYWJvcnRDb250cm9sbGVyLnNpZ25hbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgcmVzcG9uc2U7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICByZXNwb25zZSA9IGF3YWl0IFByb21pc2UucmFjZShbIHdhaXQodGltZW91dCksIGZldGNoKGZldGNoVXJsLCBPYmplY3QuYXNzaWduKHt9LCBmZXRjaE9wdGlvbnMpKSBdKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICBpZiAoYWJvcnRDb250cm9sbGVyKSBhYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgIGVycm9yOiAiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVycyA9IGZyb21FbnRyaWVzKHJlc3BvbnNlLmhlYWRlcnMpOwogICAgICAgICAgICBqc29uID0gYXdhaXQgcmVzcG9uc2UuanNvbigpOwogICAgICAgICAgICBpZiAoanNvbi5yZWZyZXNoX3Rva2VuKSB7CiAgICAgICAgICAgICAgICBpZiAodXNlTXJydCkgewogICAgICAgICAgICAgICAgICAgIHJlZnJlc2hUb2tlbnNbImxhdGVzdF9yZWZyZXNoX3Rva2VuIl0gPSBqc29uLnJlZnJlc2hfdG9rZW47CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUmVmcmVzaFRva2VucyhyZWZyZXNoVG9rZW4sIGpzb24ucmVmcmVzaF90b2tlbik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzZXRSZWZyZXNoVG9rZW4oanNvbi5yZWZyZXNoX3Rva2VuLCBhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgZGVsZXRlIGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IHJlc3BvbnNlLm9rLAogICAgICAgICAgICAgICAganNvbjoganNvbiwKICAgICAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMKICAgICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogZmFsc2UsCiAgICAgICAgICAgICAgICBqc29uOiB7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLmVycm9yLAogICAgICAgICAgICAgICAgICAgIGVycm9yX2Rlc2NyaXB0aW9uOiBlcnJvci5tZXNzYWdlCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9OwogICAgewogICAgICAgIGFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBtZXNzYWdlSGFuZGxlcik7CiAgICB9Cn0pKCk7Cgo=", null, false);
|
|
2100
|
+
var WorkerFactory = createBase64WorkerFactory("Lyogcm9sbHVwLXBsdW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ICAgICByZXR1cm4gcGFyc2VkUXVlcnk7CiAgICB9OwogICAgY29uc3QgdXBkYXRlUmVmcmVzaFRva2VucyA9IChvbGRSZWZyZXNoVG9rZW4sIG5ld1JlZnJlc2hUb2tlbikgPT4gewogICAgICAgIE9iamVjdC5lbnRyaWVzKHJlZnJlc2hUb2tlbnMpLmZvckVhY2goX3JlZiA9PiB7CiAgICAgICAgICAgIGxldCBba2V5LCB0b2tlbl0gPSBfcmVmOwogICAgICAgICAgICBpZiAodG9rZW4gPT09IG9sZFJlZnJlc2hUb2tlbikgewogICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1trZXldID0gbmV3UmVmcmVzaFRva2VuOwogICAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICB9OwogICAgY29uc3QgY2hlY2tEb3duc2NvcGluZyA9IChzY29wZSwgYXVkaWVuY2UpID0+IHsKICAgICAgICBjb25zdCBmaW5kQ29pbmNpZGVuY2UgPSBPYmplY3Qua2V5cyhyZWZyZXNoVG9rZW5zKS5maW5kKGtleSA9PiB7CiAgICAgICAgICAgIGlmIChrZXkgIT09ICJsYXRlc3RfcmVmcmVzaF90b2tlbiIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGlzU2FtZUF1ZGllbmNlID0gY2FjaGVLZXlDb250YWluc0F1ZGllbmNlKGF1ZGllbmNlLCBrZXkpOwogICAgICAgICAgICAgICAgY29uc3Qgc2NvcGVzS2V5ID0ga2V5LnNwbGl0KCJ8IilbMV0uc3BsaXQoIiAiKTsKICAgICAgICAgICAgICAgIGNvbnN0IHJlcXVlc3RlZFNjb3BlcyA9IHNjb3BlLnNwbGl0KCIgIik7CiAgICAgICAgICAgICAgICBjb25zdCBzY29wZXNBcmVJbmNsdWRlZCA9IHJlcXVlc3RlZFNjb3Blcy5ldmVyeShrZXkgPT4gc2NvcGVzS2V5LmluY2x1ZGVzKGtleSkpOwogICAgICAgICAgICAgICAgcmV0dXJuIGlzU2FtZUF1ZGllbmNlICYmIHNjb3Bl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gICAgICAgICAgICAgICAgICBjb25zdCBpc0Rvd25zY29waW5nID0gY2hlY2tEb3duc2NvcGluZyhzY29wZSwgYXVkaWVuY2UpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXRlc3RSZWZyZXNoVG9rZW4gJiYgIWlzRG93bnNjb3BpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2VuID0gbGF0ZXN0UmVmcmVzaFRva2VuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvcihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLmJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKSA6IEpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICBpZiAodHlwZW9mIEFib3J0Q29udHJvbGxlciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5zaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgUHJvbWlzZS5yYWNlKFsgd2FpdCh0aW1lb3V0KSwgZmV0Y2goZmV0Y2hVcmwsIE9iamVjdC5hc3NpZ24oe30sIGZldGNoT3B0aW9ucykpIF0pOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6ICJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCciCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXJzID0gZnJvbUVudHJpZXMocmVzcG9uc2UuaGVhZGVycyk7CiAgICAgICAgICAgIGpzb24gPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICAgIGlmIChqc29uLnJlZnJlc2hfdG9rZW4pIHsKICAgICAgICAgICAgICAgIGlmICh1c2VNcnJ0KSB7CiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFRva2Vuc1sibGF0ZXN0X3JlZnJlc2hfdG9rZW4iXSA9IGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWZyZXNoVG9rZW5zKHJlZnJlc2hUb2tlbiwganNvbi5yZWZyZXNoX3Rva2VuKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHNldFJlZnJlc2hUb2tlbihqc29uLnJlZnJlc2hfdG9rZW4sIGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgICAgICBkZWxldGUganNvbi5yZWZyZXNoX3Rva2VuOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZGVsZXRlUmVmcmVzaFRva2VuKGF1ZGllbmNlLCBzY29wZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICBvazogcmVzcG9uc2Uub2ssCiAgICAgICAgICAgICAgICBqc29uOiBqc29uLAogICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycwogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIG9rOiBmYWxzZSwKICAgICAgICAgICAgICAgIGpzb246IHsKICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3IuZXJyb3IsCiAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH07CiAgICB7CiAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsIG1lc3NhZ2VIYW5kbGVyKTsKICAgIH0KfSkoKTsKCg==", null, false);
|
|
2101
2101
|
|
|
2102
2102
|
const singlePromiseMap = {};
|
|
2103
2103
|
|
|
2104
2104
|
const singlePromise = (cb, key) => {
|
|
2105
2105
|
let promise = singlePromiseMap[key];
|
|
2106
2106
|
if (!promise) {
|
|
2107
|
-
promise = cb().finally((
|
|
2107
|
+
promise = cb().finally(() => {
|
|
2108
2108
|
delete singlePromiseMap[key];
|
|
2109
2109
|
promise = null;
|
|
2110
|
-
})
|
|
2110
|
+
});
|
|
2111
2111
|
singlePromiseMap[key] = promise;
|
|
2112
2112
|
}
|
|
2113
2113
|
return promise;
|
|
@@ -2197,13 +2197,13 @@ const patchOpenUrlWithOnRedirect = options => {
|
|
|
2197
2197
|
const allScopesAreIncluded = (scopeToInclude, scopes) => {
|
|
2198
2198
|
const scopeGroup = (scopes === null || scopes === void 0 ? void 0 : scopes.split(" ")) || [];
|
|
2199
2199
|
const scopesToInclude = (scopeToInclude === null || scopeToInclude === void 0 ? void 0 : scopeToInclude.split(" ")) || [];
|
|
2200
|
-
return scopesToInclude.every(
|
|
2200
|
+
return scopesToInclude.every(key => scopeGroup.includes(key));
|
|
2201
2201
|
};
|
|
2202
2202
|
|
|
2203
2203
|
const getMissingScopes = (requestedScope, respondedScope) => {
|
|
2204
2204
|
const requestedScopes = (requestedScope === null || requestedScope === void 0 ? void 0 : requestedScope.split(" ")) || [];
|
|
2205
2205
|
const respondedScopes = (respondedScope === null || respondedScope === void 0 ? void 0 : respondedScope.split(" ")) || [];
|
|
2206
|
-
const missingScopes = requestedScopes.filter(
|
|
2206
|
+
const missingScopes = requestedScopes.filter(scope => respondedScopes.indexOf(scope) == -1);
|
|
2207
2207
|
return missingScopes.join(",");
|
|
2208
2208
|
};
|
|
2209
2209
|
|
|
@@ -2215,7 +2215,7 @@ const getScopeToRequest = (useMrrt, authorizationParams, cachedAudience, cachedS
|
|
|
2215
2215
|
}
|
|
2216
2216
|
const cachedScopes = cachedScope.split(" ");
|
|
2217
2217
|
const newScopes = ((_a = authorizationParams.scope) === null || _a === void 0 ? void 0 : _a.split(" ")) || [];
|
|
2218
|
-
const newScopesAreIncluded = newScopes.every(
|
|
2218
|
+
const newScopesAreIncluded = newScopes.every(scope => cachedScopes.includes(scope));
|
|
2219
2219
|
return cachedScopes.length >= newScopes.length && newScopesAreIncluded ? cachedScope : authorizationParams.scope;
|
|
2220
2220
|
}
|
|
2221
2221
|
return authorizationParams.scope;
|
|
@@ -2248,11 +2248,11 @@ class DpopStorage {
|
|
|
2248
2248
|
}
|
|
2249
2249
|
createDbHandle() {
|
|
2250
2250
|
const req = window.indexedDB.open(NAME, this.getVersion());
|
|
2251
|
-
return new Promise((
|
|
2252
|
-
req.onupgradeneeded = () => Object.values(TABLES).forEach(
|
|
2251
|
+
return new Promise((resolve, reject) => {
|
|
2252
|
+
req.onupgradeneeded = () => Object.values(TABLES).forEach(t => req.result.createObjectStore(t));
|
|
2253
2253
|
req.onerror = () => reject(req.error);
|
|
2254
2254
|
req.onsuccess = () => resolve(req.result);
|
|
2255
|
-
})
|
|
2255
|
+
});
|
|
2256
2256
|
}
|
|
2257
2257
|
async getDbHandle() {
|
|
2258
2258
|
if (!this.dbHandle) {
|
|
@@ -2265,10 +2265,10 @@ class DpopStorage {
|
|
|
2265
2265
|
const txn = db.transaction(table, mode);
|
|
2266
2266
|
const store = txn.objectStore(table);
|
|
2267
2267
|
const request = requestFactory(store);
|
|
2268
|
-
return new Promise((
|
|
2268
|
+
return new Promise((resolve, reject) => {
|
|
2269
2269
|
request.onsuccess = () => resolve(request.result);
|
|
2270
2270
|
request.onerror = () => reject(request.error);
|
|
2271
|
-
})
|
|
2271
|
+
});
|
|
2272
2272
|
}
|
|
2273
2273
|
buildKey(id) {
|
|
2274
2274
|
const finalId = id ? "_".concat(id) : AUTH0_NONCE_ID;
|
|
@@ -2281,7 +2281,7 @@ class DpopStorage {
|
|
|
2281
2281
|
return this.save(TABLES.KEYPAIR, this.buildKey(), keyPair);
|
|
2282
2282
|
}
|
|
2283
2283
|
async save(table, key, obj) {
|
|
2284
|
-
return void await this.executeDbRequest(table, "readwrite",
|
|
2284
|
+
return void await this.executeDbRequest(table, "readwrite", table => table.put(obj, key));
|
|
2285
2285
|
}
|
|
2286
2286
|
findNonce(id) {
|
|
2287
2287
|
return this.find(TABLES.NONCE, this.buildKey(id));
|
|
@@ -2290,14 +2290,14 @@ class DpopStorage {
|
|
|
2290
2290
|
return this.find(TABLES.KEYPAIR, this.buildKey());
|
|
2291
2291
|
}
|
|
2292
2292
|
find(table, key) {
|
|
2293
|
-
return this.executeDbRequest(table, "readonly",
|
|
2293
|
+
return this.executeDbRequest(table, "readonly", table => table.get(key));
|
|
2294
2294
|
}
|
|
2295
2295
|
async deleteBy(table, predicate) {
|
|
2296
|
-
const allKeys = await this.executeDbRequest(table, "readonly",
|
|
2297
|
-
allKeys === null || allKeys === void 0 ? void 0 : allKeys.filter(predicate).map(
|
|
2296
|
+
const allKeys = await this.executeDbRequest(table, "readonly", table => table.getAllKeys());
|
|
2297
|
+
allKeys === null || allKeys === void 0 ? void 0 : allKeys.filter(predicate).map(k => this.executeDbRequest(table, "readwrite", table => table.delete(k)));
|
|
2298
2298
|
}
|
|
2299
2299
|
deleteByClientId(table, clientId) {
|
|
2300
|
-
return this.deleteBy(table,
|
|
2300
|
+
return this.deleteBy(table, k => typeof k === "string" && k.startsWith("".concat(clientId, "::")));
|
|
2301
2301
|
}
|
|
2302
2302
|
clearNonces() {
|
|
2303
2303
|
return this.deleteByClientId(TABLES.NONCE, this.clientId);
|
|
@@ -2627,9 +2627,9 @@ function ownKeys(e, r) {
|
|
|
2627
2627
|
var t = Object.keys(e);
|
|
2628
2628
|
if (Object.getOwnPropertySymbols) {
|
|
2629
2629
|
var o = Object.getOwnPropertySymbols(e);
|
|
2630
|
-
r && (o = o.filter(
|
|
2630
|
+
r && (o = o.filter(function(r) {
|
|
2631
2631
|
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
2632
|
-
}))
|
|
2632
|
+
})), t.push.apply(t, o);
|
|
2633
2633
|
}
|
|
2634
2634
|
return t;
|
|
2635
2635
|
}
|
|
@@ -2637,11 +2637,11 @@ function ownKeys(e, r) {
|
|
|
2637
2637
|
function _objectSpread2(e) {
|
|
2638
2638
|
for (var r = 1; r < arguments.length; r++) {
|
|
2639
2639
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
2640
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(
|
|
2640
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
2641
2641
|
_defineProperty(e, r, t[r]);
|
|
2642
|
-
})
|
|
2642
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
2643
2643
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
2644
|
-
})
|
|
2644
|
+
});
|
|
2645
2645
|
}
|
|
2646
2646
|
return e;
|
|
2647
2647
|
}
|
|
@@ -2693,16 +2693,16 @@ function AsyncGenerator(e) {
|
|
|
2693
2693
|
function resume(r, t) {
|
|
2694
2694
|
try {
|
|
2695
2695
|
var n = e[r](t), o = n.value, u = o instanceof _OverloadYield;
|
|
2696
|
-
Promise.resolve(u ? o.v : o).then(
|
|
2696
|
+
Promise.resolve(u ? o.v : o).then(function(t) {
|
|
2697
2697
|
if (u) {
|
|
2698
2698
|
var i = "return" === r ? "return" : "next";
|
|
2699
2699
|
if (!o.k || t.done) return resume(i, t);
|
|
2700
2700
|
t = e[i](t).value;
|
|
2701
2701
|
}
|
|
2702
2702
|
settle(n.done ? "return" : "normal", t);
|
|
2703
|
-
}
|
|
2703
|
+
}, function(e) {
|
|
2704
2704
|
resume("throw", e);
|
|
2705
|
-
})
|
|
2705
|
+
});
|
|
2706
2706
|
} catch (e) {
|
|
2707
2707
|
settle("throw", e);
|
|
2708
2708
|
}
|
|
@@ -2729,7 +2729,7 @@ function AsyncGenerator(e) {
|
|
|
2729
2729
|
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
|
2730
2730
|
}
|
|
2731
2731
|
this._invoke = function(e, n) {
|
|
2732
|
-
return new Promise(
|
|
2732
|
+
return new Promise(function(o, u) {
|
|
2733
2733
|
var i = {
|
|
2734
2734
|
key: e,
|
|
2735
2735
|
arg: n,
|
|
@@ -2738,7 +2738,7 @@ function AsyncGenerator(e) {
|
|
|
2738
2738
|
next: null
|
|
2739
2739
|
};
|
|
2740
2740
|
t ? t = t.next = i : (r = t = i, resume(e, n));
|
|
2741
|
-
})
|
|
2741
|
+
});
|
|
2742
2742
|
}, "function" != typeof e.return && (this.return = void 0);
|
|
2743
2743
|
}
|
|
2744
2744
|
|
|
@@ -2758,7 +2758,7 @@ let USER_AGENT$2;
|
|
|
2758
2758
|
|
|
2759
2759
|
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 "))) {
|
|
2760
2760
|
const NAME = "oauth4webapi";
|
|
2761
|
-
const VERSION = "v3.8.
|
|
2761
|
+
const VERSION = "v3.8.5";
|
|
2762
2762
|
USER_AGENT$2 = "".concat(NAME, "/").concat(VERSION);
|
|
2763
2763
|
}
|
|
2764
2764
|
|
|
@@ -2988,7 +2988,7 @@ async function performDiscovery$1(input, urlName, transform, options) {
|
|
|
2988
2988
|
}
|
|
2989
2989
|
|
|
2990
2990
|
async function discoveryRequest(issuerIdentifier, options) {
|
|
2991
|
-
return performDiscovery$1(issuerIdentifier, "issuerIdentifier",
|
|
2991
|
+
return performDiscovery$1(issuerIdentifier, "issuerIdentifier", url => {
|
|
2992
2992
|
switch (options === null || options === void 0 ? void 0 : options.algorithm) {
|
|
2993
2993
|
case undefined:
|
|
2994
2994
|
case "oidc":
|
|
@@ -3003,7 +3003,7 @@ async function discoveryRequest(issuerIdentifier, options) {
|
|
|
3003
3003
|
throw CodedTypeError$1('"options.algorithm" must be "oidc" (default), or "oauth2"', ERR_INVALID_ARG_VALUE$1);
|
|
3004
3004
|
}
|
|
3005
3005
|
return url;
|
|
3006
|
-
}
|
|
3006
|
+
}, options);
|
|
3007
3007
|
}
|
|
3008
3008
|
|
|
3009
3009
|
function assertNumber(input, allow0, it, code, cause) {
|
|
@@ -4351,10 +4351,10 @@ function concat() {
|
|
|
4351
4351
|
for (var _len = arguments.length, buffers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4352
4352
|
buffers[_key] = arguments[_key];
|
|
4353
4353
|
}
|
|
4354
|
-
const size = buffers.reduce((
|
|
4354
|
+
const size = buffers.reduce((acc, _ref) => {
|
|
4355
4355
|
let {length: length} = _ref;
|
|
4356
4356
|
return acc + length;
|
|
4357
|
-
}
|
|
4357
|
+
}, 0);
|
|
4358
4358
|
const buf = new Uint8Array(size);
|
|
4359
4359
|
let i = 0;
|
|
4360
4360
|
for (const buffer of buffers) {
|
|
@@ -4406,6 +4406,145 @@ function decode(input) {
|
|
|
4406
4406
|
}
|
|
4407
4407
|
}
|
|
4408
4408
|
|
|
4409
|
+
const unusable = function unusable(name) {
|
|
4410
|
+
let prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "algorithm.name";
|
|
4411
|
+
return new TypeError("CryptoKey does not support this operation, its ".concat(prop, " must be ").concat(name));
|
|
4412
|
+
};
|
|
4413
|
+
|
|
4414
|
+
const isAlgorithm = (algorithm, name) => algorithm.name === name;
|
|
4415
|
+
|
|
4416
|
+
function getHashLength(hash) {
|
|
4417
|
+
return parseInt(hash.name.slice(4), 10);
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4420
|
+
function checkHashLength(algorithm, expected) {
|
|
4421
|
+
const actual = getHashLength(algorithm.hash);
|
|
4422
|
+
if (actual !== expected) throw unusable("SHA-".concat(expected), "algorithm.hash");
|
|
4423
|
+
}
|
|
4424
|
+
|
|
4425
|
+
function getNamedCurve(alg) {
|
|
4426
|
+
switch (alg) {
|
|
4427
|
+
case "ES256":
|
|
4428
|
+
return "P-256";
|
|
4429
|
+
|
|
4430
|
+
case "ES384":
|
|
4431
|
+
return "P-384";
|
|
4432
|
+
|
|
4433
|
+
case "ES512":
|
|
4434
|
+
return "P-521";
|
|
4435
|
+
|
|
4436
|
+
default:
|
|
4437
|
+
throw new Error("unreachable");
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
|
|
4441
|
+
function checkUsage(key, usage) {
|
|
4442
|
+
if (usage && !key.usages.includes(usage)) {
|
|
4443
|
+
throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(usage, "."));
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4446
|
+
|
|
4447
|
+
function checkSigCryptoKey(key, alg, usage) {
|
|
4448
|
+
switch (alg) {
|
|
4449
|
+
case "HS256":
|
|
4450
|
+
case "HS384":
|
|
4451
|
+
case "HS512":
|
|
4452
|
+
{
|
|
4453
|
+
if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
|
|
4454
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
4455
|
+
break;
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4458
|
+
case "RS256":
|
|
4459
|
+
case "RS384":
|
|
4460
|
+
case "RS512":
|
|
4461
|
+
{
|
|
4462
|
+
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
|
|
4463
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
4464
|
+
break;
|
|
4465
|
+
}
|
|
4466
|
+
|
|
4467
|
+
case "PS256":
|
|
4468
|
+
case "PS384":
|
|
4469
|
+
case "PS512":
|
|
4470
|
+
{
|
|
4471
|
+
if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
|
|
4472
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
4473
|
+
break;
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
case "Ed25519":
|
|
4477
|
+
case "EdDSA":
|
|
4478
|
+
{
|
|
4479
|
+
if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
|
|
4480
|
+
break;
|
|
4481
|
+
}
|
|
4482
|
+
|
|
4483
|
+
case "ML-DSA-44":
|
|
4484
|
+
case "ML-DSA-65":
|
|
4485
|
+
case "ML-DSA-87":
|
|
4486
|
+
{
|
|
4487
|
+
if (!isAlgorithm(key.algorithm, alg)) throw unusable(alg);
|
|
4488
|
+
break;
|
|
4489
|
+
}
|
|
4490
|
+
|
|
4491
|
+
case "ES256":
|
|
4492
|
+
case "ES384":
|
|
4493
|
+
case "ES512":
|
|
4494
|
+
{
|
|
4495
|
+
if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
|
|
4496
|
+
const expected = getNamedCurve(alg);
|
|
4497
|
+
const actual = key.algorithm.namedCurve;
|
|
4498
|
+
if (actual !== expected) throw unusable(expected, "algorithm.namedCurve");
|
|
4499
|
+
break;
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
default:
|
|
4503
|
+
throw new TypeError("CryptoKey does not support this operation");
|
|
4504
|
+
}
|
|
4505
|
+
checkUsage(key, usage);
|
|
4506
|
+
}
|
|
4507
|
+
|
|
4508
|
+
function message(msg, actual) {
|
|
4509
|
+
for (var _len = arguments.length, types = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
4510
|
+
types[_key - 2] = arguments[_key];
|
|
4511
|
+
}
|
|
4512
|
+
types = types.filter(Boolean);
|
|
4513
|
+
if (types.length > 2) {
|
|
4514
|
+
const last = types.pop();
|
|
4515
|
+
msg += "one of type ".concat(types.join(", "), ", or ").concat(last, ".");
|
|
4516
|
+
} else if (types.length === 2) {
|
|
4517
|
+
msg += "one of type ".concat(types[0], " or ").concat(types[1], ".");
|
|
4518
|
+
} else {
|
|
4519
|
+
msg += "of type ".concat(types[0], ".");
|
|
4520
|
+
}
|
|
4521
|
+
if (actual == null) {
|
|
4522
|
+
msg += " Received ".concat(actual);
|
|
4523
|
+
} else if (typeof actual === "function" && actual.name) {
|
|
4524
|
+
msg += " Received function ".concat(actual.name);
|
|
4525
|
+
} else if (typeof actual === "object" && actual != null) {
|
|
4526
|
+
var _actual$constructor;
|
|
4527
|
+
if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
|
|
4528
|
+
msg += " Received an instance of ".concat(actual.constructor.name);
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
return msg;
|
|
4532
|
+
}
|
|
4533
|
+
|
|
4534
|
+
const invalidKeyInput = function invalidKeyInput(actual) {
|
|
4535
|
+
for (var _len2 = arguments.length, types = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
4536
|
+
types[_key2 - 1] = arguments[_key2];
|
|
4537
|
+
}
|
|
4538
|
+
return message("Key must be ", actual, ...types);
|
|
4539
|
+
};
|
|
4540
|
+
|
|
4541
|
+
const withAlg = function withAlg(alg, actual) {
|
|
4542
|
+
for (var _len3 = arguments.length, types = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
4543
|
+
types[_key3 - 2] = arguments[_key3];
|
|
4544
|
+
}
|
|
4545
|
+
return message("Key for the ".concat(alg, " algorithm must be "), actual, ...types);
|
|
4546
|
+
};
|
|
4547
|
+
|
|
4409
4548
|
class JOSEError extends Error {
|
|
4410
4549
|
constructor(message, options) {
|
|
4411
4550
|
var _Error$captureStackTr;
|
|
@@ -4583,207 +4722,486 @@ class JWSSignatureVerificationFailed extends JOSEError {
|
|
|
4583
4722
|
|
|
4584
4723
|
_defineProperty(JWSSignatureVerificationFailed, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
4585
4724
|
|
|
4586
|
-
const
|
|
4587
|
-
|
|
4588
|
-
|
|
4725
|
+
const isCryptoKey = key => {
|
|
4726
|
+
if ((key === null || key === void 0 ? void 0 : key[Symbol.toStringTag]) === "CryptoKey") return true;
|
|
4727
|
+
try {
|
|
4728
|
+
return key instanceof CryptoKey;
|
|
4729
|
+
} catch (_unused) {
|
|
4730
|
+
return false;
|
|
4731
|
+
}
|
|
4589
4732
|
};
|
|
4590
4733
|
|
|
4591
|
-
const
|
|
4592
|
-
|
|
4593
|
-
function getHashLength(hash) {
|
|
4594
|
-
return parseInt(hash.name.slice(4), 10);
|
|
4595
|
-
}
|
|
4734
|
+
const isKeyObject = key => (key === null || key === void 0 ? void 0 : key[Symbol.toStringTag]) === "KeyObject";
|
|
4596
4735
|
|
|
4597
|
-
|
|
4598
|
-
switch (alg) {
|
|
4599
|
-
case "ES256":
|
|
4600
|
-
return "P-256";
|
|
4736
|
+
const isKeyLike = key => isCryptoKey(key) || isKeyObject(key);
|
|
4601
4737
|
|
|
4602
|
-
|
|
4603
|
-
|
|
4738
|
+
function decodeBase64url(value, label, ErrorClass) {
|
|
4739
|
+
try {
|
|
4740
|
+
return decode(value);
|
|
4741
|
+
} catch (_unused) {
|
|
4742
|
+
throw new ErrorClass("Failed to base64url decode the ".concat(label));
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4604
4745
|
|
|
4605
|
-
|
|
4606
|
-
return "P-521";
|
|
4746
|
+
const isObjectLike = value => typeof value === "object" && value !== null;
|
|
4607
4747
|
|
|
4608
|
-
|
|
4609
|
-
|
|
4748
|
+
function isObject(input) {
|
|
4749
|
+
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
4750
|
+
return false;
|
|
4751
|
+
}
|
|
4752
|
+
if (Object.getPrototypeOf(input) === null) {
|
|
4753
|
+
return true;
|
|
4754
|
+
}
|
|
4755
|
+
let proto = input;
|
|
4756
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
4757
|
+
proto = Object.getPrototypeOf(proto);
|
|
4610
4758
|
}
|
|
4759
|
+
return Object.getPrototypeOf(input) === proto;
|
|
4611
4760
|
}
|
|
4612
4761
|
|
|
4613
|
-
function
|
|
4614
|
-
|
|
4615
|
-
|
|
4762
|
+
function isDisjoint() {
|
|
4763
|
+
for (var _len = arguments.length, headers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4764
|
+
headers[_key] = arguments[_key];
|
|
4616
4765
|
}
|
|
4766
|
+
const sources = headers.filter(Boolean);
|
|
4767
|
+
if (sources.length === 0 || sources.length === 1) {
|
|
4768
|
+
return true;
|
|
4769
|
+
}
|
|
4770
|
+
let acc;
|
|
4771
|
+
for (const header of sources) {
|
|
4772
|
+
const parameters = Object.keys(header);
|
|
4773
|
+
if (!acc || acc.size === 0) {
|
|
4774
|
+
acc = new Set(parameters);
|
|
4775
|
+
continue;
|
|
4776
|
+
}
|
|
4777
|
+
for (const parameter of parameters) {
|
|
4778
|
+
if (acc.has(parameter)) {
|
|
4779
|
+
return false;
|
|
4780
|
+
}
|
|
4781
|
+
acc.add(parameter);
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
return true;
|
|
4617
4785
|
}
|
|
4618
4786
|
|
|
4619
|
-
|
|
4787
|
+
const isJWK = key => isObject(key) && typeof key.kty === "string";
|
|
4788
|
+
|
|
4789
|
+
const isPrivateJWK = key => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
4790
|
+
|
|
4791
|
+
const isPublicJWK = key => key.kty !== "oct" && key.d === undefined && key.priv === undefined;
|
|
4792
|
+
|
|
4793
|
+
const isSecretJWK = key => key.kty === "oct" && typeof key.k === "string";
|
|
4794
|
+
|
|
4795
|
+
function checkKeyLength(alg, key) {
|
|
4796
|
+
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
4797
|
+
const {modulusLength: modulusLength} = key.algorithm;
|
|
4798
|
+
if (typeof modulusLength !== "number" || modulusLength < 2048) {
|
|
4799
|
+
throw new TypeError("".concat(alg, " requires key modulusLength to be 2048 bits or larger"));
|
|
4800
|
+
}
|
|
4801
|
+
}
|
|
4802
|
+
}
|
|
4803
|
+
|
|
4804
|
+
function subtleAlgorithm(alg, algorithm) {
|
|
4805
|
+
const hash = "SHA-".concat(alg.slice(-3));
|
|
4620
4806
|
switch (alg) {
|
|
4621
4807
|
case "HS256":
|
|
4622
4808
|
case "HS384":
|
|
4623
4809
|
case "HS512":
|
|
4624
|
-
{
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4810
|
+
return {
|
|
4811
|
+
hash: hash,
|
|
4812
|
+
name: "HMAC"
|
|
4813
|
+
};
|
|
4814
|
+
|
|
4815
|
+
case "PS256":
|
|
4816
|
+
case "PS384":
|
|
4817
|
+
case "PS512":
|
|
4818
|
+
return {
|
|
4819
|
+
hash: hash,
|
|
4820
|
+
name: "RSA-PSS",
|
|
4821
|
+
saltLength: parseInt(alg.slice(-3), 10) >> 3
|
|
4822
|
+
};
|
|
4631
4823
|
|
|
4632
4824
|
case "RS256":
|
|
4633
4825
|
case "RS384":
|
|
4634
4826
|
case "RS512":
|
|
4635
|
-
{
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4827
|
+
return {
|
|
4828
|
+
hash: hash,
|
|
4829
|
+
name: "RSASSA-PKCS1-v1_5"
|
|
4830
|
+
};
|
|
4831
|
+
|
|
4832
|
+
case "ES256":
|
|
4833
|
+
case "ES384":
|
|
4834
|
+
case "ES512":
|
|
4835
|
+
return {
|
|
4836
|
+
hash: hash,
|
|
4837
|
+
name: "ECDSA",
|
|
4838
|
+
namedCurve: algorithm.namedCurve
|
|
4839
|
+
};
|
|
4840
|
+
|
|
4841
|
+
case "Ed25519":
|
|
4842
|
+
case "EdDSA":
|
|
4843
|
+
return {
|
|
4844
|
+
name: "Ed25519"
|
|
4845
|
+
};
|
|
4846
|
+
|
|
4847
|
+
case "ML-DSA-44":
|
|
4848
|
+
case "ML-DSA-65":
|
|
4849
|
+
case "ML-DSA-87":
|
|
4850
|
+
return {
|
|
4851
|
+
name: alg
|
|
4852
|
+
};
|
|
4853
|
+
|
|
4854
|
+
default:
|
|
4855
|
+
throw new JOSENotSupported("alg ".concat(alg, " is not supported either by JOSE or your javascript runtime"));
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
|
|
4859
|
+
async function getSigKey(alg, key, usage) {
|
|
4860
|
+
if (key instanceof Uint8Array) {
|
|
4861
|
+
if (!alg.startsWith("HS")) {
|
|
4862
|
+
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
4641
4863
|
}
|
|
4864
|
+
return crypto.subtle.importKey("raw", key, {
|
|
4865
|
+
hash: "SHA-".concat(alg.slice(-3)),
|
|
4866
|
+
name: "HMAC"
|
|
4867
|
+
}, false, [ usage ]);
|
|
4868
|
+
}
|
|
4869
|
+
checkSigCryptoKey(key, alg, usage);
|
|
4870
|
+
return key;
|
|
4871
|
+
}
|
|
4642
4872
|
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4873
|
+
async function verify(alg, key, signature, data) {
|
|
4874
|
+
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
4875
|
+
checkKeyLength(alg, cryptoKey);
|
|
4876
|
+
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
4877
|
+
try {
|
|
4878
|
+
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
|
|
4879
|
+
} catch (_unused) {
|
|
4880
|
+
return false;
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4883
|
+
|
|
4884
|
+
const unsupportedAlg = 'Invalid or unsupported JWK "alg" (Algorithm) Parameter value';
|
|
4885
|
+
|
|
4886
|
+
function subtleMapping(jwk) {
|
|
4887
|
+
let algorithm;
|
|
4888
|
+
let keyUsages;
|
|
4889
|
+
switch (jwk.kty) {
|
|
4890
|
+
case "AKP":
|
|
4646
4891
|
{
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4892
|
+
switch (jwk.alg) {
|
|
4893
|
+
case "ML-DSA-44":
|
|
4894
|
+
case "ML-DSA-65":
|
|
4895
|
+
case "ML-DSA-87":
|
|
4896
|
+
algorithm = {
|
|
4897
|
+
name: jwk.alg
|
|
4898
|
+
};
|
|
4899
|
+
keyUsages = jwk.priv ? [ "sign" ] : [ "verify" ];
|
|
4900
|
+
break;
|
|
4901
|
+
|
|
4902
|
+
default:
|
|
4903
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
4904
|
+
}
|
|
4651
4905
|
break;
|
|
4652
4906
|
}
|
|
4653
4907
|
|
|
4654
|
-
case "
|
|
4655
|
-
case "EdDSA":
|
|
4908
|
+
case "RSA":
|
|
4656
4909
|
{
|
|
4657
|
-
|
|
4910
|
+
switch (jwk.alg) {
|
|
4911
|
+
case "PS256":
|
|
4912
|
+
case "PS384":
|
|
4913
|
+
case "PS512":
|
|
4914
|
+
algorithm = {
|
|
4915
|
+
name: "RSA-PSS",
|
|
4916
|
+
hash: "SHA-".concat(jwk.alg.slice(-3))
|
|
4917
|
+
};
|
|
4918
|
+
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
4919
|
+
break;
|
|
4920
|
+
|
|
4921
|
+
case "RS256":
|
|
4922
|
+
case "RS384":
|
|
4923
|
+
case "RS512":
|
|
4924
|
+
algorithm = {
|
|
4925
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
4926
|
+
hash: "SHA-".concat(jwk.alg.slice(-3))
|
|
4927
|
+
};
|
|
4928
|
+
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
4929
|
+
break;
|
|
4930
|
+
|
|
4931
|
+
case "RSA-OAEP":
|
|
4932
|
+
case "RSA-OAEP-256":
|
|
4933
|
+
case "RSA-OAEP-384":
|
|
4934
|
+
case "RSA-OAEP-512":
|
|
4935
|
+
algorithm = {
|
|
4936
|
+
name: "RSA-OAEP",
|
|
4937
|
+
hash: "SHA-".concat(parseInt(jwk.alg.slice(-3), 10) || 1)
|
|
4938
|
+
};
|
|
4939
|
+
keyUsages = jwk.d ? [ "decrypt", "unwrapKey" ] : [ "encrypt", "wrapKey" ];
|
|
4940
|
+
break;
|
|
4941
|
+
|
|
4942
|
+
default:
|
|
4943
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
4944
|
+
}
|
|
4658
4945
|
break;
|
|
4659
4946
|
}
|
|
4660
4947
|
|
|
4661
|
-
case "
|
|
4662
|
-
case "ML-DSA-65":
|
|
4663
|
-
case "ML-DSA-87":
|
|
4948
|
+
case "EC":
|
|
4664
4949
|
{
|
|
4665
|
-
|
|
4950
|
+
switch (jwk.alg) {
|
|
4951
|
+
case "ES256":
|
|
4952
|
+
case "ES384":
|
|
4953
|
+
case "ES512":
|
|
4954
|
+
algorithm = {
|
|
4955
|
+
name: "ECDSA",
|
|
4956
|
+
namedCurve: {
|
|
4957
|
+
ES256: "P-256",
|
|
4958
|
+
ES384: "P-384",
|
|
4959
|
+
ES512: "P-521"
|
|
4960
|
+
}[jwk.alg]
|
|
4961
|
+
};
|
|
4962
|
+
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
4963
|
+
break;
|
|
4964
|
+
|
|
4965
|
+
case "ECDH-ES":
|
|
4966
|
+
case "ECDH-ES+A128KW":
|
|
4967
|
+
case "ECDH-ES+A192KW":
|
|
4968
|
+
case "ECDH-ES+A256KW":
|
|
4969
|
+
algorithm = {
|
|
4970
|
+
name: "ECDH",
|
|
4971
|
+
namedCurve: jwk.crv
|
|
4972
|
+
};
|
|
4973
|
+
keyUsages = jwk.d ? [ "deriveBits" ] : [];
|
|
4974
|
+
break;
|
|
4975
|
+
|
|
4976
|
+
default:
|
|
4977
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
4978
|
+
}
|
|
4666
4979
|
break;
|
|
4667
4980
|
}
|
|
4668
4981
|
|
|
4669
|
-
case "
|
|
4670
|
-
case "ES384":
|
|
4671
|
-
case "ES512":
|
|
4982
|
+
case "OKP":
|
|
4672
4983
|
{
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4984
|
+
switch (jwk.alg) {
|
|
4985
|
+
case "Ed25519":
|
|
4986
|
+
case "EdDSA":
|
|
4987
|
+
algorithm = {
|
|
4988
|
+
name: "Ed25519"
|
|
4989
|
+
};
|
|
4990
|
+
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
4991
|
+
break;
|
|
4992
|
+
|
|
4993
|
+
case "ECDH-ES":
|
|
4994
|
+
case "ECDH-ES+A128KW":
|
|
4995
|
+
case "ECDH-ES+A192KW":
|
|
4996
|
+
case "ECDH-ES+A256KW":
|
|
4997
|
+
algorithm = {
|
|
4998
|
+
name: jwk.crv
|
|
4999
|
+
};
|
|
5000
|
+
keyUsages = jwk.d ? [ "deriveBits" ] : [];
|
|
5001
|
+
break;
|
|
5002
|
+
|
|
5003
|
+
default:
|
|
5004
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
5005
|
+
}
|
|
4677
5006
|
break;
|
|
4678
5007
|
}
|
|
4679
5008
|
|
|
4680
5009
|
default:
|
|
4681
|
-
throw new
|
|
5010
|
+
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
4682
5011
|
}
|
|
4683
|
-
|
|
5012
|
+
return {
|
|
5013
|
+
algorithm: algorithm,
|
|
5014
|
+
keyUsages: keyUsages
|
|
5015
|
+
};
|
|
4684
5016
|
}
|
|
4685
5017
|
|
|
4686
|
-
function
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
types = types.filter(Boolean);
|
|
4691
|
-
if (types.length > 2) {
|
|
4692
|
-
const last = types.pop();
|
|
4693
|
-
msg += "one of type ".concat(types.join(", "), ", or ").concat(last, ".");
|
|
4694
|
-
} else if (types.length === 2) {
|
|
4695
|
-
msg += "one of type ".concat(types[0], " or ").concat(types[1], ".");
|
|
4696
|
-
} else {
|
|
4697
|
-
msg += "of type ".concat(types[0], ".");
|
|
5018
|
+
async function jwkToKey(jwk) {
|
|
5019
|
+
var _jwk$ext, _jwk$key_ops;
|
|
5020
|
+
if (!jwk.alg) {
|
|
5021
|
+
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
4698
5022
|
}
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
} else if (typeof actual === "object" && actual != null) {
|
|
4704
|
-
var _actual$constructor;
|
|
4705
|
-
if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
|
|
4706
|
-
msg += " Received an instance of ".concat(actual.constructor.name);
|
|
4707
|
-
}
|
|
5023
|
+
const {algorithm: algorithm, keyUsages: keyUsages} = subtleMapping(jwk);
|
|
5024
|
+
const keyData = _objectSpread2({}, jwk);
|
|
5025
|
+
if (keyData.kty !== "AKP") {
|
|
5026
|
+
delete keyData.alg;
|
|
4708
5027
|
}
|
|
4709
|
-
|
|
5028
|
+
delete keyData.use;
|
|
5029
|
+
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);
|
|
4710
5030
|
}
|
|
4711
5031
|
|
|
4712
|
-
const
|
|
4713
|
-
|
|
4714
|
-
|
|
5032
|
+
const unusableForAlg = "given KeyObject instance cannot be used for this algorithm";
|
|
5033
|
+
|
|
5034
|
+
let cache;
|
|
5035
|
+
|
|
5036
|
+
const handleJWK = async function handleJWK(key, jwk, alg) {
|
|
5037
|
+
let freeze = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
5038
|
+
cache || (cache = new WeakMap);
|
|
5039
|
+
let cached = cache.get(key);
|
|
5040
|
+
if (cached !== null && cached !== void 0 && cached[alg]) {
|
|
5041
|
+
return cached[alg];
|
|
4715
5042
|
}
|
|
4716
|
-
|
|
5043
|
+
const cryptoKey = await jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
5044
|
+
alg: alg
|
|
5045
|
+
}));
|
|
5046
|
+
if (freeze) Object.freeze(key);
|
|
5047
|
+
if (!cached) {
|
|
5048
|
+
cache.set(key, {
|
|
5049
|
+
[alg]: cryptoKey
|
|
5050
|
+
});
|
|
5051
|
+
} else {
|
|
5052
|
+
cached[alg] = cryptoKey;
|
|
5053
|
+
}
|
|
5054
|
+
return cryptoKey;
|
|
4717
5055
|
};
|
|
4718
5056
|
|
|
4719
|
-
const
|
|
4720
|
-
|
|
4721
|
-
|
|
5057
|
+
const handleKeyObject = (keyObject, alg) => {
|
|
5058
|
+
cache || (cache = new WeakMap);
|
|
5059
|
+
let cached = cache.get(keyObject);
|
|
5060
|
+
if (cached !== null && cached !== void 0 && cached[alg]) {
|
|
5061
|
+
return cached[alg];
|
|
5062
|
+
}
|
|
5063
|
+
const isPublic = keyObject.type === "public";
|
|
5064
|
+
const extractable = isPublic ? true : false;
|
|
5065
|
+
let cryptoKey;
|
|
5066
|
+
if (keyObject.asymmetricKeyType === "x25519") {
|
|
5067
|
+
switch (alg) {
|
|
5068
|
+
case "ECDH-ES":
|
|
5069
|
+
case "ECDH-ES+A128KW":
|
|
5070
|
+
case "ECDH-ES+A192KW":
|
|
5071
|
+
case "ECDH-ES+A256KW":
|
|
5072
|
+
break;
|
|
5073
|
+
|
|
5074
|
+
default:
|
|
5075
|
+
throw new TypeError(unusableForAlg);
|
|
5076
|
+
}
|
|
5077
|
+
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : [ "deriveBits" ]);
|
|
5078
|
+
}
|
|
5079
|
+
if (keyObject.asymmetricKeyType === "ed25519") {
|
|
5080
|
+
if (alg !== "EdDSA" && alg !== "Ed25519") {
|
|
5081
|
+
throw new TypeError(unusableForAlg);
|
|
5082
|
+
}
|
|
5083
|
+
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5084
|
+
}
|
|
5085
|
+
switch (keyObject.asymmetricKeyType) {
|
|
5086
|
+
case "ml-dsa-44":
|
|
5087
|
+
case "ml-dsa-65":
|
|
5088
|
+
case "ml-dsa-87":
|
|
5089
|
+
{
|
|
5090
|
+
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
|
|
5091
|
+
throw new TypeError(unusableForAlg);
|
|
5092
|
+
}
|
|
5093
|
+
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
if (keyObject.asymmetricKeyType === "rsa") {
|
|
5097
|
+
let hash;
|
|
5098
|
+
switch (alg) {
|
|
5099
|
+
case "RSA-OAEP":
|
|
5100
|
+
hash = "SHA-1";
|
|
5101
|
+
break;
|
|
5102
|
+
|
|
5103
|
+
case "RS256":
|
|
5104
|
+
case "PS256":
|
|
5105
|
+
case "RSA-OAEP-256":
|
|
5106
|
+
hash = "SHA-256";
|
|
5107
|
+
break;
|
|
5108
|
+
|
|
5109
|
+
case "RS384":
|
|
5110
|
+
case "PS384":
|
|
5111
|
+
case "RSA-OAEP-384":
|
|
5112
|
+
hash = "SHA-384";
|
|
5113
|
+
break;
|
|
5114
|
+
|
|
5115
|
+
case "RS512":
|
|
5116
|
+
case "PS512":
|
|
5117
|
+
case "RSA-OAEP-512":
|
|
5118
|
+
hash = "SHA-512";
|
|
5119
|
+
break;
|
|
5120
|
+
|
|
5121
|
+
default:
|
|
5122
|
+
throw new TypeError(unusableForAlg);
|
|
5123
|
+
}
|
|
5124
|
+
if (alg.startsWith("RSA-OAEP")) {
|
|
5125
|
+
return keyObject.toCryptoKey({
|
|
5126
|
+
name: "RSA-OAEP",
|
|
5127
|
+
hash: hash
|
|
5128
|
+
}, extractable, isPublic ? [ "encrypt" ] : [ "decrypt" ]);
|
|
5129
|
+
}
|
|
5130
|
+
cryptoKey = keyObject.toCryptoKey({
|
|
5131
|
+
name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
5132
|
+
hash: hash
|
|
5133
|
+
}, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5134
|
+
}
|
|
5135
|
+
if (keyObject.asymmetricKeyType === "ec") {
|
|
5136
|
+
var _keyObject$asymmetric;
|
|
5137
|
+
const nist = new Map([ [ "prime256v1", "P-256" ], [ "secp384r1", "P-384" ], [ "secp521r1", "P-521" ] ]);
|
|
5138
|
+
const namedCurve = nist.get((_keyObject$asymmetric = keyObject.asymmetricKeyDetails) === null || _keyObject$asymmetric === void 0 ? void 0 : _keyObject$asymmetric.namedCurve);
|
|
5139
|
+
if (!namedCurve) {
|
|
5140
|
+
throw new TypeError(unusableForAlg);
|
|
5141
|
+
}
|
|
5142
|
+
const expectedCurve = {
|
|
5143
|
+
ES256: "P-256",
|
|
5144
|
+
ES384: "P-384",
|
|
5145
|
+
ES512: "P-521"
|
|
5146
|
+
};
|
|
5147
|
+
if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {
|
|
5148
|
+
cryptoKey = keyObject.toCryptoKey({
|
|
5149
|
+
name: "ECDSA",
|
|
5150
|
+
namedCurve: namedCurve
|
|
5151
|
+
}, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5152
|
+
}
|
|
5153
|
+
if (alg.startsWith("ECDH-ES")) {
|
|
5154
|
+
cryptoKey = keyObject.toCryptoKey({
|
|
5155
|
+
name: "ECDH",
|
|
5156
|
+
namedCurve: namedCurve
|
|
5157
|
+
}, extractable, isPublic ? [] : [ "deriveBits" ]);
|
|
5158
|
+
}
|
|
5159
|
+
}
|
|
5160
|
+
if (!cryptoKey) {
|
|
5161
|
+
throw new TypeError(unusableForAlg);
|
|
4722
5162
|
}
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
return key instanceof CryptoKey;
|
|
4730
|
-
} catch (_unused) {
|
|
4731
|
-
return false;
|
|
5163
|
+
if (!cached) {
|
|
5164
|
+
cache.set(keyObject, {
|
|
5165
|
+
[alg]: cryptoKey
|
|
5166
|
+
});
|
|
5167
|
+
} else {
|
|
5168
|
+
cached[alg] = cryptoKey;
|
|
4732
5169
|
}
|
|
5170
|
+
return cryptoKey;
|
|
4733
5171
|
};
|
|
4734
5172
|
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
function isDisjoint() {
|
|
4740
|
-
for (var _len = arguments.length, headers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4741
|
-
headers[_key] = arguments[_key];
|
|
5173
|
+
async function normalizeKey(key, alg) {
|
|
5174
|
+
if (key instanceof Uint8Array) {
|
|
5175
|
+
return key;
|
|
4742
5176
|
}
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
return true;
|
|
5177
|
+
if (isCryptoKey(key)) {
|
|
5178
|
+
return key;
|
|
4746
5179
|
}
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
if (!acc || acc.size === 0) {
|
|
4751
|
-
acc = new Set(parameters);
|
|
4752
|
-
continue;
|
|
5180
|
+
if (isKeyObject(key)) {
|
|
5181
|
+
if (key.type === "secret") {
|
|
5182
|
+
return key.export();
|
|
4753
5183
|
}
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
return
|
|
5184
|
+
if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") {
|
|
5185
|
+
try {
|
|
5186
|
+
return handleKeyObject(key, alg);
|
|
5187
|
+
} catch (err) {
|
|
5188
|
+
if (err instanceof TypeError) {
|
|
5189
|
+
throw err;
|
|
5190
|
+
}
|
|
4757
5191
|
}
|
|
4758
|
-
acc.add(parameter);
|
|
4759
5192
|
}
|
|
5193
|
+
let jwk = key.export({
|
|
5194
|
+
format: "jwk"
|
|
5195
|
+
});
|
|
5196
|
+
return handleJWK(key, jwk, alg);
|
|
4760
5197
|
}
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
const isObjectLike = value => typeof value === "object" && value !== null;
|
|
4765
|
-
|
|
4766
|
-
function isObject(input) {
|
|
4767
|
-
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
4768
|
-
return false;
|
|
4769
|
-
}
|
|
4770
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
4771
|
-
return true;
|
|
4772
|
-
}
|
|
4773
|
-
let proto = input;
|
|
4774
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
4775
|
-
proto = Object.getPrototypeOf(proto);
|
|
4776
|
-
}
|
|
4777
|
-
return Object.getPrototypeOf(input) === proto;
|
|
4778
|
-
}
|
|
4779
|
-
|
|
4780
|
-
function checkKeyLength(alg, key) {
|
|
4781
|
-
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
4782
|
-
const {modulusLength: modulusLength} = key.algorithm;
|
|
4783
|
-
if (typeof modulusLength !== "number" || modulusLength < 2048) {
|
|
4784
|
-
throw new TypeError("".concat(alg, " requires key modulusLength to be 2048 bits or larger"));
|
|
5198
|
+
if (isJWK(key)) {
|
|
5199
|
+
if (key.k) {
|
|
5200
|
+
return decode(key.k);
|
|
4785
5201
|
}
|
|
5202
|
+
return handleJWK(key, key, alg, true);
|
|
4786
5203
|
}
|
|
5204
|
+
throw new Error("unreachable");
|
|
4787
5205
|
}
|
|
4788
5206
|
|
|
4789
5207
|
const bytesEqual = (a, b) => {
|
|
@@ -4927,223 +5345,67 @@ const genericImport = async (keyFormat, keyData, alg, options) => {
|
|
|
4927
5345
|
};
|
|
4928
5346
|
keyUsages = getSigUsages();
|
|
4929
5347
|
break;
|
|
4930
|
-
}
|
|
4931
|
-
|
|
4932
|
-
case "ECDH-ES":
|
|
4933
|
-
case "ECDH-ES+A128KW":
|
|
4934
|
-
case "ECDH-ES+A192KW":
|
|
4935
|
-
case "ECDH-ES+A256KW":
|
|
4936
|
-
{
|
|
4937
|
-
try {
|
|
4938
|
-
const namedCurve = options.getNamedCurve(keyData);
|
|
4939
|
-
algorithm = namedCurve === "X25519" ? {
|
|
4940
|
-
name: "X25519"
|
|
4941
|
-
} : {
|
|
4942
|
-
name: "ECDH",
|
|
4943
|
-
namedCurve: namedCurve
|
|
4944
|
-
};
|
|
4945
|
-
} catch (cause) {
|
|
4946
|
-
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
4947
|
-
}
|
|
4948
|
-
keyUsages = isPublic ? [] : [ "deriveBits" ];
|
|
4949
|
-
break;
|
|
4950
|
-
}
|
|
4951
|
-
|
|
4952
|
-
case "Ed25519":
|
|
4953
|
-
case "EdDSA":
|
|
4954
|
-
algorithm = {
|
|
4955
|
-
name: "Ed25519"
|
|
4956
|
-
};
|
|
4957
|
-
keyUsages = getSigUsages();
|
|
4958
|
-
break;
|
|
4959
|
-
|
|
4960
|
-
case "ML-DSA-44":
|
|
4961
|
-
case "ML-DSA-65":
|
|
4962
|
-
case "ML-DSA-87":
|
|
4963
|
-
algorithm = {
|
|
4964
|
-
name: alg
|
|
4965
|
-
};
|
|
4966
|
-
keyUsages = getSigUsages();
|
|
4967
|
-
break;
|
|
4968
|
-
|
|
4969
|
-
default:
|
|
4970
|
-
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
4971
|
-
}
|
|
4972
|
-
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);
|
|
4973
|
-
};
|
|
4974
|
-
|
|
4975
|
-
const processPEMData = (pem, pattern) => decodeBase64(pem.replace(pattern, ""));
|
|
4976
|
-
|
|
4977
|
-
const fromPKCS8 = (pem, alg, options) => {
|
|
4978
|
-
var _alg$startsWith;
|
|
4979
|
-
const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
4980
|
-
let opts = options;
|
|
4981
|
-
if (alg !== null && alg !== void 0 && (_alg$startsWith = alg.startsWith) !== null && _alg$startsWith !== void 0 && _alg$startsWith.call(alg, "ECDH-ES")) {
|
|
4982
|
-
opts || (opts = {});
|
|
4983
|
-
opts.getNamedCurve = keyData => {
|
|
4984
|
-
const state = createASN1State(keyData);
|
|
4985
|
-
parsePKCS8Header(state);
|
|
4986
|
-
return parseECAlgorithmIdentifier(state);
|
|
4987
|
-
};
|
|
4988
|
-
}
|
|
4989
|
-
return genericImport("pkcs8", keyData, alg, opts);
|
|
4990
|
-
};
|
|
4991
|
-
|
|
4992
|
-
function subtleMapping(jwk) {
|
|
4993
|
-
let algorithm;
|
|
4994
|
-
let keyUsages;
|
|
4995
|
-
switch (jwk.kty) {
|
|
4996
|
-
case "AKP":
|
|
4997
|
-
{
|
|
4998
|
-
switch (jwk.alg) {
|
|
4999
|
-
case "ML-DSA-44":
|
|
5000
|
-
case "ML-DSA-65":
|
|
5001
|
-
case "ML-DSA-87":
|
|
5002
|
-
algorithm = {
|
|
5003
|
-
name: jwk.alg
|
|
5004
|
-
};
|
|
5005
|
-
keyUsages = jwk.priv ? [ "sign" ] : [ "verify" ];
|
|
5006
|
-
break;
|
|
5007
|
-
|
|
5008
|
-
default:
|
|
5009
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
5010
|
-
}
|
|
5011
|
-
break;
|
|
5012
|
-
}
|
|
5013
|
-
|
|
5014
|
-
case "RSA":
|
|
5015
|
-
{
|
|
5016
|
-
switch (jwk.alg) {
|
|
5017
|
-
case "PS256":
|
|
5018
|
-
case "PS384":
|
|
5019
|
-
case "PS512":
|
|
5020
|
-
algorithm = {
|
|
5021
|
-
name: "RSA-PSS",
|
|
5022
|
-
hash: "SHA-".concat(jwk.alg.slice(-3))
|
|
5023
|
-
};
|
|
5024
|
-
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
5025
|
-
break;
|
|
5026
|
-
|
|
5027
|
-
case "RS256":
|
|
5028
|
-
case "RS384":
|
|
5029
|
-
case "RS512":
|
|
5030
|
-
algorithm = {
|
|
5031
|
-
name: "RSASSA-PKCS1-v1_5",
|
|
5032
|
-
hash: "SHA-".concat(jwk.alg.slice(-3))
|
|
5033
|
-
};
|
|
5034
|
-
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
5035
|
-
break;
|
|
5036
|
-
|
|
5037
|
-
case "RSA-OAEP":
|
|
5038
|
-
case "RSA-OAEP-256":
|
|
5039
|
-
case "RSA-OAEP-384":
|
|
5040
|
-
case "RSA-OAEP-512":
|
|
5041
|
-
algorithm = {
|
|
5042
|
-
name: "RSA-OAEP",
|
|
5043
|
-
hash: "SHA-".concat(parseInt(jwk.alg.slice(-3), 10) || 1)
|
|
5044
|
-
};
|
|
5045
|
-
keyUsages = jwk.d ? [ "decrypt", "unwrapKey" ] : [ "encrypt", "wrapKey" ];
|
|
5046
|
-
break;
|
|
5047
|
-
|
|
5048
|
-
default:
|
|
5049
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
5050
|
-
}
|
|
5051
|
-
break;
|
|
5052
|
-
}
|
|
5053
|
-
|
|
5054
|
-
case "EC":
|
|
5055
|
-
{
|
|
5056
|
-
switch (jwk.alg) {
|
|
5057
|
-
case "ES256":
|
|
5058
|
-
algorithm = {
|
|
5059
|
-
name: "ECDSA",
|
|
5060
|
-
namedCurve: "P-256"
|
|
5061
|
-
};
|
|
5062
|
-
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
5063
|
-
break;
|
|
5064
|
-
|
|
5065
|
-
case "ES384":
|
|
5066
|
-
algorithm = {
|
|
5067
|
-
name: "ECDSA",
|
|
5068
|
-
namedCurve: "P-384"
|
|
5069
|
-
};
|
|
5070
|
-
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
5071
|
-
break;
|
|
5072
|
-
|
|
5073
|
-
case "ES512":
|
|
5074
|
-
algorithm = {
|
|
5075
|
-
name: "ECDSA",
|
|
5076
|
-
namedCurve: "P-521"
|
|
5077
|
-
};
|
|
5078
|
-
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
5079
|
-
break;
|
|
5080
|
-
|
|
5081
|
-
case "ECDH-ES":
|
|
5082
|
-
case "ECDH-ES+A128KW":
|
|
5083
|
-
case "ECDH-ES+A192KW":
|
|
5084
|
-
case "ECDH-ES+A256KW":
|
|
5085
|
-
algorithm = {
|
|
5086
|
-
name: "ECDH",
|
|
5087
|
-
namedCurve: jwk.crv
|
|
5088
|
-
};
|
|
5089
|
-
keyUsages = jwk.d ? [ "deriveBits" ] : [];
|
|
5090
|
-
break;
|
|
5091
|
-
|
|
5092
|
-
default:
|
|
5093
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
5094
|
-
}
|
|
5095
|
-
break;
|
|
5096
|
-
}
|
|
5097
|
-
|
|
5098
|
-
case "OKP":
|
|
5099
|
-
{
|
|
5100
|
-
switch (jwk.alg) {
|
|
5101
|
-
case "Ed25519":
|
|
5102
|
-
case "EdDSA":
|
|
5103
|
-
algorithm = {
|
|
5104
|
-
name: "Ed25519"
|
|
5105
|
-
};
|
|
5106
|
-
keyUsages = jwk.d ? [ "sign" ] : [ "verify" ];
|
|
5107
|
-
break;
|
|
5348
|
+
}
|
|
5108
5349
|
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5350
|
+
case "ECDH-ES":
|
|
5351
|
+
case "ECDH-ES+A128KW":
|
|
5352
|
+
case "ECDH-ES+A192KW":
|
|
5353
|
+
case "ECDH-ES+A256KW":
|
|
5354
|
+
{
|
|
5355
|
+
try {
|
|
5356
|
+
const namedCurve = options.getNamedCurve(keyData);
|
|
5357
|
+
algorithm = namedCurve === "X25519" ? {
|
|
5358
|
+
name: "X25519"
|
|
5359
|
+
} : {
|
|
5360
|
+
name: "ECDH",
|
|
5361
|
+
namedCurve: namedCurve
|
|
5115
5362
|
};
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
default:
|
|
5120
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
5363
|
+
} catch (cause) {
|
|
5364
|
+
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
5121
5365
|
}
|
|
5366
|
+
keyUsages = isPublic ? [] : [ "deriveBits" ];
|
|
5122
5367
|
break;
|
|
5123
5368
|
}
|
|
5124
5369
|
|
|
5370
|
+
case "Ed25519":
|
|
5371
|
+
case "EdDSA":
|
|
5372
|
+
algorithm = {
|
|
5373
|
+
name: "Ed25519"
|
|
5374
|
+
};
|
|
5375
|
+
keyUsages = getSigUsages();
|
|
5376
|
+
break;
|
|
5377
|
+
|
|
5378
|
+
case "ML-DSA-44":
|
|
5379
|
+
case "ML-DSA-65":
|
|
5380
|
+
case "ML-DSA-87":
|
|
5381
|
+
algorithm = {
|
|
5382
|
+
name: alg
|
|
5383
|
+
};
|
|
5384
|
+
keyUsages = getSigUsages();
|
|
5385
|
+
break;
|
|
5386
|
+
|
|
5125
5387
|
default:
|
|
5126
|
-
throw new JOSENotSupported('Invalid or unsupported
|
|
5388
|
+
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
5127
5389
|
}
|
|
5128
|
-
return
|
|
5129
|
-
|
|
5130
|
-
keyUsages: keyUsages
|
|
5131
|
-
};
|
|
5132
|
-
}
|
|
5390
|
+
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);
|
|
5391
|
+
};
|
|
5133
5392
|
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5393
|
+
const processPEMData = (pem, pattern) => decodeBase64(pem.replace(pattern, ""));
|
|
5394
|
+
|
|
5395
|
+
const fromPKCS8 = (pem, alg, options) => {
|
|
5396
|
+
var _alg$startsWith;
|
|
5397
|
+
const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
5398
|
+
let opts = options;
|
|
5399
|
+
if (alg !== null && alg !== void 0 && (_alg$startsWith = alg.startsWith) !== null && _alg$startsWith !== void 0 && _alg$startsWith.call(alg, "ECDH-ES")) {
|
|
5400
|
+
opts || (opts = {});
|
|
5401
|
+
opts.getNamedCurve = keyData => {
|
|
5402
|
+
const state = createASN1State(keyData);
|
|
5403
|
+
parsePKCS8Header(state);
|
|
5404
|
+
return parseECAlgorithmIdentifier(state);
|
|
5405
|
+
};
|
|
5143
5406
|
}
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
}
|
|
5407
|
+
return genericImport("pkcs8", keyData, alg, opts);
|
|
5408
|
+
};
|
|
5147
5409
|
|
|
5148
5410
|
async function importPKCS8(pkcs8, alg, options) {
|
|
5149
5411
|
if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
|
|
@@ -5194,239 +5456,51 @@ async function importJWK(jwk, alg, options) {
|
|
|
5194
5456
|
return jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
5195
5457
|
alg: alg,
|
|
5196
5458
|
ext: ext
|
|
5197
|
-
}));
|
|
5198
|
-
|
|
5199
|
-
default:
|
|
5200
|
-
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
5201
|
-
}
|
|
5202
|
-
}
|
|
5203
|
-
|
|
5204
|
-
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
5205
|
-
if (joseHeader.crit !== undefined && (protectedHeader === null || protectedHeader === void 0 ? void 0 : protectedHeader.crit) === undefined) {
|
|
5206
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
5207
|
-
}
|
|
5208
|
-
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
5209
|
-
return new Set;
|
|
5210
|
-
}
|
|
5211
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input => typeof input !== "string" || input.length === 0))) {
|
|
5212
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
5213
|
-
}
|
|
5214
|
-
let recognized;
|
|
5215
|
-
if (recognizedOption !== undefined) {
|
|
5216
|
-
recognized = new Map([ ...Object.entries(recognizedOption), ...recognizedDefault.entries() ]);
|
|
5217
|
-
} else {
|
|
5218
|
-
recognized = recognizedDefault;
|
|
5219
|
-
}
|
|
5220
|
-
for (const parameter of protectedHeader.crit) {
|
|
5221
|
-
if (!recognized.has(parameter)) {
|
|
5222
|
-
throw new JOSENotSupported('Extension Header Parameter "'.concat(parameter, '" is not recognized'));
|
|
5223
|
-
}
|
|
5224
|
-
if (joseHeader[parameter] === undefined) {
|
|
5225
|
-
throw new Err('Extension Header Parameter "'.concat(parameter, '" is missing'));
|
|
5226
|
-
}
|
|
5227
|
-
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
5228
|
-
throw new Err('Extension Header Parameter "'.concat(parameter, '" MUST be integrity protected'));
|
|
5229
|
-
}
|
|
5230
|
-
}
|
|
5231
|
-
return new Set(protectedHeader.crit);
|
|
5232
|
-
}
|
|
5233
|
-
|
|
5234
|
-
function validateAlgorithms(option, algorithms) {
|
|
5235
|
-
if (algorithms !== undefined && (!Array.isArray(algorithms) || algorithms.some((s => typeof s !== "string")))) {
|
|
5236
|
-
throw new TypeError('"'.concat(option, '" option must be an array of strings'));
|
|
5237
|
-
}
|
|
5238
|
-
if (!algorithms) {
|
|
5239
|
-
return undefined;
|
|
5240
|
-
}
|
|
5241
|
-
return new Set(algorithms);
|
|
5242
|
-
}
|
|
5243
|
-
|
|
5244
|
-
const isJWK = key => isObject(key) && typeof key.kty === "string";
|
|
5245
|
-
|
|
5246
|
-
const isPrivateJWK = key => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
5247
|
-
|
|
5248
|
-
const isPublicJWK = key => key.kty !== "oct" && key.d === undefined && key.priv === undefined;
|
|
5249
|
-
|
|
5250
|
-
const isSecretJWK = key => key.kty === "oct" && typeof key.k === "string";
|
|
5251
|
-
|
|
5252
|
-
let cache;
|
|
5253
|
-
|
|
5254
|
-
const handleJWK = async function handleJWK(key, jwk, alg) {
|
|
5255
|
-
let freeze = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
5256
|
-
cache || (cache = new WeakMap);
|
|
5257
|
-
let cached = cache.get(key);
|
|
5258
|
-
if (cached !== null && cached !== void 0 && cached[alg]) {
|
|
5259
|
-
return cached[alg];
|
|
5260
|
-
}
|
|
5261
|
-
const cryptoKey = await jwkToKey(_objectSpread2(_objectSpread2({}, jwk), {}, {
|
|
5262
|
-
alg: alg
|
|
5263
|
-
}));
|
|
5264
|
-
if (freeze) Object.freeze(key);
|
|
5265
|
-
if (!cached) {
|
|
5266
|
-
cache.set(key, {
|
|
5267
|
-
[alg]: cryptoKey
|
|
5268
|
-
});
|
|
5269
|
-
} else {
|
|
5270
|
-
cached[alg] = cryptoKey;
|
|
5271
|
-
}
|
|
5272
|
-
return cryptoKey;
|
|
5273
|
-
};
|
|
5274
|
-
|
|
5275
|
-
const handleKeyObject = (keyObject, alg) => {
|
|
5276
|
-
cache || (cache = new WeakMap);
|
|
5277
|
-
let cached = cache.get(keyObject);
|
|
5278
|
-
if (cached !== null && cached !== void 0 && cached[alg]) {
|
|
5279
|
-
return cached[alg];
|
|
5280
|
-
}
|
|
5281
|
-
const isPublic = keyObject.type === "public";
|
|
5282
|
-
const extractable = isPublic ? true : false;
|
|
5283
|
-
let cryptoKey;
|
|
5284
|
-
if (keyObject.asymmetricKeyType === "x25519") {
|
|
5285
|
-
switch (alg) {
|
|
5286
|
-
case "ECDH-ES":
|
|
5287
|
-
case "ECDH-ES+A128KW":
|
|
5288
|
-
case "ECDH-ES+A192KW":
|
|
5289
|
-
case "ECDH-ES+A256KW":
|
|
5290
|
-
break;
|
|
5291
|
-
|
|
5292
|
-
default:
|
|
5293
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
5294
|
-
}
|
|
5295
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : [ "deriveBits" ]);
|
|
5296
|
-
}
|
|
5297
|
-
if (keyObject.asymmetricKeyType === "ed25519") {
|
|
5298
|
-
if (alg !== "EdDSA" && alg !== "Ed25519") {
|
|
5299
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
5300
|
-
}
|
|
5301
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5302
|
-
}
|
|
5303
|
-
switch (keyObject.asymmetricKeyType) {
|
|
5304
|
-
case "ml-dsa-44":
|
|
5305
|
-
case "ml-dsa-65":
|
|
5306
|
-
case "ml-dsa-87":
|
|
5307
|
-
{
|
|
5308
|
-
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
|
|
5309
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
5310
|
-
}
|
|
5311
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5312
|
-
}
|
|
5313
|
-
}
|
|
5314
|
-
if (keyObject.asymmetricKeyType === "rsa") {
|
|
5315
|
-
let hash;
|
|
5316
|
-
switch (alg) {
|
|
5317
|
-
case "RSA-OAEP":
|
|
5318
|
-
hash = "SHA-1";
|
|
5319
|
-
break;
|
|
5320
|
-
|
|
5321
|
-
case "RS256":
|
|
5322
|
-
case "PS256":
|
|
5323
|
-
case "RSA-OAEP-256":
|
|
5324
|
-
hash = "SHA-256";
|
|
5325
|
-
break;
|
|
5326
|
-
|
|
5327
|
-
case "RS384":
|
|
5328
|
-
case "PS384":
|
|
5329
|
-
case "RSA-OAEP-384":
|
|
5330
|
-
hash = "SHA-384";
|
|
5331
|
-
break;
|
|
5332
|
-
|
|
5333
|
-
case "RS512":
|
|
5334
|
-
case "PS512":
|
|
5335
|
-
case "RSA-OAEP-512":
|
|
5336
|
-
hash = "SHA-512";
|
|
5337
|
-
break;
|
|
5338
|
-
|
|
5339
|
-
default:
|
|
5340
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
5341
|
-
}
|
|
5342
|
-
if (alg.startsWith("RSA-OAEP")) {
|
|
5343
|
-
return keyObject.toCryptoKey({
|
|
5344
|
-
name: "RSA-OAEP",
|
|
5345
|
-
hash: hash
|
|
5346
|
-
}, extractable, isPublic ? [ "encrypt" ] : [ "decrypt" ]);
|
|
5347
|
-
}
|
|
5348
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
5349
|
-
name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
5350
|
-
hash: hash
|
|
5351
|
-
}, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5352
|
-
}
|
|
5353
|
-
if (keyObject.asymmetricKeyType === "ec") {
|
|
5354
|
-
var _keyObject$asymmetric;
|
|
5355
|
-
const nist = new Map([ [ "prime256v1", "P-256" ], [ "secp384r1", "P-384" ], [ "secp521r1", "P-521" ] ]);
|
|
5356
|
-
const namedCurve = nist.get((_keyObject$asymmetric = keyObject.asymmetricKeyDetails) === null || _keyObject$asymmetric === void 0 ? void 0 : _keyObject$asymmetric.namedCurve);
|
|
5357
|
-
if (!namedCurve) {
|
|
5358
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
5359
|
-
}
|
|
5360
|
-
if (alg === "ES256" && namedCurve === "P-256") {
|
|
5361
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
5362
|
-
name: "ECDSA",
|
|
5363
|
-
namedCurve: namedCurve
|
|
5364
|
-
}, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5365
|
-
}
|
|
5366
|
-
if (alg === "ES384" && namedCurve === "P-384") {
|
|
5367
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
5368
|
-
name: "ECDSA",
|
|
5369
|
-
namedCurve: namedCurve
|
|
5370
|
-
}, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5371
|
-
}
|
|
5372
|
-
if (alg === "ES512" && namedCurve === "P-521") {
|
|
5373
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
5374
|
-
name: "ECDSA",
|
|
5375
|
-
namedCurve: namedCurve
|
|
5376
|
-
}, extractable, [ isPublic ? "verify" : "sign" ]);
|
|
5377
|
-
}
|
|
5378
|
-
if (alg.startsWith("ECDH-ES")) {
|
|
5379
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
5380
|
-
name: "ECDH",
|
|
5381
|
-
namedCurve: namedCurve
|
|
5382
|
-
}, extractable, isPublic ? [] : [ "deriveBits" ]);
|
|
5383
|
-
}
|
|
5459
|
+
}));
|
|
5460
|
+
|
|
5461
|
+
default:
|
|
5462
|
+
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
5384
5463
|
}
|
|
5385
|
-
|
|
5386
|
-
|
|
5464
|
+
}
|
|
5465
|
+
|
|
5466
|
+
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
5467
|
+
if (joseHeader.crit !== undefined && (protectedHeader === null || protectedHeader === void 0 ? void 0 : protectedHeader.crit) === undefined) {
|
|
5468
|
+
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
5387
5469
|
}
|
|
5388
|
-
if (!
|
|
5389
|
-
|
|
5390
|
-
[alg]: cryptoKey
|
|
5391
|
-
});
|
|
5392
|
-
} else {
|
|
5393
|
-
cached[alg] = cryptoKey;
|
|
5470
|
+
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
5471
|
+
return new Set;
|
|
5394
5472
|
}
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
async function normalizeKey(key, alg) {
|
|
5399
|
-
if (key instanceof Uint8Array) {
|
|
5400
|
-
return key;
|
|
5473
|
+
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some(input => typeof input !== "string" || input.length === 0)) {
|
|
5474
|
+
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
5401
5475
|
}
|
|
5402
|
-
|
|
5403
|
-
|
|
5476
|
+
let recognized;
|
|
5477
|
+
if (recognizedOption !== undefined) {
|
|
5478
|
+
recognized = new Map([ ...Object.entries(recognizedOption), ...recognizedDefault.entries() ]);
|
|
5479
|
+
} else {
|
|
5480
|
+
recognized = recognizedDefault;
|
|
5404
5481
|
}
|
|
5405
|
-
|
|
5406
|
-
if (
|
|
5407
|
-
|
|
5482
|
+
for (const parameter of protectedHeader.crit) {
|
|
5483
|
+
if (!recognized.has(parameter)) {
|
|
5484
|
+
throw new JOSENotSupported('Extension Header Parameter "'.concat(parameter, '" is not recognized'));
|
|
5408
5485
|
}
|
|
5409
|
-
if (
|
|
5410
|
-
|
|
5411
|
-
return handleKeyObject(key, alg);
|
|
5412
|
-
} catch (err) {
|
|
5413
|
-
if (err instanceof TypeError) {
|
|
5414
|
-
throw err;
|
|
5415
|
-
}
|
|
5416
|
-
}
|
|
5486
|
+
if (joseHeader[parameter] === undefined) {
|
|
5487
|
+
throw new Err('Extension Header Parameter "'.concat(parameter, '" is missing'));
|
|
5417
5488
|
}
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
});
|
|
5421
|
-
return handleJWK(key, jwk, alg);
|
|
5422
|
-
}
|
|
5423
|
-
if (isJWK(key)) {
|
|
5424
|
-
if (key.k) {
|
|
5425
|
-
return decode(key.k);
|
|
5489
|
+
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
5490
|
+
throw new Err('Extension Header Parameter "'.concat(parameter, '" MUST be integrity protected'));
|
|
5426
5491
|
}
|
|
5427
|
-
return handleJWK(key, key, alg, true);
|
|
5428
5492
|
}
|
|
5429
|
-
|
|
5493
|
+
return new Set(protectedHeader.crit);
|
|
5494
|
+
}
|
|
5495
|
+
|
|
5496
|
+
function validateAlgorithms(option, algorithms) {
|
|
5497
|
+
if (algorithms !== undefined && (!Array.isArray(algorithms) || algorithms.some(s => typeof s !== "string"))) {
|
|
5498
|
+
throw new TypeError('"'.concat(option, '" option must be an array of strings'));
|
|
5499
|
+
}
|
|
5500
|
+
if (!algorithms) {
|
|
5501
|
+
return undefined;
|
|
5502
|
+
}
|
|
5503
|
+
return new Set(algorithms);
|
|
5430
5504
|
}
|
|
5431
5505
|
|
|
5432
5506
|
const tag = key => key === null || key === void 0 ? void 0 : key[Symbol.toStringTag];
|
|
@@ -5566,7 +5640,7 @@ let USER_AGENT$1;
|
|
|
5566
5640
|
|
|
5567
5641
|
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 "))) {
|
|
5568
5642
|
const NAME = "openid-client";
|
|
5569
|
-
const VERSION = "v6.8.
|
|
5643
|
+
const VERSION = "v6.8.2";
|
|
5570
5644
|
USER_AGENT$1 = "".concat(NAME, "/").concat(VERSION);
|
|
5571
5645
|
headers = {
|
|
5572
5646
|
"user-agent": USER_AGENT$1
|
|
@@ -5778,7 +5852,7 @@ async function performDiscovery(server, options) {
|
|
|
5778
5852
|
method: "GET",
|
|
5779
5853
|
redirect: "manual",
|
|
5780
5854
|
signal: signal
|
|
5781
|
-
})).then(
|
|
5855
|
+
})).then(response => processDiscoveryResponse(_nodiscoverycheck, response)).catch(errorHandler);
|
|
5782
5856
|
if (resolve && new URL(as.issuer).href !== server.href) {
|
|
5783
5857
|
handleEntraId(server, as, options) || handleB2Clogin(server, options) || (() => {
|
|
5784
5858
|
throw new ClientError("discovered metadata issuer does not match the expected issuer", {
|
|
@@ -5953,7 +6027,7 @@ async function handleRetryAfter(response, currentInterval, signal) {
|
|
|
5953
6027
|
}
|
|
5954
6028
|
|
|
5955
6029
|
function wait(duration, signal) {
|
|
5956
|
-
return new Promise((
|
|
6030
|
+
return new Promise((resolve, reject) => {
|
|
5957
6031
|
const waitStep = remaining => {
|
|
5958
6032
|
try {
|
|
5959
6033
|
signal.throwIfAborted();
|
|
@@ -5966,10 +6040,10 @@ function wait(duration, signal) {
|
|
|
5966
6040
|
return;
|
|
5967
6041
|
}
|
|
5968
6042
|
const currentWait = Math.min(remaining, 5);
|
|
5969
|
-
setTimeout((
|
|
6043
|
+
setTimeout(() => waitStep(remaining - currentWait), currentWait * 1e3);
|
|
5970
6044
|
};
|
|
5971
6045
|
waitStep(duration);
|
|
5972
|
-
})
|
|
6046
|
+
});
|
|
5973
6047
|
}
|
|
5974
6048
|
|
|
5975
6049
|
async function initiateBackchannelAuthentication(config, parameters) {
|
|
@@ -5980,7 +6054,7 @@ async function initiateBackchannelAuthentication(config, parameters) {
|
|
|
5980
6054
|
[allowInsecureRequests$1]: !tlsOnly,
|
|
5981
6055
|
headers: new Headers(headers),
|
|
5982
6056
|
signal: signal(timeout)
|
|
5983
|
-
}).then(
|
|
6057
|
+
}).then(response => processBackchannelAuthenticationResponse(as, c, response)).catch(errorHandler);
|
|
5984
6058
|
}
|
|
5985
6059
|
|
|
5986
6060
|
async function pollBackchannelAuthenticationGrant(config, backchannelAuthenticationResponse, parameters, options) {
|
|
@@ -6307,7 +6381,7 @@ async function genericGrantRequest(config, grantType, parameters, options) {
|
|
|
6307
6381
|
DPoP: options === null || options === void 0 ? void 0 : options.DPoP,
|
|
6308
6382
|
headers: new Headers(headers),
|
|
6309
6383
|
signal: signal(timeout)
|
|
6310
|
-
}).then(
|
|
6384
|
+
}).then(response => {
|
|
6311
6385
|
let recognizedTokenTypes;
|
|
6312
6386
|
if (grantType === "urn:ietf:params:oauth:grant-type:token-exchange") {
|
|
6313
6387
|
recognizedTokenTypes = {
|
|
@@ -6318,91 +6392,11 @@ async function genericGrantRequest(config, grantType, parameters, options) {
|
|
|
6318
6392
|
[jweDecrypt]: decrypt,
|
|
6319
6393
|
recognizedTokenTypes: recognizedTokenTypes
|
|
6320
6394
|
});
|
|
6321
|
-
})
|
|
6395
|
+
}).catch(errorHandler);
|
|
6322
6396
|
addHelpers(result);
|
|
6323
6397
|
return result;
|
|
6324
6398
|
}
|
|
6325
6399
|
|
|
6326
|
-
function subtleAlgorithm(alg, algorithm) {
|
|
6327
|
-
const hash = "SHA-".concat(alg.slice(-3));
|
|
6328
|
-
switch (alg) {
|
|
6329
|
-
case "HS256":
|
|
6330
|
-
case "HS384":
|
|
6331
|
-
case "HS512":
|
|
6332
|
-
return {
|
|
6333
|
-
hash: hash,
|
|
6334
|
-
name: "HMAC"
|
|
6335
|
-
};
|
|
6336
|
-
|
|
6337
|
-
case "PS256":
|
|
6338
|
-
case "PS384":
|
|
6339
|
-
case "PS512":
|
|
6340
|
-
return {
|
|
6341
|
-
hash: hash,
|
|
6342
|
-
name: "RSA-PSS",
|
|
6343
|
-
saltLength: parseInt(alg.slice(-3), 10) >> 3
|
|
6344
|
-
};
|
|
6345
|
-
|
|
6346
|
-
case "RS256":
|
|
6347
|
-
case "RS384":
|
|
6348
|
-
case "RS512":
|
|
6349
|
-
return {
|
|
6350
|
-
hash: hash,
|
|
6351
|
-
name: "RSASSA-PKCS1-v1_5"
|
|
6352
|
-
};
|
|
6353
|
-
|
|
6354
|
-
case "ES256":
|
|
6355
|
-
case "ES384":
|
|
6356
|
-
case "ES512":
|
|
6357
|
-
return {
|
|
6358
|
-
hash: hash,
|
|
6359
|
-
name: "ECDSA",
|
|
6360
|
-
namedCurve: algorithm.namedCurve
|
|
6361
|
-
};
|
|
6362
|
-
|
|
6363
|
-
case "Ed25519":
|
|
6364
|
-
case "EdDSA":
|
|
6365
|
-
return {
|
|
6366
|
-
name: "Ed25519"
|
|
6367
|
-
};
|
|
6368
|
-
|
|
6369
|
-
case "ML-DSA-44":
|
|
6370
|
-
case "ML-DSA-65":
|
|
6371
|
-
case "ML-DSA-87":
|
|
6372
|
-
return {
|
|
6373
|
-
name: alg
|
|
6374
|
-
};
|
|
6375
|
-
|
|
6376
|
-
default:
|
|
6377
|
-
throw new JOSENotSupported("alg ".concat(alg, " is not supported either by JOSE or your javascript runtime"));
|
|
6378
|
-
}
|
|
6379
|
-
}
|
|
6380
|
-
|
|
6381
|
-
async function getSigKey(alg, key, usage) {
|
|
6382
|
-
if (key instanceof Uint8Array) {
|
|
6383
|
-
if (!alg.startsWith("HS")) {
|
|
6384
|
-
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
6385
|
-
}
|
|
6386
|
-
return crypto.subtle.importKey("raw", key, {
|
|
6387
|
-
hash: "SHA-".concat(alg.slice(-3)),
|
|
6388
|
-
name: "HMAC"
|
|
6389
|
-
}, false, [ usage ]);
|
|
6390
|
-
}
|
|
6391
|
-
checkSigCryptoKey(key, alg, usage);
|
|
6392
|
-
return key;
|
|
6393
|
-
}
|
|
6394
|
-
|
|
6395
|
-
async function verify(alg, key, signature, data) {
|
|
6396
|
-
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
6397
|
-
checkKeyLength(alg, cryptoKey);
|
|
6398
|
-
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
6399
|
-
try {
|
|
6400
|
-
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
|
|
6401
|
-
} catch (_unused) {
|
|
6402
|
-
return false;
|
|
6403
|
-
}
|
|
6404
|
-
}
|
|
6405
|
-
|
|
6406
6400
|
async function flattenedVerify(jws, key, options) {
|
|
6407
6401
|
if (!isObject(jws)) {
|
|
6408
6402
|
throw new JWSInvalid("Flattened JWS must be an object");
|
|
@@ -6465,12 +6459,7 @@ async function flattenedVerify(jws, key, options) {
|
|
|
6465
6459
|
}
|
|
6466
6460
|
checkKeyType(alg, key, "verify");
|
|
6467
6461
|
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);
|
|
6468
|
-
|
|
6469
|
-
try {
|
|
6470
|
-
signature = decode(jws.signature);
|
|
6471
|
-
} catch (_unused2) {
|
|
6472
|
-
throw new JWSInvalid("Failed to base64url decode the signature");
|
|
6473
|
-
}
|
|
6462
|
+
const signature = decodeBase64url(jws.signature, "signature", JWSInvalid);
|
|
6474
6463
|
const k = await normalizeKey(key, alg);
|
|
6475
6464
|
const verified = await verify(alg, k, signature, data);
|
|
6476
6465
|
if (!verified) {
|
|
@@ -6478,11 +6467,7 @@ async function flattenedVerify(jws, key, options) {
|
|
|
6478
6467
|
}
|
|
6479
6468
|
let payload;
|
|
6480
6469
|
if (b64) {
|
|
6481
|
-
|
|
6482
|
-
payload = decode(jws.payload);
|
|
6483
|
-
} catch (_unused3) {
|
|
6484
|
-
throw new JWSInvalid("Failed to base64url decode the payload");
|
|
6485
|
-
}
|
|
6470
|
+
payload = decodeBase64url(jws.payload, "payload", JWSInvalid);
|
|
6486
6471
|
} else if (typeof jws.payload === "string") {
|
|
6487
6472
|
payload = encoder.encode(jws.payload);
|
|
6488
6473
|
} else {
|
|
@@ -6769,7 +6754,7 @@ class LocalJWKSet {
|
|
|
6769
6754
|
async getKey(protectedHeader, token) {
|
|
6770
6755
|
const {alg: alg, kid: kid} = _objectSpread2(_objectSpread2({}, protectedHeader), token === null || token === void 0 ? void 0 : token.header);
|
|
6771
6756
|
const kty = getKtyFromAlg(alg);
|
|
6772
|
-
const candidates = _classPrivateFieldGet2(_jwks$1, this).keys.filter(
|
|
6757
|
+
const candidates = _classPrivateFieldGet2(_jwks$1, this).keys.filter(jwk => {
|
|
6773
6758
|
let candidate = kty === jwk.kty;
|
|
6774
6759
|
if (candidate && typeof kid === "string") {
|
|
6775
6760
|
candidate = kid === jwk.kid;
|
|
@@ -6804,7 +6789,7 @@ class LocalJWKSet {
|
|
|
6804
6789
|
}
|
|
6805
6790
|
}
|
|
6806
6791
|
return candidate;
|
|
6807
|
-
})
|
|
6792
|
+
});
|
|
6808
6793
|
const {0: jwk, length: length} = candidates;
|
|
6809
6794
|
if (length === 0) {
|
|
6810
6795
|
throw new JWKSNoMatchingKey;
|
|
@@ -6812,13 +6797,13 @@ class LocalJWKSet {
|
|
|
6812
6797
|
if (length !== 1) {
|
|
6813
6798
|
const error = new JWKSMultipleMatchingKeys;
|
|
6814
6799
|
const _cached = _classPrivateFieldGet2(_cached2, this);
|
|
6815
|
-
error[Symbol.asyncIterator] = _wrapAsyncGenerator(
|
|
6800
|
+
error[Symbol.asyncIterator] = _wrapAsyncGenerator(function*() {
|
|
6816
6801
|
for (const jwk of candidates) {
|
|
6817
6802
|
try {
|
|
6818
6803
|
yield yield _awaitAsyncGenerator(importWithAlgCache(_cached, jwk, alg));
|
|
6819
6804
|
} catch (_unused) {}
|
|
6820
6805
|
}
|
|
6821
|
-
})
|
|
6806
|
+
});
|
|
6822
6807
|
throw error;
|
|
6823
6808
|
}
|
|
6824
6809
|
return importWithAlgCache(_classPrivateFieldGet2(_cached2, this), jwk, alg);
|
|
@@ -6863,7 +6848,7 @@ let USER_AGENT;
|
|
|
6863
6848
|
|
|
6864
6849
|
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 "))) {
|
|
6865
6850
|
const NAME = "jose";
|
|
6866
|
-
const VERSION = "v6.1
|
|
6851
|
+
const VERSION = "v6.2.1";
|
|
6867
6852
|
USER_AGENT = "".concat(NAME, "/").concat(VERSION);
|
|
6868
6853
|
}
|
|
6869
6854
|
|
|
@@ -6876,12 +6861,12 @@ async function fetchJwks(url, headers, signal) {
|
|
|
6876
6861
|
signal: signal,
|
|
6877
6862
|
redirect: "manual",
|
|
6878
6863
|
headers: headers
|
|
6879
|
-
}).catch(
|
|
6864
|
+
}).catch(err => {
|
|
6880
6865
|
if (err.name === "TimeoutError") {
|
|
6881
6866
|
throw new JWKSTimeout;
|
|
6882
6867
|
}
|
|
6883
6868
|
throw err;
|
|
6884
|
-
})
|
|
6869
|
+
});
|
|
6885
6870
|
if (response.status !== 200) {
|
|
6886
6871
|
throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
|
|
6887
6872
|
}
|
|
@@ -6996,7 +6981,7 @@ class RemoteJWKSet {
|
|
|
6996
6981
|
if (_classPrivateFieldGet2(_pendingFetch, this) && isCloudflareWorkers()) {
|
|
6997
6982
|
_classPrivateFieldSet2(_pendingFetch, this, undefined);
|
|
6998
6983
|
}
|
|
6999
|
-
_classPrivateFieldGet2(_pendingFetch, this) || _classPrivateFieldSet2(_pendingFetch, this, fetchJwks(_classPrivateFieldGet2(_url, this).href, _classPrivateFieldGet2(_headers, this), AbortSignal.timeout(_classPrivateFieldGet2(_timeoutDuration, this)), _classPrivateFieldGet2(_customFetch$1, this)).then(
|
|
6984
|
+
_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 => {
|
|
7000
6985
|
_classPrivateFieldSet2(_local, this, createLocalJWKSet(json));
|
|
7001
6986
|
if (_classPrivateFieldGet2(_cache, this)) {
|
|
7002
6987
|
_classPrivateFieldGet2(_cache, this).uat = Date.now();
|
|
@@ -7004,10 +6989,10 @@ class RemoteJWKSet {
|
|
|
7004
6989
|
}
|
|
7005
6990
|
_classPrivateFieldSet2(_jwksTimestamp, this, Date.now());
|
|
7006
6991
|
_classPrivateFieldSet2(_pendingFetch, this, undefined);
|
|
7007
|
-
})
|
|
6992
|
+
}).catch(err => {
|
|
7008
6993
|
_classPrivateFieldSet2(_pendingFetch, this, undefined);
|
|
7009
6994
|
throw err;
|
|
7010
|
-
}))
|
|
6995
|
+
}));
|
|
7011
6996
|
await _classPrivateFieldGet2(_pendingFetch, this);
|
|
7012
6997
|
}
|
|
7013
6998
|
}
|
|
@@ -7049,7 +7034,7 @@ function createRemoteJWKSet(url, options) {
|
|
|
7049
7034
|
|
|
7050
7035
|
const _excluded = [ "mfaToken" ], _excluded2 = [ "mfaToken" ];
|
|
7051
7036
|
|
|
7052
|
-
var _baseUrl, _clientId, _customFetch, _configuration, _serverMetadata, _options, _jwks,
|
|
7037
|
+
var _baseUrl, _clientId, _customFetch, _entries, _ttlMs, _maxEntries, _configuration, _serverMetadata, _clientAuthPromise, _options, _customFetch2, _jwks, _discoveryCache, _inFlightDiscovery, _jwksCache, _Class9_brand;
|
|
7053
7038
|
|
|
7054
7039
|
var NotSupportedError = class NotSupportedError extends Error {
|
|
7055
7040
|
constructor(code, message) {
|
|
@@ -7155,12 +7140,12 @@ var MissingClientAuthError = class MissingClientAuthError extends Error {
|
|
|
7155
7140
|
};
|
|
7156
7141
|
|
|
7157
7142
|
function stripUndefinedProperties(value) {
|
|
7158
|
-
return Object.entries(value).filter(
|
|
7143
|
+
return Object.entries(value).filter(_ref => {
|
|
7159
7144
|
let [, value2] = _ref;
|
|
7160
7145
|
return typeof value2 !== "undefined";
|
|
7161
|
-
})
|
|
7146
|
+
}).reduce((acc, curr) => _objectSpread2(_objectSpread2({}, acc), {}, {
|
|
7162
7147
|
[curr[0]]: curr[1]
|
|
7163
|
-
})
|
|
7148
|
+
}), {});
|
|
7164
7149
|
}
|
|
7165
7150
|
|
|
7166
7151
|
var MfaError$1 = class MfaError extends Error {
|
|
@@ -7232,7 +7217,9 @@ function transformEnrollmentResponse(api) {
|
|
|
7232
7217
|
oobChannel: api.oob_channel,
|
|
7233
7218
|
oobCode: api.oob_code,
|
|
7234
7219
|
bindingMethod: api.binding_method,
|
|
7235
|
-
id: api.id
|
|
7220
|
+
id: api.id,
|
|
7221
|
+
barcodeUri: api.barcode_uri,
|
|
7222
|
+
recoveryCodes: api.recovery_codes
|
|
7236
7223
|
};
|
|
7237
7224
|
}
|
|
7238
7225
|
throw new Error("Unexpected authenticator type: ".concat(api.authenticator_type));
|
|
@@ -7353,6 +7340,42 @@ class MfaClient {
|
|
|
7353
7340
|
}
|
|
7354
7341
|
});
|
|
7355
7342
|
|
|
7343
|
+
function createTelemetryFetch(baseFetch, config) {
|
|
7344
|
+
if (config.enabled === false) {
|
|
7345
|
+
return baseFetch;
|
|
7346
|
+
}
|
|
7347
|
+
const telemetryData = {
|
|
7348
|
+
name: config.name,
|
|
7349
|
+
version: config.version
|
|
7350
|
+
};
|
|
7351
|
+
const headerValue = btoa(JSON.stringify(telemetryData));
|
|
7352
|
+
return async (input, init) => {
|
|
7353
|
+
const headers = input instanceof Request ? new Headers(input.headers) : new Headers;
|
|
7354
|
+
if (init !== null && init !== void 0 && init.headers) {
|
|
7355
|
+
const initHeaders = new Headers(init.headers);
|
|
7356
|
+
initHeaders.forEach((value, key) => {
|
|
7357
|
+
headers.set(key, value);
|
|
7358
|
+
});
|
|
7359
|
+
}
|
|
7360
|
+
headers.set("Auth0-Client", headerValue);
|
|
7361
|
+
return baseFetch(input, _objectSpread2(_objectSpread2({}, init), {}, {
|
|
7362
|
+
headers: headers
|
|
7363
|
+
}));
|
|
7364
|
+
};
|
|
7365
|
+
}
|
|
7366
|
+
|
|
7367
|
+
function getTelemetryConfig(config) {
|
|
7368
|
+
var _config$name, _config$version;
|
|
7369
|
+
if ((config === null || config === void 0 ? void 0 : config.enabled) === false) {
|
|
7370
|
+
return config;
|
|
7371
|
+
}
|
|
7372
|
+
return {
|
|
7373
|
+
enabled: true,
|
|
7374
|
+
name: (_config$name = config === null || config === void 0 ? void 0 : config.name) !== null && _config$name !== void 0 ? _config$name : "@auth0/auth0-auth-js",
|
|
7375
|
+
version: (_config$version = config === null || config === void 0 ? void 0 : config.version) !== null && _config$version !== void 0 ? _config$version : "1.5.0"
|
|
7376
|
+
};
|
|
7377
|
+
}
|
|
7378
|
+
|
|
7356
7379
|
var TokenResponse = class _TokenResponse {
|
|
7357
7380
|
constructor(accessToken, expiresAt, idToken, refreshToken, scope, claims, authorizationDetails) {
|
|
7358
7381
|
_defineProperty(this, "accessToken", void 0);
|
|
@@ -7381,6 +7404,81 @@ var TokenResponse = class _TokenResponse {
|
|
|
7381
7404
|
}
|
|
7382
7405
|
};
|
|
7383
7406
|
|
|
7407
|
+
var LruCache = (_entries = new WeakMap, _ttlMs = new WeakMap, _maxEntries = new WeakMap,
|
|
7408
|
+
class LruCache {
|
|
7409
|
+
constructor(maxEntries, ttlMs) {
|
|
7410
|
+
_classPrivateFieldInitSpec(this, _entries, new Map);
|
|
7411
|
+
_classPrivateFieldInitSpec(this, _ttlMs, void 0);
|
|
7412
|
+
_classPrivateFieldInitSpec(this, _maxEntries, void 0);
|
|
7413
|
+
_classPrivateFieldSet2(_maxEntries, this, Math.max(1, Math.floor(maxEntries)));
|
|
7414
|
+
_classPrivateFieldSet2(_ttlMs, this, Math.max(0, Math.floor(ttlMs)));
|
|
7415
|
+
}
|
|
7416
|
+
get(key) {
|
|
7417
|
+
const entry = _classPrivateFieldGet2(_entries, this).get(key);
|
|
7418
|
+
if (!entry) {
|
|
7419
|
+
return;
|
|
7420
|
+
}
|
|
7421
|
+
if (Date.now() >= entry.expiresAt) {
|
|
7422
|
+
_classPrivateFieldGet2(_entries, this).delete(key);
|
|
7423
|
+
return;
|
|
7424
|
+
}
|
|
7425
|
+
_classPrivateFieldGet2(_entries, this).delete(key);
|
|
7426
|
+
_classPrivateFieldGet2(_entries, this).set(key, entry);
|
|
7427
|
+
return entry.value;
|
|
7428
|
+
}
|
|
7429
|
+
set(key, value) {
|
|
7430
|
+
if (_classPrivateFieldGet2(_entries, this).has(key)) {
|
|
7431
|
+
_classPrivateFieldGet2(_entries, this).delete(key);
|
|
7432
|
+
}
|
|
7433
|
+
_classPrivateFieldGet2(_entries, this).set(key, {
|
|
7434
|
+
value: value,
|
|
7435
|
+
expiresAt: Date.now() + _classPrivateFieldGet2(_ttlMs, this)
|
|
7436
|
+
});
|
|
7437
|
+
while (_classPrivateFieldGet2(_entries, this).size > _classPrivateFieldGet2(_maxEntries, this)) {
|
|
7438
|
+
const oldestKey = _classPrivateFieldGet2(_entries, this).keys().next().value;
|
|
7439
|
+
if (oldestKey === void 0) {
|
|
7440
|
+
break;
|
|
7441
|
+
}
|
|
7442
|
+
_classPrivateFieldGet2(_entries, this).delete(oldestKey);
|
|
7443
|
+
}
|
|
7444
|
+
}
|
|
7445
|
+
});
|
|
7446
|
+
|
|
7447
|
+
var globalCaches = new Map;
|
|
7448
|
+
|
|
7449
|
+
function getGlobalCache(key) {
|
|
7450
|
+
return globalCaches.get(key);
|
|
7451
|
+
}
|
|
7452
|
+
|
|
7453
|
+
function getGlobalCacheKey(maxEntries, ttlMs) {
|
|
7454
|
+
return "".concat(maxEntries, ":").concat(ttlMs);
|
|
7455
|
+
}
|
|
7456
|
+
|
|
7457
|
+
function resolveCacheConfig(options) {
|
|
7458
|
+
const ttlSeconds = typeof (options === null || options === void 0 ? void 0 : options.ttl) === "number" ? options.ttl : 600;
|
|
7459
|
+
const maxEntries = typeof (options === null || options === void 0 ? void 0 : options.maxEntries) === "number" && options.maxEntries > 0 ? options.maxEntries : 100;
|
|
7460
|
+
const ttlMs = ttlSeconds * 1e3;
|
|
7461
|
+
return {
|
|
7462
|
+
ttlMs: ttlMs,
|
|
7463
|
+
maxEntries: maxEntries
|
|
7464
|
+
};
|
|
7465
|
+
}
|
|
7466
|
+
|
|
7467
|
+
var DiscoveryCacheFactory = class {
|
|
7468
|
+
static createDiscoveryCache(config) {
|
|
7469
|
+
const cacheKey = getGlobalCacheKey(config.maxEntries, config.ttlMs);
|
|
7470
|
+
let cache = getGlobalCache(cacheKey);
|
|
7471
|
+
if (!cache) {
|
|
7472
|
+
cache = new LruCache(config.maxEntries, config.ttlMs);
|
|
7473
|
+
globalCaches.set(cacheKey, cache);
|
|
7474
|
+
}
|
|
7475
|
+
return cache;
|
|
7476
|
+
}
|
|
7477
|
+
static createJwksCache() {
|
|
7478
|
+
return {};
|
|
7479
|
+
}
|
|
7480
|
+
};
|
|
7481
|
+
|
|
7384
7482
|
var DEFAULT_SCOPES = "openid profile email offline_access";
|
|
7385
7483
|
|
|
7386
7484
|
var MAX_ARRAY_VALUES_PER_KEY = 20;
|
|
@@ -7413,9 +7511,9 @@ function appendExtraParams(params, extra) {
|
|
|
7413
7511
|
if (parameterValue.length > MAX_ARRAY_VALUES_PER_KEY) {
|
|
7414
7512
|
throw new TokenExchangeError("Parameter '".concat(parameterKey, "' exceeds maximum array size of ").concat(MAX_ARRAY_VALUES_PER_KEY));
|
|
7415
7513
|
}
|
|
7416
|
-
parameterValue.forEach(
|
|
7514
|
+
parameterValue.forEach(arrayItem => {
|
|
7417
7515
|
params.append(parameterKey, arrayItem);
|
|
7418
|
-
})
|
|
7516
|
+
});
|
|
7419
7517
|
} else {
|
|
7420
7518
|
params.append(parameterKey, parameterValue);
|
|
7421
7519
|
}
|
|
@@ -7432,39 +7530,58 @@ var SUBJECT_TYPE_ACCESS_TOKEN = "urn:ietf:params:oauth:token-type:access_token";
|
|
|
7432
7530
|
|
|
7433
7531
|
var REQUESTED_TOKEN_TYPE_FEDERATED_CONNECTION_ACCESS_TOKEN = "http://auth0.com/oauth/token-type/federated-connection-access-token";
|
|
7434
7532
|
|
|
7435
|
-
var AuthClient = (_configuration = new WeakMap, _serverMetadata = new WeakMap,
|
|
7436
|
-
|
|
7533
|
+
var AuthClient = (_configuration = new WeakMap, _serverMetadata = new WeakMap, _clientAuthPromise = new WeakMap,
|
|
7534
|
+
_options = new WeakMap, _customFetch2 = new WeakMap, _jwks = new WeakMap, _discoveryCache = new WeakMap,
|
|
7535
|
+
_inFlightDiscovery = new WeakMap, _jwksCache = new WeakMap, _Class9_brand = new WeakSet,
|
|
7536
|
+
class AuthClient {
|
|
7437
7537
|
constructor(_options2) {
|
|
7438
|
-
|
|
7538
|
+
var _options2$customFetch;
|
|
7539
|
+
_classPrivateMethodInitSpec(this, _Class9_brand);
|
|
7439
7540
|
_classPrivateFieldInitSpec(this, _configuration, void 0);
|
|
7440
7541
|
_classPrivateFieldInitSpec(this, _serverMetadata, void 0);
|
|
7542
|
+
_classPrivateFieldInitSpec(this, _clientAuthPromise, void 0);
|
|
7441
7543
|
_classPrivateFieldInitSpec(this, _options, void 0);
|
|
7544
|
+
_classPrivateFieldInitSpec(this, _customFetch2, void 0);
|
|
7442
7545
|
_classPrivateFieldInitSpec(this, _jwks, void 0);
|
|
7546
|
+
_classPrivateFieldInitSpec(this, _discoveryCache, void 0);
|
|
7547
|
+
_classPrivateFieldInitSpec(this, _inFlightDiscovery, void 0);
|
|
7548
|
+
_classPrivateFieldInitSpec(this, _jwksCache, void 0);
|
|
7443
7549
|
_defineProperty(this, "mfa", void 0);
|
|
7444
7550
|
_classPrivateFieldSet2(_options, this, _options2);
|
|
7445
7551
|
if (_options2.useMtls && !_options2.customFetch) {
|
|
7446
7552
|
throw new NotSupportedError("mtls_without_custom_fetch_not_supported", "Using mTLS without a custom fetch implementation is not supported");
|
|
7447
7553
|
}
|
|
7554
|
+
_classPrivateFieldSet2(_customFetch2, this, createTelemetryFetch((_options2$customFetch = _options2.customFetch) !== null && _options2$customFetch !== void 0 ? _options2$customFetch : function() {
|
|
7555
|
+
return fetch(...arguments);
|
|
7556
|
+
}, getTelemetryConfig(_options2.telemetry)));
|
|
7557
|
+
const cacheConfig = resolveCacheConfig(_options2.discoveryCache);
|
|
7558
|
+
_classPrivateFieldSet2(_discoveryCache, this, DiscoveryCacheFactory.createDiscoveryCache(cacheConfig));
|
|
7559
|
+
_classPrivateFieldSet2(_inFlightDiscovery, this, new Map);
|
|
7560
|
+
_classPrivateFieldSet2(_jwksCache, this, DiscoveryCacheFactory.createJwksCache());
|
|
7448
7561
|
this.mfa = new MfaClient({
|
|
7449
7562
|
domain: _classPrivateFieldGet2(_options, this).domain,
|
|
7450
7563
|
clientId: _classPrivateFieldGet2(_options, this).clientId,
|
|
7451
|
-
customFetch: _classPrivateFieldGet2(
|
|
7564
|
+
customFetch: _classPrivateFieldGet2(_customFetch2, this)
|
|
7452
7565
|
});
|
|
7453
7566
|
}
|
|
7567
|
+
async getServerMetadata() {
|
|
7568
|
+
const {serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7569
|
+
return serverMetadata;
|
|
7570
|
+
}
|
|
7454
7571
|
async buildAuthorizationUrl(options) {
|
|
7455
|
-
const {serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7572
|
+
const {serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7456
7573
|
if (options !== null && options !== void 0 && options.pushedAuthorizationRequests && !serverMetadata.pushed_authorization_request_endpoint) {
|
|
7457
7574
|
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");
|
|
7458
7575
|
}
|
|
7459
7576
|
try {
|
|
7460
|
-
return await _assertClassBrand(
|
|
7577
|
+
return await _assertClassBrand(_Class9_brand, this, _buildAuthorizationUrl).call(this, options);
|
|
7461
7578
|
} catch (e) {
|
|
7462
7579
|
throw new BuildAuthorizationUrlError(e);
|
|
7463
7580
|
}
|
|
7464
7581
|
}
|
|
7465
7582
|
async buildLinkUserUrl(options) {
|
|
7466
7583
|
try {
|
|
7467
|
-
const result = await _assertClassBrand(
|
|
7584
|
+
const result = await _assertClassBrand(_Class9_brand, this, _buildAuthorizationUrl).call(this, {
|
|
7468
7585
|
authorizationParams: _objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
|
|
7469
7586
|
requested_connection: options.connection,
|
|
7470
7587
|
requested_connection_scope: options.connectionScope,
|
|
@@ -7482,7 +7599,7 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7482
7599
|
}
|
|
7483
7600
|
async buildUnlinkUserUrl(options) {
|
|
7484
7601
|
try {
|
|
7485
|
-
const result = await _assertClassBrand(
|
|
7602
|
+
const result = await _assertClassBrand(_Class9_brand, this, _buildAuthorizationUrl).call(this, {
|
|
7486
7603
|
authorizationParams: _objectSpread2(_objectSpread2({}, options.authorizationParams), {}, {
|
|
7487
7604
|
requested_connection: options.connection,
|
|
7488
7605
|
scope: "openid unlink_account",
|
|
@@ -7498,7 +7615,7 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7498
7615
|
}
|
|
7499
7616
|
}
|
|
7500
7617
|
async backchannelAuthentication(options) {
|
|
7501
|
-
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7618
|
+
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7502
7619
|
const additionalParams = stripUndefinedProperties(_objectSpread2(_objectSpread2({}, _classPrivateFieldGet2(_options, this).authorizationParams), options === null || options === void 0 ? void 0 : options.authorizationParams));
|
|
7503
7620
|
const params = new URLSearchParams(_objectSpread2(_objectSpread2({
|
|
7504
7621
|
scope: DEFAULT_SCOPES
|
|
@@ -7526,7 +7643,7 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7526
7643
|
}
|
|
7527
7644
|
}
|
|
7528
7645
|
async initiateBackchannelAuthentication(options) {
|
|
7529
|
-
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7646
|
+
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7530
7647
|
const additionalParams = stripUndefinedProperties(_objectSpread2(_objectSpread2({}, _classPrivateFieldGet2(_options, this).authorizationParams), options === null || options === void 0 ? void 0 : options.authorizationParams));
|
|
7531
7648
|
const params = new URLSearchParams(_objectSpread2(_objectSpread2({
|
|
7532
7649
|
scope: DEFAULT_SCOPES
|
|
@@ -7558,7 +7675,7 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7558
7675
|
}
|
|
7559
7676
|
async backchannelAuthenticationGrant(_ref2) {
|
|
7560
7677
|
let {authReqId: authReqId} = _ref2;
|
|
7561
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7678
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7562
7679
|
const params = new URLSearchParams({
|
|
7563
7680
|
auth_req_id: authReqId
|
|
7564
7681
|
});
|
|
@@ -7593,10 +7710,10 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7593
7710
|
}
|
|
7594
7711
|
}
|
|
7595
7712
|
async exchangeToken(options) {
|
|
7596
|
-
return "connection" in options ? _assertClassBrand(
|
|
7713
|
+
return "connection" in options ? _assertClassBrand(_Class9_brand, this, _exchangeTokenVaultToken).call(this, options) : _assertClassBrand(_Class9_brand, this, _exchangeProfileToken).call(this, options);
|
|
7597
7714
|
}
|
|
7598
7715
|
async getTokenByCode(url, options) {
|
|
7599
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7716
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7600
7717
|
try {
|
|
7601
7718
|
const tokenEndpointResponse = await authorizationCodeGrant(configuration, url, {
|
|
7602
7719
|
pkceCodeVerifier: options.codeVerifier
|
|
@@ -7607,16 +7724,23 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7607
7724
|
}
|
|
7608
7725
|
}
|
|
7609
7726
|
async getTokenByRefreshToken(options) {
|
|
7610
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7727
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7728
|
+
const additionalParameters = new URLSearchParams;
|
|
7729
|
+
if (options.audience) {
|
|
7730
|
+
additionalParameters.append("audience", options.audience);
|
|
7731
|
+
}
|
|
7732
|
+
if (options.scope) {
|
|
7733
|
+
additionalParameters.append("scope", options.scope);
|
|
7734
|
+
}
|
|
7611
7735
|
try {
|
|
7612
|
-
const tokenEndpointResponse = await refreshTokenGrant(configuration, options.refreshToken);
|
|
7736
|
+
const tokenEndpointResponse = await refreshTokenGrant(configuration, options.refreshToken, additionalParameters);
|
|
7613
7737
|
return TokenResponse.fromTokenEndpointResponse(tokenEndpointResponse);
|
|
7614
7738
|
} catch (e) {
|
|
7615
7739
|
throw new TokenByRefreshTokenError("The access token has expired and there was an error while trying to refresh it.", e);
|
|
7616
7740
|
}
|
|
7617
7741
|
}
|
|
7618
7742
|
async getTokenByClientCredentials(options) {
|
|
7619
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7743
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7620
7744
|
try {
|
|
7621
7745
|
const params = new URLSearchParams({
|
|
7622
7746
|
audience: options.audience
|
|
@@ -7631,7 +7755,7 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7631
7755
|
}
|
|
7632
7756
|
}
|
|
7633
7757
|
async buildLogoutUrl(options) {
|
|
7634
|
-
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7758
|
+
const {configuration: configuration, serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7635
7759
|
if (!serverMetadata.end_session_endpoint) {
|
|
7636
7760
|
const url = new URL("https://".concat(_classPrivateFieldGet2(_options, this).domain, "/v2/logout"));
|
|
7637
7761
|
url.searchParams.set("returnTo", options.returnTo);
|
|
@@ -7643,9 +7767,13 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7643
7767
|
});
|
|
7644
7768
|
}
|
|
7645
7769
|
async verifyLogoutToken(options) {
|
|
7646
|
-
const {serverMetadata: serverMetadata} = await _assertClassBrand(
|
|
7647
|
-
|
|
7648
|
-
|
|
7770
|
+
const {serverMetadata: serverMetadata} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7771
|
+
const cacheConfig = resolveCacheConfig(_classPrivateFieldGet2(_options, this).discoveryCache);
|
|
7772
|
+
const jwksUri = serverMetadata.jwks_uri;
|
|
7773
|
+
_classPrivateFieldGet2(_jwks, this) || _classPrivateFieldSet2(_jwks, this, createRemoteJWKSet(new URL(jwksUri), {
|
|
7774
|
+
cacheMaxAge: cacheConfig.ttlMs,
|
|
7775
|
+
[customFetch]: _classPrivateFieldGet2(_customFetch2, this),
|
|
7776
|
+
[jwksCache]: _classPrivateFieldGet2(_jwksCache, this)
|
|
7649
7777
|
}));
|
|
7650
7778
|
const {payload: payload} = await jwtVerify(options.logoutToken, _classPrivateFieldGet2(_jwks, this), {
|
|
7651
7779
|
issuer: serverMetadata.issuer,
|
|
@@ -7684,6 +7812,18 @@ _jwks = new WeakMap, _Class8_brand = new WeakSet, class AuthClient {
|
|
|
7684
7812
|
}
|
|
7685
7813
|
});
|
|
7686
7814
|
|
|
7815
|
+
function _getDiscoveryCacheKey() {
|
|
7816
|
+
const domain = _classPrivateFieldGet2(_options, this).domain.toLowerCase();
|
|
7817
|
+
return "".concat(domain, "|mtls:").concat(_classPrivateFieldGet2(_options, this).useMtls ? "1" : "0");
|
|
7818
|
+
}
|
|
7819
|
+
|
|
7820
|
+
async function _createConfiguration(serverMetadata) {
|
|
7821
|
+
const clientAuth = await _assertClassBrand(_Class9_brand, this, _getClientAuth).call(this);
|
|
7822
|
+
const configuration = new Configuration(serverMetadata, _classPrivateFieldGet2(_options, this).clientId, _classPrivateFieldGet2(_options, this).clientSecret, clientAuth);
|
|
7823
|
+
configuration[customFetch$1] = _classPrivateFieldGet2(_customFetch2, this);
|
|
7824
|
+
return configuration;
|
|
7825
|
+
}
|
|
7826
|
+
|
|
7687
7827
|
async function _discover() {
|
|
7688
7828
|
if (_classPrivateFieldGet2(_configuration, this) && _classPrivateFieldGet2(_serverMetadata, this)) {
|
|
7689
7829
|
return {
|
|
@@ -7691,14 +7831,58 @@ async function _discover() {
|
|
|
7691
7831
|
serverMetadata: _classPrivateFieldGet2(_serverMetadata, this)
|
|
7692
7832
|
};
|
|
7693
7833
|
}
|
|
7694
|
-
const
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7834
|
+
const cacheKey = _assertClassBrand(_Class9_brand, this, _getDiscoveryCacheKey).call(this);
|
|
7835
|
+
const cached = _classPrivateFieldGet2(_discoveryCache, this).get(cacheKey);
|
|
7836
|
+
if (cached) {
|
|
7837
|
+
_classPrivateFieldSet2(_serverMetadata, this, cached.serverMetadata);
|
|
7838
|
+
_classPrivateFieldSet2(_configuration, this, await _assertClassBrand(_Class9_brand, this, _createConfiguration).call(this, cached.serverMetadata));
|
|
7839
|
+
return {
|
|
7840
|
+
configuration: _classPrivateFieldGet2(_configuration, this),
|
|
7841
|
+
serverMetadata: _classPrivateFieldGet2(_serverMetadata, this)
|
|
7842
|
+
};
|
|
7843
|
+
}
|
|
7844
|
+
const inFlight = _classPrivateFieldGet2(_inFlightDiscovery, this).get(cacheKey);
|
|
7845
|
+
if (inFlight) {
|
|
7846
|
+
const entry = await inFlight;
|
|
7847
|
+
_classPrivateFieldSet2(_serverMetadata, this, entry.serverMetadata);
|
|
7848
|
+
_classPrivateFieldSet2(_configuration, this, await _assertClassBrand(_Class9_brand, this, _createConfiguration).call(this, entry.serverMetadata));
|
|
7849
|
+
return {
|
|
7850
|
+
configuration: _classPrivateFieldGet2(_configuration, this),
|
|
7851
|
+
serverMetadata: _classPrivateFieldGet2(_serverMetadata, this)
|
|
7852
|
+
};
|
|
7853
|
+
}
|
|
7854
|
+
const discoveryPromise = (async () => {
|
|
7855
|
+
const clientAuth = await _assertClassBrand(_Class9_brand, this, _getClientAuth).call(this);
|
|
7856
|
+
const configuration = await discovery(new URL("https://".concat(_classPrivateFieldGet2(_options, this).domain)), _classPrivateFieldGet2(_options, this).clientId, {
|
|
7857
|
+
use_mtls_endpoint_aliases: _classPrivateFieldGet2(_options, this).useMtls
|
|
7858
|
+
}, clientAuth, {
|
|
7859
|
+
[customFetch$1]: _classPrivateFieldGet2(_customFetch2, this)
|
|
7860
|
+
});
|
|
7861
|
+
const serverMetadata = configuration.serverMetadata();
|
|
7862
|
+
_classPrivateFieldGet2(_discoveryCache, this).set(cacheKey, {
|
|
7863
|
+
serverMetadata: serverMetadata
|
|
7864
|
+
});
|
|
7865
|
+
return {
|
|
7866
|
+
configuration: configuration,
|
|
7867
|
+
serverMetadata: serverMetadata
|
|
7868
|
+
};
|
|
7869
|
+
})();
|
|
7870
|
+
const inFlightEntry = discoveryPromise.then(_ref3 => {
|
|
7871
|
+
let {serverMetadata: serverMetadata} = _ref3;
|
|
7872
|
+
return {
|
|
7873
|
+
serverMetadata: serverMetadata
|
|
7874
|
+
};
|
|
7875
|
+
});
|
|
7876
|
+
void inFlightEntry.catch(() => void 0);
|
|
7877
|
+
_classPrivateFieldGet2(_inFlightDiscovery, this).set(cacheKey, inFlightEntry);
|
|
7878
|
+
try {
|
|
7879
|
+
const {configuration: configuration, serverMetadata: serverMetadata} = await discoveryPromise;
|
|
7880
|
+
_classPrivateFieldSet2(_configuration, this, configuration);
|
|
7881
|
+
_classPrivateFieldSet2(_serverMetadata, this, serverMetadata);
|
|
7882
|
+
_classPrivateFieldGet2(_configuration, this)[customFetch$1] = _classPrivateFieldGet2(_customFetch2, this);
|
|
7883
|
+
} finally {
|
|
7884
|
+
_classPrivateFieldGet2(_inFlightDiscovery, this).delete(cacheKey);
|
|
7885
|
+
}
|
|
7702
7886
|
return {
|
|
7703
7887
|
configuration: _classPrivateFieldGet2(_configuration, this),
|
|
7704
7888
|
serverMetadata: _classPrivateFieldGet2(_serverMetadata, this)
|
|
@@ -7707,7 +7891,7 @@ async function _discover() {
|
|
|
7707
7891
|
|
|
7708
7892
|
async function _exchangeTokenVaultToken(options) {
|
|
7709
7893
|
var _options$subjectToken, _options$requestedTok;
|
|
7710
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7894
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7711
7895
|
if ("audience" in options || "resource" in options) {
|
|
7712
7896
|
throw new TokenExchangeError("audience and resource parameters are not supported for Token Vault exchanges");
|
|
7713
7897
|
}
|
|
@@ -7734,7 +7918,7 @@ async function _exchangeTokenVaultToken(options) {
|
|
|
7734
7918
|
}
|
|
7735
7919
|
|
|
7736
7920
|
async function _exchangeProfileToken(options) {
|
|
7737
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7921
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7738
7922
|
validateSubjectToken(options.subjectToken);
|
|
7739
7923
|
const tokenRequestParams = new URLSearchParams({
|
|
7740
7924
|
subject_token_type: options.subjectTokenType,
|
|
@@ -7762,21 +7946,29 @@ async function _exchangeProfileToken(options) {
|
|
|
7762
7946
|
}
|
|
7763
7947
|
|
|
7764
7948
|
async function _getClientAuth() {
|
|
7765
|
-
if (!_classPrivateFieldGet2(
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7949
|
+
if (!_classPrivateFieldGet2(_clientAuthPromise, this)) {
|
|
7950
|
+
_classPrivateFieldSet2(_clientAuthPromise, this, (async () => {
|
|
7951
|
+
if (!_classPrivateFieldGet2(_options, this).clientSecret && !_classPrivateFieldGet2(_options, this).clientAssertionSigningKey && !_classPrivateFieldGet2(_options, this).useMtls) {
|
|
7952
|
+
throw new MissingClientAuthError;
|
|
7953
|
+
}
|
|
7954
|
+
if (_classPrivateFieldGet2(_options, this).useMtls) {
|
|
7955
|
+
return TlsClientAuth();
|
|
7956
|
+
}
|
|
7957
|
+
let clientPrivateKey = _classPrivateFieldGet2(_options, this).clientAssertionSigningKey;
|
|
7958
|
+
if (clientPrivateKey && !(clientPrivateKey instanceof CryptoKey)) {
|
|
7959
|
+
clientPrivateKey = await importPKCS8(clientPrivateKey, _classPrivateFieldGet2(_options, this).clientAssertionSigningAlg || "RS256");
|
|
7960
|
+
}
|
|
7961
|
+
return clientPrivateKey ? PrivateKeyJwt(clientPrivateKey) : ClientSecretPost(_classPrivateFieldGet2(_options, this).clientSecret);
|
|
7962
|
+
})().catch(error => {
|
|
7963
|
+
_classPrivateFieldSet2(_clientAuthPromise, this, void 0);
|
|
7964
|
+
throw error;
|
|
7965
|
+
}));
|
|
7774
7966
|
}
|
|
7775
|
-
return
|
|
7967
|
+
return _classPrivateFieldGet2(_clientAuthPromise, this);
|
|
7776
7968
|
}
|
|
7777
7969
|
|
|
7778
7970
|
async function _buildAuthorizationUrl(options) {
|
|
7779
|
-
const {configuration: configuration} = await _assertClassBrand(
|
|
7971
|
+
const {configuration: configuration} = await _assertClassBrand(_Class9_brand, this, _discover).call(this);
|
|
7780
7972
|
const codeChallengeMethod = "S256";
|
|
7781
7973
|
const codeVerifier = randomPKCECodeVerifier();
|
|
7782
7974
|
const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);
|
|
@@ -7901,15 +8093,15 @@ class MfaApiClient {
|
|
|
7901
8093
|
if (!((_a = context === null || context === void 0 ? void 0 : context.mfaRequirements) === null || _a === void 0 ? void 0 : _a.challenge) || context.mfaRequirements.challenge.length === 0) {
|
|
7902
8094
|
throw new MfaListAuthenticatorsError("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
|
|
7903
8095
|
}
|
|
7904
|
-
const challengeTypes = context.mfaRequirements.challenge.map(
|
|
8096
|
+
const challengeTypes = context.mfaRequirements.challenge.map(c => c.type);
|
|
7905
8097
|
try {
|
|
7906
8098
|
const allAuthenticators = await this.authJsMfaClient.listAuthenticators({
|
|
7907
8099
|
mfaToken: mfaToken
|
|
7908
8100
|
});
|
|
7909
|
-
return allAuthenticators.filter(
|
|
8101
|
+
return allAuthenticators.filter(auth => {
|
|
7910
8102
|
if (!auth.type) return false;
|
|
7911
8103
|
return challengeTypes.includes(auth.type);
|
|
7912
|
-
})
|
|
8104
|
+
});
|
|
7913
8105
|
} catch (error) {
|
|
7914
8106
|
if (error instanceof MfaListAuthenticatorsError$1) {
|
|
7915
8107
|
throw new MfaListAuthenticatorsError((_b = error.cause) === null || _b === void 0 ? void 0 : _b.error, error.message);
|
|
@@ -8275,7 +8467,7 @@ class Auth0Client {
|
|
|
8275
8467
|
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)
|
|
8276
8468
|
})
|
|
8277
8469
|
});
|
|
8278
|
-
const result = await singlePromise((
|
|
8470
|
+
const result = await singlePromise(() => this._getTokenSilently(localOptions), "".concat(this.options.clientId, "::").concat(localOptions.authorizationParams.audience, "::").concat(localOptions.authorizationParams.scope));
|
|
8279
8471
|
return options.detailedResponse ? result : result === null || result === void 0 ? void 0 : result.access_token;
|
|
8280
8472
|
}
|
|
8281
8473
|
async _getTokenSilently(options) {
|
|
@@ -8296,7 +8488,7 @@ class Auth0Client {
|
|
|
8296
8488
|
}
|
|
8297
8489
|
const lockKey = buildGetTokenSilentlyLockKey(this.options.clientId, getTokenOptions.authorizationParams.audience || "default");
|
|
8298
8490
|
try {
|
|
8299
|
-
return await this.lockManager.runWithLock(lockKey, 5e3,
|
|
8491
|
+
return await this.lockManager.runWithLock(lockKey, 5e3, async () => {
|
|
8300
8492
|
if (cacheMode !== "off") {
|
|
8301
8493
|
const entry = await this._getEntryFromCache({
|
|
8302
8494
|
scope: getTokenOptions.authorizationParams.scope,
|
|
@@ -8318,7 +8510,7 @@ class Auth0Client {
|
|
|
8318
8510
|
} : null), {
|
|
8319
8511
|
expires_in: expires_in
|
|
8320
8512
|
});
|
|
8321
|
-
})
|
|
8513
|
+
});
|
|
8322
8514
|
} catch (error) {
|
|
8323
8515
|
if (this._isInteractiveError(error) && this.options.interactiveErrorHandler === "popup") {
|
|
8324
8516
|
return await this._handleInteractiveErrorWithPopup(getTokenOptions);
|
|
@@ -8412,7 +8604,7 @@ class Auth0Client {
|
|
|
8412
8604
|
async _getTokenFromIFrame(options) {
|
|
8413
8605
|
const iframeLockKey = buildIframeLockKey(this.options.clientId);
|
|
8414
8606
|
try {
|
|
8415
|
-
return await this.lockManager.runWithLock(iframeLockKey, 5e3,
|
|
8607
|
+
return await this.lockManager.runWithLock(iframeLockKey, 5e3, async () => {
|
|
8416
8608
|
const params = Object.assign(Object.assign({}, options.authorizationParams), {
|
|
8417
8609
|
prompt: "none"
|
|
8418
8610
|
});
|
|
@@ -8452,7 +8644,7 @@ class Auth0Client {
|
|
|
8452
8644
|
oauthTokenScope: tokenResult.scope,
|
|
8453
8645
|
audience: audience
|
|
8454
8646
|
});
|
|
8455
|
-
})
|
|
8647
|
+
});
|
|
8456
8648
|
} catch (e) {
|
|
8457
8649
|
if (e.error === "login_required") {
|
|
8458
8650
|
const shouldSkipLogoutForMfaStepUp = e instanceof GenericError && this._isIframeMfaError(e) && this.options.interactiveErrorHandler === "popup";
|