@camstack/addon-auth 1.2.126 → 1.2.127
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/{dist-Y4IbR-lV.js → dist-CrTS14S8.js} +191 -122
- package/dist/{dist-DoUGHO_G.mjs → dist-UznM2RaH.mjs} +191 -122
- package/dist/magic-link/auth-magic-link.addon.js +3 -3
- package/dist/magic-link/auth-magic-link.addon.mjs +3 -3
- package/dist/oidc/auth-oidc.addon.js +485 -943
- package/dist/oidc/auth-oidc.addon.mjs +485 -943
- package/dist/webauthn/_stub.js +1 -1
- package/dist/webauthn/{_virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-NDvjK4u_.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-DLh4dk7u.mjs} +3 -3
- package/dist/webauthn/_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BtyGSrb1.mjs +26 -0
- package/dist/webauthn/auth-webauthn.addon.js +6 -6
- package/dist/webauthn/auth-webauthn.addon.mjs +5 -5
- package/dist/webauthn/{hostInit-DYFGWxH_.mjs → hostInit-6Xuu_16a.mjs} +3 -3
- package/dist/webauthn/remoteEntry.js +1 -1
- package/package.json +1 -1
- package/dist/webauthn/_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BV1VZzL3.mjs +0 -26
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { a as loginMethodCapability, c as BaseAddon, i as buildAddonRouteProvider, r as authProviderCapability, s as errMsg, t as addonRoutesCapability } from "../dist-
|
|
1
|
+
import { a as loginMethodCapability, c as BaseAddon, i as buildAddonRouteProvider, r as authProviderCapability, s as errMsg, t as addonRoutesCapability } from "../dist-UznM2RaH.mjs";
|
|
2
2
|
import * as crypto$1 from "node:crypto";
|
|
3
|
-
//#region node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
4
|
-
var encoder = new TextEncoder();
|
|
5
|
-
var decoder = new TextDecoder();
|
|
3
|
+
//#region ../../node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
4
|
+
var encoder = new TextEncoder(), decoder = new TextDecoder(), strictDecoder = new TextDecoder("utf-8", { fatal: !0 });
|
|
6
5
|
function concat(...buffers) {
|
|
7
|
-
const size = buffers.reduce((acc, { length }) => acc + length, 0);
|
|
8
|
-
const buf = new Uint8Array(size);
|
|
6
|
+
const size = buffers.reduce((acc, { length }) => acc + length, 0), buf = new Uint8Array(size);
|
|
9
7
|
let i = 0;
|
|
10
|
-
for (const buffer of buffers)
|
|
11
|
-
buf.set(buffer, i);
|
|
12
|
-
i += buffer.length;
|
|
13
|
-
}
|
|
8
|
+
for (const buffer of buffers) buf.set(buffer, i), i += buffer.length;
|
|
14
9
|
return buf;
|
|
15
10
|
}
|
|
11
|
+
var NON_ASCII = /[^\x00-\x7f]/;
|
|
16
12
|
function encode(string) {
|
|
13
|
+
if (typeof string == "string" && string.length >= 128) {
|
|
14
|
+
if (NON_ASCII.test(string)) throw new TypeError("non-ASCII string encountered in encode()");
|
|
15
|
+
return encoder.encode(string);
|
|
16
|
+
}
|
|
17
17
|
const bytes = new Uint8Array(string.length);
|
|
18
18
|
for (let i = 0; i < string.length; i++) {
|
|
19
19
|
const code = string.charCodeAt(i);
|
|
@@ -22,117 +22,23 @@ function encode(string) {
|
|
|
22
22
|
}
|
|
23
23
|
return bytes;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
function decodeBase64(encoded, url = !1) {
|
|
26
|
+
if (Uint8Array.fromBase64) return Uint8Array.fromBase64(encoded, { alphabet: url ? "base64url" : "base64" });
|
|
27
|
+
if (url) {
|
|
28
|
+
if (encoded.includes("+") || encoded.includes("/")) throw new TypeError("Invalid base64url");
|
|
29
|
+
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
30
|
+
}
|
|
31
|
+
const binary = atob(encoded), bytes = new Uint8Array(binary.length);
|
|
31
32
|
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
32
33
|
return bytes;
|
|
33
34
|
}
|
|
34
35
|
//#endregion
|
|
35
|
-
//#region node_modules/jose/dist/webapi/util/
|
|
36
|
-
function decode(input) {
|
|
37
|
-
if (Uint8Array.fromBase64) return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), { alphabet: "base64url" });
|
|
38
|
-
let encoded = input;
|
|
39
|
-
if (encoded instanceof Uint8Array) encoded = decoder.decode(encoded);
|
|
40
|
-
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
41
|
-
try {
|
|
42
|
-
return decodeBase64(encoded);
|
|
43
|
-
} catch {
|
|
44
|
-
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
49
|
-
var unusable = (name, prop = "algorithm.name") => /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
50
|
-
var isAlgorithm = (algorithm, name) => algorithm.name === name;
|
|
51
|
-
function getHashLength(hash) {
|
|
52
|
-
return parseInt(hash.name.slice(4), 10);
|
|
53
|
-
}
|
|
54
|
-
function checkHashLength(algorithm, expected) {
|
|
55
|
-
if (getHashLength(algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
56
|
-
}
|
|
57
|
-
function getNamedCurve(alg) {
|
|
58
|
-
switch (alg) {
|
|
59
|
-
case "ES256": return "P-256";
|
|
60
|
-
case "ES384": return "P-384";
|
|
61
|
-
case "ES512": return "P-521";
|
|
62
|
-
default: throw new Error("unreachable");
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function checkUsage(key, usage) {
|
|
66
|
-
if (usage && !key.usages.includes(usage)) throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
67
|
-
}
|
|
68
|
-
function checkSigCryptoKey(key, alg, usage) {
|
|
69
|
-
switch (alg) {
|
|
70
|
-
case "HS256":
|
|
71
|
-
case "HS384":
|
|
72
|
-
case "HS512":
|
|
73
|
-
if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
|
|
74
|
-
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
75
|
-
break;
|
|
76
|
-
case "RS256":
|
|
77
|
-
case "RS384":
|
|
78
|
-
case "RS512":
|
|
79
|
-
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
|
|
80
|
-
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
81
|
-
break;
|
|
82
|
-
case "PS256":
|
|
83
|
-
case "PS384":
|
|
84
|
-
case "PS512":
|
|
85
|
-
if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
|
|
86
|
-
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
87
|
-
break;
|
|
88
|
-
case "Ed25519":
|
|
89
|
-
case "EdDSA":
|
|
90
|
-
if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
|
|
91
|
-
break;
|
|
92
|
-
case "ML-DSA-44":
|
|
93
|
-
case "ML-DSA-65":
|
|
94
|
-
case "ML-DSA-87":
|
|
95
|
-
if (!isAlgorithm(key.algorithm, alg)) throw unusable(alg);
|
|
96
|
-
break;
|
|
97
|
-
case "ES256":
|
|
98
|
-
case "ES384":
|
|
99
|
-
case "ES512": {
|
|
100
|
-
if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
|
|
101
|
-
const expected = getNamedCurve(alg);
|
|
102
|
-
if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
default: throw new TypeError("CryptoKey does not support this operation");
|
|
106
|
-
}
|
|
107
|
-
checkUsage(key, usage);
|
|
108
|
-
}
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
111
|
-
function message(msg, actual, ...types) {
|
|
112
|
-
types = types.filter(Boolean);
|
|
113
|
-
if (types.length > 2) {
|
|
114
|
-
const last = types.pop();
|
|
115
|
-
msg += `one of type ${types.join(", ")}, or ${last}.`;
|
|
116
|
-
} else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
|
|
117
|
-
else msg += `of type ${types[0]}.`;
|
|
118
|
-
if (actual == null) msg += ` Received ${actual}`;
|
|
119
|
-
else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
|
|
120
|
-
else if (typeof actual === "object" && actual != null) {
|
|
121
|
-
if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
|
|
122
|
-
}
|
|
123
|
-
return msg;
|
|
124
|
-
}
|
|
125
|
-
var invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types);
|
|
126
|
-
var withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region node_modules/jose/dist/webapi/util/errors.js
|
|
36
|
+
//#region ../../node_modules/jose/dist/webapi/util/errors.js
|
|
129
37
|
var JOSEError = class extends Error {
|
|
130
38
|
static code = "ERR_JOSE_GENERIC";
|
|
131
39
|
code = "ERR_JOSE_GENERIC";
|
|
132
40
|
constructor(message, options) {
|
|
133
|
-
super(message, options);
|
|
134
|
-
this.name = this.constructor.name;
|
|
135
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
41
|
+
super(message, options), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
|
|
136
42
|
}
|
|
137
43
|
};
|
|
138
44
|
var JWTClaimValidationFailed = class extends JOSEError {
|
|
@@ -146,10 +52,7 @@ var JWTClaimValidationFailed = class extends JOSEError {
|
|
|
146
52
|
claim,
|
|
147
53
|
reason,
|
|
148
54
|
payload
|
|
149
|
-
} });
|
|
150
|
-
this.claim = claim;
|
|
151
|
-
this.reason = reason;
|
|
152
|
-
this.payload = payload;
|
|
55
|
+
} }), this.claim = claim, this.reason = reason, this.payload = payload;
|
|
153
56
|
}
|
|
154
57
|
};
|
|
155
58
|
var JWTExpired = class extends JOSEError {
|
|
@@ -163,10 +66,7 @@ var JWTExpired = class extends JOSEError {
|
|
|
163
66
|
claim,
|
|
164
67
|
reason,
|
|
165
68
|
payload
|
|
166
|
-
} });
|
|
167
|
-
this.claim = claim;
|
|
168
|
-
this.reason = reason;
|
|
169
|
-
this.payload = payload;
|
|
69
|
+
} }), this.claim = claim, this.reason = reason, this.payload = payload;
|
|
170
70
|
}
|
|
171
71
|
};
|
|
172
72
|
var JOSEAlgNotAllowed = class extends JOSEError {
|
|
@@ -197,7 +97,7 @@ var JWKSNoMatchingKey = class extends JOSEError {
|
|
|
197
97
|
}
|
|
198
98
|
};
|
|
199
99
|
var JWKSMultipleMatchingKeys = class extends JOSEError {
|
|
200
|
-
[Symbol.asyncIterator];
|
|
100
|
+
[Symbol.asyncIterator] = async function* () {};
|
|
201
101
|
static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
202
102
|
code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
203
103
|
constructor(message = "multiple matching keys found in the JSON Web Key Set", options) {
|
|
@@ -219,810 +119,504 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
|
|
|
219
119
|
}
|
|
220
120
|
};
|
|
221
121
|
//#endregion
|
|
222
|
-
//#region node_modules/jose/dist/webapi/
|
|
223
|
-
var
|
|
224
|
-
|
|
225
|
-
try {
|
|
226
|
-
return key instanceof CryptoKey;
|
|
227
|
-
} catch {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
var isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
|
|
232
|
-
var isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region node_modules/jose/dist/webapi/lib/helpers.js
|
|
235
|
-
function decodeBase64url(value, label, ErrorClass) {
|
|
122
|
+
//#region ../../node_modules/jose/dist/webapi/util/base64url.js
|
|
123
|
+
var invalid = "The input to be decoded is not correctly encoded.";
|
|
124
|
+
function decode(input) {
|
|
236
125
|
try {
|
|
237
|
-
return decode(
|
|
238
|
-
} catch {
|
|
239
|
-
throw new
|
|
126
|
+
return decodeBase64(typeof input == "string" ? input : decoder.decode(input), !0);
|
|
127
|
+
} catch (cause) {
|
|
128
|
+
throw new TypeError(invalid, { cause });
|
|
240
129
|
}
|
|
241
130
|
}
|
|
242
131
|
//#endregion
|
|
243
|
-
//#region node_modules/jose/dist/webapi/lib/
|
|
244
|
-
var isObjectLike = (value) => typeof value === "object" && value !== null;
|
|
132
|
+
//#region ../../node_modules/jose/dist/webapi/lib/validate.js
|
|
245
133
|
function isObject(input) {
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
250
|
-
return Object.getPrototypeOf(input) === proto;
|
|
251
|
-
}
|
|
252
|
-
function isDisjoint(...headers) {
|
|
253
|
-
const sources = headers.filter(Boolean);
|
|
254
|
-
if (sources.length === 0 || sources.length === 1) return true;
|
|
255
|
-
let acc;
|
|
256
|
-
for (const header of sources) {
|
|
257
|
-
const parameters = Object.keys(header);
|
|
258
|
-
if (!acc || acc.size === 0) {
|
|
259
|
-
acc = new Set(parameters);
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
for (const parameter of parameters) {
|
|
263
|
-
if (acc.has(parameter)) return false;
|
|
264
|
-
acc.add(parameter);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return true;
|
|
134
|
+
if (typeof input != "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]") return !1;
|
|
135
|
+
const prototype = Object.getPrototypeOf(input);
|
|
136
|
+
return prototype === null || Object.getPrototypeOf(prototype) === null;
|
|
268
137
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
var isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
|
|
272
|
-
var isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region node_modules/jose/dist/webapi/lib/signing.js
|
|
275
|
-
function checkKeyLength(alg, key) {
|
|
276
|
-
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
277
|
-
const { modulusLength } = key.algorithm;
|
|
278
|
-
if (typeof modulusLength !== "number" || modulusLength < 2048) throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
279
|
-
}
|
|
138
|
+
function isJwkSet(input) {
|
|
139
|
+
return isObject(input) && Array.isArray(input.keys) && Array.from(input.keys).every(isObject);
|
|
280
140
|
}
|
|
281
|
-
function
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
case "HS512": return {
|
|
287
|
-
hash,
|
|
288
|
-
name: "HMAC"
|
|
289
|
-
};
|
|
290
|
-
case "PS256":
|
|
291
|
-
case "PS384":
|
|
292
|
-
case "PS512": return {
|
|
293
|
-
hash,
|
|
294
|
-
name: "RSA-PSS",
|
|
295
|
-
saltLength: parseInt(alg.slice(-3), 10) >> 3
|
|
296
|
-
};
|
|
297
|
-
case "RS256":
|
|
298
|
-
case "RS384":
|
|
299
|
-
case "RS512": return {
|
|
300
|
-
hash,
|
|
301
|
-
name: "RSASSA-PKCS1-v1_5"
|
|
302
|
-
};
|
|
303
|
-
case "ES256":
|
|
304
|
-
case "ES384":
|
|
305
|
-
case "ES512": return {
|
|
306
|
-
hash,
|
|
307
|
-
name: "ECDSA",
|
|
308
|
-
namedCurve: algorithm.namedCurve
|
|
309
|
-
};
|
|
310
|
-
case "Ed25519":
|
|
311
|
-
case "EdDSA": return { name: "Ed25519" };
|
|
312
|
-
case "ML-DSA-44":
|
|
313
|
-
case "ML-DSA-65":
|
|
314
|
-
case "ML-DSA-87": return { name: alg };
|
|
315
|
-
default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
141
|
+
function isDisjoint(...headers) {
|
|
142
|
+
const parameters = /* @__PURE__ */ new Set();
|
|
143
|
+
for (const header of headers) if (header) for (const parameter of Object.keys(header)) {
|
|
144
|
+
if (parameters.has(parameter)) return !1;
|
|
145
|
+
parameters.add(parameter);
|
|
316
146
|
}
|
|
147
|
+
return !0;
|
|
317
148
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
name: "HMAC"
|
|
324
|
-
}, false, [usage]);
|
|
149
|
+
function decodeBase64url(value, label, ErrorClass) {
|
|
150
|
+
try {
|
|
151
|
+
return decode(value);
|
|
152
|
+
} catch {
|
|
153
|
+
throw new ErrorClass(`Failed to base64url decode the ${label}`);
|
|
325
154
|
}
|
|
326
|
-
checkSigCryptoKey(key, alg, usage);
|
|
327
|
-
return key;
|
|
328
155
|
}
|
|
329
|
-
|
|
330
|
-
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
331
|
-
checkKeyLength(alg, cryptoKey);
|
|
332
|
-
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
156
|
+
function encodeBase64url(value, label, ErrorClass) {
|
|
333
157
|
try {
|
|
334
|
-
return
|
|
158
|
+
return encode(value);
|
|
335
159
|
} catch {
|
|
336
|
-
|
|
160
|
+
throw new ErrorClass(`The ${label} is not a valid base64url string`);
|
|
337
161
|
}
|
|
338
162
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
switch (jwk.kty) {
|
|
346
|
-
case "AKP":
|
|
347
|
-
switch (jwk.alg) {
|
|
348
|
-
case "ML-DSA-44":
|
|
349
|
-
case "ML-DSA-65":
|
|
350
|
-
case "ML-DSA-87":
|
|
351
|
-
algorithm = { name: jwk.alg };
|
|
352
|
-
keyUsages = jwk.priv ? ["sign"] : ["verify"];
|
|
353
|
-
break;
|
|
354
|
-
default: throw new JOSENotSupported(unsupportedAlg);
|
|
355
|
-
}
|
|
356
|
-
break;
|
|
357
|
-
case "RSA":
|
|
358
|
-
switch (jwk.alg) {
|
|
359
|
-
case "PS256":
|
|
360
|
-
case "PS384":
|
|
361
|
-
case "PS512":
|
|
362
|
-
algorithm = {
|
|
363
|
-
name: "RSA-PSS",
|
|
364
|
-
hash: `SHA-${jwk.alg.slice(-3)}`
|
|
365
|
-
};
|
|
366
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
367
|
-
break;
|
|
368
|
-
case "RS256":
|
|
369
|
-
case "RS384":
|
|
370
|
-
case "RS512":
|
|
371
|
-
algorithm = {
|
|
372
|
-
name: "RSASSA-PKCS1-v1_5",
|
|
373
|
-
hash: `SHA-${jwk.alg.slice(-3)}`
|
|
374
|
-
};
|
|
375
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
376
|
-
break;
|
|
377
|
-
case "RSA-OAEP":
|
|
378
|
-
case "RSA-OAEP-256":
|
|
379
|
-
case "RSA-OAEP-384":
|
|
380
|
-
case "RSA-OAEP-512":
|
|
381
|
-
algorithm = {
|
|
382
|
-
name: "RSA-OAEP",
|
|
383
|
-
hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
|
|
384
|
-
};
|
|
385
|
-
keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
386
|
-
break;
|
|
387
|
-
default: throw new JOSENotSupported(unsupportedAlg);
|
|
388
|
-
}
|
|
389
|
-
break;
|
|
390
|
-
case "EC":
|
|
391
|
-
switch (jwk.alg) {
|
|
392
|
-
case "ES256":
|
|
393
|
-
case "ES384":
|
|
394
|
-
case "ES512":
|
|
395
|
-
algorithm = {
|
|
396
|
-
name: "ECDSA",
|
|
397
|
-
namedCurve: {
|
|
398
|
-
ES256: "P-256",
|
|
399
|
-
ES384: "P-384",
|
|
400
|
-
ES512: "P-521"
|
|
401
|
-
}[jwk.alg]
|
|
402
|
-
};
|
|
403
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
404
|
-
break;
|
|
405
|
-
case "ECDH-ES":
|
|
406
|
-
case "ECDH-ES+A128KW":
|
|
407
|
-
case "ECDH-ES+A192KW":
|
|
408
|
-
case "ECDH-ES+A256KW":
|
|
409
|
-
algorithm = {
|
|
410
|
-
name: "ECDH",
|
|
411
|
-
namedCurve: jwk.crv
|
|
412
|
-
};
|
|
413
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
414
|
-
break;
|
|
415
|
-
default: throw new JOSENotSupported(unsupportedAlg);
|
|
416
|
-
}
|
|
417
|
-
break;
|
|
418
|
-
case "OKP":
|
|
419
|
-
switch (jwk.alg) {
|
|
420
|
-
case "Ed25519":
|
|
421
|
-
case "EdDSA":
|
|
422
|
-
algorithm = { name: "Ed25519" };
|
|
423
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
424
|
-
break;
|
|
425
|
-
case "ECDH-ES":
|
|
426
|
-
case "ECDH-ES+A128KW":
|
|
427
|
-
case "ECDH-ES+A192KW":
|
|
428
|
-
case "ECDH-ES+A256KW":
|
|
429
|
-
algorithm = { name: jwk.crv };
|
|
430
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
431
|
-
break;
|
|
432
|
-
default: throw new JOSENotSupported(unsupportedAlg);
|
|
433
|
-
}
|
|
434
|
-
break;
|
|
435
|
-
default: throw new JOSENotSupported("Invalid or unsupported JWK \"kty\" (Key Type) Parameter value");
|
|
163
|
+
function parseJoseHeader(b64, ErrorClass, message) {
|
|
164
|
+
let parsed;
|
|
165
|
+
try {
|
|
166
|
+
parsed = JSON.parse(strictDecoder.decode(decode(b64)));
|
|
167
|
+
} catch {
|
|
168
|
+
throw new ErrorClass(message);
|
|
436
169
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
keyUsages
|
|
440
|
-
};
|
|
170
|
+
if (!isObject(parsed)) throw new ErrorClass(message);
|
|
171
|
+
return parsed;
|
|
441
172
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
const keyData = { ...jwk };
|
|
446
|
-
if (keyData.kty !== "AKP") delete keyData.alg;
|
|
447
|
-
delete keyData.use;
|
|
448
|
-
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
449
|
-
}
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region node_modules/jose/dist/webapi/lib/normalize_key.js
|
|
452
|
-
var unusableForAlg = "given KeyObject instance cannot be used for this algorithm";
|
|
453
|
-
var cache;
|
|
454
|
-
var handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
455
|
-
cache ||= /* @__PURE__ */ new WeakMap();
|
|
456
|
-
let cached = cache.get(key);
|
|
457
|
-
if (cached?.[alg]) return cached[alg];
|
|
458
|
-
const cryptoKey = await jwkToKey({
|
|
459
|
-
...jwk,
|
|
460
|
-
alg
|
|
461
|
-
});
|
|
462
|
-
if (freeze) Object.freeze(key);
|
|
463
|
-
if (!cached) cache.set(key, { [alg]: cryptoKey });
|
|
464
|
-
else cached[alg] = cryptoKey;
|
|
465
|
-
return cryptoKey;
|
|
466
|
-
};
|
|
467
|
-
var handleKeyObject = (keyObject, alg) => {
|
|
468
|
-
cache ||= /* @__PURE__ */ new WeakMap();
|
|
469
|
-
let cached = cache.get(keyObject);
|
|
470
|
-
if (cached?.[alg]) return cached[alg];
|
|
471
|
-
const isPublic = keyObject.type === "public";
|
|
472
|
-
const extractable = isPublic ? true : false;
|
|
473
|
-
let cryptoKey;
|
|
474
|
-
if (keyObject.asymmetricKeyType === "x25519") {
|
|
475
|
-
switch (alg) {
|
|
476
|
-
case "ECDH-ES":
|
|
477
|
-
case "ECDH-ES+A128KW":
|
|
478
|
-
case "ECDH-ES+A192KW":
|
|
479
|
-
case "ECDH-ES+A256KW": break;
|
|
480
|
-
default: throw new TypeError(unusableForAlg);
|
|
481
|
-
}
|
|
482
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
|
|
483
|
-
}
|
|
484
|
-
if (keyObject.asymmetricKeyType === "ed25519") {
|
|
485
|
-
if (alg !== "EdDSA" && alg !== "Ed25519") throw new TypeError(unusableForAlg);
|
|
486
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [isPublic ? "verify" : "sign"]);
|
|
487
|
-
}
|
|
488
|
-
switch (keyObject.asymmetricKeyType) {
|
|
489
|
-
case "ml-dsa-44":
|
|
490
|
-
case "ml-dsa-65":
|
|
491
|
-
case "ml-dsa-87":
|
|
492
|
-
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) throw new TypeError(unusableForAlg);
|
|
493
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [isPublic ? "verify" : "sign"]);
|
|
494
|
-
}
|
|
495
|
-
if (keyObject.asymmetricKeyType === "rsa") {
|
|
496
|
-
let hash;
|
|
497
|
-
switch (alg) {
|
|
498
|
-
case "RSA-OAEP":
|
|
499
|
-
hash = "SHA-1";
|
|
500
|
-
break;
|
|
501
|
-
case "RS256":
|
|
502
|
-
case "PS256":
|
|
503
|
-
case "RSA-OAEP-256":
|
|
504
|
-
hash = "SHA-256";
|
|
505
|
-
break;
|
|
506
|
-
case "RS384":
|
|
507
|
-
case "PS384":
|
|
508
|
-
case "RSA-OAEP-384":
|
|
509
|
-
hash = "SHA-384";
|
|
510
|
-
break;
|
|
511
|
-
case "RS512":
|
|
512
|
-
case "PS512":
|
|
513
|
-
case "RSA-OAEP-512":
|
|
514
|
-
hash = "SHA-512";
|
|
515
|
-
break;
|
|
516
|
-
default: throw new TypeError(unusableForAlg);
|
|
517
|
-
}
|
|
518
|
-
if (alg.startsWith("RSA-OAEP")) return keyObject.toCryptoKey({
|
|
519
|
-
name: "RSA-OAEP",
|
|
520
|
-
hash
|
|
521
|
-
}, extractable, isPublic ? ["encrypt"] : ["decrypt"]);
|
|
522
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
523
|
-
name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
524
|
-
hash
|
|
525
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
526
|
-
}
|
|
527
|
-
if (keyObject.asymmetricKeyType === "ec") {
|
|
528
|
-
const namedCurve = new Map([
|
|
529
|
-
["prime256v1", "P-256"],
|
|
530
|
-
["secp384r1", "P-384"],
|
|
531
|
-
["secp521r1", "P-521"]
|
|
532
|
-
]).get(keyObject.asymmetricKeyDetails?.namedCurve);
|
|
533
|
-
if (!namedCurve) throw new TypeError(unusableForAlg);
|
|
534
|
-
const expectedCurve = {
|
|
535
|
-
ES256: "P-256",
|
|
536
|
-
ES384: "P-384",
|
|
537
|
-
ES512: "P-521"
|
|
538
|
-
};
|
|
539
|
-
if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) cryptoKey = keyObject.toCryptoKey({
|
|
540
|
-
name: "ECDSA",
|
|
541
|
-
namedCurve
|
|
542
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
543
|
-
if (alg.startsWith("ECDH-ES")) cryptoKey = keyObject.toCryptoKey({
|
|
544
|
-
name: "ECDH",
|
|
545
|
-
namedCurve
|
|
546
|
-
}, extractable, isPublic ? [] : ["deriveBits"]);
|
|
547
|
-
}
|
|
548
|
-
if (!cryptoKey) throw new TypeError(unusableForAlg);
|
|
549
|
-
if (!cached) cache.set(keyObject, { [alg]: cryptoKey });
|
|
550
|
-
else cached[alg] = cryptoKey;
|
|
551
|
-
return cryptoKey;
|
|
173
|
+
var JWS_RECOGNIZED = {
|
|
174
|
+
__proto__: null,
|
|
175
|
+
b64: !0
|
|
552
176
|
};
|
|
553
|
-
|
|
554
|
-
if (
|
|
555
|
-
|
|
556
|
-
if (isKeyObject(key)) {
|
|
557
|
-
if (key.type === "secret") return key.export();
|
|
558
|
-
if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") try {
|
|
559
|
-
return handleKeyObject(key, alg);
|
|
560
|
-
} catch (err) {
|
|
561
|
-
if (err instanceof TypeError) throw err;
|
|
562
|
-
}
|
|
563
|
-
return handleJWK(key, key.export({ format: "jwk" }), alg);
|
|
564
|
-
}
|
|
565
|
-
if (isJWK(key)) {
|
|
566
|
-
if (key.k) return decode(key.k);
|
|
567
|
-
return handleJWK(key, key, alg, true);
|
|
568
|
-
}
|
|
569
|
-
throw new Error("unreachable");
|
|
570
|
-
}
|
|
571
|
-
//#endregion
|
|
572
|
-
//#region node_modules/jose/dist/webapi/key/import.js
|
|
573
|
-
async function importJWK(jwk, alg, options) {
|
|
574
|
-
if (!isObject(jwk)) throw new TypeError("JWK must be an object");
|
|
575
|
-
let ext;
|
|
576
|
-
alg ??= jwk.alg;
|
|
577
|
-
ext ??= options?.extractable ?? jwk.ext;
|
|
578
|
-
switch (jwk.kty) {
|
|
579
|
-
case "oct":
|
|
580
|
-
if (typeof jwk.k !== "string" || !jwk.k) throw new TypeError("missing \"k\" (Key Value) Parameter value");
|
|
581
|
-
return decode(jwk.k);
|
|
582
|
-
case "RSA":
|
|
583
|
-
if ("oth" in jwk && jwk.oth !== void 0) throw new JOSENotSupported("RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported");
|
|
584
|
-
return jwkToKey({
|
|
585
|
-
...jwk,
|
|
586
|
-
alg,
|
|
587
|
-
ext
|
|
588
|
-
});
|
|
589
|
-
case "AKP":
|
|
590
|
-
if (typeof jwk.alg !== "string" || !jwk.alg) throw new TypeError("missing \"alg\" (Algorithm) Parameter value");
|
|
591
|
-
if (alg !== void 0 && alg !== jwk.alg) throw new TypeError("JWK alg and alg option value mismatch");
|
|
592
|
-
return jwkToKey({
|
|
593
|
-
...jwk,
|
|
594
|
-
ext
|
|
595
|
-
});
|
|
596
|
-
case "EC":
|
|
597
|
-
case "OKP": return jwkToKey({
|
|
598
|
-
...jwk,
|
|
599
|
-
alg,
|
|
600
|
-
ext
|
|
601
|
-
});
|
|
602
|
-
default: throw new JOSENotSupported("Unsupported \"kty\" (Key Type) Parameter value");
|
|
603
|
-
}
|
|
177
|
+
function validateAlgorithms(option, algorithms) {
|
|
178
|
+
if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s != "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
|
|
179
|
+
return algorithms === void 0 ? void 0 : new Set(algorithms);
|
|
604
180
|
}
|
|
605
|
-
//#endregion
|
|
606
|
-
//#region node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
607
181
|
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
608
182
|
if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
|
|
609
|
-
if (!protectedHeader || protectedHeader.crit === void 0) return
|
|
610
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
183
|
+
if (!protectedHeader || protectedHeader.crit === void 0) return [];
|
|
184
|
+
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input != "string" || input.length === 0)) throw new Err("\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present");
|
|
185
|
+
const recognized = recognizedOption === void 0 ? recognizedDefault : {
|
|
186
|
+
__proto__: null,
|
|
187
|
+
...recognizedOption,
|
|
188
|
+
...recognizedDefault
|
|
189
|
+
};
|
|
614
190
|
for (const parameter of protectedHeader.crit) {
|
|
615
|
-
if (!
|
|
616
|
-
if (joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
617
|
-
if (recognized.
|
|
191
|
+
if (!(parameter in recognized)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
192
|
+
if (!Object.hasOwn(joseHeader, parameter) || joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
193
|
+
if (recognized[parameter] && (!Object.hasOwn(protectedHeader, parameter) || protectedHeader[parameter] === void 0)) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
618
194
|
}
|
|
619
|
-
return
|
|
195
|
+
return protectedHeader.crit;
|
|
620
196
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
197
|
+
function validateB64(protectedHeader, extensions) {
|
|
198
|
+
if (extensions.includes("b64")) {
|
|
199
|
+
const b64 = protectedHeader.b64;
|
|
200
|
+
if (typeof b64 != "boolean") throw new JWSInvalid("The \"b64\" (base64url-encode payload) Header Parameter must be a boolean");
|
|
201
|
+
return b64;
|
|
202
|
+
}
|
|
203
|
+
return !0;
|
|
627
204
|
}
|
|
628
205
|
//#endregion
|
|
629
|
-
//#region node_modules/jose/dist/webapi/lib/
|
|
630
|
-
var tag = (key) => key
|
|
631
|
-
|
|
206
|
+
//#region ../../node_modules/jose/dist/webapi/lib/key.js
|
|
207
|
+
var tag = (key) => key[Symbol.toStringTag], jwkMatchesOp = (entry, key, usage) => {
|
|
208
|
+
const { alg } = entry;
|
|
632
209
|
if (key.use !== void 0) {
|
|
633
|
-
|
|
634
|
-
switch (usage) {
|
|
635
|
-
case "sign":
|
|
636
|
-
case "verify":
|
|
637
|
-
expected = "sig";
|
|
638
|
-
break;
|
|
639
|
-
case "encrypt":
|
|
640
|
-
case "decrypt":
|
|
641
|
-
expected = "enc";
|
|
642
|
-
break;
|
|
643
|
-
}
|
|
210
|
+
const expected = usage === "sign" || usage === "verify" ? "sig" : "enc";
|
|
644
211
|
if (key.use !== expected) throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
|
|
645
212
|
}
|
|
646
213
|
if (key.alg !== void 0 && key.alg !== alg) throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
|
|
647
214
|
if (Array.isArray(key.key_ops)) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
case usage === "sign" || usage === "verify":
|
|
651
|
-
case alg === "dir":
|
|
652
|
-
case alg.includes("CBC-HS"):
|
|
653
|
-
expectedKeyOp = usage;
|
|
654
|
-
break;
|
|
655
|
-
case alg.startsWith("PBES2"):
|
|
656
|
-
expectedKeyOp = "deriveBits";
|
|
657
|
-
break;
|
|
658
|
-
case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
|
|
659
|
-
if (!alg.includes("GCM") && alg.endsWith("KW")) expectedKeyOp = usage === "encrypt" ? "wrapKey" : "unwrapKey";
|
|
660
|
-
else expectedKeyOp = usage;
|
|
661
|
-
break;
|
|
662
|
-
case usage === "encrypt" && alg.startsWith("RSA"):
|
|
663
|
-
expectedKeyOp = "wrapKey";
|
|
664
|
-
break;
|
|
665
|
-
case usage === "decrypt":
|
|
666
|
-
expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
|
|
667
|
-
break;
|
|
668
|
-
}
|
|
669
|
-
if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
|
|
215
|
+
const expectedKeyOp = usage === "encrypt" || usage === "decrypt" ? entry.ops?.[usage === "encrypt" ? 0 : 1] : usage;
|
|
216
|
+
if (expectedKeyOp && !key.key_ops.includes(expectedKeyOp)) throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
|
|
670
217
|
}
|
|
671
|
-
return true;
|
|
672
218
|
};
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
if (key.type === "public") switch (usage) {
|
|
696
|
-
case "sign": throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
697
|
-
case "decrypt": throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
698
|
-
}
|
|
699
|
-
if (key.type === "private") switch (usage) {
|
|
700
|
-
case "verify": throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
701
|
-
case "encrypt": throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
219
|
+
async function prepareKey(entry, key, usage) {
|
|
220
|
+
const { alg, secret } = entry, privateKey = usage === "decrypt" || usage === "sign";
|
|
221
|
+
if (secret && key instanceof Uint8Array) return key;
|
|
222
|
+
let normalized, keyObject;
|
|
223
|
+
if (isObject(key)) {
|
|
224
|
+
if (normalized = normalizeJwk(key), typeof normalized.kty != "string") throw invalidKeyType(alg, key, secret);
|
|
225
|
+
if (!(secret ? normalized.kty === "oct" && typeof normalized.k == "string" : normalized.kty !== "oct" && (privateKey ? normalized.kty === "AKP" && typeof normalized.priv == "string" || typeof normalized.d == "string" : normalized.d === void 0 && normalized.priv === void 0))) throw new TypeError(secret ? "JSON Web Key for symmetric algorithms must have JWK \"kty\" (Key Type) equal to \"oct\" and the JWK \"k\" (Key Value) present" : `JSON Web Key for this operation must be a ${privateKey ? "private" : "public"} JWK`);
|
|
226
|
+
if (jwkMatchesOp(entry, normalized, usage), normalized.kty === "oct") return decode(normalized.k);
|
|
227
|
+
if (!Object.isFrozen(key)) {
|
|
228
|
+
const { key_ops } = key;
|
|
229
|
+
Array.isArray(key_ops) && Object.freeze(key_ops), Object.freeze(key);
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
if (!isKeyLike(key)) throw invalidKeyType(alg, key, secret);
|
|
233
|
+
const expectedType = secret ? "secret" : privateKey ? "private" : "public";
|
|
234
|
+
if (key.type !== expectedType && (secret || [
|
|
235
|
+
"secret",
|
|
236
|
+
"public",
|
|
237
|
+
"private"
|
|
238
|
+
].includes(key.type))) throw new TypeError(`${tag(key)} instances must be of type "${expectedType}" for the ${alg} algorithm`);
|
|
239
|
+
if (isCryptoKey(key)) return key;
|
|
240
|
+
if (keyObject = key, keyObject.type === "secret") return keyObject.export();
|
|
702
241
|
}
|
|
242
|
+
cache ||= /* @__PURE__ */ new WeakMap();
|
|
243
|
+
const cacheKey = key;
|
|
244
|
+
let cached = cache.get(cacheKey);
|
|
245
|
+
if (cached?.[alg]) return cached[alg];
|
|
246
|
+
if (cached || cache.set(cacheKey, cached = {}), keyObject && typeof keyObject.toCryptoKey == "function") {
|
|
247
|
+
const isPublic = keyObject.type === "public", crv = nist[keyObject.asymmetricKeyDetails?.namedCurve], params = entry.resolve?.({
|
|
248
|
+
crv,
|
|
249
|
+
asymmetricKeyType: keyObject.asymmetricKeyType
|
|
250
|
+
}) ?? entry.subtle;
|
|
251
|
+
return cached[alg] = keyObject.toCryptoKey(params, isPublic, entry.usages[isPublic ? 0 : 1]);
|
|
252
|
+
}
|
|
253
|
+
return normalized ??= keyObject.export({ format: "jwk" }), normalized.alg = alg, cached[alg] = await jwkToKey(entry, normalized);
|
|
254
|
+
}
|
|
255
|
+
var cache;
|
|
256
|
+
var nist = {
|
|
257
|
+
__proto__: null,
|
|
258
|
+
prime256v1: "P-256",
|
|
259
|
+
secp384r1: "P-384",
|
|
260
|
+
secp521r1: "P-521"
|
|
703
261
|
};
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
case "PB":
|
|
711
|
-
symmetricTypeCheck(alg, key, usage);
|
|
712
|
-
break;
|
|
713
|
-
default: asymmetricTypeCheck(alg, key, usage);
|
|
262
|
+
var isCryptoKey = (key) => {
|
|
263
|
+
if (key?.[Symbol.toStringTag] === "CryptoKey") return !0;
|
|
264
|
+
try {
|
|
265
|
+
return key instanceof CryptoKey;
|
|
266
|
+
} catch {
|
|
267
|
+
return !1;
|
|
714
268
|
}
|
|
269
|
+
}, isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject", isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
270
|
+
function message(msg, actual, ...types) {
|
|
271
|
+
if (types.length > 2) {
|
|
272
|
+
const last = types.pop();
|
|
273
|
+
msg += `one of type ${types.join(", ")}, or ${last}.`;
|
|
274
|
+
} else types.length === 2 ? msg += `one of type ${types[0]} or ${types[1]}.` : msg += `of type ${types[0]}.`;
|
|
275
|
+
return actual == null ? msg += ` Received ${actual}` : typeof actual == "function" && actual.name ? msg += ` Received function ${actual.name}` : typeof actual == "object" && actual != null && actual.constructor?.name && (msg += ` Received an instance of ${actual.constructor.name}`), msg;
|
|
276
|
+
}
|
|
277
|
+
function invalidKeyType(alg, actual, secret) {
|
|
278
|
+
const types = [
|
|
279
|
+
"CryptoKey",
|
|
280
|
+
"KeyObject",
|
|
281
|
+
"JSON Web Key"
|
|
282
|
+
];
|
|
283
|
+
return secret && types.push("Uint8Array"), new TypeError(message(`Key for the ${alg} algorithm must be `, actual, ...types));
|
|
284
|
+
}
|
|
285
|
+
var unusable = (name, prop = "algorithm.name") => /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
286
|
+
function checkUsage(key, usage) {
|
|
287
|
+
if (usage && !key.usages.includes(usage)) throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
288
|
+
}
|
|
289
|
+
function checkModulusLength(alg, key) {
|
|
290
|
+
const { modulusLength } = key.algorithm;
|
|
291
|
+
if (typeof modulusLength != "number" || modulusLength < 2048) throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
292
|
+
}
|
|
293
|
+
function checkCryptoKey(key, expected, usage) {
|
|
294
|
+
const algorithm = key.algorithm;
|
|
295
|
+
if (algorithm.name !== expected.name) throw unusable(expected.name);
|
|
296
|
+
if (expected.hash && algorithm.hash?.name !== expected.hash) throw unusable(expected.hash, "algorithm.hash");
|
|
297
|
+
if (expected.namedCurve && algorithm.namedCurve !== expected.namedCurve) throw unusable(expected.namedCurve, "algorithm.namedCurve");
|
|
298
|
+
if (expected.length !== void 0 && algorithm.length !== expected.length) throw unusable(expected.length, "algorithm.length");
|
|
299
|
+
checkUsage(key, usage);
|
|
300
|
+
}
|
|
301
|
+
function snapshotJwk(jwk) {
|
|
302
|
+
return {
|
|
303
|
+
__proto__: null,
|
|
304
|
+
...jwk
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function normalizeJwk(jwk) {
|
|
308
|
+
const normalized = snapshotJwk(jwk);
|
|
309
|
+
if (normalized.ext !== void 0 && typeof normalized.ext != "boolean") throw new TypeError("\"ext\" (Extractable) Parameter must be a boolean");
|
|
310
|
+
if (normalized.key_ops !== void 0) {
|
|
311
|
+
const value = normalized.key_ops, keyOps = Array.isArray(value) ? [...value] : void 0;
|
|
312
|
+
if (!keyOps || keyOps.some((operation) => typeof operation != "string") || new Set(keyOps).size !== keyOps.length) throw new TypeError("\"key_ops\" (Key Operations) Parameter must be an array of unique strings");
|
|
313
|
+
normalized.key_ops = keyOps;
|
|
314
|
+
}
|
|
315
|
+
return normalized;
|
|
316
|
+
}
|
|
317
|
+
async function jwkToKey(entry, jwk, extractable) {
|
|
318
|
+
if (!entry.kty.includes(jwk.kty)) throw new JOSENotSupported("Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value");
|
|
319
|
+
const algorithm = entry.resolve?.({
|
|
320
|
+
kty: jwk.kty,
|
|
321
|
+
crv: jwk.crv
|
|
322
|
+
}) ?? entry.subtle, isPrivate = !!(jwk.d || jwk.priv), keyData = {
|
|
323
|
+
...jwk,
|
|
324
|
+
ext: extractable ?? jwk.ext
|
|
325
|
+
};
|
|
326
|
+
return keyData.kty !== "AKP" && delete keyData.alg, delete keyData.use, crypto.subtle.importKey("jwk", keyData, algorithm, keyData.ext ?? !isPrivate, jwk.key_ops ?? entry.usages[isPrivate ? 1 : 0]);
|
|
327
|
+
}
|
|
328
|
+
async function rawKey(key, expected, usage, extractable = !1) {
|
|
329
|
+
return key instanceof Uint8Array && (key = await crypto.subtle.importKey("raw", key, expected, extractable, [usage])), checkCryptoKey(key, expected, usage), key;
|
|
330
|
+
}
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region ../../node_modules/jose/dist/webapi/lib/key_descriptor.js
|
|
333
|
+
function table(entries) {
|
|
334
|
+
const out = { __proto__: null };
|
|
335
|
+
for (const alg in entries) out[alg] = {
|
|
336
|
+
...entries[alg],
|
|
337
|
+
alg
|
|
338
|
+
};
|
|
339
|
+
return out;
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region ../../node_modules/jose/dist/webapi/lib/jws_algorithms.js
|
|
343
|
+
var sig = [["verify"], ["sign"]];
|
|
344
|
+
function hmac(bits) {
|
|
345
|
+
const subtle = {
|
|
346
|
+
name: "HMAC",
|
|
347
|
+
hash: `SHA-${bits}`
|
|
348
|
+
};
|
|
349
|
+
return {
|
|
350
|
+
kty: ["oct"],
|
|
351
|
+
secret: !0,
|
|
352
|
+
subtle,
|
|
353
|
+
signing: subtle,
|
|
354
|
+
usages: sig
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function rsa(bits, saltLength) {
|
|
358
|
+
const subtle = {
|
|
359
|
+
name: saltLength ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
360
|
+
hash: `SHA-${bits}`
|
|
361
|
+
};
|
|
362
|
+
return {
|
|
363
|
+
kty: ["RSA"],
|
|
364
|
+
subtle,
|
|
365
|
+
signing: saltLength ? {
|
|
366
|
+
...subtle,
|
|
367
|
+
saltLength
|
|
368
|
+
} : subtle,
|
|
369
|
+
usages: sig,
|
|
370
|
+
minRsaBits: 2048
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function ecdsa(crv, bits) {
|
|
374
|
+
return {
|
|
375
|
+
kty: ["EC"],
|
|
376
|
+
crv,
|
|
377
|
+
subtle: {
|
|
378
|
+
name: "ECDSA",
|
|
379
|
+
namedCurve: crv
|
|
380
|
+
},
|
|
381
|
+
signing: {
|
|
382
|
+
name: "ECDSA",
|
|
383
|
+
hash: `SHA-${bits}`
|
|
384
|
+
},
|
|
385
|
+
usages: sig
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function eddsa() {
|
|
389
|
+
const subtle = { name: "Ed25519" };
|
|
390
|
+
return {
|
|
391
|
+
kty: ["OKP"],
|
|
392
|
+
crv: "Ed25519",
|
|
393
|
+
subtle,
|
|
394
|
+
signing: subtle,
|
|
395
|
+
usages: sig
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function mldsa(bits) {
|
|
399
|
+
const subtle = { name: `ML-DSA-${bits}` };
|
|
400
|
+
return {
|
|
401
|
+
kty: ["AKP"],
|
|
402
|
+
subtle,
|
|
403
|
+
signing: subtle,
|
|
404
|
+
usages: sig
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
var JWS = table({
|
|
408
|
+
HS256: hmac(256),
|
|
409
|
+
HS384: hmac(384),
|
|
410
|
+
HS512: hmac(512),
|
|
411
|
+
RS256: rsa(256),
|
|
412
|
+
RS384: rsa(384),
|
|
413
|
+
RS512: rsa(512),
|
|
414
|
+
PS256: rsa(256, 32),
|
|
415
|
+
PS384: rsa(384, 48),
|
|
416
|
+
PS512: rsa(512, 64),
|
|
417
|
+
ES256: ecdsa("P-256", 256),
|
|
418
|
+
ES384: ecdsa("P-384", 384),
|
|
419
|
+
ES512: ecdsa("P-521", 512),
|
|
420
|
+
EdDSA: eddsa(),
|
|
421
|
+
Ed25519: eddsa(),
|
|
422
|
+
"ML-DSA-44": mldsa(44),
|
|
423
|
+
"ML-DSA-65": mldsa(65),
|
|
424
|
+
"ML-DSA-87": mldsa(87)
|
|
425
|
+
});
|
|
426
|
+
function jwsAlgorithm(alg) {
|
|
427
|
+
const entry = typeof alg == "string" ? JWS[alg] : void 0;
|
|
428
|
+
if (!entry) throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
429
|
+
return entry;
|
|
715
430
|
}
|
|
716
431
|
//#endregion
|
|
717
|
-
//#region node_modules/jose/dist/webapi/
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
const protectedHeader = decode(jws.protected);
|
|
728
|
-
parsedProt = JSON.parse(decoder.decode(protectedHeader));
|
|
432
|
+
//#region ../../node_modules/jose/dist/webapi/lib/jws_verify.js
|
|
433
|
+
function prepareVerify(options) {
|
|
434
|
+
return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
|
|
435
|
+
}
|
|
436
|
+
function parseProtectedHeader(encodedProtected) {
|
|
437
|
+
return encodedProtected === void 0 ? {} : parseJoseHeader(encodedProtected, JWSInvalid, "JWS Protected Header is invalid");
|
|
438
|
+
}
|
|
439
|
+
function encodeCompactUnencodedPayload(payload) {
|
|
440
|
+
try {
|
|
441
|
+
return encode(payload);
|
|
729
442
|
} catch {
|
|
730
|
-
throw new JWSInvalid("JWS
|
|
443
|
+
throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters");
|
|
731
444
|
}
|
|
732
|
-
|
|
445
|
+
}
|
|
446
|
+
async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedProtected) {
|
|
447
|
+
const { protected: encodedProtected, header, payload: inputPayload } = jws, parsedProt = parsedProtected ?? parseProtectedHeader(encodedProtected);
|
|
448
|
+
if (!isDisjoint(parsedProt, header)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
733
449
|
const joseHeader = {
|
|
734
450
|
...parsedProt,
|
|
735
|
-
...
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
if (extensions.has("b64")) {
|
|
740
|
-
b64 = parsedProt.b64;
|
|
741
|
-
if (typeof b64 !== "boolean") throw new JWSInvalid("The \"b64\" (base64url-encode payload) Header Parameter must be a boolean");
|
|
742
|
-
}
|
|
743
|
-
const { alg } = joseHeader;
|
|
744
|
-
if (typeof alg !== "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
|
|
745
|
-
const algorithms = options && validateAlgorithms("algorithms", options.algorithms);
|
|
746
|
-
if (algorithms && !algorithms.has(alg)) throw new JOSEAlgNotAllowed("\"alg\" (Algorithm) Header Parameter value not allowed");
|
|
451
|
+
...header
|
|
452
|
+
}, b64 = validateB64(parsedProt, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], parsedProt, joseHeader)), { alg } = joseHeader;
|
|
453
|
+
if (typeof alg != "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
|
|
454
|
+
if (shared[0] && !shared[0].has(alg)) throw new JOSEAlgNotAllowed("\"alg\" (Algorithm) Header Parameter value not allowed");
|
|
747
455
|
if (b64) {
|
|
748
|
-
if (typeof
|
|
749
|
-
} else if (typeof
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
if (!
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
else if (typeof jws.payload === "string") payload = encoder.encode(jws.payload);
|
|
763
|
-
else payload = jws.payload;
|
|
764
|
-
const result = { payload };
|
|
765
|
-
if (jws.protected !== void 0) result.protectedHeader = parsedProt;
|
|
766
|
-
if (jws.header !== void 0) result.unprotectedHeader = jws.header;
|
|
767
|
-
if (resolvedKey) return {
|
|
456
|
+
if (typeof inputPayload != "string") throw new JWSInvalid("JWS Payload must be a string");
|
|
457
|
+
} else if (typeof inputPayload != "string" && !(inputPayload instanceof Uint8Array)) throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
|
|
458
|
+
const signingPayload = b64 || typeof inputPayload != "string" ? inputPayload : encodeUnencodedPayload(inputPayload);
|
|
459
|
+
let resolvedKey = !1;
|
|
460
|
+
typeof key == "function" && (key = await key(parsedProt, jws), resolvedKey = !0);
|
|
461
|
+
const entry = jwsAlgorithm(alg), data = concat(encodedProtected !== void 0 ? encode(encodedProtected) : new Uint8Array(), encode("."), typeof signingPayload == "string" ? shared[2] ??= encodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload), signature = decodeBase64url(jws.signature, "signature", JWSInvalid), k = await prepareKey(entry, key, "verify"), cryptoKey = await rawKey(k, entry.subtle, "verify");
|
|
462
|
+
entry.minRsaBits && checkModulusLength(entry.alg, cryptoKey);
|
|
463
|
+
let verified = !1;
|
|
464
|
+
try {
|
|
465
|
+
verified = await crypto.subtle.verify(entry.signing, cryptoKey, signature, data);
|
|
466
|
+
} catch {}
|
|
467
|
+
if (!verified) throw new JWSSignatureVerificationFailed();
|
|
468
|
+
const result = { payload: typeof signingPayload == "string" ? decodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload };
|
|
469
|
+
return encodedProtected !== void 0 && (result.protectedHeader = parsedProt), header !== void 0 && (result.unprotectedHeader = header), resolvedKey ? [{
|
|
768
470
|
...result,
|
|
769
471
|
key: k
|
|
770
|
-
};
|
|
771
|
-
return result;
|
|
472
|
+
}, b64] : [result, b64];
|
|
772
473
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
async function compactVerify(jws, key, options) {
|
|
776
|
-
if (jws instanceof Uint8Array) jws = decoder.decode(jws);
|
|
777
|
-
if (typeof jws !== "string") throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
|
|
474
|
+
async function verifyCompact(jws, shared, key) {
|
|
475
|
+
if (jws instanceof Uint8Array && (jws = decoder.decode(jws)), typeof jws != "string") throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
|
|
778
476
|
const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split(".");
|
|
779
477
|
if (length !== 3) throw new JWSInvalid("Invalid Compact JWS");
|
|
780
|
-
|
|
478
|
+
return verifySignature({
|
|
781
479
|
payload,
|
|
782
480
|
protected: protectedHeader,
|
|
783
481
|
signature
|
|
784
|
-
}, key,
|
|
785
|
-
const result = {
|
|
786
|
-
payload: verified.payload,
|
|
787
|
-
protectedHeader: verified.protectedHeader
|
|
788
|
-
};
|
|
789
|
-
if (typeof key === "function") return {
|
|
790
|
-
...result,
|
|
791
|
-
key: verified.key
|
|
792
|
-
};
|
|
793
|
-
return result;
|
|
482
|
+
}, shared, key, encodeCompactUnencodedPayload);
|
|
794
483
|
}
|
|
795
484
|
//#endregion
|
|
796
|
-
//#region node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
797
|
-
var epoch = (date) => Math.floor(date.getTime() / 1e3)
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
485
|
+
//#region ../../node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
486
|
+
var epoch = (date) => Math.floor(date.getTime() / 1e3), multipliers = {
|
|
487
|
+
s: 1,
|
|
488
|
+
m: 60,
|
|
489
|
+
h: 3600,
|
|
490
|
+
d: 86400,
|
|
491
|
+
w: 604800,
|
|
492
|
+
y: 31557600
|
|
493
|
+
}, REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, checkFailed = "check_failed";
|
|
494
|
+
function invalidDuration() {
|
|
495
|
+
throw new TypeError("Invalid time period format");
|
|
496
|
+
}
|
|
804
497
|
function secs(str) {
|
|
498
|
+
typeof str != "string" && invalidDuration();
|
|
805
499
|
const matched = REGEX.exec(str);
|
|
806
|
-
|
|
807
|
-
const value = parseFloat(matched[2]);
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
case "second":
|
|
814
|
-
case "seconds":
|
|
815
|
-
case "s":
|
|
816
|
-
numericDate = Math.round(value);
|
|
817
|
-
break;
|
|
818
|
-
case "minute":
|
|
819
|
-
case "minutes":
|
|
820
|
-
case "min":
|
|
821
|
-
case "mins":
|
|
822
|
-
case "m":
|
|
823
|
-
numericDate = Math.round(value * minute);
|
|
824
|
-
break;
|
|
825
|
-
case "hour":
|
|
826
|
-
case "hours":
|
|
827
|
-
case "hr":
|
|
828
|
-
case "hrs":
|
|
829
|
-
case "h":
|
|
830
|
-
numericDate = Math.round(value * hour);
|
|
831
|
-
break;
|
|
832
|
-
case "day":
|
|
833
|
-
case "days":
|
|
834
|
-
case "d":
|
|
835
|
-
numericDate = Math.round(value * day);
|
|
836
|
-
break;
|
|
837
|
-
case "week":
|
|
838
|
-
case "weeks":
|
|
839
|
-
case "w":
|
|
840
|
-
numericDate = Math.round(value * week);
|
|
841
|
-
break;
|
|
842
|
-
default:
|
|
843
|
-
numericDate = Math.round(value * year);
|
|
844
|
-
break;
|
|
845
|
-
}
|
|
846
|
-
if (matched[1] === "-" || matched[4] === "ago") return -numericDate;
|
|
847
|
-
return numericDate;
|
|
500
|
+
(!matched || matched[4] && matched[1]) && invalidDuration();
|
|
501
|
+
const value = parseFloat(matched[2]), numericDate2 = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
|
|
502
|
+
return Number.isFinite(numericDate2) || invalidDuration(), matched[1] === "-" || matched[4] === "ago" ? -numericDate2 : numericDate2;
|
|
503
|
+
}
|
|
504
|
+
function validateInput(label, input) {
|
|
505
|
+
if (!Number.isFinite(input)) throw new TypeError(`Invalid ${label} input`);
|
|
506
|
+
return input;
|
|
848
507
|
}
|
|
849
508
|
var normalizeTyp = (value) => {
|
|
850
|
-
|
|
851
|
-
return `application/${
|
|
852
|
-
};
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
if (
|
|
856
|
-
|
|
857
|
-
|
|
509
|
+
const normalized = value.toLowerCase();
|
|
510
|
+
return value.includes("/") ? normalized : `application/${normalized}`;
|
|
511
|
+
}, checkAudiencePresence = (audPayload, audOption) => typeof audPayload == "string" ? audOption.includes(audPayload) : Array.isArray(audPayload) ? audOption.some((aud) => audPayload.includes(aud)) : !1;
|
|
512
|
+
function validateNumericDate(payload, claim, required = !1) {
|
|
513
|
+
const value = payload[claim];
|
|
514
|
+
if (!(value === void 0 && !required)) {
|
|
515
|
+
if (typeof value != "number") throw new JWTClaimValidationFailed(`"${claim}" claim must be a number`, payload, claim, "invalid");
|
|
516
|
+
return value;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function unexpectedClaim(payload, claim) {
|
|
520
|
+
throw new JWTClaimValidationFailed(`unexpected "${claim}" claim value`, payload, claim, checkFailed);
|
|
521
|
+
}
|
|
858
522
|
function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
859
523
|
let payload;
|
|
860
524
|
try {
|
|
861
|
-
payload = JSON.parse(
|
|
525
|
+
payload = JSON.parse(strictDecoder.decode(encodedPayload));
|
|
862
526
|
} catch {}
|
|
863
527
|
if (!isObject(payload)) throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
|
|
864
528
|
const { typ } = options;
|
|
865
|
-
if (typ && (typeof protectedHeader.typ
|
|
866
|
-
const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
if (
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
break;
|
|
887
|
-
default: throw new TypeError("Invalid clockTolerance option type");
|
|
888
|
-
}
|
|
889
|
-
const { currentDate } = options;
|
|
890
|
-
const now = epoch(currentDate || /* @__PURE__ */ new Date());
|
|
891
|
-
if ((payload.iat !== void 0 || maxTokenAge) && typeof payload.iat !== "number") throw new JWTClaimValidationFailed("\"iat\" claim must be a number", payload, "iat", "invalid");
|
|
892
|
-
if (payload.nbf !== void 0) {
|
|
893
|
-
if (typeof payload.nbf !== "number") throw new JWTClaimValidationFailed("\"nbf\" claim must be a number", payload, "nbf", "invalid");
|
|
894
|
-
if (payload.nbf > now + tolerance) throw new JWTClaimValidationFailed("\"nbf\" claim timestamp check failed", payload, "nbf", "check_failed");
|
|
895
|
-
}
|
|
896
|
-
if (payload.exp !== void 0) {
|
|
897
|
-
if (typeof payload.exp !== "number") throw new JWTClaimValidationFailed("\"exp\" claim must be a number", payload, "exp", "invalid");
|
|
898
|
-
if (payload.exp <= now - tolerance) throw new JWTExpired("\"exp\" claim timestamp check failed", payload, "exp", "check_failed");
|
|
899
|
-
}
|
|
900
|
-
if (maxTokenAge) {
|
|
901
|
-
const age = now - payload.iat;
|
|
902
|
-
const max = typeof maxTokenAge === "number" ? maxTokenAge : secs(maxTokenAge);
|
|
903
|
-
if (age - tolerance > max) throw new JWTExpired("\"iat\" claim timestamp check failed (too far in the past)", payload, "iat", "check_failed");
|
|
904
|
-
if (age < 0 - tolerance) throw new JWTClaimValidationFailed("\"iat\" claim timestamp check failed (it should be in the past)", payload, "iat", "check_failed");
|
|
529
|
+
if (typ !== void 0 && (typeof protectedHeader.typ != "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) throw new JWTClaimValidationFailed("unexpected \"typ\" JWT header value", payload, "typ", checkFailed);
|
|
530
|
+
const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options, presenceCheck = [...requiredClaims];
|
|
531
|
+
maxTokenAge !== void 0 && presenceCheck.push("iat"), audience !== void 0 && presenceCheck.push("aud"), subject !== void 0 && presenceCheck.push("sub"), issuer !== void 0 && presenceCheck.push("iss");
|
|
532
|
+
for (const claim of new Set(presenceCheck.reverse())) if (!Object.hasOwn(payload, claim)) throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, payload, claim, "missing");
|
|
533
|
+
issuer !== void 0 && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss) && unexpectedClaim(payload, "iss"), subject !== void 0 && payload.sub !== subject && unexpectedClaim(payload, "sub"), audience !== void 0 && !checkAudiencePresence(payload.aud, typeof audience == "string" ? [audience] : audience) && unexpectedClaim(payload, "aud");
|
|
534
|
+
const { clockTolerance } = options;
|
|
535
|
+
let tolerance = 0;
|
|
536
|
+
if (typeof clockTolerance == "string") tolerance = secs(clockTolerance);
|
|
537
|
+
else if (clockTolerance !== void 0) {
|
|
538
|
+
if (typeof clockTolerance != "number") throw new TypeError("Invalid clockTolerance option type");
|
|
539
|
+
tolerance = clockTolerance;
|
|
540
|
+
}
|
|
541
|
+
validateInput("clockTolerance option", tolerance);
|
|
542
|
+
const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(payload, "iat", maxTokenAge !== void 0), nbf = validateNumericDate(payload, "nbf");
|
|
543
|
+
if (nbf !== void 0 && nbf > now + tolerance) throw new JWTClaimValidationFailed("\"nbf\" claim timestamp check failed", payload, "nbf", checkFailed);
|
|
544
|
+
const exp = validateNumericDate(payload, "exp");
|
|
545
|
+
if (exp !== void 0 && exp <= now - tolerance) throw new JWTExpired("\"exp\" claim timestamp check failed", payload, "exp", checkFailed);
|
|
546
|
+
if (maxTokenAge !== void 0) {
|
|
547
|
+
const age = now - iat, max = validateInput("maxTokenAge option", typeof maxTokenAge == "number" ? maxTokenAge : secs(maxTokenAge));
|
|
548
|
+
if (age - tolerance > max) throw new JWTExpired("\"iat\" claim timestamp check failed (too far in the past)", payload, "iat", checkFailed);
|
|
549
|
+
if (age < -tolerance) throw new JWTClaimValidationFailed("\"iat\" claim timestamp check failed (it should be in the past)", payload, "iat", checkFailed);
|
|
905
550
|
}
|
|
906
551
|
return payload;
|
|
907
552
|
}
|
|
908
553
|
//#endregion
|
|
909
|
-
//#region node_modules/jose/dist/webapi/jwt/verify.js
|
|
554
|
+
//#region ../../node_modules/jose/dist/webapi/jwt/verify.js
|
|
910
555
|
async function jwtVerify(jwt, key, options) {
|
|
911
|
-
const verified = await
|
|
912
|
-
if (
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
if (typeof key === "function") return {
|
|
918
|
-
...result,
|
|
919
|
-
key: verified.key
|
|
556
|
+
const [verified, b64] = await verifyCompact(jwt, prepareVerify(options), key);
|
|
557
|
+
if (!b64) throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
558
|
+
const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options);
|
|
559
|
+
return {
|
|
560
|
+
...verified,
|
|
561
|
+
payload
|
|
920
562
|
};
|
|
921
|
-
return result;
|
|
922
563
|
}
|
|
923
564
|
//#endregion
|
|
924
|
-
//#region node_modules/jose/dist/webapi/jwks/local.js
|
|
925
|
-
function
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
case "PS": return "RSA";
|
|
929
|
-
case "ES": return "EC";
|
|
930
|
-
case "Ed": return "OKP";
|
|
931
|
-
case "ML": return "AKP";
|
|
932
|
-
default: throw new JOSENotSupported("Unsupported \"alg\" value for a JSON Web Key Set");
|
|
933
|
-
}
|
|
565
|
+
//#region ../../node_modules/jose/dist/webapi/jwks/local.js
|
|
566
|
+
function isUsableJWK(jwk, entry, alg, kid) {
|
|
567
|
+
const { kty, key_ops: keyOps, ext, kid: jwkKid, alg: jwkAlg, use, crv } = jwk;
|
|
568
|
+
return (ext === void 0 || typeof ext == "boolean") && (keyOps === void 0 || Array.isArray(keyOps) && keyOps.every((operation, index) => typeof operation == "string" && keyOps.indexOf(operation) === index) && keyOps.includes("verify")) && entry.kty.includes(kty) && (kid === void 0 || typeof kid == "string" && kid === jwkKid) && (jwkAlg === void 0 ? kty !== "AKP" : alg === jwkAlg) && (use === void 0 || use === "sig") && (!entry.crv || crv === entry.crv);
|
|
934
569
|
}
|
|
935
|
-
function
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
if (!isJWKSLike(jwks)) throw new JWKSInvalid("JSON Web Key Set malformed");
|
|
946
|
-
this.#jwks = structuredClone(jwks);
|
|
947
|
-
}
|
|
948
|
-
jwks() {
|
|
949
|
-
return this.#jwks;
|
|
570
|
+
async function importWithAlgCache(cache, jwk, entry) {
|
|
571
|
+
const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk), { alg } = entry;
|
|
572
|
+
if (cached[alg] === void 0) {
|
|
573
|
+
const pending = jwkToKey(entry, jwk, !0).then((key) => {
|
|
574
|
+
if (key.type !== "public") throw new JWKSInvalid("JSON Web Key Set members must be public keys");
|
|
575
|
+
return cached[alg] = key, key;
|
|
576
|
+
}).catch((error) => {
|
|
577
|
+
throw cached[alg] === pending && delete cached[alg], error;
|
|
578
|
+
});
|
|
579
|
+
cached[alg] = pending;
|
|
950
580
|
}
|
|
951
|
-
|
|
581
|
+
return cached[alg];
|
|
582
|
+
}
|
|
583
|
+
function createLocalJWKSet(jwks) {
|
|
584
|
+
let snapshot;
|
|
585
|
+
try {
|
|
586
|
+
snapshot = structuredClone(jwks);
|
|
587
|
+
} catch {}
|
|
588
|
+
if (!isJwkSet(snapshot)) throw new JWKSInvalid("JSON Web Key Set malformed");
|
|
589
|
+
const metadata = snapshot.keys.map((jwk) => {
|
|
590
|
+
const normalized = snapshotJwk(jwk);
|
|
591
|
+
return Array.isArray(normalized.key_ops) && (normalized.key_ops = [...normalized.key_ops]), normalized;
|
|
592
|
+
}), cached = /* @__PURE__ */ new WeakMap();
|
|
593
|
+
return Object.defineProperty(async (protectedHeader, token) => {
|
|
952
594
|
const { alg, kid } = {
|
|
953
595
|
...protectedHeader,
|
|
954
596
|
...token?.header
|
|
955
|
-
};
|
|
956
|
-
|
|
957
|
-
const candidates =
|
|
958
|
-
|
|
959
|
-
if (candidate && typeof kid === "string") candidate = kid === jwk.kid;
|
|
960
|
-
if (candidate && (typeof jwk.alg === "string" || kty === "AKP")) candidate = alg === jwk.alg;
|
|
961
|
-
if (candidate && typeof jwk.use === "string") candidate = jwk.use === "sig";
|
|
962
|
-
if (candidate && Array.isArray(jwk.key_ops)) candidate = jwk.key_ops.includes("verify");
|
|
963
|
-
if (candidate) switch (alg) {
|
|
964
|
-
case "ES256":
|
|
965
|
-
candidate = jwk.crv === "P-256";
|
|
966
|
-
break;
|
|
967
|
-
case "ES384":
|
|
968
|
-
candidate = jwk.crv === "P-384";
|
|
969
|
-
break;
|
|
970
|
-
case "ES512":
|
|
971
|
-
candidate = jwk.crv === "P-521";
|
|
972
|
-
break;
|
|
973
|
-
case "Ed25519":
|
|
974
|
-
case "EdDSA":
|
|
975
|
-
candidate = jwk.crv === "Ed25519";
|
|
976
|
-
break;
|
|
977
|
-
}
|
|
978
|
-
return candidate;
|
|
979
|
-
});
|
|
980
|
-
const { 0: jwk, length } = candidates;
|
|
981
|
-
if (length === 0) throw new JWKSNoMatchingKey();
|
|
597
|
+
}, entry = typeof alg == "string" ? JWS[alg] : void 0;
|
|
598
|
+
if (!entry || entry.secret) throw new JOSENotSupported("Unsupported \"alg\" value for a JSON Web Key Set");
|
|
599
|
+
const candidates = snapshot.keys.filter((_, index) => isUsableJWK(metadata[index], entry, alg, kid)), { 0: jwk, length } = candidates;
|
|
600
|
+
if (!length) throw new JWKSNoMatchingKey();
|
|
982
601
|
if (length !== 1) {
|
|
983
602
|
const error = new JWKSMultipleMatchingKeys();
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
yield await importWithAlgCache(_cached, jwk, alg);
|
|
603
|
+
throw error[Symbol.asyncIterator] = async function* () {
|
|
604
|
+
for (const jwk2 of candidates) try {
|
|
605
|
+
yield await importWithAlgCache(cached, jwk2, entry);
|
|
988
606
|
} catch {}
|
|
989
|
-
};
|
|
990
|
-
throw error;
|
|
607
|
+
}, error;
|
|
991
608
|
}
|
|
992
|
-
return importWithAlgCache(
|
|
993
|
-
}
|
|
994
|
-
};
|
|
995
|
-
async function importWithAlgCache(cache, jwk, alg) {
|
|
996
|
-
const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
|
|
997
|
-
if (cached[alg] === void 0) {
|
|
998
|
-
const key = await importJWK({
|
|
999
|
-
...jwk,
|
|
1000
|
-
ext: true
|
|
1001
|
-
}, alg);
|
|
1002
|
-
if (key instanceof Uint8Array || key.type !== "public") throw new JWKSInvalid("JSON Web Key Set members must be public keys");
|
|
1003
|
-
cached[alg] = key;
|
|
1004
|
-
}
|
|
1005
|
-
return cached[alg];
|
|
1006
|
-
}
|
|
1007
|
-
function createLocalJWKSet(jwks) {
|
|
1008
|
-
const set = new LocalJWKSet(jwks);
|
|
1009
|
-
const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
|
|
1010
|
-
Object.defineProperties(localJWKSet, { jwks: {
|
|
1011
|
-
value: () => structuredClone(set.jwks()),
|
|
1012
|
-
enumerable: false,
|
|
1013
|
-
configurable: false,
|
|
1014
|
-
writable: false
|
|
1015
|
-
} });
|
|
1016
|
-
return localJWKSet;
|
|
609
|
+
return importWithAlgCache(cached, jwk, entry);
|
|
610
|
+
}, "jwks", { value: () => structuredClone(snapshot) });
|
|
1017
611
|
}
|
|
1018
612
|
//#endregion
|
|
1019
|
-
//#region node_modules/jose/dist/webapi/jwks/remote.js
|
|
613
|
+
//#region ../../node_modules/jose/dist/webapi/jwks/remote.js
|
|
1020
614
|
function isCloudflareWorkers() {
|
|
1021
|
-
return typeof WebSocketPair
|
|
615
|
+
return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
|
|
1022
616
|
}
|
|
1023
617
|
var USER_AGENT;
|
|
1024
|
-
|
|
1025
|
-
var customFetch = Symbol();
|
|
618
|
+
(typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.12");
|
|
619
|
+
var customFetch = /* @__PURE__ */ Symbol();
|
|
1026
620
|
async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
|
|
1027
621
|
const response = await fetchImpl(url, {
|
|
1028
622
|
method: "GET",
|
|
@@ -1030,8 +624,7 @@ async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
|
|
|
1030
624
|
redirect: "manual",
|
|
1031
625
|
headers
|
|
1032
626
|
}).catch((err) => {
|
|
1033
|
-
|
|
1034
|
-
throw err;
|
|
627
|
+
throw err.name === "TimeoutError" ? new JWKSTimeout() : err;
|
|
1035
628
|
});
|
|
1036
629
|
if (response.status !== 200) throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
|
|
1037
630
|
try {
|
|
@@ -1040,121 +633,70 @@ async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
|
|
|
1040
633
|
throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
|
|
1041
634
|
}
|
|
1042
635
|
}
|
|
1043
|
-
var jwksCache = Symbol();
|
|
1044
|
-
function
|
|
1045
|
-
|
|
1046
|
-
if (!("uat" in input) || typeof input.uat !== "number" || Date.now() - input.uat >= cacheMaxAge) return false;
|
|
1047
|
-
if (!("jwks" in input) || !isObject(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isObject)) return false;
|
|
1048
|
-
return true;
|
|
636
|
+
var jwksCache = /* @__PURE__ */ Symbol();
|
|
637
|
+
function isFreshFor(timestamp, duration) {
|
|
638
|
+
return Number.isFinite(timestamp) && Date.now() < timestamp + duration;
|
|
1049
639
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
this.#jwksTimestamp = this.#cache.uat;
|
|
1078
|
-
this.#local = createLocalJWKSet(this.#cache.jwks);
|
|
1079
|
-
}
|
|
640
|
+
function validateDuration(value, fallback, option) {
|
|
641
|
+
if (Number.isNaN(value)) throw new TypeError(`"${option}" option must not be NaN`);
|
|
642
|
+
return typeof value == "number" ? value : fallback;
|
|
643
|
+
}
|
|
644
|
+
function createRemoteJWKSet(url, options) {
|
|
645
|
+
if (!(url instanceof URL)) throw new TypeError("url must be an instance of URL");
|
|
646
|
+
const href = new URL(url.href).href, opts = options ?? {}, timeoutOption = opts.timeoutDuration;
|
|
647
|
+
if (typeof timeoutOption == "number" && (!Number.isInteger(timeoutOption) || timeoutOption < 0)) throw new TypeError("\"timeoutDuration\" option must be a non-negative integer");
|
|
648
|
+
const timeoutDuration = typeof timeoutOption == "number" ? timeoutOption : 5e3, cooldownDuration = validateDuration(opts.cooldownDuration, 3e4, "cooldownDuration"), cacheMaxAge = validateDuration(opts.cacheMaxAge, 6e5, "cacheMaxAge"), headers = new Headers(opts.headers);
|
|
649
|
+
USER_AGENT && !headers.has("User-Agent") && headers.set("User-Agent", USER_AGENT), headers.has("accept") || headers.set("accept", "application/json, application/jwk-set+json");
|
|
650
|
+
const fetchImpl = opts[customFetch], cache = opts[jwksCache];
|
|
651
|
+
let jwksTimestamp, pendingFetch, reloadSequence = 0, appliedSequence = 0, local;
|
|
652
|
+
if (cache && typeof cache == "object") {
|
|
653
|
+
const { uat, jwks } = cache;
|
|
654
|
+
isFreshFor(uat, cacheMaxAge) && isJwkSet(jwks) && (jwksTimestamp = uat, local = createLocalJWKSet(jwks));
|
|
655
|
+
}
|
|
656
|
+
const reload = async () => {
|
|
657
|
+
if (pendingFetch && isCloudflareWorkers() && (pendingFetch = void 0), !pendingFetch) {
|
|
658
|
+
const sequence = ++reloadSequence, current = pendingFetch = fetchJwks(href, headers, AbortSignal.timeout(timeoutDuration), fetchImpl).then((json) => {
|
|
659
|
+
const next = createLocalJWKSet(json);
|
|
660
|
+
if (sequence <= appliedSequence) return;
|
|
661
|
+
local = next;
|
|
662
|
+
const updatedAt = Date.now();
|
|
663
|
+
cache && (cache.uat = updatedAt, cache.jwks = json), jwksTimestamp = updatedAt, appliedSequence = sequence;
|
|
664
|
+
}).finally(() => {
|
|
665
|
+
pendingFetch === current && (pendingFetch = void 0);
|
|
666
|
+
});
|
|
1080
667
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
coolingDown() {
|
|
1086
|
-
return typeof this.#jwksTimestamp === "number" ? Date.now() < this.#jwksTimestamp + this.#cooldownDuration : false;
|
|
1087
|
-
}
|
|
1088
|
-
fresh() {
|
|
1089
|
-
return typeof this.#jwksTimestamp === "number" ? Date.now() < this.#jwksTimestamp + this.#cacheMaxAge : false;
|
|
1090
|
-
}
|
|
1091
|
-
jwks() {
|
|
1092
|
-
return this.#local?.jwks();
|
|
1093
|
-
}
|
|
1094
|
-
async getKey(protectedHeader, token) {
|
|
1095
|
-
if (!this.#local || !this.fresh()) await this.reload();
|
|
668
|
+
await pendingFetch;
|
|
669
|
+
};
|
|
670
|
+
return Object.defineProperties(async (protectedHeader, token) => {
|
|
671
|
+
(!local || !isFreshFor(jwksTimestamp, cacheMaxAge)) && await reload();
|
|
1096
672
|
try {
|
|
1097
|
-
return await
|
|
673
|
+
return await local(protectedHeader, token);
|
|
1098
674
|
} catch (err) {
|
|
1099
|
-
if (err instanceof JWKSNoMatchingKey)
|
|
1100
|
-
if (this.coolingDown() === false) {
|
|
1101
|
-
await this.reload();
|
|
1102
|
-
return this.#local(protectedHeader, token);
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
675
|
+
if (err instanceof JWKSNoMatchingKey && !isFreshFor(jwksTimestamp, cooldownDuration)) return await reload(), local(protectedHeader, token);
|
|
1105
676
|
throw err;
|
|
1106
677
|
}
|
|
1107
|
-
}
|
|
1108
|
-
async reload() {
|
|
1109
|
-
if (this.#pendingFetch && isCloudflareWorkers()) this.#pendingFetch = void 0;
|
|
1110
|
-
this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch).then((json) => {
|
|
1111
|
-
this.#local = createLocalJWKSet(json);
|
|
1112
|
-
if (this.#cache) {
|
|
1113
|
-
this.#cache.uat = Date.now();
|
|
1114
|
-
this.#cache.jwks = json;
|
|
1115
|
-
}
|
|
1116
|
-
this.#jwksTimestamp = Date.now();
|
|
1117
|
-
this.#pendingFetch = void 0;
|
|
1118
|
-
}).catch((err) => {
|
|
1119
|
-
this.#pendingFetch = void 0;
|
|
1120
|
-
throw err;
|
|
1121
|
-
});
|
|
1122
|
-
await this.#pendingFetch;
|
|
1123
|
-
}
|
|
1124
|
-
};
|
|
1125
|
-
function createRemoteJWKSet(url, options) {
|
|
1126
|
-
const set = new RemoteJWKSet(url, options);
|
|
1127
|
-
const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
|
|
1128
|
-
Object.defineProperties(remoteJWKSet, {
|
|
678
|
+
}, {
|
|
1129
679
|
coolingDown: {
|
|
1130
|
-
get: () =>
|
|
1131
|
-
enumerable:
|
|
1132
|
-
configurable: false
|
|
680
|
+
get: () => isFreshFor(jwksTimestamp, cooldownDuration),
|
|
681
|
+
enumerable: !0
|
|
1133
682
|
},
|
|
1134
683
|
fresh: {
|
|
1135
|
-
get: () =>
|
|
1136
|
-
enumerable:
|
|
1137
|
-
configurable: false
|
|
684
|
+
get: () => isFreshFor(jwksTimestamp, cacheMaxAge),
|
|
685
|
+
enumerable: !0
|
|
1138
686
|
},
|
|
1139
687
|
reload: {
|
|
1140
|
-
value:
|
|
1141
|
-
enumerable:
|
|
1142
|
-
configurable: false,
|
|
1143
|
-
writable: false
|
|
688
|
+
value: reload,
|
|
689
|
+
enumerable: !0
|
|
1144
690
|
},
|
|
1145
691
|
reloading: {
|
|
1146
|
-
get: () =>
|
|
1147
|
-
enumerable:
|
|
1148
|
-
configurable: false
|
|
692
|
+
get: () => !!pendingFetch,
|
|
693
|
+
enumerable: !0
|
|
1149
694
|
},
|
|
1150
695
|
jwks: {
|
|
1151
|
-
value: () =>
|
|
1152
|
-
enumerable:
|
|
1153
|
-
configurable: false,
|
|
1154
|
-
writable: false
|
|
696
|
+
value: () => local?.jwks(),
|
|
697
|
+
enumerable: !0
|
|
1155
698
|
}
|
|
1156
699
|
});
|
|
1157
|
-
return remoteJWKSet;
|
|
1158
700
|
}
|
|
1159
701
|
//#endregion
|
|
1160
702
|
//#region src/oidc/auth-oidc.addon.ts
|
|
@@ -1338,7 +880,7 @@ var AuthOidcAddon = class extends BaseAddon {
|
|
|
1338
880
|
type: "text",
|
|
1339
881
|
key: "redirectUri",
|
|
1340
882
|
label: "Redirect URI override",
|
|
1341
|
-
description: "Optional. Default uses
|
|
883
|
+
description: "Optional. Default uses CAMSTACK_HUB_PUBLIC_URL + the instance id.",
|
|
1342
884
|
default: ""
|
|
1343
885
|
},
|
|
1344
886
|
{
|
|
@@ -1432,7 +974,7 @@ var AuthOidcAddon = class extends BaseAddon {
|
|
|
1432
974
|
if (!inst) throw new Error(`OIDC: no provider configured with id "${providerId}"`);
|
|
1433
975
|
const configured = inst.config.redirectUri?.trim();
|
|
1434
976
|
if (configured) return configured;
|
|
1435
|
-
return `${(process.env["
|
|
977
|
+
return `${(process.env["CAMSTACK_HUB_PUBLIC_URL"] || "https://localhost:4443").replace(/\/+$/, "")}/addon/auth-oidc/${providerId}/callback`;
|
|
1436
978
|
}
|
|
1437
979
|
async buildLoginUrl(providerId, state) {
|
|
1438
980
|
const inst = this.instances.get(providerId);
|