@golocalinteractive/golocal-cloud-wrapper 1.0.54 → 1.0.56
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/golocal-cloud-wrapper.css +2 -1
- package/dist/golocal-cloud-wrapper.es.js +88 -17632
- package/dist/golocal-cloud-wrapper.es10.js +66 -0
- package/dist/golocal-cloud-wrapper.es100.js +4 -0
- package/dist/golocal-cloud-wrapper.es101.js +62 -0
- package/dist/golocal-cloud-wrapper.es102.js +77 -0
- package/dist/golocal-cloud-wrapper.es103.js +4 -0
- package/dist/golocal-cloud-wrapper.es104.js +41 -0
- package/dist/golocal-cloud-wrapper.es105.js +4 -0
- package/dist/golocal-cloud-wrapper.es106.js +106 -0
- package/dist/golocal-cloud-wrapper.es107.js +148 -0
- package/dist/golocal-cloud-wrapper.es108.js +28 -0
- package/dist/golocal-cloud-wrapper.es109.js +51 -0
- package/dist/golocal-cloud-wrapper.es11.js +233 -0
- package/dist/golocal-cloud-wrapper.es110.js +25 -0
- package/dist/golocal-cloud-wrapper.es111.js +30 -0
- package/dist/golocal-cloud-wrapper.es112.js +82 -0
- package/dist/golocal-cloud-wrapper.es113.js +125 -0
- package/dist/golocal-cloud-wrapper.es114.js +39 -0
- package/dist/golocal-cloud-wrapper.es115.js +38 -0
- package/dist/golocal-cloud-wrapper.es116.js +7 -0
- package/dist/golocal-cloud-wrapper.es117.js +4 -0
- package/dist/golocal-cloud-wrapper.es118.js +4 -0
- package/dist/golocal-cloud-wrapper.es119.js +4 -0
- package/dist/golocal-cloud-wrapper.es12.js +23 -0
- package/dist/golocal-cloud-wrapper.es120.js +208 -0
- package/dist/golocal-cloud-wrapper.es121.js +145 -0
- package/dist/golocal-cloud-wrapper.es122.js +58 -0
- package/dist/golocal-cloud-wrapper.es123.js +34 -0
- package/dist/golocal-cloud-wrapper.es124.js +4 -0
- package/dist/golocal-cloud-wrapper.es125.js +39 -0
- package/dist/golocal-cloud-wrapper.es126.js +4 -0
- package/dist/golocal-cloud-wrapper.es127.js +4 -0
- package/dist/golocal-cloud-wrapper.es128.js +224 -0
- package/dist/golocal-cloud-wrapper.es129.js +4 -0
- package/dist/golocal-cloud-wrapper.es13.js +24 -0
- package/dist/golocal-cloud-wrapper.es130.js +4 -0
- package/dist/golocal-cloud-wrapper.es131.js +35 -0
- package/dist/golocal-cloud-wrapper.es132.js +4 -0
- package/dist/golocal-cloud-wrapper.es133.js +23 -0
- package/dist/golocal-cloud-wrapper.es134.js +123 -0
- package/dist/golocal-cloud-wrapper.es135.js +469 -0
- package/dist/golocal-cloud-wrapper.es136.js +46 -0
- package/dist/golocal-cloud-wrapper.es137.js +71 -0
- package/dist/golocal-cloud-wrapper.es138.js +66 -0
- package/dist/golocal-cloud-wrapper.es139.js +4 -0
- package/dist/golocal-cloud-wrapper.es14.js +115 -0
- package/dist/golocal-cloud-wrapper.es140.js +27 -0
- package/dist/golocal-cloud-wrapper.es141.js +66 -0
- package/dist/golocal-cloud-wrapper.es142.js +27 -0
- package/dist/golocal-cloud-wrapper.es143.js +5 -0
- package/dist/golocal-cloud-wrapper.es144.js +650 -0
- package/dist/golocal-cloud-wrapper.es145.js +301 -0
- package/dist/golocal-cloud-wrapper.es146.js +90 -0
- package/dist/golocal-cloud-wrapper.es147.js +83 -0
- package/dist/golocal-cloud-wrapper.es148.js +65 -0
- package/dist/golocal-cloud-wrapper.es149.js +1230 -0
- package/dist/golocal-cloud-wrapper.es15.js +641 -0
- package/dist/golocal-cloud-wrapper.es150.js +8 -0
- package/dist/golocal-cloud-wrapper.es151.js +15 -0
- package/dist/golocal-cloud-wrapper.es152.js +139 -0
- package/dist/golocal-cloud-wrapper.es153.js +23 -0
- package/dist/golocal-cloud-wrapper.es154.js +132 -0
- package/dist/golocal-cloud-wrapper.es155.js +19 -0
- package/dist/golocal-cloud-wrapper.es156.js +37 -0
- package/dist/golocal-cloud-wrapper.es157.js +49 -0
- package/dist/golocal-cloud-wrapper.es158.js +10 -0
- package/dist/golocal-cloud-wrapper.es159.js +5 -0
- package/dist/golocal-cloud-wrapper.es16.js +17 -0
- package/dist/golocal-cloud-wrapper.es160.js +35 -0
- package/dist/golocal-cloud-wrapper.es161.js +174 -0
- package/dist/golocal-cloud-wrapper.es162.js +21 -0
- package/dist/golocal-cloud-wrapper.es163.js +4 -0
- package/dist/golocal-cloud-wrapper.es164.js +330 -0
- package/dist/golocal-cloud-wrapper.es165.js +4 -0
- package/dist/golocal-cloud-wrapper.es166.js +34 -0
- package/dist/golocal-cloud-wrapper.es167.js +40 -0
- package/dist/golocal-cloud-wrapper.es168.js +30 -0
- package/dist/golocal-cloud-wrapper.es169.js +62 -0
- package/dist/golocal-cloud-wrapper.es17.js +26 -0
- package/dist/golocal-cloud-wrapper.es170.js +4 -0
- package/dist/golocal-cloud-wrapper.es171.js +340 -0
- package/dist/golocal-cloud-wrapper.es172.js +4 -0
- package/dist/golocal-cloud-wrapper.es173.js +4 -0
- package/dist/golocal-cloud-wrapper.es174.js +4 -0
- package/dist/golocal-cloud-wrapper.es175.js +4 -0
- package/dist/golocal-cloud-wrapper.es176.js +4 -0
- package/dist/golocal-cloud-wrapper.es177.js +24 -0
- package/dist/golocal-cloud-wrapper.es178.js +4 -0
- package/dist/golocal-cloud-wrapper.es179.js +24 -0
- package/dist/golocal-cloud-wrapper.es18.js +5 -0
- package/dist/golocal-cloud-wrapper.es180.js +98 -0
- package/dist/golocal-cloud-wrapper.es181.js +4 -0
- package/dist/golocal-cloud-wrapper.es182.js +46 -0
- package/dist/golocal-cloud-wrapper.es183.js +35 -0
- package/dist/golocal-cloud-wrapper.es184.js +61 -0
- package/dist/golocal-cloud-wrapper.es185.js +4 -0
- package/dist/golocal-cloud-wrapper.es186.js +4 -0
- package/dist/golocal-cloud-wrapper.es187.js +4 -0
- package/dist/golocal-cloud-wrapper.es188.js +23 -0
- package/dist/golocal-cloud-wrapper.es189.js +4 -0
- package/dist/golocal-cloud-wrapper.es19.js +110 -0
- package/dist/golocal-cloud-wrapper.es190.js +4 -0
- package/dist/golocal-cloud-wrapper.es191.js +720 -0
- package/dist/golocal-cloud-wrapper.es192.js +153 -0
- package/dist/golocal-cloud-wrapper.es193.js +166 -0
- package/dist/golocal-cloud-wrapper.es194.js +49 -0
- package/dist/golocal-cloud-wrapper.es195.js +71 -0
- package/dist/golocal-cloud-wrapper.es196.js +25 -0
- package/dist/golocal-cloud-wrapper.es197.js +5 -0
- package/dist/golocal-cloud-wrapper.es198.js +118 -0
- package/dist/golocal-cloud-wrapper.es199.js +16 -0
- package/dist/golocal-cloud-wrapper.es20.js +12 -0
- package/dist/golocal-cloud-wrapper.es200.js +4 -0
- package/dist/golocal-cloud-wrapper.es201.js +429 -0
- package/dist/golocal-cloud-wrapper.es202.js +335 -0
- package/dist/golocal-cloud-wrapper.es203.js +235 -0
- package/dist/golocal-cloud-wrapper.es204.js +38 -0
- package/dist/golocal-cloud-wrapper.es205.js +88 -0
- package/dist/golocal-cloud-wrapper.es206.js +47 -0
- package/dist/golocal-cloud-wrapper.es207.js +13 -0
- package/dist/golocal-cloud-wrapper.es208.js +19 -0
- package/dist/golocal-cloud-wrapper.es209.js +102 -0
- package/dist/golocal-cloud-wrapper.es21.js +185 -0
- package/dist/golocal-cloud-wrapper.es210.js +4 -0
- package/dist/golocal-cloud-wrapper.es211.js +4 -0
- package/dist/golocal-cloud-wrapper.es212.js +24 -0
- package/dist/golocal-cloud-wrapper.es213.js +30 -0
- package/dist/golocal-cloud-wrapper.es214.js +30 -0
- package/dist/golocal-cloud-wrapper.es215.js +34 -0
- package/dist/golocal-cloud-wrapper.es216.js +4 -0
- package/dist/golocal-cloud-wrapper.es217.js +4 -0
- package/dist/golocal-cloud-wrapper.es218.js +48 -0
- package/dist/golocal-cloud-wrapper.es219.js +33 -0
- package/dist/golocal-cloud-wrapper.es22.js +23 -0
- package/dist/golocal-cloud-wrapper.es220.js +30 -0
- package/dist/golocal-cloud-wrapper.es221.js +4 -0
- package/dist/golocal-cloud-wrapper.es222.js +4 -0
- package/dist/golocal-cloud-wrapper.es223.js +78 -0
- package/dist/golocal-cloud-wrapper.es224.js +4 -0
- package/dist/golocal-cloud-wrapper.es225.js +4 -0
- package/dist/golocal-cloud-wrapper.es226.js +4 -0
- package/dist/golocal-cloud-wrapper.es227.js +4 -0
- package/dist/golocal-cloud-wrapper.es228.js +4 -0
- package/dist/golocal-cloud-wrapper.es229.js +24 -0
- package/dist/golocal-cloud-wrapper.es23.js +38 -0
- package/dist/golocal-cloud-wrapper.es230.js +4 -0
- package/dist/golocal-cloud-wrapper.es231.js +4 -0
- package/dist/golocal-cloud-wrapper.es232.js +202 -0
- package/dist/golocal-cloud-wrapper.es233.js +97 -0
- package/dist/golocal-cloud-wrapper.es234.js +4 -0
- package/dist/golocal-cloud-wrapper.es235.js +173 -0
- package/dist/golocal-cloud-wrapper.es236.js +4 -0
- package/dist/golocal-cloud-wrapper.es237.js +21 -0
- package/dist/golocal-cloud-wrapper.es238.js +30 -0
- package/dist/golocal-cloud-wrapper.es239.js +154 -0
- package/dist/golocal-cloud-wrapper.es24.js +16 -0
- package/dist/golocal-cloud-wrapper.es240.js +131 -0
- package/dist/golocal-cloud-wrapper.es241.js +61 -0
- package/dist/golocal-cloud-wrapper.es242.js +42 -0
- package/dist/golocal-cloud-wrapper.es243.js +89 -0
- package/dist/golocal-cloud-wrapper.es244.js +24 -0
- package/dist/golocal-cloud-wrapper.es245.js +19 -0
- package/dist/golocal-cloud-wrapper.es246.js +127 -0
- package/dist/golocal-cloud-wrapper.es247.js +24 -0
- package/dist/golocal-cloud-wrapper.es248.js +33 -0
- package/dist/golocal-cloud-wrapper.es249.js +12 -0
- package/dist/golocal-cloud-wrapper.es25.js +17 -0
- package/dist/golocal-cloud-wrapper.es250.js +24 -0
- package/dist/golocal-cloud-wrapper.es251.js +17 -0
- package/dist/golocal-cloud-wrapper.es252.js +78 -0
- package/dist/golocal-cloud-wrapper.es253.js +19 -0
- package/dist/golocal-cloud-wrapper.es254.js +102 -0
- package/dist/golocal-cloud-wrapper.es255.js +29 -0
- package/dist/golocal-cloud-wrapper.es256.js +151 -0
- package/dist/golocal-cloud-wrapper.es257.js +4 -0
- package/dist/golocal-cloud-wrapper.es258.js +76 -0
- package/dist/golocal-cloud-wrapper.es259.js +92 -0
- package/dist/golocal-cloud-wrapper.es26.js +102 -0
- package/dist/golocal-cloud-wrapper.es260.js +71 -0
- package/dist/golocal-cloud-wrapper.es261.js +124 -0
- package/dist/golocal-cloud-wrapper.es262.js +35 -0
- package/dist/golocal-cloud-wrapper.es263.js +7 -0
- package/dist/golocal-cloud-wrapper.es264.js +23 -0
- package/dist/golocal-cloud-wrapper.es265.js +102 -0
- package/dist/golocal-cloud-wrapper.es266.js +106 -0
- package/dist/golocal-cloud-wrapper.es267.js +4 -0
- package/dist/golocal-cloud-wrapper.es268.js +4 -0
- package/dist/golocal-cloud-wrapper.es269.js +38 -0
- package/dist/golocal-cloud-wrapper.es27.js +45 -0
- package/dist/golocal-cloud-wrapper.es270.js +4 -0
- package/dist/golocal-cloud-wrapper.es271.js +4 -0
- package/dist/golocal-cloud-wrapper.es272.js +4 -0
- package/dist/golocal-cloud-wrapper.es273.js +4 -0
- package/dist/golocal-cloud-wrapper.es274.js +4 -0
- package/dist/golocal-cloud-wrapper.es275.js +4 -0
- package/dist/golocal-cloud-wrapper.es276.js +4 -0
- package/dist/golocal-cloud-wrapper.es277.js +11 -0
- package/dist/golocal-cloud-wrapper.es278.js +29 -0
- package/dist/golocal-cloud-wrapper.es279.js +4 -0
- package/dist/golocal-cloud-wrapper.es28.js +8 -0
- package/dist/golocal-cloud-wrapper.es280.js +4 -0
- package/dist/golocal-cloud-wrapper.es281.js +4 -0
- package/dist/golocal-cloud-wrapper.es282.js +4 -0
- package/dist/golocal-cloud-wrapper.es283.js +5 -0
- package/dist/golocal-cloud-wrapper.es284.js +36 -0
- package/dist/golocal-cloud-wrapper.es285.js +46 -0
- package/dist/golocal-cloud-wrapper.es286.js +55 -0
- package/dist/golocal-cloud-wrapper.es287.js +41 -0
- package/dist/golocal-cloud-wrapper.es288.js +70 -0
- package/dist/golocal-cloud-wrapper.es289.js +20 -0
- package/dist/golocal-cloud-wrapper.es29.js +13 -0
- package/dist/golocal-cloud-wrapper.es290.js +8 -0
- package/dist/golocal-cloud-wrapper.es291.js +4 -0
- package/dist/golocal-cloud-wrapper.es292.js +58 -0
- package/dist/golocal-cloud-wrapper.es293.js +31 -0
- package/dist/golocal-cloud-wrapper.es294.js +6 -0
- package/dist/golocal-cloud-wrapper.es295.js +11 -0
- package/dist/golocal-cloud-wrapper.es296.js +24 -0
- package/dist/golocal-cloud-wrapper.es297.js +32 -0
- package/dist/golocal-cloud-wrapper.es298.js +12 -0
- package/dist/golocal-cloud-wrapper.es299.js +10 -0
- package/dist/golocal-cloud-wrapper.es3.js +22 -0
- package/dist/golocal-cloud-wrapper.es30.js +13 -0
- package/dist/golocal-cloud-wrapper.es300.js +10 -0
- package/dist/golocal-cloud-wrapper.es301.js +159 -0
- package/dist/golocal-cloud-wrapper.es302.js +24 -0
- package/dist/golocal-cloud-wrapper.es303.js +21 -0
- package/dist/golocal-cloud-wrapper.es304.js +16 -0
- package/dist/golocal-cloud-wrapper.es305.js +48 -0
- package/dist/golocal-cloud-wrapper.es306.js +9 -0
- package/dist/golocal-cloud-wrapper.es307.js +37 -0
- package/dist/golocal-cloud-wrapper.es308.js +8 -0
- package/dist/golocal-cloud-wrapper.es309.js +9 -0
- package/dist/golocal-cloud-wrapper.es31.js +299 -0
- package/dist/golocal-cloud-wrapper.es310.js +15 -0
- package/dist/golocal-cloud-wrapper.es32.js +13 -0
- package/dist/golocal-cloud-wrapper.es33.js +13 -0
- package/dist/golocal-cloud-wrapper.es34.js +30 -0
- package/dist/golocal-cloud-wrapper.es35.js +342 -0
- package/dist/golocal-cloud-wrapper.es36.js +16 -0
- package/dist/golocal-cloud-wrapper.es37.js +16 -0
- package/dist/golocal-cloud-wrapper.es38.js +16 -0
- package/dist/golocal-cloud-wrapper.es39.js +491 -0
- package/dist/golocal-cloud-wrapper.es4.js +20 -0
- package/dist/golocal-cloud-wrapper.es40.js +17 -0
- package/dist/golocal-cloud-wrapper.es41.js +4 -0
- package/dist/golocal-cloud-wrapper.es42.js +41 -0
- package/dist/golocal-cloud-wrapper.es43.js +274 -0
- package/dist/golocal-cloud-wrapper.es44.js +4 -0
- package/dist/golocal-cloud-wrapper.es45.js +30 -0
- package/dist/golocal-cloud-wrapper.es46.js +22 -0
- package/dist/golocal-cloud-wrapper.es47.js +16 -0
- package/dist/golocal-cloud-wrapper.es48.js +18 -0
- package/dist/golocal-cloud-wrapper.es49.js +22 -0
- package/dist/golocal-cloud-wrapper.es5.js +12 -0
- package/dist/golocal-cloud-wrapper.es50.js +22 -0
- package/dist/golocal-cloud-wrapper.es51.js +26 -0
- package/dist/golocal-cloud-wrapper.es52.js +22 -0
- package/dist/golocal-cloud-wrapper.es53.js +17 -0
- package/dist/golocal-cloud-wrapper.es54.js +4 -0
- package/dist/golocal-cloud-wrapper.es55.js +4 -0
- package/dist/golocal-cloud-wrapper.es56.js +39 -0
- package/dist/golocal-cloud-wrapper.es57.js +17 -0
- package/dist/golocal-cloud-wrapper.es58.js +2959 -0
- package/dist/golocal-cloud-wrapper.es59.js +417 -0
- package/dist/golocal-cloud-wrapper.es6.js +68 -0
- package/dist/golocal-cloud-wrapper.es60.js +25 -0
- package/dist/golocal-cloud-wrapper.es61.js +28 -0
- package/dist/golocal-cloud-wrapper.es62.js +32 -0
- package/dist/golocal-cloud-wrapper.es63.js +41 -0
- package/dist/golocal-cloud-wrapper.es64.js +20 -0
- package/dist/golocal-cloud-wrapper.es65.js +11 -0
- package/dist/golocal-cloud-wrapper.es66.js +81 -0
- package/dist/golocal-cloud-wrapper.es67.js +14 -0
- package/dist/golocal-cloud-wrapper.es68.js +71 -0
- package/dist/golocal-cloud-wrapper.es69.js +212 -0
- package/dist/golocal-cloud-wrapper.es7.js +16 -0
- package/dist/golocal-cloud-wrapper.es70.js +208 -0
- package/dist/golocal-cloud-wrapper.es71.js +18 -0
- package/dist/golocal-cloud-wrapper.es72.js +129 -0
- package/dist/golocal-cloud-wrapper.es73.js +43 -0
- package/dist/golocal-cloud-wrapper.es74.js +29 -0
- package/dist/golocal-cloud-wrapper.es75.js +11 -0
- package/dist/golocal-cloud-wrapper.es76.js +122 -0
- package/dist/golocal-cloud-wrapper.es77.js +880 -0
- package/dist/golocal-cloud-wrapper.es78.js +288 -0
- package/dist/golocal-cloud-wrapper.es79.js +36 -0
- package/dist/golocal-cloud-wrapper.es8.js +48 -0
- package/dist/golocal-cloud-wrapper.es80.js +12 -0
- package/dist/golocal-cloud-wrapper.es81.js +334 -0
- package/dist/golocal-cloud-wrapper.es82.js +5 -0
- package/dist/golocal-cloud-wrapper.es83.js +8 -0
- package/dist/golocal-cloud-wrapper.es84.js +58 -0
- package/dist/golocal-cloud-wrapper.es85.js +5 -0
- package/dist/golocal-cloud-wrapper.es86.js +104 -0
- package/dist/golocal-cloud-wrapper.es87.js +468 -0
- package/dist/golocal-cloud-wrapper.es88.js +10 -0
- package/dist/golocal-cloud-wrapper.es89.js +6 -0
- package/dist/golocal-cloud-wrapper.es9.js +90 -0
- package/dist/golocal-cloud-wrapper.es90.js +14 -0
- package/dist/golocal-cloud-wrapper.es91.js +17 -0
- package/dist/golocal-cloud-wrapper.es92.js +70 -0
- package/dist/golocal-cloud-wrapper.es93.js +10 -0
- package/dist/golocal-cloud-wrapper.es94.js +227 -0
- package/dist/golocal-cloud-wrapper.es95.js +297 -0
- package/dist/golocal-cloud-wrapper.es96.js +25 -0
- package/dist/golocal-cloud-wrapper.es97.js +39 -0
- package/dist/golocal-cloud-wrapper.es98.js +616 -0
- package/dist/golocal-cloud-wrapper.es99.js +17 -0
- package/package.json +1 -1
- package/dist/golocal-cloud-wrapper.umd.js +0 -197
|
@@ -0,0 +1,1230 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
var _a, _b;
|
|
5
|
+
let USER_AGENT;
|
|
6
|
+
if (typeof navigator === "undefined" || !((_b = (_a = navigator.userAgent) == null ? void 0 : _a.startsWith) == null ? void 0 : _b.call(_a, "Mozilla/5.0 "))) {
|
|
7
|
+
const NAME = "oauth4webapi";
|
|
8
|
+
const VERSION = "v3.5.3";
|
|
9
|
+
USER_AGENT = `${NAME}/${VERSION}`;
|
|
10
|
+
}
|
|
11
|
+
function looseInstanceOf(input, expected) {
|
|
12
|
+
if (input == null) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return input instanceof expected || Object.getPrototypeOf(input)[Symbol.toStringTag] === expected.prototype[Symbol.toStringTag];
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
|
|
22
|
+
const ERR_INVALID_ARG_TYPE = "ERR_INVALID_ARG_TYPE";
|
|
23
|
+
function CodedTypeError(message, code, cause) {
|
|
24
|
+
const err = new TypeError(message, { cause });
|
|
25
|
+
Object.assign(err, { code });
|
|
26
|
+
return err;
|
|
27
|
+
}
|
|
28
|
+
const allowInsecureRequests = Symbol();
|
|
29
|
+
const clockSkew = Symbol();
|
|
30
|
+
const clockTolerance = Symbol();
|
|
31
|
+
const customFetch = Symbol();
|
|
32
|
+
const jweDecrypt = Symbol();
|
|
33
|
+
const encoder = new TextEncoder();
|
|
34
|
+
const decoder = new TextDecoder();
|
|
35
|
+
function buf(input) {
|
|
36
|
+
if (typeof input === "string") {
|
|
37
|
+
return encoder.encode(input);
|
|
38
|
+
}
|
|
39
|
+
return decoder.decode(input);
|
|
40
|
+
}
|
|
41
|
+
let encodeBase64Url;
|
|
42
|
+
if (Uint8Array.prototype.toBase64) {
|
|
43
|
+
encodeBase64Url = (input) => {
|
|
44
|
+
if (input instanceof ArrayBuffer) {
|
|
45
|
+
input = new Uint8Array(input);
|
|
46
|
+
}
|
|
47
|
+
return input.toBase64({ alphabet: "base64url", omitPadding: true });
|
|
48
|
+
};
|
|
49
|
+
} else {
|
|
50
|
+
const CHUNK_SIZE = 32768;
|
|
51
|
+
encodeBase64Url = (input) => {
|
|
52
|
+
if (input instanceof ArrayBuffer) {
|
|
53
|
+
input = new Uint8Array(input);
|
|
54
|
+
}
|
|
55
|
+
const arr = [];
|
|
56
|
+
for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) {
|
|
57
|
+
arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
|
|
58
|
+
}
|
|
59
|
+
return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
let decodeBase64Url;
|
|
63
|
+
if (Uint8Array.fromBase64) {
|
|
64
|
+
decodeBase64Url = (input) => {
|
|
65
|
+
try {
|
|
66
|
+
return Uint8Array.fromBase64(input, { alphabet: "base64url" });
|
|
67
|
+
} catch (cause) {
|
|
68
|
+
throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
} else {
|
|
72
|
+
decodeBase64Url = (input) => {
|
|
73
|
+
try {
|
|
74
|
+
const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
|
|
75
|
+
const bytes = new Uint8Array(binary.length);
|
|
76
|
+
for (let i = 0; i < binary.length; i++) {
|
|
77
|
+
bytes[i] = binary.charCodeAt(i);
|
|
78
|
+
}
|
|
79
|
+
return bytes;
|
|
80
|
+
} catch (cause) {
|
|
81
|
+
throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function b64u(input) {
|
|
86
|
+
if (typeof input === "string") {
|
|
87
|
+
return decodeBase64Url(input);
|
|
88
|
+
}
|
|
89
|
+
return encodeBase64Url(input);
|
|
90
|
+
}
|
|
91
|
+
class UnsupportedOperationError extends Error {
|
|
92
|
+
constructor(message, options) {
|
|
93
|
+
var _a2;
|
|
94
|
+
super(message, options);
|
|
95
|
+
__publicField(this, "code");
|
|
96
|
+
this.name = this.constructor.name;
|
|
97
|
+
this.code = UNSUPPORTED_OPERATION;
|
|
98
|
+
(_a2 = Error.captureStackTrace) == null ? void 0 : _a2.call(Error, this, this.constructor);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
class OperationProcessingError extends Error {
|
|
102
|
+
constructor(message, options) {
|
|
103
|
+
var _a2;
|
|
104
|
+
super(message, options);
|
|
105
|
+
__publicField(this, "code");
|
|
106
|
+
this.name = this.constructor.name;
|
|
107
|
+
if (options == null ? void 0 : options.code) {
|
|
108
|
+
this.code = options == null ? void 0 : options.code;
|
|
109
|
+
}
|
|
110
|
+
(_a2 = Error.captureStackTrace) == null ? void 0 : _a2.call(Error, this, this.constructor);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function OPE(message, code, cause) {
|
|
114
|
+
return new OperationProcessingError(message, { code, cause });
|
|
115
|
+
}
|
|
116
|
+
function assertCryptoKey(key, it) {
|
|
117
|
+
if (!(key instanceof CryptoKey)) {
|
|
118
|
+
throw CodedTypeError(`${it} must be a CryptoKey`, ERR_INVALID_ARG_TYPE);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function assertPrivateKey(key, it) {
|
|
122
|
+
assertCryptoKey(key, it);
|
|
123
|
+
if (key.type !== "private") {
|
|
124
|
+
throw CodedTypeError(`${it} must be a private CryptoKey`, ERR_INVALID_ARG_VALUE);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function isJsonObject(input) {
|
|
128
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
function prepareHeaders(input) {
|
|
134
|
+
if (looseInstanceOf(input, Headers)) {
|
|
135
|
+
input = Object.fromEntries(input.entries());
|
|
136
|
+
}
|
|
137
|
+
const headers = new Headers(input ?? {});
|
|
138
|
+
if (USER_AGENT && !headers.has("user-agent")) {
|
|
139
|
+
headers.set("user-agent", USER_AGENT);
|
|
140
|
+
}
|
|
141
|
+
if (headers.has("authorization")) {
|
|
142
|
+
throw CodedTypeError('"options.headers" must not include the "authorization" header name', ERR_INVALID_ARG_VALUE);
|
|
143
|
+
}
|
|
144
|
+
return headers;
|
|
145
|
+
}
|
|
146
|
+
function signal(value) {
|
|
147
|
+
if (typeof value === "function") {
|
|
148
|
+
value = value();
|
|
149
|
+
}
|
|
150
|
+
if (!(value instanceof AbortSignal)) {
|
|
151
|
+
throw CodedTypeError('"options.signal" must return or be an instance of AbortSignal', ERR_INVALID_ARG_TYPE);
|
|
152
|
+
}
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
function replaceDoubleSlash(pathname) {
|
|
156
|
+
if (pathname.includes("//")) {
|
|
157
|
+
return pathname.replace("//", "/");
|
|
158
|
+
}
|
|
159
|
+
return pathname;
|
|
160
|
+
}
|
|
161
|
+
function prependWellKnown(url, wellKnown) {
|
|
162
|
+
if (url.pathname === "/") {
|
|
163
|
+
url.pathname = wellKnown;
|
|
164
|
+
} else {
|
|
165
|
+
url.pathname = replaceDoubleSlash(`${wellKnown}/${url.pathname}`);
|
|
166
|
+
}
|
|
167
|
+
return url;
|
|
168
|
+
}
|
|
169
|
+
function appendWellKnown(url, wellKnown) {
|
|
170
|
+
url.pathname = replaceDoubleSlash(`${url.pathname}/${wellKnown}`);
|
|
171
|
+
return url;
|
|
172
|
+
}
|
|
173
|
+
async function performDiscovery(input, urlName, transform, options) {
|
|
174
|
+
if (!(input instanceof URL)) {
|
|
175
|
+
throw CodedTypeError(`"${urlName}" must be an instance of URL`, ERR_INVALID_ARG_TYPE);
|
|
176
|
+
}
|
|
177
|
+
checkProtocol(input, (options == null ? void 0 : options[allowInsecureRequests]) !== true);
|
|
178
|
+
const url = transform(new URL(input.href));
|
|
179
|
+
const headers = prepareHeaders(options == null ? void 0 : options.headers);
|
|
180
|
+
headers.set("accept", "application/json");
|
|
181
|
+
return ((options == null ? void 0 : options[customFetch]) || fetch)(url.href, {
|
|
182
|
+
body: void 0,
|
|
183
|
+
headers: Object.fromEntries(headers.entries()),
|
|
184
|
+
method: "GET",
|
|
185
|
+
redirect: "manual",
|
|
186
|
+
signal: (options == null ? void 0 : options.signal) ? signal(options.signal) : void 0
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
async function discoveryRequest(issuerIdentifier, options) {
|
|
190
|
+
return performDiscovery(issuerIdentifier, "issuerIdentifier", (url) => {
|
|
191
|
+
switch (options == null ? void 0 : options.algorithm) {
|
|
192
|
+
case void 0:
|
|
193
|
+
case "oidc":
|
|
194
|
+
appendWellKnown(url, ".well-known/openid-configuration");
|
|
195
|
+
break;
|
|
196
|
+
case "oauth2":
|
|
197
|
+
prependWellKnown(url, ".well-known/oauth-authorization-server");
|
|
198
|
+
break;
|
|
199
|
+
default:
|
|
200
|
+
throw CodedTypeError('"options.algorithm" must be "oidc" (default), or "oauth2"', ERR_INVALID_ARG_VALUE);
|
|
201
|
+
}
|
|
202
|
+
return url;
|
|
203
|
+
}, options);
|
|
204
|
+
}
|
|
205
|
+
function assertNumber(input, allow0, it, code, cause) {
|
|
206
|
+
try {
|
|
207
|
+
if (typeof input !== "number" || !Number.isFinite(input)) {
|
|
208
|
+
throw CodedTypeError(`${it} must be a number`, ERR_INVALID_ARG_TYPE, cause);
|
|
209
|
+
}
|
|
210
|
+
if (input > 0)
|
|
211
|
+
return;
|
|
212
|
+
if (allow0) ;
|
|
213
|
+
throw CodedTypeError(`${it} must be a positive number`, ERR_INVALID_ARG_VALUE, cause);
|
|
214
|
+
} catch (err) {
|
|
215
|
+
if (code) {
|
|
216
|
+
throw OPE(err.message, code, cause);
|
|
217
|
+
}
|
|
218
|
+
throw err;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function assertString(input, it, code, cause) {
|
|
222
|
+
try {
|
|
223
|
+
if (typeof input !== "string") {
|
|
224
|
+
throw CodedTypeError(`${it} must be a string`, ERR_INVALID_ARG_TYPE, cause);
|
|
225
|
+
}
|
|
226
|
+
if (input.length === 0) {
|
|
227
|
+
throw CodedTypeError(`${it} must not be empty`, ERR_INVALID_ARG_VALUE, cause);
|
|
228
|
+
}
|
|
229
|
+
} catch (err) {
|
|
230
|
+
if (code) {
|
|
231
|
+
throw OPE(err.message, code, cause);
|
|
232
|
+
}
|
|
233
|
+
throw err;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async function processDiscoveryResponse(expectedIssuerIdentifier, response) {
|
|
237
|
+
const expected = expectedIssuerIdentifier;
|
|
238
|
+
if (!(expected instanceof URL) && expected !== _nodiscoverycheck) {
|
|
239
|
+
throw CodedTypeError('"expectedIssuerIdentifier" must be an instance of URL', ERR_INVALID_ARG_TYPE);
|
|
240
|
+
}
|
|
241
|
+
if (!looseInstanceOf(response, Response)) {
|
|
242
|
+
throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE);
|
|
243
|
+
}
|
|
244
|
+
if (response.status !== 200) {
|
|
245
|
+
throw OPE('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)', RESPONSE_IS_NOT_CONFORM, response);
|
|
246
|
+
}
|
|
247
|
+
assertReadableResponse(response);
|
|
248
|
+
const json = await getResponseJsonBody(response);
|
|
249
|
+
assertString(json.issuer, '"response" body "issuer" property', INVALID_RESPONSE, { body: json });
|
|
250
|
+
if (expected !== _nodiscoverycheck && new URL(json.issuer).href !== expected.href) {
|
|
251
|
+
throw OPE('"response" body "issuer" property does not match the expected value', JSON_ATTRIBUTE_COMPARISON, { expected: expected.href, body: json, attribute: "issuer" });
|
|
252
|
+
}
|
|
253
|
+
return json;
|
|
254
|
+
}
|
|
255
|
+
function assertApplicationJson(response) {
|
|
256
|
+
assertContentType(response, "application/json");
|
|
257
|
+
}
|
|
258
|
+
function notJson(response, ...types) {
|
|
259
|
+
let msg = '"response" content-type must be ';
|
|
260
|
+
if (types.length > 2) {
|
|
261
|
+
const last = types.pop();
|
|
262
|
+
msg += `${types.join(", ")}, or ${last}`;
|
|
263
|
+
} else if (types.length === 2) {
|
|
264
|
+
msg += `${types[0]} or ${types[1]}`;
|
|
265
|
+
} else {
|
|
266
|
+
msg += types[0];
|
|
267
|
+
}
|
|
268
|
+
return OPE(msg, RESPONSE_IS_NOT_JSON, response);
|
|
269
|
+
}
|
|
270
|
+
function assertContentType(response, contentType) {
|
|
271
|
+
if (getContentType(response) !== contentType) {
|
|
272
|
+
throw notJson(response, contentType);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function randomBytes() {
|
|
276
|
+
return b64u(crypto.getRandomValues(new Uint8Array(32)));
|
|
277
|
+
}
|
|
278
|
+
function generateRandomCodeVerifier() {
|
|
279
|
+
return randomBytes();
|
|
280
|
+
}
|
|
281
|
+
function generateRandomState() {
|
|
282
|
+
return randomBytes();
|
|
283
|
+
}
|
|
284
|
+
function generateRandomNonce() {
|
|
285
|
+
return randomBytes();
|
|
286
|
+
}
|
|
287
|
+
async function calculatePKCECodeChallenge(codeVerifier) {
|
|
288
|
+
assertString(codeVerifier, "codeVerifier");
|
|
289
|
+
return b64u(await crypto.subtle.digest("SHA-256", buf(codeVerifier)));
|
|
290
|
+
}
|
|
291
|
+
function getKeyAndKid(input) {
|
|
292
|
+
if (input instanceof CryptoKey) {
|
|
293
|
+
return { key: input };
|
|
294
|
+
}
|
|
295
|
+
if (!((input == null ? void 0 : input.key) instanceof CryptoKey)) {
|
|
296
|
+
return {};
|
|
297
|
+
}
|
|
298
|
+
if (input.kid !== void 0) {
|
|
299
|
+
assertString(input.kid, '"kid"');
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
key: input.key,
|
|
303
|
+
kid: input.kid
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function psAlg(key) {
|
|
307
|
+
switch (key.algorithm.hash.name) {
|
|
308
|
+
case "SHA-256":
|
|
309
|
+
return "PS256";
|
|
310
|
+
case "SHA-384":
|
|
311
|
+
return "PS384";
|
|
312
|
+
case "SHA-512":
|
|
313
|
+
return "PS512";
|
|
314
|
+
default:
|
|
315
|
+
throw new UnsupportedOperationError("unsupported RsaHashedKeyAlgorithm hash name", {
|
|
316
|
+
cause: key
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function rsAlg(key) {
|
|
321
|
+
switch (key.algorithm.hash.name) {
|
|
322
|
+
case "SHA-256":
|
|
323
|
+
return "RS256";
|
|
324
|
+
case "SHA-384":
|
|
325
|
+
return "RS384";
|
|
326
|
+
case "SHA-512":
|
|
327
|
+
return "RS512";
|
|
328
|
+
default:
|
|
329
|
+
throw new UnsupportedOperationError("unsupported RsaHashedKeyAlgorithm hash name", {
|
|
330
|
+
cause: key
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function esAlg(key) {
|
|
335
|
+
switch (key.algorithm.namedCurve) {
|
|
336
|
+
case "P-256":
|
|
337
|
+
return "ES256";
|
|
338
|
+
case "P-384":
|
|
339
|
+
return "ES384";
|
|
340
|
+
case "P-521":
|
|
341
|
+
return "ES512";
|
|
342
|
+
default:
|
|
343
|
+
throw new UnsupportedOperationError("unsupported EcKeyAlgorithm namedCurve", { cause: key });
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function keyToJws(key) {
|
|
347
|
+
switch (key.algorithm.name) {
|
|
348
|
+
case "RSA-PSS":
|
|
349
|
+
return psAlg(key);
|
|
350
|
+
case "RSASSA-PKCS1-v1_5":
|
|
351
|
+
return rsAlg(key);
|
|
352
|
+
case "ECDSA":
|
|
353
|
+
return esAlg(key);
|
|
354
|
+
case "Ed25519":
|
|
355
|
+
case "EdDSA":
|
|
356
|
+
return "Ed25519";
|
|
357
|
+
default:
|
|
358
|
+
throw new UnsupportedOperationError("unsupported CryptoKey algorithm name", { cause: key });
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function getClockSkew(client) {
|
|
362
|
+
const skew = client == null ? void 0 : client[clockSkew];
|
|
363
|
+
return typeof skew === "number" && Number.isFinite(skew) ? skew : 0;
|
|
364
|
+
}
|
|
365
|
+
function getClockTolerance(client) {
|
|
366
|
+
const tolerance = client == null ? void 0 : client[clockTolerance];
|
|
367
|
+
return typeof tolerance === "number" && Number.isFinite(tolerance) && Math.sign(tolerance) !== -1 ? tolerance : 30;
|
|
368
|
+
}
|
|
369
|
+
function epochTime() {
|
|
370
|
+
return Math.floor(Date.now() / 1e3);
|
|
371
|
+
}
|
|
372
|
+
function assertAs(as) {
|
|
373
|
+
if (typeof as !== "object" || as === null) {
|
|
374
|
+
throw CodedTypeError('"as" must be an object', ERR_INVALID_ARG_TYPE);
|
|
375
|
+
}
|
|
376
|
+
assertString(as.issuer, '"as.issuer"');
|
|
377
|
+
}
|
|
378
|
+
function assertClient(client) {
|
|
379
|
+
if (typeof client !== "object" || client === null) {
|
|
380
|
+
throw CodedTypeError('"client" must be an object', ERR_INVALID_ARG_TYPE);
|
|
381
|
+
}
|
|
382
|
+
assertString(client.client_id, '"client.client_id"');
|
|
383
|
+
}
|
|
384
|
+
function ClientSecretPost(clientSecret) {
|
|
385
|
+
assertString(clientSecret, '"clientSecret"');
|
|
386
|
+
return (_as, client, body, _headers) => {
|
|
387
|
+
body.set("client_id", client.client_id);
|
|
388
|
+
body.set("client_secret", clientSecret);
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function clientAssertionPayload(as, client) {
|
|
392
|
+
const now = epochTime() + getClockSkew(client);
|
|
393
|
+
return {
|
|
394
|
+
jti: randomBytes(),
|
|
395
|
+
aud: as.issuer,
|
|
396
|
+
exp: now + 60,
|
|
397
|
+
iat: now,
|
|
398
|
+
nbf: now,
|
|
399
|
+
iss: client.client_id,
|
|
400
|
+
sub: client.client_id
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function PrivateKeyJwt(clientPrivateKey, options) {
|
|
404
|
+
const { key, kid } = getKeyAndKid(clientPrivateKey);
|
|
405
|
+
assertPrivateKey(key, '"clientPrivateKey.key"');
|
|
406
|
+
return async (as, client, body, _headers) => {
|
|
407
|
+
const header = { alg: keyToJws(key), kid };
|
|
408
|
+
const payload = clientAssertionPayload(as, client);
|
|
409
|
+
body.set("client_id", client.client_id);
|
|
410
|
+
body.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer");
|
|
411
|
+
body.set("client_assertion", await signJwt(header, payload, key));
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
async function signJwt(header, payload, key) {
|
|
415
|
+
if (!key.usages.includes("sign")) {
|
|
416
|
+
throw CodedTypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"', ERR_INVALID_ARG_VALUE);
|
|
417
|
+
}
|
|
418
|
+
const input = `${b64u(buf(JSON.stringify(header)))}.${b64u(buf(JSON.stringify(payload)))}`;
|
|
419
|
+
const signature = b64u(await crypto.subtle.sign(keyToSubtle(key), key, buf(input)));
|
|
420
|
+
return `${input}.${signature}`;
|
|
421
|
+
}
|
|
422
|
+
const URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
|
|
423
|
+
try {
|
|
424
|
+
return new URL(url, base);
|
|
425
|
+
} catch {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
function checkProtocol(url, enforceHttps) {
|
|
430
|
+
if (enforceHttps && url.protocol !== "https:") {
|
|
431
|
+
throw OPE("only requests to HTTPS are allowed", HTTP_REQUEST_FORBIDDEN, url);
|
|
432
|
+
}
|
|
433
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
434
|
+
throw OPE("only HTTP and HTTPS requests are allowed", REQUEST_PROTOCOL_FORBIDDEN, url);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function validateEndpoint(value, endpoint, useMtlsAlias, enforceHttps) {
|
|
438
|
+
let url;
|
|
439
|
+
if (typeof value !== "string" || !(url = URLParse(value))) {
|
|
440
|
+
throw OPE(`authorization server metadata does not contain a valid ${useMtlsAlias ? `"as.mtls_endpoint_aliases.${endpoint}"` : `"as.${endpoint}"`}`, value === void 0 ? MISSING_SERVER_METADATA : INVALID_SERVER_METADATA, { attribute: useMtlsAlias ? `mtls_endpoint_aliases.${endpoint}` : endpoint });
|
|
441
|
+
}
|
|
442
|
+
checkProtocol(url, enforceHttps);
|
|
443
|
+
return url;
|
|
444
|
+
}
|
|
445
|
+
function resolveEndpoint(as, endpoint, useMtlsAlias, enforceHttps) {
|
|
446
|
+
if (useMtlsAlias && as.mtls_endpoint_aliases && endpoint in as.mtls_endpoint_aliases) {
|
|
447
|
+
return validateEndpoint(as.mtls_endpoint_aliases[endpoint], endpoint, useMtlsAlias, enforceHttps);
|
|
448
|
+
}
|
|
449
|
+
return validateEndpoint(as[endpoint], endpoint, useMtlsAlias, enforceHttps);
|
|
450
|
+
}
|
|
451
|
+
async function pushedAuthorizationRequest(as, client, clientAuthentication, parameters, options) {
|
|
452
|
+
var _a2;
|
|
453
|
+
assertAs(as);
|
|
454
|
+
assertClient(client);
|
|
455
|
+
const url = resolveEndpoint(as, "pushed_authorization_request_endpoint", client.use_mtls_endpoint_aliases, (options == null ? void 0 : options[allowInsecureRequests]) !== true);
|
|
456
|
+
const body = new URLSearchParams(parameters);
|
|
457
|
+
body.set("client_id", client.client_id);
|
|
458
|
+
const headers = prepareHeaders(options == null ? void 0 : options.headers);
|
|
459
|
+
headers.set("accept", "application/json");
|
|
460
|
+
if ((options == null ? void 0 : options.DPoP) !== void 0) {
|
|
461
|
+
assertDPoP(options.DPoP);
|
|
462
|
+
await options.DPoP.addProof(url, headers, "POST");
|
|
463
|
+
}
|
|
464
|
+
const response = await authenticatedRequest(as, client, clientAuthentication, url, body, headers, options);
|
|
465
|
+
(_a2 = options == null ? void 0 : options.DPoP) == null ? void 0 : _a2.cacheNonce(response);
|
|
466
|
+
return response;
|
|
467
|
+
}
|
|
468
|
+
class ResponseBodyError extends Error {
|
|
469
|
+
constructor(message, options) {
|
|
470
|
+
var _a2;
|
|
471
|
+
super(message, options);
|
|
472
|
+
__publicField(this, "cause");
|
|
473
|
+
__publicField(this, "code");
|
|
474
|
+
__publicField(this, "error");
|
|
475
|
+
__publicField(this, "status");
|
|
476
|
+
__publicField(this, "error_description");
|
|
477
|
+
__publicField(this, "response");
|
|
478
|
+
this.name = this.constructor.name;
|
|
479
|
+
this.code = RESPONSE_BODY_ERROR;
|
|
480
|
+
this.cause = options.cause;
|
|
481
|
+
this.error = options.cause.error;
|
|
482
|
+
this.status = options.response.status;
|
|
483
|
+
this.error_description = options.cause.error_description;
|
|
484
|
+
Object.defineProperty(this, "response", { enumerable: false, value: options.response });
|
|
485
|
+
(_a2 = Error.captureStackTrace) == null ? void 0 : _a2.call(Error, this, this.constructor);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
class AuthorizationResponseError extends Error {
|
|
489
|
+
constructor(message, options) {
|
|
490
|
+
var _a2;
|
|
491
|
+
super(message, options);
|
|
492
|
+
__publicField(this, "cause");
|
|
493
|
+
__publicField(this, "code");
|
|
494
|
+
__publicField(this, "error");
|
|
495
|
+
__publicField(this, "error_description");
|
|
496
|
+
this.name = this.constructor.name;
|
|
497
|
+
this.code = AUTHORIZATION_RESPONSE_ERROR;
|
|
498
|
+
this.cause = options.cause;
|
|
499
|
+
this.error = options.cause.get("error");
|
|
500
|
+
this.error_description = options.cause.get("error_description") ?? void 0;
|
|
501
|
+
(_a2 = Error.captureStackTrace) == null ? void 0 : _a2.call(Error, this, this.constructor);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
class WWWAuthenticateChallengeError extends Error {
|
|
505
|
+
constructor(message, options) {
|
|
506
|
+
var _a2;
|
|
507
|
+
super(message, options);
|
|
508
|
+
__publicField(this, "cause");
|
|
509
|
+
__publicField(this, "code");
|
|
510
|
+
__publicField(this, "response");
|
|
511
|
+
__publicField(this, "status");
|
|
512
|
+
this.name = this.constructor.name;
|
|
513
|
+
this.code = WWW_AUTHENTICATE_CHALLENGE;
|
|
514
|
+
this.cause = options.cause;
|
|
515
|
+
this.status = options.response.status;
|
|
516
|
+
this.response = options.response;
|
|
517
|
+
Object.defineProperty(this, "response", { enumerable: false });
|
|
518
|
+
(_a2 = Error.captureStackTrace) == null ? void 0 : _a2.call(Error, this, this.constructor);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
|
|
522
|
+
const token68Match = "[a-zA-Z0-9\\-\\._\\~\\+\\/]+[=]{0,2}";
|
|
523
|
+
const quotedMatch = '"((?:[^"\\\\]|\\\\.)*)"';
|
|
524
|
+
const quotedParamMatcher = "(" + tokenMatch + ")\\s*=\\s*" + quotedMatch;
|
|
525
|
+
const paramMatcher = "(" + tokenMatch + ")\\s*=\\s*(" + tokenMatch + ")";
|
|
526
|
+
const schemeRE = new RegExp("^[,\\s]*(" + tokenMatch + ")\\s(.*)");
|
|
527
|
+
const quotedParamRE = new RegExp("^[,\\s]*" + quotedParamMatcher + "[,\\s]*(.*)");
|
|
528
|
+
const unquotedParamRE = new RegExp("^[,\\s]*" + paramMatcher + "[,\\s]*(.*)");
|
|
529
|
+
const token68ParamRE = new RegExp("^(" + token68Match + ")(?:$|[,\\s])(.*)");
|
|
530
|
+
function parseWwwAuthenticateChallenges(response) {
|
|
531
|
+
if (!looseInstanceOf(response, Response)) {
|
|
532
|
+
throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE);
|
|
533
|
+
}
|
|
534
|
+
const header = response.headers.get("www-authenticate");
|
|
535
|
+
if (header === null) {
|
|
536
|
+
return void 0;
|
|
537
|
+
}
|
|
538
|
+
const challenges = [];
|
|
539
|
+
let rest = header;
|
|
540
|
+
while (rest) {
|
|
541
|
+
let match = rest.match(schemeRE);
|
|
542
|
+
const scheme = match == null ? void 0 : match["1"].toLowerCase();
|
|
543
|
+
rest = match == null ? void 0 : match["2"];
|
|
544
|
+
if (!scheme) {
|
|
545
|
+
return void 0;
|
|
546
|
+
}
|
|
547
|
+
const parameters = {};
|
|
548
|
+
let token68;
|
|
549
|
+
while (rest) {
|
|
550
|
+
let key;
|
|
551
|
+
let value;
|
|
552
|
+
if (match = rest.match(quotedParamRE)) {
|
|
553
|
+
[, key, value, rest] = match;
|
|
554
|
+
if (value.includes("\\")) {
|
|
555
|
+
try {
|
|
556
|
+
value = JSON.parse(`"${value}"`);
|
|
557
|
+
} catch {
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
parameters[key.toLowerCase()] = value;
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
if (match = rest.match(unquotedParamRE)) {
|
|
564
|
+
[, key, value, rest] = match;
|
|
565
|
+
parameters[key.toLowerCase()] = value;
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
if (match = rest.match(token68ParamRE)) {
|
|
569
|
+
if (Object.keys(parameters).length) {
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
[, token68, rest] = match;
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
return void 0;
|
|
576
|
+
}
|
|
577
|
+
const challenge = { scheme, parameters };
|
|
578
|
+
if (token68) {
|
|
579
|
+
challenge.token68 = token68;
|
|
580
|
+
}
|
|
581
|
+
challenges.push(challenge);
|
|
582
|
+
}
|
|
583
|
+
if (!challenges.length) {
|
|
584
|
+
return void 0;
|
|
585
|
+
}
|
|
586
|
+
return challenges;
|
|
587
|
+
}
|
|
588
|
+
async function processPushedAuthorizationResponse(as, client, response) {
|
|
589
|
+
assertAs(as);
|
|
590
|
+
assertClient(client);
|
|
591
|
+
if (!looseInstanceOf(response, Response)) {
|
|
592
|
+
throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE);
|
|
593
|
+
}
|
|
594
|
+
checkAuthenticationChallenges(response);
|
|
595
|
+
await checkOAuthBodyError(response, 201, "Pushed Authorization Request Endpoint");
|
|
596
|
+
assertReadableResponse(response);
|
|
597
|
+
const json = await getResponseJsonBody(response);
|
|
598
|
+
assertString(json.request_uri, '"response" body "request_uri" property', INVALID_RESPONSE, {
|
|
599
|
+
body: json
|
|
600
|
+
});
|
|
601
|
+
let expiresIn = typeof json.expires_in !== "number" ? parseFloat(json.expires_in) : json.expires_in;
|
|
602
|
+
assertNumber(expiresIn, false, '"response" body "expires_in" property', INVALID_RESPONSE, {
|
|
603
|
+
body: json
|
|
604
|
+
});
|
|
605
|
+
json.expires_in = expiresIn;
|
|
606
|
+
return json;
|
|
607
|
+
}
|
|
608
|
+
async function parseOAuthResponseErrorBody(response) {
|
|
609
|
+
if (response.status > 399 && response.status < 500) {
|
|
610
|
+
assertReadableResponse(response);
|
|
611
|
+
assertApplicationJson(response);
|
|
612
|
+
try {
|
|
613
|
+
const json = await response.clone().json();
|
|
614
|
+
if (isJsonObject(json) && typeof json.error === "string" && json.error.length) {
|
|
615
|
+
return json;
|
|
616
|
+
}
|
|
617
|
+
} catch {
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return void 0;
|
|
621
|
+
}
|
|
622
|
+
async function checkOAuthBodyError(response, expected, label) {
|
|
623
|
+
var _a2;
|
|
624
|
+
if (response.status !== expected) {
|
|
625
|
+
let err;
|
|
626
|
+
if (err = await parseOAuthResponseErrorBody(response)) {
|
|
627
|
+
await ((_a2 = response.body) == null ? void 0 : _a2.cancel());
|
|
628
|
+
throw new ResponseBodyError("server responded with an error in the response body", {
|
|
629
|
+
cause: err,
|
|
630
|
+
response
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
throw OPE(`"response" is not a conform ${label} response (unexpected HTTP status code)`, RESPONSE_IS_NOT_CONFORM, response);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function assertDPoP(option) {
|
|
637
|
+
if (!branded.has(option)) {
|
|
638
|
+
throw CodedTypeError('"options.DPoP" is not a valid DPoPHandle', ERR_INVALID_ARG_VALUE);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function getContentType(input) {
|
|
642
|
+
var _a2;
|
|
643
|
+
return (_a2 = input.headers.get("content-type")) == null ? void 0 : _a2.split(";")[0];
|
|
644
|
+
}
|
|
645
|
+
async function authenticatedRequest(as, client, clientAuthentication, url, body, headers, options) {
|
|
646
|
+
await clientAuthentication(as, client, body, headers);
|
|
647
|
+
headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
|
|
648
|
+
return ((options == null ? void 0 : options[customFetch]) || fetch)(url.href, {
|
|
649
|
+
body,
|
|
650
|
+
headers: Object.fromEntries(headers.entries()),
|
|
651
|
+
method: "POST",
|
|
652
|
+
redirect: "manual",
|
|
653
|
+
signal: (options == null ? void 0 : options.signal) ? signal(options.signal) : void 0
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
async function tokenEndpointRequest(as, client, clientAuthentication, grantType, parameters, options) {
|
|
657
|
+
var _a2;
|
|
658
|
+
const url = resolveEndpoint(as, "token_endpoint", client.use_mtls_endpoint_aliases, (options == null ? void 0 : options[allowInsecureRequests]) !== true);
|
|
659
|
+
parameters.set("grant_type", grantType);
|
|
660
|
+
const headers = prepareHeaders(options == null ? void 0 : options.headers);
|
|
661
|
+
headers.set("accept", "application/json");
|
|
662
|
+
if ((options == null ? void 0 : options.DPoP) !== void 0) {
|
|
663
|
+
assertDPoP(options.DPoP);
|
|
664
|
+
await options.DPoP.addProof(url, headers, "POST");
|
|
665
|
+
}
|
|
666
|
+
const response = await authenticatedRequest(as, client, clientAuthentication, url, parameters, headers, options);
|
|
667
|
+
(_a2 = options == null ? void 0 : options.DPoP) == null ? void 0 : _a2.cacheNonce(response);
|
|
668
|
+
return response;
|
|
669
|
+
}
|
|
670
|
+
async function refreshTokenGrantRequest(as, client, clientAuthentication, refreshToken, options) {
|
|
671
|
+
assertAs(as);
|
|
672
|
+
assertClient(client);
|
|
673
|
+
assertString(refreshToken, '"refreshToken"');
|
|
674
|
+
const parameters = new URLSearchParams(options == null ? void 0 : options.additionalParameters);
|
|
675
|
+
parameters.set("refresh_token", refreshToken);
|
|
676
|
+
return tokenEndpointRequest(as, client, clientAuthentication, "refresh_token", parameters, options);
|
|
677
|
+
}
|
|
678
|
+
const idTokenClaims = /* @__PURE__ */ new WeakMap();
|
|
679
|
+
const jwtRefs = /* @__PURE__ */ new WeakMap();
|
|
680
|
+
function getValidatedIdTokenClaims(ref) {
|
|
681
|
+
if (!ref.id_token) {
|
|
682
|
+
return void 0;
|
|
683
|
+
}
|
|
684
|
+
const claims = idTokenClaims.get(ref);
|
|
685
|
+
if (!claims) {
|
|
686
|
+
throw CodedTypeError('"ref" was already garbage collected or did not resolve from the proper sources', ERR_INVALID_ARG_VALUE);
|
|
687
|
+
}
|
|
688
|
+
return claims;
|
|
689
|
+
}
|
|
690
|
+
async function processGenericAccessTokenResponse(as, client, response, additionalRequiredIdTokenClaims, options) {
|
|
691
|
+
assertAs(as);
|
|
692
|
+
assertClient(client);
|
|
693
|
+
if (!looseInstanceOf(response, Response)) {
|
|
694
|
+
throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE);
|
|
695
|
+
}
|
|
696
|
+
checkAuthenticationChallenges(response);
|
|
697
|
+
await checkOAuthBodyError(response, 200, "Token Endpoint");
|
|
698
|
+
assertReadableResponse(response);
|
|
699
|
+
const json = await getResponseJsonBody(response);
|
|
700
|
+
assertString(json.access_token, '"response" body "access_token" property', INVALID_RESPONSE, {
|
|
701
|
+
body: json
|
|
702
|
+
});
|
|
703
|
+
assertString(json.token_type, '"response" body "token_type" property', INVALID_RESPONSE, {
|
|
704
|
+
body: json
|
|
705
|
+
});
|
|
706
|
+
json.token_type = json.token_type.toLowerCase();
|
|
707
|
+
if (json.token_type !== "dpop" && json.token_type !== "bearer") {
|
|
708
|
+
throw new UnsupportedOperationError("unsupported `token_type` value", { cause: { body: json } });
|
|
709
|
+
}
|
|
710
|
+
if (json.expires_in !== void 0) {
|
|
711
|
+
let expiresIn = typeof json.expires_in !== "number" ? parseFloat(json.expires_in) : json.expires_in;
|
|
712
|
+
assertNumber(expiresIn, false, '"response" body "expires_in" property', INVALID_RESPONSE, {
|
|
713
|
+
body: json
|
|
714
|
+
});
|
|
715
|
+
json.expires_in = expiresIn;
|
|
716
|
+
}
|
|
717
|
+
if (json.refresh_token !== void 0) {
|
|
718
|
+
assertString(json.refresh_token, '"response" body "refresh_token" property', INVALID_RESPONSE, {
|
|
719
|
+
body: json
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
if (json.scope !== void 0 && typeof json.scope !== "string") {
|
|
723
|
+
throw OPE('"response" body "scope" property must be a string', INVALID_RESPONSE, { body: json });
|
|
724
|
+
}
|
|
725
|
+
if (json.id_token !== void 0) {
|
|
726
|
+
assertString(json.id_token, '"response" body "id_token" property', INVALID_RESPONSE, {
|
|
727
|
+
body: json
|
|
728
|
+
});
|
|
729
|
+
const requiredClaims = ["aud", "exp", "iat", "iss", "sub"];
|
|
730
|
+
if (client.require_auth_time === true) {
|
|
731
|
+
requiredClaims.push("auth_time");
|
|
732
|
+
}
|
|
733
|
+
if (client.default_max_age !== void 0) {
|
|
734
|
+
assertNumber(client.default_max_age, false, '"client.default_max_age"');
|
|
735
|
+
requiredClaims.push("auth_time");
|
|
736
|
+
}
|
|
737
|
+
if (additionalRequiredIdTokenClaims == null ? void 0 : additionalRequiredIdTokenClaims.length) {
|
|
738
|
+
requiredClaims.push(...additionalRequiredIdTokenClaims);
|
|
739
|
+
}
|
|
740
|
+
const { claims, jwt } = await validateJwt(json.id_token, checkSigningAlgorithm.bind(void 0, client.id_token_signed_response_alg, as.id_token_signing_alg_values_supported, "RS256"), getClockSkew(client), getClockTolerance(client), options == null ? void 0 : options[jweDecrypt]).then(validatePresence.bind(void 0, requiredClaims)).then(validateIssuer.bind(void 0, as)).then(validateAudience.bind(void 0, client.client_id));
|
|
741
|
+
if (Array.isArray(claims.aud) && claims.aud.length !== 1) {
|
|
742
|
+
if (claims.azp === void 0) {
|
|
743
|
+
throw OPE('ID Token "aud" (audience) claim includes additional untrusted audiences', JWT_CLAIM_COMPARISON, { claims, claim: "aud" });
|
|
744
|
+
}
|
|
745
|
+
if (claims.azp !== client.client_id) {
|
|
746
|
+
throw OPE('unexpected ID Token "azp" (authorized party) claim value', JWT_CLAIM_COMPARISON, { expected: client.client_id, claims, claim: "azp" });
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (claims.auth_time !== void 0) {
|
|
750
|
+
assertNumber(claims.auth_time, false, 'ID Token "auth_time" (authentication time)', INVALID_RESPONSE, { claims });
|
|
751
|
+
}
|
|
752
|
+
jwtRefs.set(response, jwt);
|
|
753
|
+
idTokenClaims.set(json, claims);
|
|
754
|
+
}
|
|
755
|
+
return json;
|
|
756
|
+
}
|
|
757
|
+
function checkAuthenticationChallenges(response) {
|
|
758
|
+
let challenges;
|
|
759
|
+
if (challenges = parseWwwAuthenticateChallenges(response)) {
|
|
760
|
+
throw new WWWAuthenticateChallengeError("server responded with a challenge in the WWW-Authenticate HTTP Header", { cause: challenges, response });
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
async function processRefreshTokenResponse(as, client, response, options) {
|
|
764
|
+
return processGenericAccessTokenResponse(as, client, response, void 0, options);
|
|
765
|
+
}
|
|
766
|
+
function validateAudience(expected, result) {
|
|
767
|
+
if (Array.isArray(result.claims.aud)) {
|
|
768
|
+
if (!result.claims.aud.includes(expected)) {
|
|
769
|
+
throw OPE('unexpected JWT "aud" (audience) claim value', JWT_CLAIM_COMPARISON, {
|
|
770
|
+
expected,
|
|
771
|
+
claims: result.claims,
|
|
772
|
+
claim: "aud"
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
} else if (result.claims.aud !== expected) {
|
|
776
|
+
throw OPE('unexpected JWT "aud" (audience) claim value', JWT_CLAIM_COMPARISON, {
|
|
777
|
+
expected,
|
|
778
|
+
claims: result.claims,
|
|
779
|
+
claim: "aud"
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
return result;
|
|
783
|
+
}
|
|
784
|
+
function validateIssuer(as, result) {
|
|
785
|
+
var _a2;
|
|
786
|
+
const expected = ((_a2 = as[_expectedIssuer]) == null ? void 0 : _a2.call(as, result)) ?? as.issuer;
|
|
787
|
+
if (result.claims.iss !== expected) {
|
|
788
|
+
throw OPE('unexpected JWT "iss" (issuer) claim value', JWT_CLAIM_COMPARISON, {
|
|
789
|
+
expected,
|
|
790
|
+
claims: result.claims,
|
|
791
|
+
claim: "iss"
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
return result;
|
|
795
|
+
}
|
|
796
|
+
const branded = /* @__PURE__ */ new WeakSet();
|
|
797
|
+
function brand(searchParams) {
|
|
798
|
+
branded.add(searchParams);
|
|
799
|
+
return searchParams;
|
|
800
|
+
}
|
|
801
|
+
const nopkce = Symbol();
|
|
802
|
+
async function authorizationCodeGrantRequest(as, client, clientAuthentication, callbackParameters, redirectUri, codeVerifier, options) {
|
|
803
|
+
assertAs(as);
|
|
804
|
+
assertClient(client);
|
|
805
|
+
if (!branded.has(callbackParameters)) {
|
|
806
|
+
throw CodedTypeError('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()', ERR_INVALID_ARG_VALUE);
|
|
807
|
+
}
|
|
808
|
+
assertString(redirectUri, '"redirectUri"');
|
|
809
|
+
const code = getURLSearchParameter(callbackParameters, "code");
|
|
810
|
+
if (!code) {
|
|
811
|
+
throw OPE('no authorization code in "callbackParameters"', INVALID_RESPONSE);
|
|
812
|
+
}
|
|
813
|
+
const parameters = new URLSearchParams(options == null ? void 0 : options.additionalParameters);
|
|
814
|
+
parameters.set("redirect_uri", redirectUri);
|
|
815
|
+
parameters.set("code", code);
|
|
816
|
+
if (codeVerifier !== nopkce) {
|
|
817
|
+
assertString(codeVerifier, '"codeVerifier"');
|
|
818
|
+
parameters.set("code_verifier", codeVerifier);
|
|
819
|
+
}
|
|
820
|
+
return tokenEndpointRequest(as, client, clientAuthentication, "authorization_code", parameters, options);
|
|
821
|
+
}
|
|
822
|
+
const jwtClaimNames = {
|
|
823
|
+
aud: "audience",
|
|
824
|
+
c_hash: "code hash",
|
|
825
|
+
client_id: "client id",
|
|
826
|
+
exp: "expiration time",
|
|
827
|
+
iat: "issued at",
|
|
828
|
+
iss: "issuer",
|
|
829
|
+
jti: "jwt id",
|
|
830
|
+
nonce: "nonce",
|
|
831
|
+
s_hash: "state hash",
|
|
832
|
+
sub: "subject",
|
|
833
|
+
ath: "access token hash",
|
|
834
|
+
htm: "http method",
|
|
835
|
+
htu: "http uri",
|
|
836
|
+
cnf: "confirmation",
|
|
837
|
+
auth_time: "authentication time"
|
|
838
|
+
};
|
|
839
|
+
function validatePresence(required, result) {
|
|
840
|
+
for (const claim of required) {
|
|
841
|
+
if (result.claims[claim] === void 0) {
|
|
842
|
+
throw OPE(`JWT "${claim}" (${jwtClaimNames[claim]}) claim missing`, INVALID_RESPONSE, {
|
|
843
|
+
claims: result.claims
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return result;
|
|
848
|
+
}
|
|
849
|
+
const expectNoNonce = Symbol();
|
|
850
|
+
const skipAuthTimeCheck = Symbol();
|
|
851
|
+
async function processAuthorizationCodeResponse(as, client, response, options) {
|
|
852
|
+
{
|
|
853
|
+
return processAuthorizationCodeOpenIDResponse(as, client, response, options.expectedNonce, options.maxAge, {
|
|
854
|
+
[jweDecrypt]: options[jweDecrypt]
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
async function processAuthorizationCodeOpenIDResponse(as, client, response, expectedNonce, maxAge, options) {
|
|
859
|
+
const additionalRequiredClaims = [];
|
|
860
|
+
switch (expectedNonce) {
|
|
861
|
+
case void 0:
|
|
862
|
+
expectedNonce = expectNoNonce;
|
|
863
|
+
break;
|
|
864
|
+
case expectNoNonce:
|
|
865
|
+
break;
|
|
866
|
+
default:
|
|
867
|
+
assertString(expectedNonce, '"expectedNonce" argument');
|
|
868
|
+
additionalRequiredClaims.push("nonce");
|
|
869
|
+
}
|
|
870
|
+
maxAge ?? (maxAge = client.default_max_age);
|
|
871
|
+
switch (maxAge) {
|
|
872
|
+
case void 0:
|
|
873
|
+
maxAge = skipAuthTimeCheck;
|
|
874
|
+
break;
|
|
875
|
+
case skipAuthTimeCheck:
|
|
876
|
+
break;
|
|
877
|
+
default:
|
|
878
|
+
assertNumber(maxAge, false, '"maxAge" argument');
|
|
879
|
+
additionalRequiredClaims.push("auth_time");
|
|
880
|
+
}
|
|
881
|
+
const result = await processGenericAccessTokenResponse(as, client, response, additionalRequiredClaims, options);
|
|
882
|
+
assertString(result.id_token, '"response" body "id_token" property', INVALID_RESPONSE, {
|
|
883
|
+
body: result
|
|
884
|
+
});
|
|
885
|
+
const claims = getValidatedIdTokenClaims(result);
|
|
886
|
+
if (maxAge !== skipAuthTimeCheck) {
|
|
887
|
+
const now = epochTime() + getClockSkew(client);
|
|
888
|
+
const tolerance = getClockTolerance(client);
|
|
889
|
+
if (claims.auth_time + maxAge < now - tolerance) {
|
|
890
|
+
throw OPE("too much time has elapsed since the last End-User authentication", JWT_TIMESTAMP_CHECK, { claims, now, tolerance, claim: "auth_time" });
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
if (expectedNonce === expectNoNonce) {
|
|
894
|
+
if (claims.nonce !== void 0) {
|
|
895
|
+
throw OPE('unexpected ID Token "nonce" claim value', JWT_CLAIM_COMPARISON, {
|
|
896
|
+
expected: void 0,
|
|
897
|
+
claims,
|
|
898
|
+
claim: "nonce"
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
} else if (claims.nonce !== expectedNonce) {
|
|
902
|
+
throw OPE('unexpected ID Token "nonce" claim value', JWT_CLAIM_COMPARISON, {
|
|
903
|
+
expected: expectedNonce,
|
|
904
|
+
claims,
|
|
905
|
+
claim: "nonce"
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
return result;
|
|
909
|
+
}
|
|
910
|
+
const WWW_AUTHENTICATE_CHALLENGE = "OAUTH_WWW_AUTHENTICATE_CHALLENGE";
|
|
911
|
+
const RESPONSE_BODY_ERROR = "OAUTH_RESPONSE_BODY_ERROR";
|
|
912
|
+
const UNSUPPORTED_OPERATION = "OAUTH_UNSUPPORTED_OPERATION";
|
|
913
|
+
const AUTHORIZATION_RESPONSE_ERROR = "OAUTH_AUTHORIZATION_RESPONSE_ERROR";
|
|
914
|
+
const PARSE_ERROR = "OAUTH_PARSE_ERROR";
|
|
915
|
+
const INVALID_RESPONSE = "OAUTH_INVALID_RESPONSE";
|
|
916
|
+
const RESPONSE_IS_NOT_JSON = "OAUTH_RESPONSE_IS_NOT_JSON";
|
|
917
|
+
const RESPONSE_IS_NOT_CONFORM = "OAUTH_RESPONSE_IS_NOT_CONFORM";
|
|
918
|
+
const HTTP_REQUEST_FORBIDDEN = "OAUTH_HTTP_REQUEST_FORBIDDEN";
|
|
919
|
+
const REQUEST_PROTOCOL_FORBIDDEN = "OAUTH_REQUEST_PROTOCOL_FORBIDDEN";
|
|
920
|
+
const JWT_TIMESTAMP_CHECK = "OAUTH_JWT_TIMESTAMP_CHECK_FAILED";
|
|
921
|
+
const JWT_CLAIM_COMPARISON = "OAUTH_JWT_CLAIM_COMPARISON_FAILED";
|
|
922
|
+
const JSON_ATTRIBUTE_COMPARISON = "OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED";
|
|
923
|
+
const MISSING_SERVER_METADATA = "OAUTH_MISSING_SERVER_METADATA";
|
|
924
|
+
const INVALID_SERVER_METADATA = "OAUTH_INVALID_SERVER_METADATA";
|
|
925
|
+
async function genericTokenEndpointRequest(as, client, clientAuthentication, grantType, parameters, options) {
|
|
926
|
+
assertAs(as);
|
|
927
|
+
assertClient(client);
|
|
928
|
+
assertString(grantType, '"grantType"');
|
|
929
|
+
return tokenEndpointRequest(as, client, clientAuthentication, grantType, new URLSearchParams(parameters), options);
|
|
930
|
+
}
|
|
931
|
+
async function processGenericTokenEndpointResponse(as, client, response, options) {
|
|
932
|
+
return processGenericAccessTokenResponse(as, client, response, void 0, options);
|
|
933
|
+
}
|
|
934
|
+
function assertReadableResponse(response) {
|
|
935
|
+
if (response.bodyUsed) {
|
|
936
|
+
throw CodedTypeError('"response" body has been used already', ERR_INVALID_ARG_VALUE);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
function checkRsaKeyAlgorithm(key) {
|
|
940
|
+
const { algorithm } = key;
|
|
941
|
+
if (typeof algorithm.modulusLength !== "number" || algorithm.modulusLength < 2048) {
|
|
942
|
+
throw new UnsupportedOperationError(`unsupported ${algorithm.name} modulusLength`, {
|
|
943
|
+
cause: key
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
function ecdsaHashName(key) {
|
|
948
|
+
const { algorithm } = key;
|
|
949
|
+
switch (algorithm.namedCurve) {
|
|
950
|
+
case "P-256":
|
|
951
|
+
return "SHA-256";
|
|
952
|
+
case "P-384":
|
|
953
|
+
return "SHA-384";
|
|
954
|
+
case "P-521":
|
|
955
|
+
return "SHA-512";
|
|
956
|
+
default:
|
|
957
|
+
throw new UnsupportedOperationError("unsupported ECDSA namedCurve", { cause: key });
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
function keyToSubtle(key) {
|
|
961
|
+
switch (key.algorithm.name) {
|
|
962
|
+
case "ECDSA":
|
|
963
|
+
return {
|
|
964
|
+
name: key.algorithm.name,
|
|
965
|
+
hash: ecdsaHashName(key)
|
|
966
|
+
};
|
|
967
|
+
case "RSA-PSS": {
|
|
968
|
+
checkRsaKeyAlgorithm(key);
|
|
969
|
+
switch (key.algorithm.hash.name) {
|
|
970
|
+
case "SHA-256":
|
|
971
|
+
case "SHA-384":
|
|
972
|
+
case "SHA-512":
|
|
973
|
+
return {
|
|
974
|
+
name: key.algorithm.name,
|
|
975
|
+
saltLength: parseInt(key.algorithm.hash.name.slice(-3), 10) >> 3
|
|
976
|
+
};
|
|
977
|
+
default:
|
|
978
|
+
throw new UnsupportedOperationError("unsupported RSA-PSS hash name", { cause: key });
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
case "RSASSA-PKCS1-v1_5":
|
|
982
|
+
checkRsaKeyAlgorithm(key);
|
|
983
|
+
return key.algorithm.name;
|
|
984
|
+
case "Ed25519":
|
|
985
|
+
return key.algorithm.name;
|
|
986
|
+
}
|
|
987
|
+
throw new UnsupportedOperationError("unsupported CryptoKey algorithm name", { cause: key });
|
|
988
|
+
}
|
|
989
|
+
async function validateJwt(jws, checkAlg, clockSkew2, clockTolerance2, decryptJwt) {
|
|
990
|
+
let { 0: protectedHeader, 1: payload, length } = jws.split(".");
|
|
991
|
+
if (length === 5) {
|
|
992
|
+
if (decryptJwt !== void 0) {
|
|
993
|
+
jws = await decryptJwt(jws);
|
|
994
|
+
({ 0: protectedHeader, 1: payload, length } = jws.split("."));
|
|
995
|
+
} else {
|
|
996
|
+
throw new UnsupportedOperationError("JWE decryption is not configured", { cause: jws });
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
if (length !== 3) {
|
|
1000
|
+
throw OPE("Invalid JWT", INVALID_RESPONSE, jws);
|
|
1001
|
+
}
|
|
1002
|
+
let header;
|
|
1003
|
+
try {
|
|
1004
|
+
header = JSON.parse(buf(b64u(protectedHeader)));
|
|
1005
|
+
} catch (cause) {
|
|
1006
|
+
throw OPE("failed to parse JWT Header body as base64url encoded JSON", PARSE_ERROR, cause);
|
|
1007
|
+
}
|
|
1008
|
+
if (!isJsonObject(header)) {
|
|
1009
|
+
throw OPE("JWT Header must be a top level object", INVALID_RESPONSE, jws);
|
|
1010
|
+
}
|
|
1011
|
+
checkAlg(header);
|
|
1012
|
+
if (header.crit !== void 0) {
|
|
1013
|
+
throw new UnsupportedOperationError('no JWT "crit" header parameter extensions are supported', {
|
|
1014
|
+
cause: { header }
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
let claims;
|
|
1018
|
+
try {
|
|
1019
|
+
claims = JSON.parse(buf(b64u(payload)));
|
|
1020
|
+
} catch (cause) {
|
|
1021
|
+
throw OPE("failed to parse JWT Payload body as base64url encoded JSON", PARSE_ERROR, cause);
|
|
1022
|
+
}
|
|
1023
|
+
if (!isJsonObject(claims)) {
|
|
1024
|
+
throw OPE("JWT Payload must be a top level object", INVALID_RESPONSE, jws);
|
|
1025
|
+
}
|
|
1026
|
+
const now = epochTime() + clockSkew2;
|
|
1027
|
+
if (claims.exp !== void 0) {
|
|
1028
|
+
if (typeof claims.exp !== "number") {
|
|
1029
|
+
throw OPE('unexpected JWT "exp" (expiration time) claim type', INVALID_RESPONSE, { claims });
|
|
1030
|
+
}
|
|
1031
|
+
if (claims.exp <= now - clockTolerance2) {
|
|
1032
|
+
throw OPE('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp', JWT_TIMESTAMP_CHECK, { claims, now, tolerance: clockTolerance2, claim: "exp" });
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
if (claims.iat !== void 0) {
|
|
1036
|
+
if (typeof claims.iat !== "number") {
|
|
1037
|
+
throw OPE('unexpected JWT "iat" (issued at) claim type', INVALID_RESPONSE, { claims });
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
if (claims.iss !== void 0) {
|
|
1041
|
+
if (typeof claims.iss !== "string") {
|
|
1042
|
+
throw OPE('unexpected JWT "iss" (issuer) claim type', INVALID_RESPONSE, { claims });
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
if (claims.nbf !== void 0) {
|
|
1046
|
+
if (typeof claims.nbf !== "number") {
|
|
1047
|
+
throw OPE('unexpected JWT "nbf" (not before) claim type', INVALID_RESPONSE, { claims });
|
|
1048
|
+
}
|
|
1049
|
+
if (claims.nbf > now + clockTolerance2) {
|
|
1050
|
+
throw OPE('unexpected JWT "nbf" (not before) claim value', JWT_TIMESTAMP_CHECK, {
|
|
1051
|
+
claims,
|
|
1052
|
+
now,
|
|
1053
|
+
tolerance: clockTolerance2,
|
|
1054
|
+
claim: "nbf"
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
if (claims.aud !== void 0) {
|
|
1059
|
+
if (typeof claims.aud !== "string" && !Array.isArray(claims.aud)) {
|
|
1060
|
+
throw OPE('unexpected JWT "aud" (audience) claim type', INVALID_RESPONSE, { claims });
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
return { header, claims, jwt: jws };
|
|
1064
|
+
}
|
|
1065
|
+
function checkSigningAlgorithm(client, issuer, fallback, header) {
|
|
1066
|
+
if (client !== void 0) {
|
|
1067
|
+
if (typeof client === "string" ? header.alg !== client : !client.includes(header.alg)) {
|
|
1068
|
+
throw OPE('unexpected JWT "alg" header parameter', INVALID_RESPONSE, {
|
|
1069
|
+
header,
|
|
1070
|
+
expected: client,
|
|
1071
|
+
reason: "client configuration"
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
if (Array.isArray(issuer)) {
|
|
1077
|
+
if (!issuer.includes(header.alg)) {
|
|
1078
|
+
throw OPE('unexpected JWT "alg" header parameter', INVALID_RESPONSE, {
|
|
1079
|
+
header,
|
|
1080
|
+
expected: issuer,
|
|
1081
|
+
reason: "authorization server metadata"
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (fallback !== void 0) {
|
|
1087
|
+
if (typeof fallback === "string" ? header.alg !== fallback : typeof fallback === "function" ? !fallback(header.alg) : !fallback.includes(header.alg)) {
|
|
1088
|
+
throw OPE('unexpected JWT "alg" header parameter', INVALID_RESPONSE, {
|
|
1089
|
+
header,
|
|
1090
|
+
expected: fallback,
|
|
1091
|
+
reason: "default value"
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
throw OPE('missing client or server configuration to verify used JWT "alg" header parameter', void 0, { client, issuer, fallback });
|
|
1097
|
+
}
|
|
1098
|
+
function getURLSearchParameter(parameters, name) {
|
|
1099
|
+
const { 0: value, length } = parameters.getAll(name);
|
|
1100
|
+
if (length > 1) {
|
|
1101
|
+
throw OPE(`"${name}" parameter must be provided only once`, INVALID_RESPONSE);
|
|
1102
|
+
}
|
|
1103
|
+
return value;
|
|
1104
|
+
}
|
|
1105
|
+
const skipStateCheck = Symbol();
|
|
1106
|
+
const expectNoState = Symbol();
|
|
1107
|
+
function validateAuthResponse(as, client, parameters, expectedState) {
|
|
1108
|
+
assertAs(as);
|
|
1109
|
+
assertClient(client);
|
|
1110
|
+
if (parameters instanceof URL) {
|
|
1111
|
+
parameters = parameters.searchParams;
|
|
1112
|
+
}
|
|
1113
|
+
if (!(parameters instanceof URLSearchParams)) {
|
|
1114
|
+
throw CodedTypeError('"parameters" must be an instance of URLSearchParams, or URL', ERR_INVALID_ARG_TYPE);
|
|
1115
|
+
}
|
|
1116
|
+
if (getURLSearchParameter(parameters, "response")) {
|
|
1117
|
+
throw OPE('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()', INVALID_RESPONSE, { parameters });
|
|
1118
|
+
}
|
|
1119
|
+
const iss = getURLSearchParameter(parameters, "iss");
|
|
1120
|
+
const state = getURLSearchParameter(parameters, "state");
|
|
1121
|
+
if (!iss && as.authorization_response_iss_parameter_supported) {
|
|
1122
|
+
throw OPE('response parameter "iss" (issuer) missing', INVALID_RESPONSE, { parameters });
|
|
1123
|
+
}
|
|
1124
|
+
if (iss && iss !== as.issuer) {
|
|
1125
|
+
throw OPE('unexpected "iss" (issuer) response parameter value', INVALID_RESPONSE, {
|
|
1126
|
+
expected: as.issuer,
|
|
1127
|
+
parameters
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
switch (expectedState) {
|
|
1131
|
+
case void 0:
|
|
1132
|
+
case expectNoState:
|
|
1133
|
+
if (state !== void 0) {
|
|
1134
|
+
throw OPE('unexpected "state" response parameter encountered', INVALID_RESPONSE, {
|
|
1135
|
+
expected: void 0,
|
|
1136
|
+
parameters
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
break;
|
|
1140
|
+
case skipStateCheck:
|
|
1141
|
+
break;
|
|
1142
|
+
default:
|
|
1143
|
+
assertString(expectedState, '"expectedState" argument');
|
|
1144
|
+
if (state !== expectedState) {
|
|
1145
|
+
throw OPE(state === void 0 ? 'response parameter "state" missing' : 'unexpected "state" response parameter value', INVALID_RESPONSE, { expected: expectedState, parameters });
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
const error = getURLSearchParameter(parameters, "error");
|
|
1149
|
+
if (error) {
|
|
1150
|
+
throw new AuthorizationResponseError("authorization response from the server is an error", {
|
|
1151
|
+
cause: parameters
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
const id_token = getURLSearchParameter(parameters, "id_token");
|
|
1155
|
+
const token = getURLSearchParameter(parameters, "token");
|
|
1156
|
+
if (id_token !== void 0 || token !== void 0) {
|
|
1157
|
+
throw new UnsupportedOperationError("implicit and hybrid flows are not supported");
|
|
1158
|
+
}
|
|
1159
|
+
return brand(new URLSearchParams(parameters));
|
|
1160
|
+
}
|
|
1161
|
+
async function getResponseJsonBody(response, check = assertApplicationJson) {
|
|
1162
|
+
let json;
|
|
1163
|
+
try {
|
|
1164
|
+
json = await response.json();
|
|
1165
|
+
} catch (cause) {
|
|
1166
|
+
check(response);
|
|
1167
|
+
throw OPE('failed to parse "response" body as JSON', PARSE_ERROR, cause);
|
|
1168
|
+
}
|
|
1169
|
+
if (!isJsonObject(json)) {
|
|
1170
|
+
throw OPE('"response" body must be a top level object', INVALID_RESPONSE, { body: json });
|
|
1171
|
+
}
|
|
1172
|
+
return json;
|
|
1173
|
+
}
|
|
1174
|
+
const _nodiscoverycheck = Symbol();
|
|
1175
|
+
const _expectedIssuer = Symbol();
|
|
1176
|
+
export {
|
|
1177
|
+
AUTHORIZATION_RESPONSE_ERROR,
|
|
1178
|
+
AuthorizationResponseError,
|
|
1179
|
+
ClientSecretPost,
|
|
1180
|
+
HTTP_REQUEST_FORBIDDEN,
|
|
1181
|
+
INVALID_RESPONSE,
|
|
1182
|
+
INVALID_SERVER_METADATA,
|
|
1183
|
+
JSON_ATTRIBUTE_COMPARISON,
|
|
1184
|
+
JWT_CLAIM_COMPARISON,
|
|
1185
|
+
JWT_TIMESTAMP_CHECK,
|
|
1186
|
+
MISSING_SERVER_METADATA,
|
|
1187
|
+
OperationProcessingError,
|
|
1188
|
+
PARSE_ERROR,
|
|
1189
|
+
PrivateKeyJwt,
|
|
1190
|
+
REQUEST_PROTOCOL_FORBIDDEN,
|
|
1191
|
+
RESPONSE_BODY_ERROR,
|
|
1192
|
+
RESPONSE_IS_NOT_CONFORM,
|
|
1193
|
+
RESPONSE_IS_NOT_JSON,
|
|
1194
|
+
ResponseBodyError,
|
|
1195
|
+
UNSUPPORTED_OPERATION,
|
|
1196
|
+
UnsupportedOperationError,
|
|
1197
|
+
WWWAuthenticateChallengeError,
|
|
1198
|
+
WWW_AUTHENTICATE_CHALLENGE,
|
|
1199
|
+
_expectedIssuer,
|
|
1200
|
+
_nodiscoverycheck,
|
|
1201
|
+
allowInsecureRequests,
|
|
1202
|
+
authorizationCodeGrantRequest,
|
|
1203
|
+
calculatePKCECodeChallenge,
|
|
1204
|
+
checkProtocol,
|
|
1205
|
+
clockSkew,
|
|
1206
|
+
clockTolerance,
|
|
1207
|
+
customFetch,
|
|
1208
|
+
discoveryRequest,
|
|
1209
|
+
expectNoNonce,
|
|
1210
|
+
expectNoState,
|
|
1211
|
+
generateRandomCodeVerifier,
|
|
1212
|
+
generateRandomNonce,
|
|
1213
|
+
generateRandomState,
|
|
1214
|
+
genericTokenEndpointRequest,
|
|
1215
|
+
getContentType,
|
|
1216
|
+
getValidatedIdTokenClaims,
|
|
1217
|
+
jweDecrypt,
|
|
1218
|
+
nopkce,
|
|
1219
|
+
processAuthorizationCodeResponse,
|
|
1220
|
+
processDiscoveryResponse,
|
|
1221
|
+
processGenericTokenEndpointResponse,
|
|
1222
|
+
processPushedAuthorizationResponse,
|
|
1223
|
+
processRefreshTokenResponse,
|
|
1224
|
+
pushedAuthorizationRequest,
|
|
1225
|
+
refreshTokenGrantRequest,
|
|
1226
|
+
resolveEndpoint,
|
|
1227
|
+
skipAuthTimeCheck,
|
|
1228
|
+
skipStateCheck,
|
|
1229
|
+
validateAuthResponse
|
|
1230
|
+
};
|