@meshagent/meshagent-ts-auth 0.49.1 → 0.51.0
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/CHANGELOG.md +13 -0
- package/dist/browser/ma-auth.global.js +1082 -781
- package/package.json +2 -2
|
@@ -52,7 +52,6 @@ meshagent.auth = (() => {
|
|
|
52
52
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
53
53
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
54
54
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
55
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
56
55
|
|
|
57
56
|
// ../node_modules/@kayahr/text-encoding/data/big5.cp.js
|
|
58
57
|
var big5_cp_default;
|
|
@@ -3121,14 +3120,18 @@ meshagent.auth = (() => {
|
|
|
3121
3120
|
msecs ?? (msecs = Date.now());
|
|
3122
3121
|
nsecs ?? (nsecs = 0);
|
|
3123
3122
|
clockseq ?? (clockseq = (rnds[8] << 8 | rnds[9]) & 16383);
|
|
3124
|
-
|
|
3123
|
+
if (node == null) {
|
|
3124
|
+
node = rnds.slice(10, 16);
|
|
3125
|
+
node[0] |= 1;
|
|
3126
|
+
}
|
|
3125
3127
|
msecs += 122192928e5;
|
|
3126
|
-
const
|
|
3128
|
+
const t = (msecs & 268435455) * 1e4 + nsecs;
|
|
3129
|
+
const tl = t >>> 0;
|
|
3127
3130
|
buf[offset++] = tl >>> 24 & 255;
|
|
3128
3131
|
buf[offset++] = tl >>> 16 & 255;
|
|
3129
3132
|
buf[offset++] = tl >>> 8 & 255;
|
|
3130
3133
|
buf[offset++] = tl & 255;
|
|
3131
|
-
const tmh = msecs /
|
|
3134
|
+
const tmh = (msecs / 268435456 | 0) * 625 + (t / 4294967296 | 0) & 268435455;
|
|
3132
3135
|
buf[offset++] = tmh >>> 8 & 255;
|
|
3133
3136
|
buf[offset++] = tmh & 255;
|
|
3134
3137
|
buf[offset++] = tmh >>> 24 & 15 | 16;
|
|
@@ -3553,7 +3556,7 @@ meshagent.auth = (() => {
|
|
|
3553
3556
|
state.msecs ?? (state.msecs = -Infinity);
|
|
3554
3557
|
state.seq ?? (state.seq = 0);
|
|
3555
3558
|
if (now > state.msecs) {
|
|
3556
|
-
state.seq = rnds
|
|
3559
|
+
state.seq = v7Sequence(rnds);
|
|
3557
3560
|
state.msecs = now;
|
|
3558
3561
|
} else {
|
|
3559
3562
|
state.seq = state.seq + 1 | 0;
|
|
@@ -3576,7 +3579,7 @@ meshagent.auth = (() => {
|
|
|
3576
3579
|
}
|
|
3577
3580
|
}
|
|
3578
3581
|
msecs ?? (msecs = Date.now());
|
|
3579
|
-
seq ?? (seq = rnds
|
|
3582
|
+
seq ?? (seq = v7Sequence(rnds));
|
|
3580
3583
|
buf[offset++] = msecs / 1099511627776 & 255;
|
|
3581
3584
|
buf[offset++] = msecs / 4294967296 & 255;
|
|
3582
3585
|
buf[offset++] = msecs / 16777216 & 255;
|
|
@@ -3595,6 +3598,9 @@ meshagent.auth = (() => {
|
|
|
3595
3598
|
buf[offset++] = rnds[15];
|
|
3596
3599
|
return buf;
|
|
3597
3600
|
}
|
|
3601
|
+
function v7Sequence(rnds) {
|
|
3602
|
+
return (rnds[6] & 127) << 24 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
3603
|
+
}
|
|
3598
3604
|
var _state2, v7_default;
|
|
3599
3605
|
var init_v7 = __esm({
|
|
3600
3606
|
"../node_modules/uuid/dist/v7.js"() {
|
|
@@ -36468,23 +36474,13 @@ return true;`);
|
|
|
36468
36474
|
const [encKey, macKey, keySize] = await cbcKeySetup(enc, cek, "decrypt");
|
|
36469
36475
|
const macData = concat(aad, iv, ciphertext, uint64be(aad.length * 8));
|
|
36470
36476
|
const expectedTag = await cbcHmacTag(macKey, macData, keySize);
|
|
36471
|
-
let macCheckPassed;
|
|
36472
36477
|
try {
|
|
36473
|
-
|
|
36474
|
-
|
|
36475
|
-
|
|
36476
|
-
if (!macCheckPassed) {
|
|
36477
|
-
throw new JWEDecryptionFailed();
|
|
36478
|
-
}
|
|
36479
|
-
let plaintext;
|
|
36480
|
-
try {
|
|
36481
|
-
plaintext = new Uint8Array(await crypto.subtle.decrypt({ iv, name: "AES-CBC" }, encKey, ciphertext));
|
|
36478
|
+
if (await timingSafeEqual(tag2, expectedTag)) {
|
|
36479
|
+
return new Uint8Array(await crypto.subtle.decrypt({ iv, name: "AES-CBC" }, encKey, ciphertext));
|
|
36480
|
+
}
|
|
36482
36481
|
} catch {
|
|
36483
36482
|
}
|
|
36484
|
-
|
|
36485
|
-
throw new JWEDecryptionFailed();
|
|
36486
|
-
}
|
|
36487
|
-
return plaintext;
|
|
36483
|
+
throw new JWEDecryptionFailed();
|
|
36488
36484
|
}
|
|
36489
36485
|
async function gcmEncrypt(enc, plaintext, cek, iv, aad) {
|
|
36490
36486
|
const encKey = cek instanceof Uint8Array ? await crypto.subtle.importKey("raw", cek, "AES-GCM", false, [
|
|
@@ -36539,6 +36535,9 @@ return true;`);
|
|
|
36539
36535
|
if (!tag2) {
|
|
36540
36536
|
throw new JWEInvalid("JWE Authentication Tag missing");
|
|
36541
36537
|
}
|
|
36538
|
+
if (!enc.cbc && tag2.length !== 16) {
|
|
36539
|
+
throw new JWEInvalid("Invalid Authentication Tag length");
|
|
36540
|
+
}
|
|
36542
36541
|
checkIvLength(enc, iv);
|
|
36543
36542
|
if (cek instanceof Uint8Array) {
|
|
36544
36543
|
checkCekLength(cek, enc.cekBits);
|
|
@@ -36636,19 +36635,20 @@ return true;`);
|
|
|
36636
36635
|
});
|
|
36637
36636
|
|
|
36638
36637
|
// ../node_modules/jose/dist/webapi/lib/type_checks.js
|
|
36638
|
+
function assertUint8Array(input, label) {
|
|
36639
|
+
if (!(input instanceof Uint8Array)) {
|
|
36640
|
+
throw new TypeError(`${label} must be an instance of Uint8Array`);
|
|
36641
|
+
}
|
|
36642
|
+
}
|
|
36639
36643
|
function isObject(input) {
|
|
36640
36644
|
if (typeof input !== "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
36641
36645
|
return false;
|
|
36642
36646
|
}
|
|
36643
36647
|
const prototype = Object.getPrototypeOf(input);
|
|
36644
|
-
|
|
36645
|
-
|
|
36646
|
-
|
|
36647
|
-
|
|
36648
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
36649
|
-
proto = Object.getPrototypeOf(proto);
|
|
36650
|
-
}
|
|
36651
|
-
return prototype === proto;
|
|
36648
|
+
return prototype === null || Object.getPrototypeOf(prototype) === null;
|
|
36649
|
+
}
|
|
36650
|
+
function isJwkSet(input) {
|
|
36651
|
+
return isObject(input) && Array.isArray(input.keys) && Array.from(input.keys).every(isObject);
|
|
36652
36652
|
}
|
|
36653
36653
|
function isDisjoint(...headers) {
|
|
36654
36654
|
const parameters = /* @__PURE__ */ new Set();
|
|
@@ -36664,19 +36664,14 @@ return true;`);
|
|
|
36664
36664
|
}
|
|
36665
36665
|
return true;
|
|
36666
36666
|
}
|
|
36667
|
-
var isJWK, isPrivateJWK, isPublicJWK, isSecretJWK;
|
|
36668
36667
|
var init_type_checks = __esm({
|
|
36669
36668
|
"../node_modules/jose/dist/webapi/lib/type_checks.js"() {
|
|
36670
|
-
isJWK = (key) => isObject(key) && typeof key.kty === "string";
|
|
36671
|
-
isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
36672
|
-
isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
|
|
36673
|
-
isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
36674
36669
|
}
|
|
36675
36670
|
});
|
|
36676
36671
|
|
|
36677
36672
|
// ../node_modules/jose/dist/webapi/lib/helpers.js
|
|
36678
36673
|
function assertNotSet(value, name) {
|
|
36679
|
-
if (value) {
|
|
36674
|
+
if (value !== void 0) {
|
|
36680
36675
|
throw new TypeError(`${name} can only be called once`);
|
|
36681
36676
|
}
|
|
36682
36677
|
}
|
|
@@ -36743,18 +36738,47 @@ return true;`);
|
|
|
36743
36738
|
}
|
|
36744
36739
|
});
|
|
36745
36740
|
|
|
36741
|
+
// ../node_modules/jose/dist/webapi/lib/jwk_metadata.js
|
|
36742
|
+
function snapshotJwk(jwk) {
|
|
36743
|
+
return { __proto__: null, ...jwk };
|
|
36744
|
+
}
|
|
36745
|
+
function normalizeJwk(jwk) {
|
|
36746
|
+
const normalized = snapshotJwk(jwk);
|
|
36747
|
+
if (normalized.ext !== void 0 && typeof normalized.ext !== "boolean") {
|
|
36748
|
+
throw new TypeError('"ext" (Extractable) Parameter must be a boolean');
|
|
36749
|
+
}
|
|
36750
|
+
if (normalized.key_ops !== void 0) {
|
|
36751
|
+
const value = normalized.key_ops;
|
|
36752
|
+
const keyOps = Array.isArray(value) ? [...value] : void 0;
|
|
36753
|
+
if (!keyOps || keyOps.some((operation) => typeof operation !== "string") || new Set(keyOps).size !== keyOps.length) {
|
|
36754
|
+
throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');
|
|
36755
|
+
}
|
|
36756
|
+
normalized.key_ops = keyOps;
|
|
36757
|
+
}
|
|
36758
|
+
return normalized;
|
|
36759
|
+
}
|
|
36760
|
+
var init_jwk_metadata = __esm({
|
|
36761
|
+
"../node_modules/jose/dist/webapi/lib/jwk_metadata.js"() {
|
|
36762
|
+
}
|
|
36763
|
+
});
|
|
36764
|
+
|
|
36746
36765
|
// ../node_modules/jose/dist/webapi/lib/key.js
|
|
36747
36766
|
function checkKeyType(entry, key, usage) {
|
|
36748
36767
|
const { alg, secret } = entry;
|
|
36749
36768
|
const privateKey = usage === "decrypt" || usage === "sign";
|
|
36750
36769
|
if (secret && key instanceof Uint8Array)
|
|
36751
36770
|
return [BYTES, key];
|
|
36752
|
-
if (
|
|
36753
|
-
|
|
36771
|
+
if (isObject(key)) {
|
|
36772
|
+
const normalized = normalizeJwk(key);
|
|
36773
|
+
if (typeof normalized.kty !== "string") {
|
|
36774
|
+
throw new TypeError(secret ? withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array") : withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
36775
|
+
}
|
|
36776
|
+
const valid = 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);
|
|
36777
|
+
if (!valid) {
|
|
36754
36778
|
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`);
|
|
36755
36779
|
}
|
|
36756
|
-
jwkMatchesOp(entry,
|
|
36757
|
-
return [JWK, key];
|
|
36780
|
+
jwkMatchesOp(entry, normalized, usage);
|
|
36781
|
+
return [JWK, key, normalized];
|
|
36758
36782
|
}
|
|
36759
36783
|
if (!isKeyLike(key)) {
|
|
36760
36784
|
throw new TypeError(secret ? withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array") : withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
@@ -36782,7 +36806,7 @@ return true;`);
|
|
|
36782
36806
|
if (entry) {
|
|
36783
36807
|
entry[alg] = value;
|
|
36784
36808
|
} else {
|
|
36785
|
-
cache.set(key, {
|
|
36809
|
+
cache.set(key, { [alg]: value });
|
|
36786
36810
|
}
|
|
36787
36811
|
}
|
|
36788
36812
|
return value ?? entry?.[alg];
|
|
@@ -36795,8 +36819,9 @@ return true;`);
|
|
|
36795
36819
|
return tagged[1];
|
|
36796
36820
|
case JWK: {
|
|
36797
36821
|
const key2 = tagged[1];
|
|
36798
|
-
|
|
36799
|
-
|
|
36822
|
+
const normalized = tagged[2];
|
|
36823
|
+
if (normalized.kty === "oct") {
|
|
36824
|
+
return decode(normalized.k);
|
|
36800
36825
|
}
|
|
36801
36826
|
if (!Object.isFrozen(key2)) {
|
|
36802
36827
|
const { key_ops } = key2;
|
|
@@ -36804,7 +36829,7 @@ return true;`);
|
|
|
36804
36829
|
Object.freeze(key_ops);
|
|
36805
36830
|
Object.freeze(key2);
|
|
36806
36831
|
}
|
|
36807
|
-
return handleJWK(key2,
|
|
36832
|
+
return handleJWK(key2, normalized, entry);
|
|
36808
36833
|
}
|
|
36809
36834
|
case KEYOBJECT: {
|
|
36810
36835
|
const keyObject = tagged[1];
|
|
@@ -36826,6 +36851,7 @@ return true;`);
|
|
|
36826
36851
|
init_type_checks();
|
|
36827
36852
|
init_base64url();
|
|
36828
36853
|
init_jwk_to_key();
|
|
36854
|
+
init_jwk_metadata();
|
|
36829
36855
|
tag = (key) => key[Symbol.toStringTag];
|
|
36830
36856
|
jwkMatchesOp = (entry, key, usage) => {
|
|
36831
36857
|
const { alg } = entry;
|
|
@@ -37092,7 +37118,7 @@ return true;`);
|
|
|
37092
37118
|
if (encryptedKey !== void 0)
|
|
37093
37119
|
throw new JWEInvalid("Encountered unexpected JWE Encrypted Key");
|
|
37094
37120
|
}
|
|
37095
|
-
async function decryptKeyManagement(alg, enc, key, encryptedKey, joseHeader,
|
|
37121
|
+
async function decryptKeyManagement(alg, enc, key, encryptedKey, joseHeader, maxPBES2Count) {
|
|
37096
37122
|
const entry = jweAlgorithm(alg);
|
|
37097
37123
|
if (alg === "dir") {
|
|
37098
37124
|
assertNoEncryptedKey(encryptedKey);
|
|
@@ -37134,7 +37160,7 @@ return true;`);
|
|
|
37134
37160
|
assertEncryptedKey(encryptedKey);
|
|
37135
37161
|
if (typeof joseHeader.p2c !== "number")
|
|
37136
37162
|
throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
|
|
37137
|
-
const p2cLimit =
|
|
37163
|
+
const p2cLimit = maxPBES2Count || 1e4;
|
|
37138
37164
|
if (joseHeader.p2c > p2cLimit)
|
|
37139
37165
|
throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
|
|
37140
37166
|
if (typeof joseHeader.p2s !== "string")
|
|
@@ -37172,8 +37198,14 @@ return true;`);
|
|
|
37172
37198
|
case "ECDH": {
|
|
37173
37199
|
assertEcdhKey(key);
|
|
37174
37200
|
const { apu, apv } = providedParameters;
|
|
37201
|
+
if (apu !== void 0) {
|
|
37202
|
+
assertUint8Array(apu, '"apu"');
|
|
37203
|
+
}
|
|
37204
|
+
if (apv !== void 0) {
|
|
37205
|
+
assertUint8Array(apv, '"apv"');
|
|
37206
|
+
}
|
|
37175
37207
|
let ephemeralKey;
|
|
37176
|
-
if (providedParameters.epk) {
|
|
37208
|
+
if (providedParameters.epk !== void 0) {
|
|
37177
37209
|
ephemeralKey = await prepareKey(entry, providedParameters.epk, "decrypt");
|
|
37178
37210
|
} else {
|
|
37179
37211
|
ephemeralKey = (await crypto.subtle.generateKey(key.algorithm, true, ["deriveBits"])).privateKey;
|
|
@@ -37291,16 +37323,49 @@ return true;`);
|
|
|
37291
37323
|
}
|
|
37292
37324
|
return protectedHeader.crit;
|
|
37293
37325
|
}
|
|
37326
|
+
function validateB64(protectedHeader, extensions) {
|
|
37327
|
+
if (extensions.includes("b64")) {
|
|
37328
|
+
const b64 = protectedHeader.b64;
|
|
37329
|
+
if (typeof b64 !== "boolean") {
|
|
37330
|
+
throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
37331
|
+
}
|
|
37332
|
+
return b64;
|
|
37333
|
+
}
|
|
37334
|
+
return true;
|
|
37335
|
+
}
|
|
37336
|
+
function serializeJoseHeader(Err, header) {
|
|
37337
|
+
let serialized;
|
|
37338
|
+
let parsed;
|
|
37339
|
+
try {
|
|
37340
|
+
serialized = JSON.stringify(header);
|
|
37341
|
+
parsed = JSON.parse(serialized);
|
|
37342
|
+
} catch (cause) {
|
|
37343
|
+
throw new Err("JOSE Header is not valid JSON", { cause });
|
|
37344
|
+
}
|
|
37345
|
+
if (!isObject(parsed)) {
|
|
37346
|
+
throw new Err("JOSE Header is not a JSON object");
|
|
37347
|
+
}
|
|
37348
|
+
return [parsed, serialized];
|
|
37349
|
+
}
|
|
37294
37350
|
var JWS_RECOGNIZED, JWE_RECOGNIZED;
|
|
37295
37351
|
var init_options = __esm({
|
|
37296
37352
|
"../node_modules/jose/dist/webapi/lib/options.js"() {
|
|
37297
37353
|
init_errors();
|
|
37354
|
+
init_type_checks();
|
|
37298
37355
|
JWS_RECOGNIZED = { __proto__: null, b64: true };
|
|
37299
37356
|
JWE_RECOGNIZED = { __proto__: null };
|
|
37300
37357
|
}
|
|
37301
37358
|
});
|
|
37302
37359
|
|
|
37303
37360
|
// ../node_modules/jose/dist/webapi/lib/deflate.js
|
|
37361
|
+
function validateZip(joseHeader, protectedHeader) {
|
|
37362
|
+
if (joseHeader.zip !== void 0 && joseHeader.zip !== "DEF") {
|
|
37363
|
+
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');
|
|
37364
|
+
}
|
|
37365
|
+
if (joseHeader.zip !== void 0 && !protectedHeader?.zip) {
|
|
37366
|
+
throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');
|
|
37367
|
+
}
|
|
37368
|
+
}
|
|
37304
37369
|
function supported(name) {
|
|
37305
37370
|
if (typeof globalThis[name] === "undefined") {
|
|
37306
37371
|
throw new JOSENotSupported(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${name} API.`);
|
|
@@ -37355,34 +37420,71 @@ return true;`);
|
|
|
37355
37420
|
});
|
|
37356
37421
|
|
|
37357
37422
|
// ../node_modules/jose/dist/webapi/lib/jwe_decrypt.js
|
|
37358
|
-
function
|
|
37359
|
-
const { ciphertext, protected: encodedProtected, unprotected: unprotected2 } = jwe;
|
|
37360
|
-
if (
|
|
37423
|
+
function snapshotSharedJWE(jwe) {
|
|
37424
|
+
const { aad, ciphertext, iv, protected: encodedProtected, tag: tag2, unprotected: unprotected2 } = jwe;
|
|
37425
|
+
if (iv !== void 0 && typeof iv !== "string") {
|
|
37361
37426
|
throw new JWEInvalid("JWE Initialization Vector incorrect type");
|
|
37362
37427
|
}
|
|
37363
37428
|
if (typeof ciphertext !== "string") {
|
|
37364
37429
|
throw new JWEInvalid("JWE Ciphertext missing or incorrect type");
|
|
37365
37430
|
}
|
|
37366
|
-
if (
|
|
37431
|
+
if (tag2 !== void 0 && typeof tag2 !== "string") {
|
|
37367
37432
|
throw new JWEInvalid("JWE Authentication Tag incorrect type");
|
|
37368
37433
|
}
|
|
37369
37434
|
if (encodedProtected !== void 0 && typeof encodedProtected !== "string") {
|
|
37370
37435
|
throw new JWEInvalid("JWE Protected Header incorrect type");
|
|
37371
37436
|
}
|
|
37372
|
-
if (
|
|
37437
|
+
if (aad !== void 0 && (typeof aad !== "string" || !aad)) {
|
|
37373
37438
|
throw new JWEInvalid("JWE AAD incorrect type");
|
|
37374
37439
|
}
|
|
37375
37440
|
if (unprotected2 !== void 0 && !isObject(unprotected2)) {
|
|
37376
37441
|
throw new JWEInvalid("JWE Shared Unprotected Header incorrect type");
|
|
37377
37442
|
}
|
|
37443
|
+
return {
|
|
37444
|
+
aad,
|
|
37445
|
+
ciphertext,
|
|
37446
|
+
iv,
|
|
37447
|
+
protected: encodedProtected,
|
|
37448
|
+
tag: tag2,
|
|
37449
|
+
unprotected: unprotected2 === void 0 ? void 0 : { ...unprotected2 }
|
|
37450
|
+
};
|
|
37451
|
+
}
|
|
37452
|
+
function snapshotRecipientJWE(recipient) {
|
|
37453
|
+
let header;
|
|
37454
|
+
let headerAlg;
|
|
37455
|
+
try {
|
|
37456
|
+
const { header: inputHeader } = recipient;
|
|
37457
|
+
if (isObject(inputHeader)) {
|
|
37458
|
+
headerAlg = inputHeader.alg;
|
|
37459
|
+
const parameters = Object.keys(inputHeader);
|
|
37460
|
+
if (!parameters.includes("alg"))
|
|
37461
|
+
headerAlg = void 0;
|
|
37462
|
+
header = Object.fromEntries(parameters.map((parameter) => [
|
|
37463
|
+
parameter,
|
|
37464
|
+
parameter === "alg" ? headerAlg : inputHeader[parameter]
|
|
37465
|
+
]));
|
|
37466
|
+
} else {
|
|
37467
|
+
header = inputHeader;
|
|
37468
|
+
}
|
|
37469
|
+
} catch (error) {
|
|
37470
|
+
return [void 0, headerAlg, error];
|
|
37471
|
+
}
|
|
37472
|
+
try {
|
|
37473
|
+
const { encrypted_key: encryptedKey } = recipient;
|
|
37474
|
+
return [{ encrypted_key: encryptedKey, header }, headerAlg];
|
|
37475
|
+
} catch (error) {
|
|
37476
|
+
return [void 0, headerAlg, error];
|
|
37477
|
+
}
|
|
37378
37478
|
}
|
|
37379
37479
|
function checkRecipient(jwe) {
|
|
37380
37480
|
const { encrypted_key: encryptedKey, header } = jwe;
|
|
37381
37481
|
if (encryptedKey !== void 0 && typeof encryptedKey !== "string") {
|
|
37382
37482
|
throw new JWEInvalid("JWE Encrypted Key incorrect type");
|
|
37383
37483
|
}
|
|
37384
|
-
if (header !== void 0
|
|
37385
|
-
|
|
37484
|
+
if (header !== void 0) {
|
|
37485
|
+
if (!isObject(header)) {
|
|
37486
|
+
throw new JWEInvalid("JWE Per-Recipient Unprotected Header incorrect type");
|
|
37487
|
+
}
|
|
37386
37488
|
}
|
|
37387
37489
|
if (jwe.protected === void 0 && header === void 0 && jwe.unprotected === void 0) {
|
|
37388
37490
|
throw new JWEInvalid("JOSE Header missing");
|
|
@@ -37391,7 +37493,7 @@ return true;`);
|
|
|
37391
37493
|
function shareJWE(jwe) {
|
|
37392
37494
|
const { protected: encodedProtected, ciphertext, iv, tag: tag2, aad } = jwe;
|
|
37393
37495
|
let parsedProt;
|
|
37394
|
-
if (encodedProtected) {
|
|
37496
|
+
if (encodedProtected !== void 0) {
|
|
37395
37497
|
parsedProt = parseJoseHeader(encodedProtected, JWEInvalid, "JWE Protected Header is invalid");
|
|
37396
37498
|
}
|
|
37397
37499
|
const protectedHeader = encodedProtected !== void 0 ? encode(encodedProtected) : new Uint8Array();
|
|
@@ -37428,13 +37530,14 @@ return true;`);
|
|
|
37428
37530
|
return [
|
|
37429
37531
|
options && validateAlgorithms("keyManagementAlgorithms", options.keyManagementAlgorithms),
|
|
37430
37532
|
options && validateAlgorithms("contentEncryptionAlgorithms", options.contentEncryptionAlgorithms),
|
|
37431
|
-
options
|
|
37533
|
+
options?.crit,
|
|
37534
|
+
options?.maxPBES2Count,
|
|
37535
|
+
options?.maxDecompressedLength
|
|
37432
37536
|
];
|
|
37433
37537
|
}
|
|
37434
37538
|
async function decryptRecipient(jwe, token, shared, key) {
|
|
37435
|
-
const [
|
|
37436
|
-
const
|
|
37437
|
-
const { encrypted_key: encodedKey, header, unprotected: unprotected2 } = jwe;
|
|
37539
|
+
const [parsedProt] = token;
|
|
37540
|
+
const { header, unprotected: unprotected2 } = jwe;
|
|
37438
37541
|
let joseHeader;
|
|
37439
37542
|
if (header !== void 0 || unprotected2 !== void 0) {
|
|
37440
37543
|
if (!isDisjoint(parsedProt, header, unprotected2)) {
|
|
@@ -37444,13 +37547,14 @@ return true;`);
|
|
|
37444
37547
|
} else {
|
|
37445
37548
|
joseHeader = parsedProt ?? {};
|
|
37446
37549
|
}
|
|
37447
|
-
|
|
37448
|
-
|
|
37449
|
-
|
|
37450
|
-
|
|
37451
|
-
|
|
37452
|
-
|
|
37453
|
-
|
|
37550
|
+
return decryptRecipientCore(jwe, token, shared, key, joseHeader);
|
|
37551
|
+
}
|
|
37552
|
+
async function decryptRecipientCore(jwe, token, shared, key, joseHeader) {
|
|
37553
|
+
const [keyManagementAlgorithms, contentEncryptionAlgorithms, crit, maxPBES2Count, maxDecompressedLength] = shared;
|
|
37554
|
+
const [parsedProt, ciphertext, iv, tag2, additionalData] = token;
|
|
37555
|
+
const { encrypted_key: encodedKey } = jwe;
|
|
37556
|
+
validateCrit(JWEInvalid, JWE_RECOGNIZED, crit, parsedProt, joseHeader);
|
|
37557
|
+
validateZip(joseHeader, parsedProt);
|
|
37454
37558
|
const { alg, enc } = joseHeader;
|
|
37455
37559
|
if (typeof alg !== "string" || !alg) {
|
|
37456
37560
|
throw new JWEInvalid("missing JWE Algorithm (alg) in JWE Header");
|
|
@@ -37478,7 +37582,10 @@ return true;`);
|
|
|
37478
37582
|
const k = await prepareKey(alg === "dir" ? encEntry : algEntry, key, "decrypt");
|
|
37479
37583
|
let cek;
|
|
37480
37584
|
try {
|
|
37481
|
-
cek = await decryptKeyManagement(alg, encEntry, k, encryptedKey, joseHeader,
|
|
37585
|
+
cek = await decryptKeyManagement(alg, encEntry, k, encryptedKey, joseHeader, maxPBES2Count);
|
|
37586
|
+
if (encodedKey !== void 0 && cek instanceof Uint8Array && cek.byteLength << 3 !== encEntry.cekBits) {
|
|
37587
|
+
cek = generateCek(encEntry);
|
|
37588
|
+
}
|
|
37482
37589
|
} catch (err) {
|
|
37483
37590
|
if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {
|
|
37484
37591
|
throw err;
|
|
@@ -37487,14 +37594,14 @@ return true;`);
|
|
|
37487
37594
|
}
|
|
37488
37595
|
let plaintext = await decrypt(encEntry, cek, ciphertext, iv, tag2, additionalData);
|
|
37489
37596
|
if (joseHeader.zip === "DEF") {
|
|
37490
|
-
const
|
|
37491
|
-
if (
|
|
37597
|
+
const decompressionLimit = maxDecompressedLength ?? 25e4;
|
|
37598
|
+
if (decompressionLimit === 0) {
|
|
37492
37599
|
throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
|
|
37493
37600
|
}
|
|
37494
|
-
if (
|
|
37601
|
+
if (decompressionLimit !== Infinity && (!Number.isSafeInteger(decompressionLimit) || decompressionLimit < 1)) {
|
|
37495
37602
|
throw new TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");
|
|
37496
37603
|
}
|
|
37497
|
-
plaintext = await decompress(plaintext,
|
|
37604
|
+
plaintext = await decompress(plaintext, decompressionLimit).catch((cause) => {
|
|
37498
37605
|
if (cause instanceof JWEInvalid)
|
|
37499
37606
|
throw cause;
|
|
37500
37607
|
throw new JWEInvalid("Failed to decompress plaintext", { cause });
|
|
@@ -37516,13 +37623,23 @@ return true;`);
|
|
|
37516
37623
|
if (length !== 5) {
|
|
37517
37624
|
throw new JWEInvalid("Invalid Compact JWE");
|
|
37518
37625
|
}
|
|
37519
|
-
|
|
37626
|
+
const flattened = {
|
|
37520
37627
|
ciphertext,
|
|
37521
37628
|
iv: iv || void 0,
|
|
37522
37629
|
protected: protectedHeader,
|
|
37523
37630
|
tag: tag2 || void 0,
|
|
37524
37631
|
encrypted_key: encryptedKey || void 0
|
|
37525
|
-
}
|
|
37632
|
+
};
|
|
37633
|
+
const parsedProt = parseJoseHeader(protectedHeader, JWEInvalid, "JWE Protected Header is invalid");
|
|
37634
|
+
const protectedBytes = encode(protectedHeader);
|
|
37635
|
+
const token = [
|
|
37636
|
+
parsedProt,
|
|
37637
|
+
decodeBase64url(ciphertext, "ciphertext", JWEInvalid),
|
|
37638
|
+
iv ? decodeBase64url(iv, "iv", JWEInvalid) : void 0,
|
|
37639
|
+
tag2 ? decodeBase64url(tag2, "tag", JWEInvalid) : void 0,
|
|
37640
|
+
protectedBytes
|
|
37641
|
+
];
|
|
37642
|
+
return decryptRecipientCore(flattened, token, shared, key, parsedProt);
|
|
37526
37643
|
}
|
|
37527
37644
|
var init_jwe_decrypt = __esm({
|
|
37528
37645
|
"../node_modules/jose/dist/webapi/lib/jwe_decrypt.js"() {
|
|
@@ -37559,9 +37676,13 @@ return true;`);
|
|
|
37559
37676
|
if (!isObject(jwe)) {
|
|
37560
37677
|
throw new JWEInvalid("Flattened JWE must be an object");
|
|
37561
37678
|
}
|
|
37562
|
-
|
|
37563
|
-
|
|
37564
|
-
|
|
37679
|
+
const shared = snapshotSharedJWE(jwe);
|
|
37680
|
+
const [recipient, , error] = snapshotRecipientJWE(jwe);
|
|
37681
|
+
if (!recipient)
|
|
37682
|
+
throw error;
|
|
37683
|
+
const snapshot = { ...shared, ...recipient };
|
|
37684
|
+
checkRecipient(snapshot);
|
|
37685
|
+
return decryptResult(snapshot, await decryptJWE(snapshot, prepareDecrypt(options), key));
|
|
37565
37686
|
}
|
|
37566
37687
|
var init_decrypt2 = __esm({
|
|
37567
37688
|
"../node_modules/jose/dist/webapi/jwe/flattened/decrypt.js"() {
|
|
@@ -37576,41 +37697,41 @@ return true;`);
|
|
|
37576
37697
|
if (!isObject(jwe)) {
|
|
37577
37698
|
throw new JWEInvalid("General JWE must be an object");
|
|
37578
37699
|
}
|
|
37579
|
-
|
|
37700
|
+
const inputRecipients = jwe.recipients;
|
|
37701
|
+
if (!Array.isArray(inputRecipients)) {
|
|
37580
37702
|
throw new JWEInvalid("JWE Recipients missing or incorrect type");
|
|
37581
37703
|
}
|
|
37582
|
-
|
|
37704
|
+
const recipients = Array.from(inputRecipients);
|
|
37705
|
+
if (!recipients.every(isObject)) {
|
|
37706
|
+
throw new JWEInvalid("JWE Recipients missing or incorrect type");
|
|
37707
|
+
}
|
|
37708
|
+
if (!recipients.length) {
|
|
37583
37709
|
throw new JWEInvalid("JWE Recipients has no members");
|
|
37584
37710
|
}
|
|
37585
37711
|
let shared;
|
|
37712
|
+
let sharedJwe;
|
|
37586
37713
|
let token;
|
|
37587
37714
|
try {
|
|
37588
|
-
checkShared(jwe);
|
|
37589
37715
|
shared = prepareDecrypt(options);
|
|
37590
|
-
|
|
37716
|
+
sharedJwe = snapshotSharedJWE(jwe);
|
|
37717
|
+
token = shareJWE(sharedJwe);
|
|
37591
37718
|
} catch {
|
|
37592
37719
|
throw new JWEDecryptionFailed();
|
|
37593
37720
|
}
|
|
37594
|
-
|
|
37595
|
-
|
|
37596
|
-
|
|
37721
|
+
const recipientSnapshots = recipients.map((recipient) => snapshotRecipientJWE(recipient));
|
|
37722
|
+
if (recipients.length > 1) {
|
|
37723
|
+
for (const [, headerAlg] of recipientSnapshots) {
|
|
37724
|
+
const alg = token[0]?.alg ?? headerAlg ?? sharedJwe.unprotected?.alg;
|
|
37597
37725
|
if (alg === "dir" || alg === "ECDH-ES") {
|
|
37598
37726
|
throw new JWEInvalid(`"${alg}" alg may only have a single recipient`);
|
|
37599
37727
|
}
|
|
37600
37728
|
}
|
|
37601
37729
|
}
|
|
37602
|
-
for (const recipient of
|
|
37730
|
+
for (const [recipient] of recipientSnapshots) {
|
|
37731
|
+
if (!recipient)
|
|
37732
|
+
continue;
|
|
37603
37733
|
try {
|
|
37604
|
-
const flattened = {
|
|
37605
|
-
aad: jwe.aad,
|
|
37606
|
-
ciphertext: jwe.ciphertext,
|
|
37607
|
-
encrypted_key: recipient.encrypted_key,
|
|
37608
|
-
header: recipient.header,
|
|
37609
|
-
iv: jwe.iv,
|
|
37610
|
-
protected: jwe.protected,
|
|
37611
|
-
tag: jwe.tag,
|
|
37612
|
-
unprotected: jwe.unprotected
|
|
37613
|
-
};
|
|
37734
|
+
const flattened = { ...sharedJwe, ...recipient };
|
|
37614
37735
|
checkRecipient(flattened);
|
|
37615
37736
|
return decryptResult(flattened, await decryptRecipient(flattened, token, shared, key));
|
|
37616
37737
|
} catch {
|
|
@@ -37627,23 +37748,46 @@ return true;`);
|
|
|
37627
37748
|
});
|
|
37628
37749
|
|
|
37629
37750
|
// ../node_modules/jose/dist/webapi/lib/jwe_encrypt.js
|
|
37630
|
-
function
|
|
37631
|
-
const [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, , , , , crit] = input;
|
|
37751
|
+
function checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader) {
|
|
37632
37752
|
if (!isDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader)) {
|
|
37633
37753
|
throw new JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");
|
|
37634
37754
|
}
|
|
37755
|
+
}
|
|
37756
|
+
function checkEncryptHeaders(input) {
|
|
37757
|
+
let [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, aad, cek, iv, keyManagementParameters, crit] = input;
|
|
37758
|
+
if (aad !== void 0) {
|
|
37759
|
+
assertUint8Array(aad, "JWE Additional Authenticated Data");
|
|
37760
|
+
}
|
|
37761
|
+
if (cek !== void 0) {
|
|
37762
|
+
assertUint8Array(cek, "JWE Content Encryption Key");
|
|
37763
|
+
}
|
|
37764
|
+
if (iv !== void 0) {
|
|
37765
|
+
assertUint8Array(iv, "JWE Initialization Vector");
|
|
37766
|
+
}
|
|
37767
|
+
if (protectedHeader !== void 0) {
|
|
37768
|
+
protectedHeader = serializeJoseHeader(JWEInvalid, protectedHeader)[0];
|
|
37769
|
+
input[1] = protectedHeader;
|
|
37770
|
+
}
|
|
37771
|
+
if (unprotectedHeader !== void 0) {
|
|
37772
|
+
unprotectedHeader = serializeJoseHeader(JWEInvalid, unprotectedHeader)[0];
|
|
37773
|
+
input[2] = unprotectedHeader;
|
|
37774
|
+
}
|
|
37775
|
+
if (sharedUnprotectedHeader !== void 0) {
|
|
37776
|
+
sharedUnprotectedHeader = serializeJoseHeader(JWEInvalid, sharedUnprotectedHeader)[0];
|
|
37777
|
+
input[3] = sharedUnprotectedHeader;
|
|
37778
|
+
}
|
|
37779
|
+
if (keyManagementParameters !== void 0 && !isObject(keyManagementParameters)) {
|
|
37780
|
+
throw new TypeError("JWE Key Management Parameters must be an object");
|
|
37781
|
+
}
|
|
37782
|
+
checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
|
|
37635
37783
|
const joseHeader = {
|
|
37636
37784
|
...protectedHeader,
|
|
37637
37785
|
...unprotectedHeader,
|
|
37638
37786
|
...sharedUnprotectedHeader
|
|
37639
37787
|
};
|
|
37788
|
+
validateCritDuplicates(JWEInvalid, protectedHeader);
|
|
37640
37789
|
validateCrit(JWEInvalid, JWE_RECOGNIZED, crit, protectedHeader, joseHeader);
|
|
37641
|
-
|
|
37642
|
-
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');
|
|
37643
|
-
}
|
|
37644
|
-
if (joseHeader.zip !== void 0 && !protectedHeader?.zip) {
|
|
37645
|
-
throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');
|
|
37646
|
-
}
|
|
37790
|
+
validateZip(joseHeader, protectedHeader);
|
|
37647
37791
|
const { alg, enc } = joseHeader;
|
|
37648
37792
|
if (typeof alg !== "string" || !alg) {
|
|
37649
37793
|
throw new JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');
|
|
@@ -37670,6 +37814,7 @@ return true;`);
|
|
|
37670
37814
|
} else {
|
|
37671
37815
|
protectedHeader = protectedHeader ? { ...protectedHeader, ...parameters } : parameters;
|
|
37672
37816
|
}
|
|
37817
|
+
checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
|
|
37673
37818
|
}
|
|
37674
37819
|
let protectedHeaderS;
|
|
37675
37820
|
let protectedHeaderB;
|
|
@@ -37721,7 +37866,14 @@ return true;`);
|
|
|
37721
37866
|
}
|
|
37722
37867
|
return jwe;
|
|
37723
37868
|
}
|
|
37724
|
-
async function createJWE(input, key) {
|
|
37869
|
+
async function createJWE(input, key, options) {
|
|
37870
|
+
if (!input[1] && !input[2] && !input[3]) {
|
|
37871
|
+
throw new JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");
|
|
37872
|
+
}
|
|
37873
|
+
if (options !== void 0) {
|
|
37874
|
+
input[8] = options?.crit;
|
|
37875
|
+
input[9] = options ? unprotected in options : false;
|
|
37876
|
+
}
|
|
37725
37877
|
return encryptJWE(input, checkEncryptHeaders(input), key);
|
|
37726
37878
|
}
|
|
37727
37879
|
var init_jwe_encrypt = __esm({
|
|
@@ -37736,93 +37888,7 @@ return true;`);
|
|
|
37736
37888
|
init_key();
|
|
37737
37889
|
init_jwe_algorithms();
|
|
37738
37890
|
init_deflate();
|
|
37739
|
-
}
|
|
37740
|
-
});
|
|
37741
|
-
|
|
37742
|
-
// ../node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
|
|
37743
|
-
var _plaintext, _protectedHeader, _sharedUnprotectedHeader, _unprotectedHeader, _aad, _cek, _iv, _keyManagementParameters, FlattenedEncrypt;
|
|
37744
|
-
var init_encrypt = __esm({
|
|
37745
|
-
"../node_modules/jose/dist/webapi/jwe/flattened/encrypt.js"() {
|
|
37746
37891
|
init_helpers();
|
|
37747
|
-
init_errors();
|
|
37748
|
-
init_jwe_encrypt();
|
|
37749
|
-
init_options();
|
|
37750
|
-
FlattenedEncrypt = class {
|
|
37751
|
-
constructor(plaintext) {
|
|
37752
|
-
__privateAdd(this, _plaintext);
|
|
37753
|
-
__privateAdd(this, _protectedHeader);
|
|
37754
|
-
__privateAdd(this, _sharedUnprotectedHeader);
|
|
37755
|
-
__privateAdd(this, _unprotectedHeader);
|
|
37756
|
-
__privateAdd(this, _aad);
|
|
37757
|
-
__privateAdd(this, _cek);
|
|
37758
|
-
__privateAdd(this, _iv);
|
|
37759
|
-
__privateAdd(this, _keyManagementParameters);
|
|
37760
|
-
if (!(plaintext instanceof Uint8Array)) {
|
|
37761
|
-
throw new TypeError("plaintext must be an instance of Uint8Array");
|
|
37762
|
-
}
|
|
37763
|
-
__privateSet(this, _plaintext, plaintext);
|
|
37764
|
-
}
|
|
37765
|
-
setKeyManagementParameters(parameters) {
|
|
37766
|
-
assertNotSet(__privateGet(this, _keyManagementParameters), "setKeyManagementParameters");
|
|
37767
|
-
__privateSet(this, _keyManagementParameters, parameters);
|
|
37768
|
-
return this;
|
|
37769
|
-
}
|
|
37770
|
-
setProtectedHeader(protectedHeader) {
|
|
37771
|
-
assertNotSet(__privateGet(this, _protectedHeader), "setProtectedHeader");
|
|
37772
|
-
__privateSet(this, _protectedHeader, protectedHeader);
|
|
37773
|
-
return this;
|
|
37774
|
-
}
|
|
37775
|
-
setSharedUnprotectedHeader(sharedUnprotectedHeader) {
|
|
37776
|
-
assertNotSet(__privateGet(this, _sharedUnprotectedHeader), "setSharedUnprotectedHeader");
|
|
37777
|
-
__privateSet(this, _sharedUnprotectedHeader, sharedUnprotectedHeader);
|
|
37778
|
-
return this;
|
|
37779
|
-
}
|
|
37780
|
-
setUnprotectedHeader(unprotectedHeader) {
|
|
37781
|
-
assertNotSet(__privateGet(this, _unprotectedHeader), "setUnprotectedHeader");
|
|
37782
|
-
__privateSet(this, _unprotectedHeader, unprotectedHeader);
|
|
37783
|
-
return this;
|
|
37784
|
-
}
|
|
37785
|
-
setAdditionalAuthenticatedData(aad) {
|
|
37786
|
-
__privateSet(this, _aad, aad);
|
|
37787
|
-
return this;
|
|
37788
|
-
}
|
|
37789
|
-
setContentEncryptionKey(cek) {
|
|
37790
|
-
assertNotSet(__privateGet(this, _cek), "setContentEncryptionKey");
|
|
37791
|
-
__privateSet(this, _cek, cek);
|
|
37792
|
-
return this;
|
|
37793
|
-
}
|
|
37794
|
-
setInitializationVector(iv) {
|
|
37795
|
-
assertNotSet(__privateGet(this, _iv), "setInitializationVector");
|
|
37796
|
-
__privateSet(this, _iv, iv);
|
|
37797
|
-
return this;
|
|
37798
|
-
}
|
|
37799
|
-
async encrypt(key, options) {
|
|
37800
|
-
if (!__privateGet(this, _protectedHeader) && !__privateGet(this, _unprotectedHeader) && !__privateGet(this, _sharedUnprotectedHeader)) {
|
|
37801
|
-
throw new JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");
|
|
37802
|
-
}
|
|
37803
|
-
validateCritDuplicates(JWEInvalid, __privateGet(this, _protectedHeader));
|
|
37804
|
-
return createJWE([
|
|
37805
|
-
__privateGet(this, _plaintext),
|
|
37806
|
-
__privateGet(this, _protectedHeader),
|
|
37807
|
-
__privateGet(this, _unprotectedHeader),
|
|
37808
|
-
__privateGet(this, _sharedUnprotectedHeader),
|
|
37809
|
-
__privateGet(this, _aad),
|
|
37810
|
-
__privateGet(this, _cek),
|
|
37811
|
-
__privateGet(this, _iv),
|
|
37812
|
-
__privateGet(this, _keyManagementParameters),
|
|
37813
|
-
options?.crit,
|
|
37814
|
-
options ? unprotected in options : false
|
|
37815
|
-
], key);
|
|
37816
|
-
}
|
|
37817
|
-
};
|
|
37818
|
-
_plaintext = new WeakMap();
|
|
37819
|
-
_protectedHeader = new WeakMap();
|
|
37820
|
-
_sharedUnprotectedHeader = new WeakMap();
|
|
37821
|
-
_unprotectedHeader = new WeakMap();
|
|
37822
|
-
_aad = new WeakMap();
|
|
37823
|
-
_cek = new WeakMap();
|
|
37824
|
-
_iv = new WeakMap();
|
|
37825
|
-
_keyManagementParameters = new WeakMap();
|
|
37826
37892
|
}
|
|
37827
37893
|
});
|
|
37828
37894
|
|
|
@@ -37838,19 +37904,18 @@ return true;`);
|
|
|
37838
37904
|
if (header)
|
|
37839
37905
|
recipient.header = header;
|
|
37840
37906
|
}
|
|
37841
|
-
var _parent, IndividualRecipient,
|
|
37842
|
-
var
|
|
37907
|
+
var _parent, IndividualRecipient, _plaintext, _recipients, _protectedHeader, _unprotectedHeader, _aad, GeneralEncrypt;
|
|
37908
|
+
var init_encrypt = __esm({
|
|
37843
37909
|
"../node_modules/jose/dist/webapi/jwe/general/encrypt.js"() {
|
|
37844
|
-
init_encrypt();
|
|
37845
37910
|
init_helpers();
|
|
37846
37911
|
init_errors();
|
|
37847
37912
|
init_content_encryption();
|
|
37848
37913
|
init_key_management();
|
|
37849
37914
|
init_base64url();
|
|
37850
|
-
init_options();
|
|
37851
37915
|
init_jwe_encrypt();
|
|
37852
37916
|
init_key();
|
|
37853
37917
|
init_jwe_algorithms();
|
|
37918
|
+
init_type_checks();
|
|
37854
37919
|
IndividualRecipient = class {
|
|
37855
37920
|
constructor(enc, key, crit) {
|
|
37856
37921
|
__privateAdd(this, _parent);
|
|
@@ -37881,12 +37946,12 @@ return true;`);
|
|
|
37881
37946
|
_parent = new WeakMap();
|
|
37882
37947
|
GeneralEncrypt = class {
|
|
37883
37948
|
constructor(plaintext) {
|
|
37884
|
-
__privateAdd(this,
|
|
37949
|
+
__privateAdd(this, _plaintext);
|
|
37885
37950
|
__privateAdd(this, _recipients, []);
|
|
37886
|
-
__privateAdd(this,
|
|
37887
|
-
__privateAdd(this,
|
|
37888
|
-
__privateAdd(this,
|
|
37889
|
-
__privateSet(this,
|
|
37951
|
+
__privateAdd(this, _protectedHeader);
|
|
37952
|
+
__privateAdd(this, _unprotectedHeader);
|
|
37953
|
+
__privateAdd(this, _aad);
|
|
37954
|
+
__privateSet(this, _plaintext, plaintext);
|
|
37890
37955
|
}
|
|
37891
37956
|
addRecipient(key, options) {
|
|
37892
37957
|
const recipient = new IndividualRecipient(this, key, options?.crit);
|
|
@@ -37894,30 +37959,38 @@ return true;`);
|
|
|
37894
37959
|
return recipient;
|
|
37895
37960
|
}
|
|
37896
37961
|
setProtectedHeader(protectedHeader) {
|
|
37897
|
-
assertNotSet(__privateGet(this,
|
|
37898
|
-
__privateSet(this,
|
|
37962
|
+
assertNotSet(__privateGet(this, _protectedHeader), "setProtectedHeader");
|
|
37963
|
+
__privateSet(this, _protectedHeader, protectedHeader);
|
|
37899
37964
|
return this;
|
|
37900
37965
|
}
|
|
37901
37966
|
setSharedUnprotectedHeader(sharedUnprotectedHeader) {
|
|
37902
|
-
assertNotSet(__privateGet(this,
|
|
37903
|
-
__privateSet(this,
|
|
37967
|
+
assertNotSet(__privateGet(this, _unprotectedHeader), "setSharedUnprotectedHeader");
|
|
37968
|
+
__privateSet(this, _unprotectedHeader, sharedUnprotectedHeader);
|
|
37904
37969
|
return this;
|
|
37905
37970
|
}
|
|
37906
37971
|
setAdditionalAuthenticatedData(aad) {
|
|
37907
|
-
__privateSet(this,
|
|
37972
|
+
__privateSet(this, _aad, aad);
|
|
37908
37973
|
return this;
|
|
37909
37974
|
}
|
|
37910
37975
|
async encrypt() {
|
|
37911
37976
|
if (!__privateGet(this, _recipients).length) {
|
|
37912
37977
|
throw new JWEInvalid("at least one recipient must be added");
|
|
37913
37978
|
}
|
|
37914
|
-
|
|
37915
|
-
throw new TypeError("plaintext must be an instance of Uint8Array");
|
|
37916
|
-
}
|
|
37979
|
+
assertUint8Array(__privateGet(this, _plaintext), "plaintext");
|
|
37917
37980
|
if (__privateGet(this, _recipients).length === 1) {
|
|
37918
|
-
const [
|
|
37919
|
-
const
|
|
37920
|
-
|
|
37981
|
+
const [unprotectedHeader, keyManagementParameters, key, crit] = __privateGet(this, _recipients)[0].state;
|
|
37982
|
+
const flattened = await createJWE([
|
|
37983
|
+
__privateGet(this, _plaintext),
|
|
37984
|
+
__privateGet(this, _protectedHeader),
|
|
37985
|
+
unprotectedHeader,
|
|
37986
|
+
__privateGet(this, _unprotectedHeader),
|
|
37987
|
+
__privateGet(this, _aad),
|
|
37988
|
+
void 0,
|
|
37989
|
+
void 0,
|
|
37990
|
+
keyManagementParameters,
|
|
37991
|
+
crit,
|
|
37992
|
+
false
|
|
37993
|
+
], key);
|
|
37921
37994
|
const jwe2 = {
|
|
37922
37995
|
ciphertext: flattened.ciphertext,
|
|
37923
37996
|
iv: flattened.iv,
|
|
@@ -37929,19 +38002,20 @@ return true;`);
|
|
|
37929
38002
|
copyOptionalMembers(flattened, jwe2, jwe2.recipients[0]);
|
|
37930
38003
|
return jwe2;
|
|
37931
38004
|
}
|
|
37932
|
-
validateCritDuplicates(JWEInvalid, __privateGet(this, _protectedHeader2));
|
|
37933
38005
|
let enc;
|
|
38006
|
+
let protectedHeader = __privateGet(this, _protectedHeader);
|
|
38007
|
+
let sharedUnprotectedHeader = __privateGet(this, _unprotectedHeader);
|
|
37934
38008
|
const inputs = [];
|
|
37935
38009
|
const checked = [];
|
|
37936
38010
|
for (let i = 0; i < __privateGet(this, _recipients).length; i++) {
|
|
37937
38011
|
const recipient = __privateGet(this, _recipients)[i];
|
|
37938
38012
|
const [unprotectedHeader, keyManagementParameters, , crit] = recipient.state;
|
|
37939
38013
|
const input = [
|
|
37940
|
-
__privateGet(this,
|
|
37941
|
-
|
|
38014
|
+
__privateGet(this, _plaintext),
|
|
38015
|
+
protectedHeader,
|
|
37942
38016
|
unprotectedHeader,
|
|
37943
|
-
|
|
37944
|
-
__privateGet(this,
|
|
38017
|
+
sharedUnprotectedHeader,
|
|
38018
|
+
__privateGet(this, _aad),
|
|
37945
38019
|
void 0,
|
|
37946
38020
|
void 0,
|
|
37947
38021
|
keyManagementParameters,
|
|
@@ -37951,6 +38025,10 @@ return true;`);
|
|
|
37951
38025
|
const headers = checkEncryptHeaders(input);
|
|
37952
38026
|
inputs.push(input);
|
|
37953
38027
|
checked.push(headers);
|
|
38028
|
+
if (i === 0) {
|
|
38029
|
+
protectedHeader = input[1];
|
|
38030
|
+
sharedUnprotectedHeader = input[3];
|
|
38031
|
+
}
|
|
37954
38032
|
if (headers[1] === "dir" || headers[1] === "ECDH-ES") {
|
|
37955
38033
|
throw new JWEInvalid(`"${headers[1]}" alg may only have a single recipient`);
|
|
37956
38034
|
}
|
|
@@ -37967,7 +38045,7 @@ return true;`);
|
|
|
37967
38045
|
};
|
|
37968
38046
|
for (let i = 0; i < __privateGet(this, _recipients).length; i++) {
|
|
37969
38047
|
const recipient = __privateGet(this, _recipients)[i];
|
|
37970
|
-
const [
|
|
38048
|
+
const [, keyManagementParameters, key] = recipient.state;
|
|
37971
38049
|
const target = {};
|
|
37972
38050
|
jwe.recipients.push(target);
|
|
37973
38051
|
if (i === 0) {
|
|
@@ -37981,20 +38059,25 @@ return true;`);
|
|
|
37981
38059
|
continue;
|
|
37982
38060
|
}
|
|
37983
38061
|
const [, alg, , encEntry] = checked[i];
|
|
38062
|
+
const unprotectedHeader = inputs[i][2];
|
|
37984
38063
|
const k = await prepareKey(jweAlgorithm(alg), key, "encrypt");
|
|
37985
38064
|
const [, encryptedKey, parameters] = await encryptKeyManagement(alg, encEntry, k, cek, keyManagementParameters);
|
|
37986
38065
|
target.encrypted_key = encode2(encryptedKey);
|
|
37987
|
-
if (unprotectedHeader || parameters)
|
|
37988
|
-
|
|
38066
|
+
if (unprotectedHeader || parameters) {
|
|
38067
|
+
const header = { ...unprotectedHeader, ...parameters };
|
|
38068
|
+
if (parameters)
|
|
38069
|
+
checkDisjoint(inputs[i][1], header, inputs[i][3]);
|
|
38070
|
+
target.header = header;
|
|
38071
|
+
}
|
|
37989
38072
|
}
|
|
37990
38073
|
return jwe;
|
|
37991
38074
|
}
|
|
37992
38075
|
};
|
|
37993
|
-
|
|
38076
|
+
_plaintext = new WeakMap();
|
|
37994
38077
|
_recipients = new WeakMap();
|
|
37995
|
-
|
|
37996
|
-
|
|
37997
|
-
|
|
38078
|
+
_protectedHeader = new WeakMap();
|
|
38079
|
+
_unprotectedHeader = new WeakMap();
|
|
38080
|
+
_aad = new WeakMap();
|
|
37998
38081
|
}
|
|
37999
38082
|
});
|
|
38000
38083
|
|
|
@@ -38110,6 +38193,22 @@ return true;`);
|
|
|
38110
38193
|
});
|
|
38111
38194
|
|
|
38112
38195
|
// ../node_modules/jose/dist/webapi/lib/jws_verify.js
|
|
38196
|
+
function snapshotJws(jws, sharedPayload) {
|
|
38197
|
+
const encodedProtected = jws.protected;
|
|
38198
|
+
const inputHeader = jws.header;
|
|
38199
|
+
const header = isObject(inputHeader) ? { ...inputHeader } : inputHeader;
|
|
38200
|
+
let payload = sharedPayload ? sharedPayload[0] : jws.payload;
|
|
38201
|
+
if (!sharedPayload && payload instanceof Uint8Array) {
|
|
38202
|
+
payload = new Uint8Array(payload);
|
|
38203
|
+
}
|
|
38204
|
+
const signature = jws.signature;
|
|
38205
|
+
const snapshot = { payload, signature };
|
|
38206
|
+
if (encodedProtected !== void 0)
|
|
38207
|
+
snapshot.protected = encodedProtected;
|
|
38208
|
+
if (inputHeader !== void 0)
|
|
38209
|
+
snapshot.header = header;
|
|
38210
|
+
return snapshot;
|
|
38211
|
+
}
|
|
38113
38212
|
function verifyResult(jws, verified) {
|
|
38114
38213
|
const [payload, parsedProt, , key, resolvedKey] = verified;
|
|
38115
38214
|
const result = { payload };
|
|
@@ -38127,12 +38226,22 @@ return true;`);
|
|
|
38127
38226
|
function prepareVerify(options) {
|
|
38128
38227
|
return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
|
|
38129
38228
|
}
|
|
38130
|
-
|
|
38131
|
-
|
|
38132
|
-
|
|
38133
|
-
|
|
38134
|
-
|
|
38229
|
+
function parseProtectedHeader(encodedProtected, parsedProtected = encodedProtected === void 0 ? {} : parseJoseHeader(encodedProtected, JWSInvalid, "JWS Protected Header is invalid")) {
|
|
38230
|
+
return parsedProtected;
|
|
38231
|
+
}
|
|
38232
|
+
function validateJwsHeaders(parsedProt, joseHeader, shared) {
|
|
38233
|
+
const b64 = validateB64(parsedProt, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], parsedProt, joseHeader));
|
|
38234
|
+
const alg = joseHeader.alg;
|
|
38235
|
+
if (typeof alg !== "string" || !alg) {
|
|
38236
|
+
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
38237
|
+
}
|
|
38238
|
+
if (shared[0] && !shared[0].has(alg)) {
|
|
38239
|
+
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
|
|
38135
38240
|
}
|
|
38241
|
+
return [b64, alg];
|
|
38242
|
+
}
|
|
38243
|
+
function parseJwsHeaders(encodedProtected, header, shared, parsedProtected) {
|
|
38244
|
+
const parsedProt = parseProtectedHeader(encodedProtected, parsedProtected);
|
|
38136
38245
|
let joseHeader;
|
|
38137
38246
|
if (header !== void 0) {
|
|
38138
38247
|
if (!isDisjoint(parsedProt, header)) {
|
|
@@ -38142,50 +38251,51 @@ return true;`);
|
|
|
38142
38251
|
} else {
|
|
38143
38252
|
joseHeader = parsedProt;
|
|
38144
38253
|
}
|
|
38145
|
-
|
|
38146
|
-
|
|
38147
|
-
|
|
38148
|
-
|
|
38149
|
-
|
|
38150
|
-
|
|
38151
|
-
}
|
|
38152
|
-
}
|
|
38153
|
-
const { alg } = joseHeader;
|
|
38154
|
-
if (typeof alg !== "string" || !alg) {
|
|
38155
|
-
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
38156
|
-
}
|
|
38157
|
-
if (shared[0] && !shared[0].has(alg)) {
|
|
38158
|
-
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
|
|
38254
|
+
return [parsedProt, joseHeader, ...validateJwsHeaders(parsedProt, joseHeader, shared)];
|
|
38255
|
+
}
|
|
38256
|
+
function encodeJsonUnencodedPayload(payload) {
|
|
38257
|
+
const invalid2 = /[\p{Cs}\p{Cn}]/u.exec(payload)?.[0];
|
|
38258
|
+
if (invalid2 !== void 0) {
|
|
38259
|
+
throw new JWSInvalid(/\p{Cs}/u.test(invalid2) ? "JWS Payload must be a well-formed Unicode string" : "JWS Payload must not contain unassigned Unicode code points");
|
|
38159
38260
|
}
|
|
38160
|
-
|
|
38161
|
-
|
|
38162
|
-
|
|
38163
|
-
|
|
38164
|
-
|
|
38165
|
-
|
|
38261
|
+
return encoder.encode(payload);
|
|
38262
|
+
}
|
|
38263
|
+
function encodeCompactUnencodedPayload(payload) {
|
|
38264
|
+
try {
|
|
38265
|
+
return encode(payload);
|
|
38266
|
+
} catch {
|
|
38267
|
+
throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters");
|
|
38166
38268
|
}
|
|
38269
|
+
}
|
|
38270
|
+
async function verifyPrepared(jws, shared, key, encodedProtected, parsedProt, alg, signingPayload) {
|
|
38167
38271
|
let resolvedKey = false;
|
|
38168
38272
|
if (typeof key === "function") {
|
|
38169
38273
|
key = await key(parsedProt, jws);
|
|
38170
38274
|
resolvedKey = true;
|
|
38171
38275
|
}
|
|
38276
|
+
const b64 = typeof signingPayload === "string";
|
|
38172
38277
|
const entry = jwsAlgorithm(alg);
|
|
38173
|
-
const data = concat(encodedProtected !== void 0 ? encode(encodedProtected) : new Uint8Array(), encode("."),
|
|
38278
|
+
const data = concat(encodedProtected !== void 0 ? encode(encodedProtected) : new Uint8Array(), encode("."), b64 ? shared[2] ?? (shared[2] = encodeBase64url(signingPayload, "payload", JWSInvalid)) : signingPayload);
|
|
38174
38279
|
const signature = decodeBase64url(jws.signature, "signature", JWSInvalid);
|
|
38175
38280
|
const k = await prepareKey(entry, key, "verify");
|
|
38176
|
-
|
|
38177
|
-
if (!verified) {
|
|
38281
|
+
if (!await verify(entry, k, signature, data)) {
|
|
38178
38282
|
throw new JWSSignatureVerificationFailed();
|
|
38179
38283
|
}
|
|
38180
|
-
|
|
38284
|
+
const payload = b64 ? decodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload;
|
|
38285
|
+
return [payload, parsedProt, b64, k, resolvedKey];
|
|
38286
|
+
}
|
|
38287
|
+
async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedProtected) {
|
|
38288
|
+
const { protected: encodedProtected, header, payload: inputPayload } = jws;
|
|
38289
|
+
const [parsedProt, , b64, alg] = parseJwsHeaders(encodedProtected, header, shared, parsedProtected);
|
|
38181
38290
|
if (b64) {
|
|
38182
|
-
|
|
38183
|
-
|
|
38184
|
-
|
|
38185
|
-
} else {
|
|
38186
|
-
|
|
38291
|
+
if (typeof inputPayload !== "string") {
|
|
38292
|
+
throw new JWSInvalid("JWS Payload must be a string");
|
|
38293
|
+
}
|
|
38294
|
+
} else if (typeof inputPayload !== "string" && !(inputPayload instanceof Uint8Array)) {
|
|
38295
|
+
throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
|
|
38187
38296
|
}
|
|
38188
|
-
|
|
38297
|
+
const signingPayload = b64 || typeof inputPayload !== "string" ? inputPayload : encodeUnencodedPayload(inputPayload);
|
|
38298
|
+
return verifyPrepared(jws, shared, key, encodedProtected, parsedProt, alg, signingPayload);
|
|
38189
38299
|
}
|
|
38190
38300
|
async function verifyCompact(jws, shared, key) {
|
|
38191
38301
|
if (jws instanceof Uint8Array) {
|
|
@@ -38198,7 +38308,11 @@ return true;`);
|
|
|
38198
38308
|
if (length !== 3) {
|
|
38199
38309
|
throw new JWSInvalid("Invalid Compact JWS");
|
|
38200
38310
|
}
|
|
38201
|
-
|
|
38311
|
+
const compactJws = { payload, protected: protectedHeader, signature };
|
|
38312
|
+
const parsedProt = parseProtectedHeader(protectedHeader);
|
|
38313
|
+
const [b64, alg] = validateJwsHeaders(parsedProt, parsedProt, shared);
|
|
38314
|
+
const signingPayload = b64 ? payload : encodeCompactUnencodedPayload(payload);
|
|
38315
|
+
return verifyPrepared(compactJws, shared, key, protectedHeader, parsedProt, alg, signingPayload);
|
|
38202
38316
|
}
|
|
38203
38317
|
var init_jws_verify = __esm({
|
|
38204
38318
|
"../node_modules/jose/dist/webapi/lib/jws_verify.js"() {
|
|
@@ -38233,22 +38347,23 @@ return true;`);
|
|
|
38233
38347
|
if (!isObject(jws)) {
|
|
38234
38348
|
throw new JWSInvalid("Flattened JWS must be an object");
|
|
38235
38349
|
}
|
|
38236
|
-
|
|
38350
|
+
const snapshot = snapshotJws(jws);
|
|
38351
|
+
if (snapshot.protected === void 0 && snapshot.header === void 0) {
|
|
38237
38352
|
throw new JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');
|
|
38238
38353
|
}
|
|
38239
|
-
if (
|
|
38354
|
+
if (snapshot.protected !== void 0 && typeof snapshot.protected !== "string") {
|
|
38240
38355
|
throw new JWSInvalid("JWS Protected Header incorrect type");
|
|
38241
38356
|
}
|
|
38242
|
-
if (
|
|
38357
|
+
if (snapshot.payload === void 0) {
|
|
38243
38358
|
throw new JWSInvalid("JWS Payload missing");
|
|
38244
38359
|
}
|
|
38245
|
-
if (typeof
|
|
38360
|
+
if (typeof snapshot.signature !== "string") {
|
|
38246
38361
|
throw new JWSInvalid("JWS Signature missing or incorrect type");
|
|
38247
38362
|
}
|
|
38248
|
-
if (
|
|
38363
|
+
if (snapshot.header !== void 0 && !isObject(snapshot.header)) {
|
|
38249
38364
|
throw new JWSInvalid("JWS Unprotected Header incorrect type");
|
|
38250
38365
|
}
|
|
38251
|
-
return verifyResult(
|
|
38366
|
+
return verifyResult(snapshot, await verifySignature(snapshot, prepareVerify(options), key, encodeJsonUnencodedPayload));
|
|
38252
38367
|
}
|
|
38253
38368
|
var init_verify2 = __esm({
|
|
38254
38369
|
"../node_modules/jose/dist/webapi/jws/flattened/verify.js"() {
|
|
@@ -38259,40 +38374,61 @@ return true;`);
|
|
|
38259
38374
|
});
|
|
38260
38375
|
|
|
38261
38376
|
// ../node_modules/jose/dist/webapi/jws/general/verify.js
|
|
38377
|
+
function snapshotSignature(signature, payload) {
|
|
38378
|
+
try {
|
|
38379
|
+
const jws = snapshotJws(signature, [payload]);
|
|
38380
|
+
const { protected: encodedProtected, header, signature: encodedSignature } = jws;
|
|
38381
|
+
if (encodedProtected === void 0 && header === void 0)
|
|
38382
|
+
return void 0;
|
|
38383
|
+
if (encodedProtected !== void 0 && typeof encodedProtected !== "string")
|
|
38384
|
+
return void 0;
|
|
38385
|
+
if (typeof encodedSignature !== "string")
|
|
38386
|
+
return void 0;
|
|
38387
|
+
if (header !== void 0 && !isObject(header))
|
|
38388
|
+
return void 0;
|
|
38389
|
+
const protectedHeader = parseProtectedHeader(encodedProtected);
|
|
38390
|
+
const { b64, crit } = protectedHeader;
|
|
38391
|
+
return [
|
|
38392
|
+
jws,
|
|
38393
|
+
protectedHeader,
|
|
38394
|
+
Array.isArray(crit) && crit.includes("b64") ? typeof b64 === "boolean" ? b64 ? 1 : 2 : 0 : 1
|
|
38395
|
+
];
|
|
38396
|
+
} catch {
|
|
38397
|
+
return void 0;
|
|
38398
|
+
}
|
|
38399
|
+
}
|
|
38262
38400
|
async function generalVerify(jws, key, options) {
|
|
38263
38401
|
if (!isObject(jws)) {
|
|
38264
38402
|
throw new JWSInvalid("General JWS must be an object");
|
|
38265
38403
|
}
|
|
38266
|
-
const { signatures, payload } = jws;
|
|
38267
|
-
if (!Array.isArray(signatures)
|
|
38404
|
+
const { signatures, payload: inputPayload } = jws;
|
|
38405
|
+
if (!Array.isArray(signatures)) {
|
|
38406
|
+
throw new JWSInvalid("JWS Signatures missing or incorrect type");
|
|
38407
|
+
}
|
|
38408
|
+
const signatureEntries = Array.from(signatures);
|
|
38409
|
+
if (!signatureEntries.every(isObject)) {
|
|
38268
38410
|
throw new JWSInvalid("JWS Signatures missing or incorrect type");
|
|
38269
38411
|
}
|
|
38270
38412
|
let shared;
|
|
38271
38413
|
try {
|
|
38272
|
-
if (
|
|
38414
|
+
if (inputPayload === void 0)
|
|
38273
38415
|
throw new Error();
|
|
38274
38416
|
shared = prepareVerify(options);
|
|
38275
38417
|
} catch {
|
|
38276
38418
|
throw new JWSSignatureVerificationFailed();
|
|
38277
38419
|
}
|
|
38278
|
-
|
|
38420
|
+
const payload = inputPayload instanceof Uint8Array ? new Uint8Array(inputPayload) : inputPayload;
|
|
38421
|
+
const candidates = signatureEntries.map((signature) => snapshotSignature(signature, payload)).filter((candidate) => candidate !== void 0);
|
|
38422
|
+
let modes = 0;
|
|
38423
|
+
for (const [, , mode] of candidates) {
|
|
38424
|
+
modes |= mode;
|
|
38425
|
+
if (modes === 3) {
|
|
38426
|
+
throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
|
|
38427
|
+
}
|
|
38428
|
+
}
|
|
38429
|
+
for (const candidate of candidates) {
|
|
38279
38430
|
try {
|
|
38280
|
-
|
|
38281
|
-
if (encodedProtected === void 0 && header === void 0)
|
|
38282
|
-
throw new Error();
|
|
38283
|
-
if (encodedProtected !== void 0 && typeof encodedProtected !== "string") {
|
|
38284
|
-
throw new Error();
|
|
38285
|
-
}
|
|
38286
|
-
if (typeof encodedSignature !== "string")
|
|
38287
|
-
throw new Error();
|
|
38288
|
-
if (header !== void 0 && !isObject(header))
|
|
38289
|
-
throw new Error();
|
|
38290
|
-
return verifyResult(signature, await verifySignature({
|
|
38291
|
-
header,
|
|
38292
|
-
payload,
|
|
38293
|
-
protected: encodedProtected,
|
|
38294
|
-
signature: encodedSignature
|
|
38295
|
-
}, shared, key));
|
|
38431
|
+
return verifyResult(candidate[0], await verifySignature(candidate[0], shared, key, encodeJsonUnencodedPayload, candidate[1]));
|
|
38296
38432
|
} catch {
|
|
38297
38433
|
}
|
|
38298
38434
|
}
|
|
@@ -38307,13 +38443,22 @@ return true;`);
|
|
|
38307
38443
|
});
|
|
38308
38444
|
|
|
38309
38445
|
// ../node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
38446
|
+
function invalidDuration() {
|
|
38447
|
+
throw new TypeError("Invalid time period format");
|
|
38448
|
+
}
|
|
38310
38449
|
function secs(str) {
|
|
38450
|
+
if (typeof str !== "string") {
|
|
38451
|
+
invalidDuration();
|
|
38452
|
+
}
|
|
38311
38453
|
const matched = REGEX.exec(str);
|
|
38312
38454
|
if (!matched || matched[4] && matched[1]) {
|
|
38313
|
-
|
|
38455
|
+
invalidDuration();
|
|
38314
38456
|
}
|
|
38315
38457
|
const value = parseFloat(matched[2]);
|
|
38316
38458
|
const numericDate2 = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
|
|
38459
|
+
if (!Number.isFinite(numericDate2)) {
|
|
38460
|
+
invalidDuration();
|
|
38461
|
+
}
|
|
38317
38462
|
if (matched[1] === "-" || matched[4] === "ago") {
|
|
38318
38463
|
return -numericDate2;
|
|
38319
38464
|
}
|
|
@@ -38325,6 +38470,16 @@ return true;`);
|
|
|
38325
38470
|
}
|
|
38326
38471
|
return input;
|
|
38327
38472
|
}
|
|
38473
|
+
function validateStringClaim(claim, value) {
|
|
38474
|
+
if (typeof value !== "string") {
|
|
38475
|
+
throw new TypeError(`"${claim}" claim must be a string`);
|
|
38476
|
+
}
|
|
38477
|
+
}
|
|
38478
|
+
function validateAudienceClaim(value) {
|
|
38479
|
+
if (typeof value !== "string" && (!Array.isArray(value) || Array.from(value).some((member) => typeof member !== "string"))) {
|
|
38480
|
+
throw new TypeError('"aud" claim must be a string or an array of strings');
|
|
38481
|
+
}
|
|
38482
|
+
}
|
|
38328
38483
|
function numericDate(value, label) {
|
|
38329
38484
|
if (typeof value === "number")
|
|
38330
38485
|
return validateInput(label, value);
|
|
@@ -38354,7 +38509,7 @@ return true;`);
|
|
|
38354
38509
|
throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
|
|
38355
38510
|
}
|
|
38356
38511
|
const { typ } = options;
|
|
38357
|
-
if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
|
|
38512
|
+
if (typ !== void 0 && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
|
|
38358
38513
|
throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', payload, "typ", checkFailed);
|
|
38359
38514
|
}
|
|
38360
38515
|
const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
|
|
@@ -38393,7 +38548,7 @@ return true;`);
|
|
|
38393
38548
|
}
|
|
38394
38549
|
validateInput("clockTolerance option", tolerance);
|
|
38395
38550
|
const { currentDate } = options;
|
|
38396
|
-
const now = validateInput("currentDate option", epoch(currentDate
|
|
38551
|
+
const now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate));
|
|
38397
38552
|
const iat = validateNumericDate(payload, "iat", maxTokenAge !== void 0);
|
|
38398
38553
|
const nbf = validateNumericDate(payload, "nbf");
|
|
38399
38554
|
if (nbf !== void 0) {
|
|
@@ -38409,17 +38564,33 @@ return true;`);
|
|
|
38409
38564
|
}
|
|
38410
38565
|
if (maxTokenAge !== void 0) {
|
|
38411
38566
|
const age = now - iat;
|
|
38412
|
-
const max = typeof maxTokenAge === "number" ? maxTokenAge : secs(maxTokenAge);
|
|
38567
|
+
const max = validateInput("maxTokenAge option", typeof maxTokenAge === "number" ? maxTokenAge : secs(maxTokenAge));
|
|
38413
38568
|
if (age - tolerance > max) {
|
|
38414
38569
|
throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', payload, "iat", checkFailed);
|
|
38415
38570
|
}
|
|
38416
|
-
if (age <
|
|
38571
|
+
if (age < -tolerance) {
|
|
38417
38572
|
throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', payload, "iat", checkFailed);
|
|
38418
38573
|
}
|
|
38419
38574
|
}
|
|
38420
38575
|
return payload;
|
|
38421
38576
|
}
|
|
38422
|
-
|
|
38577
|
+
function producerPayload(producer) {
|
|
38578
|
+
return producerPayloads.get(producer);
|
|
38579
|
+
}
|
|
38580
|
+
function jwtData(producer) {
|
|
38581
|
+
const payload = producerPayload(producer);
|
|
38582
|
+
for (const claim of ["iat", "nbf", "exp"]) {
|
|
38583
|
+
const value = payload[claim];
|
|
38584
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
38585
|
+
throw new TypeError(`"${claim}" claim must be a finite number`);
|
|
38586
|
+
}
|
|
38587
|
+
}
|
|
38588
|
+
return encoder.encode(JSON.stringify(payload));
|
|
38589
|
+
}
|
|
38590
|
+
function jwtClaim(producer, claim) {
|
|
38591
|
+
return producerPayload(producer)[claim];
|
|
38592
|
+
}
|
|
38593
|
+
var epoch, multipliers, REGEX, checkFailed, normalizeTyp, checkAudiencePresence, producerPayloads, JWTClaimsBuilder;
|
|
38423
38594
|
var init_jwt_claims_set = __esm({
|
|
38424
38595
|
"../node_modules/jose/dist/webapi/lib/jwt_claims_set.js"() {
|
|
38425
38596
|
init_errors();
|
|
@@ -38437,10 +38608,8 @@ return true;`);
|
|
|
38437
38608
|
REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
|
|
38438
38609
|
checkFailed = "check_failed";
|
|
38439
38610
|
normalizeTyp = (value) => {
|
|
38440
|
-
|
|
38441
|
-
|
|
38442
|
-
}
|
|
38443
|
-
return `application/${value.toLowerCase()}`;
|
|
38611
|
+
const normalized = value.toLowerCase();
|
|
38612
|
+
return value.includes("/") ? normalized : `application/${normalized}`;
|
|
38444
38613
|
};
|
|
38445
38614
|
checkAudiencePresence = (audPayload, audOption) => {
|
|
38446
38615
|
if (typeof audPayload === "string") {
|
|
@@ -38452,54 +38621,53 @@ return true;`);
|
|
|
38452
38621
|
return false;
|
|
38453
38622
|
};
|
|
38454
38623
|
JWTClaimsBuilder = class {
|
|
38455
|
-
constructor(payload) {
|
|
38456
|
-
__privateAdd(this, _payload);
|
|
38624
|
+
constructor(payload = {}) {
|
|
38457
38625
|
if (!isObject(payload)) {
|
|
38458
38626
|
throw new TypeError("JWT Claims Set MUST be an object");
|
|
38459
38627
|
}
|
|
38460
|
-
|
|
38461
|
-
|
|
38462
|
-
data() {
|
|
38463
|
-
return encoder.encode(JSON.stringify(__privateGet(this, _payload)));
|
|
38464
|
-
}
|
|
38465
|
-
get iss() {
|
|
38466
|
-
return __privateGet(this, _payload).iss;
|
|
38467
|
-
}
|
|
38468
|
-
set iss(value) {
|
|
38469
|
-
__privateGet(this, _payload).iss = value;
|
|
38470
|
-
}
|
|
38471
|
-
get sub() {
|
|
38472
|
-
return __privateGet(this, _payload).sub;
|
|
38628
|
+
;
|
|
38629
|
+
(producerPayloads || (producerPayloads = /* @__PURE__ */ new WeakMap())).set(this, structuredClone(payload));
|
|
38473
38630
|
}
|
|
38474
|
-
|
|
38475
|
-
|
|
38631
|
+
setIssuer(value) {
|
|
38632
|
+
validateStringClaim("iss", value);
|
|
38633
|
+
producerPayload(this).iss = value;
|
|
38634
|
+
return this;
|
|
38476
38635
|
}
|
|
38477
|
-
|
|
38478
|
-
|
|
38636
|
+
setSubject(value) {
|
|
38637
|
+
validateStringClaim("sub", value);
|
|
38638
|
+
producerPayload(this).sub = value;
|
|
38639
|
+
return this;
|
|
38479
38640
|
}
|
|
38480
|
-
|
|
38481
|
-
|
|
38641
|
+
setAudience(value) {
|
|
38642
|
+
validateAudienceClaim(value);
|
|
38643
|
+
producerPayload(this).aud = value;
|
|
38644
|
+
return this;
|
|
38482
38645
|
}
|
|
38483
|
-
|
|
38484
|
-
|
|
38646
|
+
setJti(value) {
|
|
38647
|
+
validateStringClaim("jti", value);
|
|
38648
|
+
producerPayload(this).jti = value;
|
|
38649
|
+
return this;
|
|
38485
38650
|
}
|
|
38486
|
-
|
|
38487
|
-
|
|
38651
|
+
setNotBefore(value) {
|
|
38652
|
+
producerPayload(this).nbf = numericDate(value, "setNotBefore");
|
|
38653
|
+
return this;
|
|
38488
38654
|
}
|
|
38489
|
-
|
|
38490
|
-
|
|
38655
|
+
setExpirationTime(value) {
|
|
38656
|
+
producerPayload(this).exp = numericDate(value, "setExpirationTime");
|
|
38657
|
+
return this;
|
|
38491
38658
|
}
|
|
38492
|
-
|
|
38659
|
+
setIssuedAt(value) {
|
|
38660
|
+
const payload = producerPayload(this);
|
|
38493
38661
|
if (value === void 0) {
|
|
38494
|
-
|
|
38662
|
+
payload.iat = epoch(/* @__PURE__ */ new Date());
|
|
38495
38663
|
} else if (typeof value === "string") {
|
|
38496
|
-
|
|
38664
|
+
payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value));
|
|
38497
38665
|
} else {
|
|
38498
|
-
|
|
38666
|
+
payload.iat = numericDate(value, "setIssuedAt");
|
|
38499
38667
|
}
|
|
38668
|
+
return this;
|
|
38500
38669
|
}
|
|
38501
38670
|
};
|
|
38502
|
-
_payload = new WeakMap();
|
|
38503
38671
|
}
|
|
38504
38672
|
});
|
|
38505
38673
|
|
|
@@ -38529,14 +38697,10 @@ return true;`);
|
|
|
38529
38697
|
const decrypted = await decryptCompact(jwt, prepareDecrypt(options), key);
|
|
38530
38698
|
const protectedHeader = decrypted[1];
|
|
38531
38699
|
const payload = validateClaimsSet(protectedHeader, decrypted[0], options);
|
|
38532
|
-
|
|
38533
|
-
|
|
38534
|
-
|
|
38535
|
-
|
|
38536
|
-
throw new JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch', payload, "sub", "mismatch");
|
|
38537
|
-
}
|
|
38538
|
-
if (protectedHeader.aud !== void 0 && JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)) {
|
|
38539
|
-
throw new JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch', payload, "aud", "mismatch");
|
|
38700
|
+
for (const claim of ["iss", "sub", "aud"]) {
|
|
38701
|
+
if (protectedHeader[claim] !== void 0 && (claim === "aud" ? JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud) : protectedHeader[claim] !== payload[claim])) {
|
|
38702
|
+
throw new JWTClaimValidationFailed(`replicated "${claim}" claim header parameter mismatch`, payload, claim, "mismatch");
|
|
38703
|
+
}
|
|
38540
38704
|
}
|
|
38541
38705
|
const result = { payload, protectedHeader };
|
|
38542
38706
|
if (typeof key === "function") {
|
|
@@ -38553,46 +38717,176 @@ return true;`);
|
|
|
38553
38717
|
});
|
|
38554
38718
|
|
|
38555
38719
|
// ../node_modules/jose/dist/webapi/jwe/compact/encrypt.js
|
|
38556
|
-
var
|
|
38557
|
-
var
|
|
38720
|
+
var _plaintext2, _protectedHeader2, _cek, _iv, _keyManagementParameters, CompactEncrypt;
|
|
38721
|
+
var init_encrypt2 = __esm({
|
|
38558
38722
|
"../node_modules/jose/dist/webapi/jwe/compact/encrypt.js"() {
|
|
38559
|
-
|
|
38723
|
+
init_helpers();
|
|
38724
|
+
init_type_checks();
|
|
38725
|
+
init_jwe_encrypt();
|
|
38560
38726
|
CompactEncrypt = class {
|
|
38561
38727
|
constructor(plaintext) {
|
|
38562
|
-
__privateAdd(this,
|
|
38563
|
-
|
|
38728
|
+
__privateAdd(this, _plaintext2);
|
|
38729
|
+
__privateAdd(this, _protectedHeader2);
|
|
38730
|
+
__privateAdd(this, _cek);
|
|
38731
|
+
__privateAdd(this, _iv);
|
|
38732
|
+
__privateAdd(this, _keyManagementParameters);
|
|
38733
|
+
assertUint8Array(plaintext, "plaintext");
|
|
38734
|
+
__privateSet(this, _plaintext2, plaintext);
|
|
38564
38735
|
}
|
|
38565
38736
|
setContentEncryptionKey(cek) {
|
|
38566
|
-
__privateGet(this,
|
|
38737
|
+
assertNotSet(__privateGet(this, _cek), "setContentEncryptionKey");
|
|
38738
|
+
__privateSet(this, _cek, cek);
|
|
38567
38739
|
return this;
|
|
38568
38740
|
}
|
|
38569
38741
|
setInitializationVector(iv) {
|
|
38570
|
-
__privateGet(this,
|
|
38742
|
+
assertNotSet(__privateGet(this, _iv), "setInitializationVector");
|
|
38743
|
+
__privateSet(this, _iv, iv);
|
|
38571
38744
|
return this;
|
|
38572
38745
|
}
|
|
38573
38746
|
setProtectedHeader(protectedHeader) {
|
|
38574
|
-
__privateGet(this,
|
|
38747
|
+
assertNotSet(__privateGet(this, _protectedHeader2), "setProtectedHeader");
|
|
38748
|
+
__privateSet(this, _protectedHeader2, protectedHeader);
|
|
38575
38749
|
return this;
|
|
38576
38750
|
}
|
|
38577
38751
|
setKeyManagementParameters(parameters) {
|
|
38578
|
-
__privateGet(this,
|
|
38752
|
+
assertNotSet(__privateGet(this, _keyManagementParameters), "setKeyManagementParameters");
|
|
38753
|
+
__privateSet(this, _keyManagementParameters, parameters);
|
|
38579
38754
|
return this;
|
|
38580
38755
|
}
|
|
38581
38756
|
async encrypt(key, options) {
|
|
38582
|
-
const jwe = await
|
|
38757
|
+
const jwe = await createJWE([
|
|
38758
|
+
__privateGet(this, _plaintext2),
|
|
38759
|
+
__privateGet(this, _protectedHeader2),
|
|
38760
|
+
void 0,
|
|
38761
|
+
void 0,
|
|
38762
|
+
void 0,
|
|
38763
|
+
__privateGet(this, _cek),
|
|
38764
|
+
__privateGet(this, _iv),
|
|
38765
|
+
__privateGet(this, _keyManagementParameters),
|
|
38766
|
+
void 0,
|
|
38767
|
+
false
|
|
38768
|
+
], key, options);
|
|
38583
38769
|
return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join(".");
|
|
38584
38770
|
}
|
|
38585
38771
|
};
|
|
38586
|
-
|
|
38772
|
+
_plaintext2 = new WeakMap();
|
|
38773
|
+
_protectedHeader2 = new WeakMap();
|
|
38774
|
+
_cek = new WeakMap();
|
|
38775
|
+
_iv = new WeakMap();
|
|
38776
|
+
_keyManagementParameters = new WeakMap();
|
|
38777
|
+
}
|
|
38778
|
+
});
|
|
38779
|
+
|
|
38780
|
+
// ../node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
|
|
38781
|
+
var _plaintext3, _protectedHeader3, _sharedUnprotectedHeader, _unprotectedHeader2, _aad2, _cek2, _iv2, _keyManagementParameters2, FlattenedEncrypt;
|
|
38782
|
+
var init_encrypt3 = __esm({
|
|
38783
|
+
"../node_modules/jose/dist/webapi/jwe/flattened/encrypt.js"() {
|
|
38784
|
+
init_helpers();
|
|
38785
|
+
init_jwe_encrypt();
|
|
38786
|
+
init_type_checks();
|
|
38787
|
+
FlattenedEncrypt = class {
|
|
38788
|
+
constructor(plaintext) {
|
|
38789
|
+
__privateAdd(this, _plaintext3);
|
|
38790
|
+
__privateAdd(this, _protectedHeader3);
|
|
38791
|
+
__privateAdd(this, _sharedUnprotectedHeader);
|
|
38792
|
+
__privateAdd(this, _unprotectedHeader2);
|
|
38793
|
+
__privateAdd(this, _aad2);
|
|
38794
|
+
__privateAdd(this, _cek2);
|
|
38795
|
+
__privateAdd(this, _iv2);
|
|
38796
|
+
__privateAdd(this, _keyManagementParameters2);
|
|
38797
|
+
assertUint8Array(plaintext, "plaintext");
|
|
38798
|
+
__privateSet(this, _plaintext3, plaintext);
|
|
38799
|
+
}
|
|
38800
|
+
setKeyManagementParameters(parameters) {
|
|
38801
|
+
assertNotSet(__privateGet(this, _keyManagementParameters2), "setKeyManagementParameters");
|
|
38802
|
+
__privateSet(this, _keyManagementParameters2, parameters);
|
|
38803
|
+
return this;
|
|
38804
|
+
}
|
|
38805
|
+
setProtectedHeader(protectedHeader) {
|
|
38806
|
+
assertNotSet(__privateGet(this, _protectedHeader3), "setProtectedHeader");
|
|
38807
|
+
__privateSet(this, _protectedHeader3, protectedHeader);
|
|
38808
|
+
return this;
|
|
38809
|
+
}
|
|
38810
|
+
setSharedUnprotectedHeader(sharedUnprotectedHeader) {
|
|
38811
|
+
assertNotSet(__privateGet(this, _sharedUnprotectedHeader), "setSharedUnprotectedHeader");
|
|
38812
|
+
__privateSet(this, _sharedUnprotectedHeader, sharedUnprotectedHeader);
|
|
38813
|
+
return this;
|
|
38814
|
+
}
|
|
38815
|
+
setUnprotectedHeader(unprotectedHeader) {
|
|
38816
|
+
assertNotSet(__privateGet(this, _unprotectedHeader2), "setUnprotectedHeader");
|
|
38817
|
+
__privateSet(this, _unprotectedHeader2, unprotectedHeader);
|
|
38818
|
+
return this;
|
|
38819
|
+
}
|
|
38820
|
+
setAdditionalAuthenticatedData(aad) {
|
|
38821
|
+
__privateSet(this, _aad2, aad);
|
|
38822
|
+
return this;
|
|
38823
|
+
}
|
|
38824
|
+
setContentEncryptionKey(cek) {
|
|
38825
|
+
assertNotSet(__privateGet(this, _cek2), "setContentEncryptionKey");
|
|
38826
|
+
__privateSet(this, _cek2, cek);
|
|
38827
|
+
return this;
|
|
38828
|
+
}
|
|
38829
|
+
setInitializationVector(iv) {
|
|
38830
|
+
assertNotSet(__privateGet(this, _iv2), "setInitializationVector");
|
|
38831
|
+
__privateSet(this, _iv2, iv);
|
|
38832
|
+
return this;
|
|
38833
|
+
}
|
|
38834
|
+
async encrypt(key, options) {
|
|
38835
|
+
return createJWE([
|
|
38836
|
+
__privateGet(this, _plaintext3),
|
|
38837
|
+
__privateGet(this, _protectedHeader3),
|
|
38838
|
+
__privateGet(this, _unprotectedHeader2),
|
|
38839
|
+
__privateGet(this, _sharedUnprotectedHeader),
|
|
38840
|
+
__privateGet(this, _aad2),
|
|
38841
|
+
__privateGet(this, _cek2),
|
|
38842
|
+
__privateGet(this, _iv2),
|
|
38843
|
+
__privateGet(this, _keyManagementParameters2),
|
|
38844
|
+
void 0,
|
|
38845
|
+
false
|
|
38846
|
+
], key, options);
|
|
38847
|
+
}
|
|
38848
|
+
};
|
|
38849
|
+
_plaintext3 = new WeakMap();
|
|
38850
|
+
_protectedHeader3 = new WeakMap();
|
|
38851
|
+
_sharedUnprotectedHeader = new WeakMap();
|
|
38852
|
+
_unprotectedHeader2 = new WeakMap();
|
|
38853
|
+
_aad2 = new WeakMap();
|
|
38854
|
+
_cek2 = new WeakMap();
|
|
38855
|
+
_iv2 = new WeakMap();
|
|
38856
|
+
_keyManagementParameters2 = new WeakMap();
|
|
38587
38857
|
}
|
|
38588
38858
|
});
|
|
38589
38859
|
|
|
38590
38860
|
// ../node_modules/jose/dist/webapi/lib/jws_sign.js
|
|
38591
|
-
function
|
|
38592
|
-
|
|
38861
|
+
function serializeProtectedHeader(protectedHeader) {
|
|
38862
|
+
if (protectedHeader === void 0)
|
|
38863
|
+
return [void 0, ""];
|
|
38864
|
+
const normalized = serializeJoseHeader(JWSInvalid, protectedHeader);
|
|
38865
|
+
return [normalized[0], encode2(normalized[1])];
|
|
38866
|
+
}
|
|
38867
|
+
function validateSignatureHeader(protectedHeader, joseHeader, crit) {
|
|
38868
|
+
validateCritDuplicates(JWSInvalid, protectedHeader);
|
|
38869
|
+
return validateB64(protectedHeader, validateCrit(JWSInvalid, JWS_RECOGNIZED, crit, protectedHeader, joseHeader));
|
|
38870
|
+
}
|
|
38871
|
+
function signatureAlgorithm(joseHeader) {
|
|
38872
|
+
const alg = joseHeader.alg;
|
|
38873
|
+
if (typeof alg !== "string" || !alg) {
|
|
38874
|
+
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
38875
|
+
}
|
|
38876
|
+
return jwsAlgorithm(alg);
|
|
38877
|
+
}
|
|
38878
|
+
async function signSignature(protectedHeader, payload, entry, key) {
|
|
38879
|
+
const data = concat(encode(protectedHeader), encode("."), payload);
|
|
38880
|
+
const k = await prepareKey(entry, key, "sign");
|
|
38881
|
+
return encode2(await sign(entry, k, data));
|
|
38593
38882
|
}
|
|
38594
|
-
async function createSignature(input, key) {
|
|
38595
|
-
|
|
38883
|
+
async function createSignature(input, key, assertB64) {
|
|
38884
|
+
let { protectedHeader, unprotectedHeader } = input;
|
|
38885
|
+
let protectedHeaderString;
|
|
38886
|
+
[protectedHeader, protectedHeaderString] = serializeProtectedHeader(protectedHeader);
|
|
38887
|
+
if (unprotectedHeader !== void 0) {
|
|
38888
|
+
unprotectedHeader = serializeJoseHeader(JWSInvalid, unprotectedHeader)[0];
|
|
38889
|
+
}
|
|
38596
38890
|
if (!protectedHeader && !unprotectedHeader) {
|
|
38597
38891
|
throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
38598
38892
|
}
|
|
@@ -38600,20 +38894,9 @@ return true;`);
|
|
|
38600
38894
|
throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
38601
38895
|
}
|
|
38602
38896
|
const joseHeader = { ...protectedHeader, ...unprotectedHeader };
|
|
38603
|
-
|
|
38604
|
-
|
|
38605
|
-
|
|
38606
|
-
if (extensions.includes("b64")) {
|
|
38607
|
-
b64 = protectedHeader.b64;
|
|
38608
|
-
if (typeof b64 !== "boolean") {
|
|
38609
|
-
throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
38610
|
-
}
|
|
38611
|
-
}
|
|
38612
|
-
const { alg } = joseHeader;
|
|
38613
|
-
if (typeof alg !== "string" || !alg) {
|
|
38614
|
-
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
38615
|
-
}
|
|
38616
|
-
const entry = jwsAlgorithm(alg);
|
|
38897
|
+
const b64 = validateSignatureHeader(protectedHeader, joseHeader, input.crit);
|
|
38898
|
+
assertB64?.(b64);
|
|
38899
|
+
const entry = signatureAlgorithm(joseHeader);
|
|
38617
38900
|
let payloadS;
|
|
38618
38901
|
let payloadB;
|
|
38619
38902
|
if (b64) {
|
|
@@ -38626,20 +38909,8 @@ return true;`);
|
|
|
38626
38909
|
payloadB = input.payload;
|
|
38627
38910
|
payloadS = "";
|
|
38628
38911
|
}
|
|
38629
|
-
let protectedHeaderString;
|
|
38630
|
-
let protectedHeaderBytes;
|
|
38631
|
-
if (protectedHeader) {
|
|
38632
|
-
protectedHeaderString = encode2(JSON.stringify(protectedHeader));
|
|
38633
|
-
protectedHeaderBytes = encode(protectedHeaderString);
|
|
38634
|
-
} else {
|
|
38635
|
-
protectedHeaderString = "";
|
|
38636
|
-
protectedHeaderBytes = new Uint8Array();
|
|
38637
|
-
}
|
|
38638
|
-
const data = concat(protectedHeaderBytes, encode("."), payloadB);
|
|
38639
|
-
const k = await prepareKey(entry, key, "sign");
|
|
38640
|
-
const signature = await sign(entry, k, data);
|
|
38641
38912
|
const jws = {
|
|
38642
|
-
signature:
|
|
38913
|
+
signature: await signSignature(protectedHeaderString, payloadB, entry, key),
|
|
38643
38914
|
payload: payloadS
|
|
38644
38915
|
};
|
|
38645
38916
|
if (protectedHeader) {
|
|
@@ -38648,7 +38919,20 @@ return true;`);
|
|
|
38648
38919
|
if (unprotectedHeader) {
|
|
38649
38920
|
jws.header = unprotectedHeader;
|
|
38650
38921
|
}
|
|
38651
|
-
return jws;
|
|
38922
|
+
return [jws, b64];
|
|
38923
|
+
}
|
|
38924
|
+
async function createCompactSignature(payload, inputProtectedHeader, inputCrit, key, rejectUnencoded) {
|
|
38925
|
+
const [protectedHeader, protectedHeaderString] = serializeProtectedHeader(inputProtectedHeader);
|
|
38926
|
+
if (!protectedHeader) {
|
|
38927
|
+
throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
38928
|
+
}
|
|
38929
|
+
const b64 = validateSignatureHeader(protectedHeader, protectedHeader, inputCrit);
|
|
38930
|
+
if (!b64)
|
|
38931
|
+
rejectUnencoded();
|
|
38932
|
+
const entry = signatureAlgorithm(protectedHeader);
|
|
38933
|
+
const encodedPayload = encode2(payload);
|
|
38934
|
+
const signature = await signSignature(protectedHeaderString, encode(encodedPayload), entry, key);
|
|
38935
|
+
return `${protectedHeaderString}.${encodedPayload}.${signature}`;
|
|
38652
38936
|
}
|
|
38653
38937
|
var init_jws_sign = __esm({
|
|
38654
38938
|
"../node_modules/jose/dist/webapi/lib/jws_sign.js"() {
|
|
@@ -38663,16 +38947,47 @@ return true;`);
|
|
|
38663
38947
|
}
|
|
38664
38948
|
});
|
|
38665
38949
|
|
|
38666
|
-
// ../node_modules/jose/dist/webapi/jws/
|
|
38667
|
-
var
|
|
38950
|
+
// ../node_modules/jose/dist/webapi/jws/compact/sign.js
|
|
38951
|
+
var _payload, _protectedHeader4, CompactSign;
|
|
38668
38952
|
var init_sign = __esm({
|
|
38953
|
+
"../node_modules/jose/dist/webapi/jws/compact/sign.js"() {
|
|
38954
|
+
init_jws_sign();
|
|
38955
|
+
init_helpers();
|
|
38956
|
+
CompactSign = class {
|
|
38957
|
+
constructor(payload) {
|
|
38958
|
+
__privateAdd(this, _payload);
|
|
38959
|
+
__privateAdd(this, _protectedHeader4);
|
|
38960
|
+
if (!(payload instanceof Uint8Array)) {
|
|
38961
|
+
throw new TypeError("payload must be an instance of Uint8Array");
|
|
38962
|
+
}
|
|
38963
|
+
__privateSet(this, _payload, payload);
|
|
38964
|
+
}
|
|
38965
|
+
setProtectedHeader(protectedHeader) {
|
|
38966
|
+
assertNotSet(__privateGet(this, _protectedHeader4), "setProtectedHeader");
|
|
38967
|
+
__privateSet(this, _protectedHeader4, protectedHeader);
|
|
38968
|
+
return this;
|
|
38969
|
+
}
|
|
38970
|
+
async sign(key, options) {
|
|
38971
|
+
return createCompactSignature(__privateGet(this, _payload), __privateGet(this, _protectedHeader4), options?.crit, key, () => {
|
|
38972
|
+
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
38973
|
+
});
|
|
38974
|
+
}
|
|
38975
|
+
};
|
|
38976
|
+
_payload = new WeakMap();
|
|
38977
|
+
_protectedHeader4 = new WeakMap();
|
|
38978
|
+
}
|
|
38979
|
+
});
|
|
38980
|
+
|
|
38981
|
+
// ../node_modules/jose/dist/webapi/jws/flattened/sign.js
|
|
38982
|
+
var _payload2, _protectedHeader5, _unprotectedHeader3, FlattenedSign;
|
|
38983
|
+
var init_sign2 = __esm({
|
|
38669
38984
|
"../node_modules/jose/dist/webapi/jws/flattened/sign.js"() {
|
|
38670
38985
|
init_jws_sign();
|
|
38671
38986
|
init_helpers();
|
|
38672
38987
|
FlattenedSign = class {
|
|
38673
38988
|
constructor(payload) {
|
|
38674
38989
|
__privateAdd(this, _payload2);
|
|
38675
|
-
__privateAdd(this,
|
|
38990
|
+
__privateAdd(this, _protectedHeader5);
|
|
38676
38991
|
__privateAdd(this, _unprotectedHeader3);
|
|
38677
38992
|
if (!(payload instanceof Uint8Array)) {
|
|
38678
38993
|
throw new TypeError("payload must be an instance of Uint8Array");
|
|
@@ -38680,8 +38995,8 @@ return true;`);
|
|
|
38680
38995
|
__privateSet(this, _payload2, payload);
|
|
38681
38996
|
}
|
|
38682
38997
|
setProtectedHeader(protectedHeader) {
|
|
38683
|
-
assertNotSet(__privateGet(this,
|
|
38684
|
-
__privateSet(this,
|
|
38998
|
+
assertNotSet(__privateGet(this, _protectedHeader5), "setProtectedHeader");
|
|
38999
|
+
__privateSet(this, _protectedHeader5, protectedHeader);
|
|
38685
39000
|
return this;
|
|
38686
39001
|
}
|
|
38687
39002
|
setUnprotectedHeader(unprotectedHeader) {
|
|
@@ -38690,50 +39005,21 @@ return true;`);
|
|
|
38690
39005
|
return this;
|
|
38691
39006
|
}
|
|
38692
39007
|
async sign(key, options) {
|
|
38693
|
-
|
|
39008
|
+
const [jws] = await createSignature({
|
|
38694
39009
|
payload: __privateGet(this, _payload2),
|
|
38695
|
-
protectedHeader: __privateGet(this,
|
|
39010
|
+
protectedHeader: __privateGet(this, _protectedHeader5),
|
|
38696
39011
|
unprotectedHeader: __privateGet(this, _unprotectedHeader3),
|
|
38697
39012
|
crit: options?.crit
|
|
38698
39013
|
}, key);
|
|
39014
|
+
return jws;
|
|
38699
39015
|
}
|
|
38700
39016
|
};
|
|
38701
39017
|
_payload2 = new WeakMap();
|
|
38702
|
-
|
|
39018
|
+
_protectedHeader5 = new WeakMap();
|
|
38703
39019
|
_unprotectedHeader3 = new WeakMap();
|
|
38704
39020
|
}
|
|
38705
39021
|
});
|
|
38706
39022
|
|
|
38707
|
-
// ../node_modules/jose/dist/webapi/jws/compact/sign.js
|
|
38708
|
-
var _flattened2, _protectedHeader4, CompactSign;
|
|
38709
|
-
var init_sign2 = __esm({
|
|
38710
|
-
"../node_modules/jose/dist/webapi/jws/compact/sign.js"() {
|
|
38711
|
-
init_sign();
|
|
38712
|
-
init_jws_sign();
|
|
38713
|
-
CompactSign = class {
|
|
38714
|
-
constructor(payload) {
|
|
38715
|
-
__privateAdd(this, _flattened2);
|
|
38716
|
-
__privateAdd(this, _protectedHeader4);
|
|
38717
|
-
__privateSet(this, _flattened2, new FlattenedSign(payload));
|
|
38718
|
-
}
|
|
38719
|
-
setProtectedHeader(protectedHeader) {
|
|
38720
|
-
__privateGet(this, _flattened2).setProtectedHeader(protectedHeader);
|
|
38721
|
-
__privateSet(this, _protectedHeader4, protectedHeader);
|
|
38722
|
-
return this;
|
|
38723
|
-
}
|
|
38724
|
-
async sign(key, options) {
|
|
38725
|
-
if (unencodedPayload(__privateGet(this, _protectedHeader4))) {
|
|
38726
|
-
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
38727
|
-
}
|
|
38728
|
-
const jws = await __privateGet(this, _flattened2).sign(key, options);
|
|
38729
|
-
return `${jws.protected}.${jws.payload}.${jws.signature}`;
|
|
38730
|
-
}
|
|
38731
|
-
};
|
|
38732
|
-
_flattened2 = new WeakMap();
|
|
38733
|
-
_protectedHeader4 = new WeakMap();
|
|
38734
|
-
}
|
|
38735
|
-
});
|
|
38736
|
-
|
|
38737
39023
|
// ../node_modules/jose/dist/webapi/jws/general/sign.js
|
|
38738
39024
|
var _parent2, IndividualSignature, _payload3, _signatures, GeneralSign;
|
|
38739
39025
|
var init_sign3 = __esm({
|
|
@@ -38792,19 +39078,21 @@ return true;`);
|
|
|
38792
39078
|
payload: ""
|
|
38793
39079
|
};
|
|
38794
39080
|
const encoded = [];
|
|
39081
|
+
let b64;
|
|
38795
39082
|
for (let i = 0; i < __privateGet(this, _signatures).length; i++) {
|
|
38796
39083
|
const signature = __privateGet(this, _signatures)[i];
|
|
38797
39084
|
const [protectedHeader, unprotectedHeader, key, crit] = signature.state;
|
|
38798
|
-
const { payload, ...rest } = await createSignature({
|
|
39085
|
+
const [{ payload, ...rest }, signatureB64] = await createSignature({
|
|
38799
39086
|
payload: __privateGet(this, _payload3),
|
|
38800
39087
|
protectedHeader,
|
|
38801
39088
|
unprotectedHeader,
|
|
38802
39089
|
crit,
|
|
38803
39090
|
encoded
|
|
38804
39091
|
}, key);
|
|
38805
|
-
if (
|
|
39092
|
+
if (b64 === void 0) {
|
|
39093
|
+
b64 = signatureB64;
|
|
38806
39094
|
jws.payload = payload;
|
|
38807
|
-
} else if (
|
|
39095
|
+
} else if (b64 !== signatureB64) {
|
|
38808
39096
|
throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
|
|
38809
39097
|
}
|
|
38810
39098
|
jws.signatures.push(rest);
|
|
@@ -38818,130 +39106,71 @@ return true;`);
|
|
|
38818
39106
|
});
|
|
38819
39107
|
|
|
38820
39108
|
// ../node_modules/jose/dist/webapi/jwt/sign.js
|
|
38821
|
-
var
|
|
39109
|
+
var SignJWT_base, _protectedHeader6, SignJWT;
|
|
38822
39110
|
var init_sign4 = __esm({
|
|
38823
39111
|
"../node_modules/jose/dist/webapi/jwt/sign.js"() {
|
|
38824
|
-
init_sign2();
|
|
38825
39112
|
init_jws_sign();
|
|
38826
39113
|
init_errors();
|
|
38827
39114
|
init_jwt_claims_set();
|
|
38828
|
-
|
|
38829
|
-
|
|
38830
|
-
|
|
38831
|
-
|
|
38832
|
-
|
|
38833
|
-
|
|
38834
|
-
setIssuer(issuer) {
|
|
38835
|
-
__privateGet(this, _jwt).iss = issuer;
|
|
38836
|
-
return this;
|
|
38837
|
-
}
|
|
38838
|
-
setSubject(subject) {
|
|
38839
|
-
__privateGet(this, _jwt).sub = subject;
|
|
38840
|
-
return this;
|
|
38841
|
-
}
|
|
38842
|
-
setAudience(audience) {
|
|
38843
|
-
__privateGet(this, _jwt).aud = audience;
|
|
38844
|
-
return this;
|
|
38845
|
-
}
|
|
38846
|
-
setJti(jwtId) {
|
|
38847
|
-
__privateGet(this, _jwt).jti = jwtId;
|
|
38848
|
-
return this;
|
|
38849
|
-
}
|
|
38850
|
-
setNotBefore(input) {
|
|
38851
|
-
__privateGet(this, _jwt).nbf = input;
|
|
38852
|
-
return this;
|
|
38853
|
-
}
|
|
38854
|
-
setExpirationTime(input) {
|
|
38855
|
-
__privateGet(this, _jwt).exp = input;
|
|
38856
|
-
return this;
|
|
38857
|
-
}
|
|
38858
|
-
setIssuedAt(input) {
|
|
38859
|
-
__privateGet(this, _jwt).iat = input;
|
|
38860
|
-
return this;
|
|
39115
|
+
init_helpers();
|
|
39116
|
+
SignJWT_base = JWTClaimsBuilder;
|
|
39117
|
+
SignJWT = class extends SignJWT_base {
|
|
39118
|
+
constructor() {
|
|
39119
|
+
super(...arguments);
|
|
39120
|
+
__privateAdd(this, _protectedHeader6);
|
|
38861
39121
|
}
|
|
38862
39122
|
setProtectedHeader(protectedHeader) {
|
|
38863
|
-
|
|
39123
|
+
assertNotSet(__privateGet(this, _protectedHeader6), "setProtectedHeader");
|
|
39124
|
+
__privateSet(this, _protectedHeader6, protectedHeader);
|
|
38864
39125
|
return this;
|
|
38865
39126
|
}
|
|
38866
39127
|
async sign(key, options) {
|
|
38867
|
-
|
|
38868
|
-
sig2.setProtectedHeader(__privateGet(this, _protectedHeader5));
|
|
38869
|
-
if (unencodedPayload(__privateGet(this, _protectedHeader5))) {
|
|
39128
|
+
return createCompactSignature(jwtData(this), __privateGet(this, _protectedHeader6), options?.crit, key, () => {
|
|
38870
39129
|
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
38871
|
-
}
|
|
38872
|
-
return sig2.sign(key, options);
|
|
39130
|
+
});
|
|
38873
39131
|
}
|
|
38874
39132
|
};
|
|
38875
|
-
|
|
38876
|
-
_jwt = new WeakMap();
|
|
39133
|
+
_protectedHeader6 = new WeakMap();
|
|
38877
39134
|
}
|
|
38878
39135
|
});
|
|
38879
39136
|
|
|
38880
39137
|
// ../node_modules/jose/dist/webapi/jwt/encrypt.js
|
|
38881
|
-
var
|
|
39138
|
+
var EncryptJWT_base, _cek3, _iv3, _keyManagementParameters3, _protectedHeader7, _replicateIssuerAsHeader, _replicateSubjectAsHeader, _replicateAudienceAsHeader, EncryptJWT;
|
|
38882
39139
|
var init_encrypt4 = __esm({
|
|
38883
39140
|
"../node_modules/jose/dist/webapi/jwt/encrypt.js"() {
|
|
38884
|
-
|
|
39141
|
+
init_jwe_encrypt();
|
|
38885
39142
|
init_jwt_claims_set();
|
|
38886
39143
|
init_helpers();
|
|
38887
|
-
|
|
38888
|
-
|
|
38889
|
-
|
|
38890
|
-
|
|
38891
|
-
__privateAdd(this,
|
|
38892
|
-
__privateAdd(this,
|
|
39144
|
+
EncryptJWT_base = JWTClaimsBuilder;
|
|
39145
|
+
EncryptJWT = class extends EncryptJWT_base {
|
|
39146
|
+
constructor() {
|
|
39147
|
+
super(...arguments);
|
|
39148
|
+
__privateAdd(this, _cek3);
|
|
39149
|
+
__privateAdd(this, _iv3);
|
|
39150
|
+
__privateAdd(this, _keyManagementParameters3);
|
|
39151
|
+
__privateAdd(this, _protectedHeader7);
|
|
38893
39152
|
__privateAdd(this, _replicateIssuerAsHeader);
|
|
38894
39153
|
__privateAdd(this, _replicateSubjectAsHeader);
|
|
38895
39154
|
__privateAdd(this, _replicateAudienceAsHeader);
|
|
38896
|
-
__privateAdd(this, _jwt2);
|
|
38897
|
-
__privateSet(this, _jwt2, new JWTClaimsBuilder(payload));
|
|
38898
|
-
}
|
|
38899
|
-
setIssuer(issuer) {
|
|
38900
|
-
__privateGet(this, _jwt2).iss = issuer;
|
|
38901
|
-
return this;
|
|
38902
|
-
}
|
|
38903
|
-
setSubject(subject) {
|
|
38904
|
-
__privateGet(this, _jwt2).sub = subject;
|
|
38905
|
-
return this;
|
|
38906
|
-
}
|
|
38907
|
-
setAudience(audience) {
|
|
38908
|
-
__privateGet(this, _jwt2).aud = audience;
|
|
38909
|
-
return this;
|
|
38910
|
-
}
|
|
38911
|
-
setJti(jwtId) {
|
|
38912
|
-
__privateGet(this, _jwt2).jti = jwtId;
|
|
38913
|
-
return this;
|
|
38914
|
-
}
|
|
38915
|
-
setNotBefore(input) {
|
|
38916
|
-
__privateGet(this, _jwt2).nbf = input;
|
|
38917
|
-
return this;
|
|
38918
|
-
}
|
|
38919
|
-
setExpirationTime(input) {
|
|
38920
|
-
__privateGet(this, _jwt2).exp = input;
|
|
38921
|
-
return this;
|
|
38922
|
-
}
|
|
38923
|
-
setIssuedAt(input) {
|
|
38924
|
-
__privateGet(this, _jwt2).iat = input;
|
|
38925
|
-
return this;
|
|
38926
39155
|
}
|
|
38927
39156
|
setProtectedHeader(protectedHeader) {
|
|
38928
|
-
assertNotSet(__privateGet(this,
|
|
38929
|
-
__privateSet(this,
|
|
39157
|
+
assertNotSet(__privateGet(this, _protectedHeader7), "setProtectedHeader");
|
|
39158
|
+
__privateSet(this, _protectedHeader7, protectedHeader);
|
|
38930
39159
|
return this;
|
|
38931
39160
|
}
|
|
38932
39161
|
setKeyManagementParameters(parameters) {
|
|
38933
|
-
assertNotSet(__privateGet(this,
|
|
38934
|
-
__privateSet(this,
|
|
39162
|
+
assertNotSet(__privateGet(this, _keyManagementParameters3), "setKeyManagementParameters");
|
|
39163
|
+
__privateSet(this, _keyManagementParameters3, parameters);
|
|
38935
39164
|
return this;
|
|
38936
39165
|
}
|
|
38937
39166
|
setContentEncryptionKey(cek) {
|
|
38938
|
-
assertNotSet(__privateGet(this,
|
|
38939
|
-
__privateSet(this,
|
|
39167
|
+
assertNotSet(__privateGet(this, _cek3), "setContentEncryptionKey");
|
|
39168
|
+
__privateSet(this, _cek3, cek);
|
|
38940
39169
|
return this;
|
|
38941
39170
|
}
|
|
38942
39171
|
setInitializationVector(iv) {
|
|
38943
|
-
assertNotSet(__privateGet(this,
|
|
38944
|
-
__privateSet(this,
|
|
39172
|
+
assertNotSet(__privateGet(this, _iv3), "setInitializationVector");
|
|
39173
|
+
__privateSet(this, _iv3, iv);
|
|
38945
39174
|
return this;
|
|
38946
39175
|
}
|
|
38947
39176
|
replicateIssuerAsHeader() {
|
|
@@ -38957,36 +39186,37 @@ return true;`);
|
|
|
38957
39186
|
return this;
|
|
38958
39187
|
}
|
|
38959
39188
|
async encrypt(key, options) {
|
|
38960
|
-
const
|
|
38961
|
-
if (__privateGet(this,
|
|
38962
|
-
__privateSet(this,
|
|
38963
|
-
...__privateGet(this,
|
|
38964
|
-
iss: __privateGet(this, _replicateIssuerAsHeader) ?
|
|
38965
|
-
sub: __privateGet(this, _replicateSubjectAsHeader) ?
|
|
38966
|
-
aud: __privateGet(this, _replicateAudienceAsHeader) ?
|
|
39189
|
+
const plaintext = jwtData(this);
|
|
39190
|
+
if (__privateGet(this, _protectedHeader7) && (__privateGet(this, _replicateIssuerAsHeader) || __privateGet(this, _replicateSubjectAsHeader) || __privateGet(this, _replicateAudienceAsHeader))) {
|
|
39191
|
+
__privateSet(this, _protectedHeader7, {
|
|
39192
|
+
...__privateGet(this, _protectedHeader7),
|
|
39193
|
+
iss: __privateGet(this, _replicateIssuerAsHeader) ? jwtClaim(this, "iss") : void 0,
|
|
39194
|
+
sub: __privateGet(this, _replicateSubjectAsHeader) ? jwtClaim(this, "sub") : void 0,
|
|
39195
|
+
aud: __privateGet(this, _replicateAudienceAsHeader) ? jwtClaim(this, "aud") : void 0
|
|
38967
39196
|
});
|
|
38968
39197
|
}
|
|
38969
|
-
|
|
38970
|
-
|
|
38971
|
-
|
|
38972
|
-
|
|
38973
|
-
|
|
38974
|
-
|
|
38975
|
-
|
|
38976
|
-
|
|
38977
|
-
|
|
38978
|
-
|
|
38979
|
-
|
|
39198
|
+
const jwe = await createJWE([
|
|
39199
|
+
plaintext,
|
|
39200
|
+
__privateGet(this, _protectedHeader7),
|
|
39201
|
+
void 0,
|
|
39202
|
+
void 0,
|
|
39203
|
+
void 0,
|
|
39204
|
+
__privateGet(this, _cek3),
|
|
39205
|
+
__privateGet(this, _iv3),
|
|
39206
|
+
__privateGet(this, _keyManagementParameters3),
|
|
39207
|
+
void 0,
|
|
39208
|
+
false
|
|
39209
|
+
], key, options);
|
|
39210
|
+
return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join(".");
|
|
38980
39211
|
}
|
|
38981
39212
|
};
|
|
38982
|
-
|
|
38983
|
-
|
|
38984
|
-
|
|
38985
|
-
|
|
39213
|
+
_cek3 = new WeakMap();
|
|
39214
|
+
_iv3 = new WeakMap();
|
|
39215
|
+
_keyManagementParameters3 = new WeakMap();
|
|
39216
|
+
_protectedHeader7 = new WeakMap();
|
|
38986
39217
|
_replicateIssuerAsHeader = new WeakMap();
|
|
38987
39218
|
_replicateSubjectAsHeader = new WeakMap();
|
|
38988
39219
|
_replicateAudienceAsHeader = new WeakMap();
|
|
38989
|
-
_jwt2 = new WeakMap();
|
|
38990
39220
|
}
|
|
38991
39221
|
});
|
|
38992
39222
|
|
|
@@ -39007,6 +39237,18 @@ return true;`);
|
|
|
39007
39237
|
}
|
|
39008
39238
|
});
|
|
39009
39239
|
|
|
39240
|
+
// ../node_modules/jose/dist/webapi/lib/key_options.js
|
|
39241
|
+
function validateExtractableOption(extractable) {
|
|
39242
|
+
if (extractable !== void 0 && typeof extractable !== "boolean") {
|
|
39243
|
+
throw new TypeError('"extractable" option must be a boolean');
|
|
39244
|
+
}
|
|
39245
|
+
return extractable;
|
|
39246
|
+
}
|
|
39247
|
+
var init_key_options = __esm({
|
|
39248
|
+
"../node_modules/jose/dist/webapi/lib/key_options.js"() {
|
|
39249
|
+
}
|
|
39250
|
+
});
|
|
39251
|
+
|
|
39010
39252
|
// ../node_modules/jose/dist/webapi/lib/asn1.js
|
|
39011
39253
|
function parseKeyHeader(state, keyFormat) {
|
|
39012
39254
|
expectTag(state, 48, `Invalid ${keyFormat === "spki" ? "SPKI" : "PKCS#8"} structure`);
|
|
@@ -39022,7 +39264,10 @@ return true;`);
|
|
|
39022
39264
|
function spkiFromX509(buf) {
|
|
39023
39265
|
const state = createASN1State(buf);
|
|
39024
39266
|
expectTag(state, 48, "Invalid certificate structure");
|
|
39025
|
-
parseLength(state);
|
|
39267
|
+
const certificateLength = parseLength(state);
|
|
39268
|
+
if (certificateLength < 0 || state.pos + certificateLength > state.data.length) {
|
|
39269
|
+
throw new Error("Unexpected end of ASN.1 input");
|
|
39270
|
+
}
|
|
39026
39271
|
expectTag(state, 48, "Invalid tbsCertificate structure");
|
|
39027
39272
|
parseLength(state);
|
|
39028
39273
|
if (buf[state.pos] === 160) {
|
|
@@ -39043,6 +39288,7 @@ return true;`);
|
|
|
39043
39288
|
init_errors();
|
|
39044
39289
|
init_key_algorithm();
|
|
39045
39290
|
init_is_key_like();
|
|
39291
|
+
init_key_options();
|
|
39046
39292
|
formatPEM = (b64, descriptor) => {
|
|
39047
39293
|
const newlined = (b64.match(/.{1,64}/g) || []).join("\n");
|
|
39048
39294
|
return `-----BEGIN ${descriptor}-----
|
|
@@ -39143,6 +39389,7 @@ ${newlined}
|
|
|
39143
39389
|
throw new Error("Unsupported named curve");
|
|
39144
39390
|
};
|
|
39145
39391
|
genericImport = async (keyFormat, keyData, alg, options) => {
|
|
39392
|
+
const extractable = validateExtractableOption(options?.extractable);
|
|
39146
39393
|
const entry = keyAlgorithm(alg, algArgument);
|
|
39147
39394
|
if (entry.secret) {
|
|
39148
39395
|
unsupportedAlg(algArgument);
|
|
@@ -39160,7 +39407,7 @@ ${newlined}
|
|
|
39160
39407
|
} else {
|
|
39161
39408
|
algorithm = entry.subtle;
|
|
39162
39409
|
}
|
|
39163
|
-
return crypto.subtle.importKey(keyFormat, keyData, algorithm,
|
|
39410
|
+
return crypto.subtle.importKey(keyFormat, keyData, algorithm, extractable ?? isPublic, entry.usages[isPublic ? 0 : 1]);
|
|
39164
39411
|
};
|
|
39165
39412
|
processPEMData = (pem, pattern) => {
|
|
39166
39413
|
return decodeBase64(pem.replace(pattern, ""));
|
|
@@ -39238,10 +39485,13 @@ ${newlined}
|
|
|
39238
39485
|
// ../node_modules/jose/dist/webapi/jwk/thumbprint.js
|
|
39239
39486
|
async function calculateJwkThumbprint(key, digestAlgorithm) {
|
|
39240
39487
|
let jwk;
|
|
39241
|
-
if (
|
|
39242
|
-
jwk = key;
|
|
39488
|
+
if (isObject(key)) {
|
|
39489
|
+
jwk = snapshotJwk(key);
|
|
39490
|
+
if (typeof jwk.kty !== "string") {
|
|
39491
|
+
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
39492
|
+
}
|
|
39243
39493
|
} else if (isKeyLike(key)) {
|
|
39244
|
-
jwk = await exportJWK(key);
|
|
39494
|
+
jwk = snapshotJwk(await exportJWK(key));
|
|
39245
39495
|
} else {
|
|
39246
39496
|
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
39247
39497
|
}
|
|
@@ -39273,7 +39523,9 @@ ${newlined}
|
|
|
39273
39523
|
components = { e: jwk.e, kty: jwk.kty, n: jwk.n };
|
|
39274
39524
|
break;
|
|
39275
39525
|
case "oct":
|
|
39276
|
-
|
|
39526
|
+
if (typeof jwk.k !== "string") {
|
|
39527
|
+
throw new JWKInvalid('"k" (Key Value) Parameter missing or invalid');
|
|
39528
|
+
}
|
|
39277
39529
|
components = { k: jwk.k, kty: jwk.kty };
|
|
39278
39530
|
break;
|
|
39279
39531
|
default:
|
|
@@ -39298,6 +39550,7 @@ ${newlined}
|
|
|
39298
39550
|
init_type_checks();
|
|
39299
39551
|
init_export();
|
|
39300
39552
|
init_invalid_key_input();
|
|
39553
|
+
init_jwk_metadata();
|
|
39301
39554
|
check = (value, description) => {
|
|
39302
39555
|
if (typeof value !== "string" || !value) {
|
|
39303
39556
|
throw new JWKInvalid(`${description} missing or invalid`);
|
|
@@ -39315,8 +39568,20 @@ ${newlined}
|
|
|
39315
39568
|
if (!isObject(joseHeader.jwk)) {
|
|
39316
39569
|
throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
|
|
39317
39570
|
}
|
|
39571
|
+
let jwk;
|
|
39572
|
+
try {
|
|
39573
|
+
jwk = normalizeJwk(joseHeader.jwk);
|
|
39574
|
+
} catch (cause) {
|
|
39575
|
+
throw new JWSInvalid("Invalid Embedded JWK", { cause });
|
|
39576
|
+
}
|
|
39318
39577
|
const entry = jwsAlgorithm(joseHeader.alg);
|
|
39319
|
-
|
|
39578
|
+
if (jwk.use !== void 0 && jwk.use !== "sig") {
|
|
39579
|
+
throw new JWSInvalid('Invalid Embedded JWK, its "use" must be "sig" when present');
|
|
39580
|
+
}
|
|
39581
|
+
if (jwk.alg !== void 0 && jwk.alg !== entry.alg) {
|
|
39582
|
+
throw new JWSInvalid(`Invalid Embedded JWK, its "alg" must be "${entry.alg}" when present`);
|
|
39583
|
+
}
|
|
39584
|
+
const key = await jwkToKey(entry, { ...jwk, ext: true });
|
|
39320
39585
|
if (key.type !== "public") {
|
|
39321
39586
|
throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');
|
|
39322
39587
|
}
|
|
@@ -39328,88 +39593,74 @@ ${newlined}
|
|
|
39328
39593
|
init_jws_algorithms();
|
|
39329
39594
|
init_type_checks();
|
|
39330
39595
|
init_errors();
|
|
39596
|
+
init_jwk_metadata();
|
|
39331
39597
|
}
|
|
39332
39598
|
});
|
|
39333
39599
|
|
|
39334
39600
|
// ../node_modules/jose/dist/webapi/jwks/local.js
|
|
39335
|
-
function
|
|
39336
|
-
const
|
|
39337
|
-
|
|
39338
|
-
|
|
39339
|
-
}
|
|
39340
|
-
return entry;
|
|
39341
|
-
}
|
|
39342
|
-
function isJWKSLike(jwks) {
|
|
39343
|
-
if (!jwks || typeof jwks !== "object") {
|
|
39344
|
-
return false;
|
|
39345
|
-
}
|
|
39346
|
-
const { keys } = jwks;
|
|
39347
|
-
return Array.isArray(keys) && keys.every(isObject);
|
|
39601
|
+
function isUsableJWK(jwk, entry, alg, kid) {
|
|
39602
|
+
const { kty, key_ops, ext, kid: jwkKid, alg: jwkAlg, use, crv } = snapshotJwk(jwk);
|
|
39603
|
+
const keyOps = Array.isArray(key_ops) ? [...key_ops] : key_ops;
|
|
39604
|
+
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);
|
|
39348
39605
|
}
|
|
39349
39606
|
async function importWithAlgCache(cache2, jwk, entry) {
|
|
39350
|
-
const cached2 = cache2.get(jwk) || cache2.set(jwk, {
|
|
39351
|
-
|
|
39352
|
-
|
|
39607
|
+
const cached2 = cache2.get(jwk) || cache2.set(jwk, {}).get(jwk);
|
|
39608
|
+
const { alg } = entry;
|
|
39609
|
+
if (cached2[alg] === void 0) {
|
|
39610
|
+
const key = await jwkToKey(entry, { ...jwk, alg, ext: true });
|
|
39353
39611
|
if (key.type !== "public") {
|
|
39354
39612
|
throw new JWKSInvalid("JSON Web Key Set members must be public keys");
|
|
39355
39613
|
}
|
|
39356
|
-
cached2[
|
|
39614
|
+
cached2[alg] = key;
|
|
39357
39615
|
}
|
|
39358
|
-
return cached2[
|
|
39616
|
+
return cached2[alg];
|
|
39359
39617
|
}
|
|
39360
39618
|
function createLocalJWKSet(jwks) {
|
|
39361
|
-
|
|
39362
|
-
|
|
39363
|
-
|
|
39364
|
-
|
|
39619
|
+
let snapshot;
|
|
39620
|
+
try {
|
|
39621
|
+
snapshot = structuredClone(jwks);
|
|
39622
|
+
} catch {
|
|
39623
|
+
}
|
|
39624
|
+
if (!isJwkSet(snapshot)) {
|
|
39625
|
+
throw new JWKSInvalid("JSON Web Key Set malformed");
|
|
39626
|
+
}
|
|
39627
|
+
const cached2 = /* @__PURE__ */ new WeakMap();
|
|
39628
|
+
const localJWKSet = async (protectedHeader, token) => {
|
|
39629
|
+
const { alg, kid } = { ...protectedHeader, ...token?.header };
|
|
39630
|
+
const entry = typeof alg === "string" ? JWS[alg] : void 0;
|
|
39631
|
+
if (!entry || entry.secret) {
|
|
39632
|
+
throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
|
|
39633
|
+
}
|
|
39634
|
+
const candidates = snapshot.keys.filter((jwk2) => isUsableJWK(jwk2, entry, alg, kid));
|
|
39635
|
+
const { 0: jwk, length } = candidates;
|
|
39636
|
+
if (!length) {
|
|
39637
|
+
throw new JWKSNoMatchingKey();
|
|
39638
|
+
}
|
|
39639
|
+
if (length !== 1) {
|
|
39640
|
+
const error = new JWKSMultipleMatchingKeys();
|
|
39641
|
+
error[Symbol.asyncIterator] = async function* () {
|
|
39642
|
+
for (const jwk2 of candidates) {
|
|
39643
|
+
try {
|
|
39644
|
+
yield await importWithAlgCache(cached2, jwk2, entry);
|
|
39645
|
+
} catch {
|
|
39646
|
+
}
|
|
39647
|
+
}
|
|
39648
|
+
};
|
|
39649
|
+
throw error;
|
|
39650
|
+
}
|
|
39651
|
+
return importWithAlgCache(cached2, jwk, entry);
|
|
39652
|
+
};
|
|
39653
|
+
return Object.defineProperty(localJWKSet, "jwks", {
|
|
39654
|
+
value: () => structuredClone(snapshot)
|
|
39365
39655
|
});
|
|
39366
|
-
return localJWKSet;
|
|
39367
39656
|
}
|
|
39368
|
-
var _jwks, _cached, LocalJWKSetImpl;
|
|
39369
39657
|
var init_local = __esm({
|
|
39370
39658
|
"../node_modules/jose/dist/webapi/jwks/local.js"() {
|
|
39371
39659
|
init_jwk_to_key();
|
|
39372
39660
|
init_jws_algorithms();
|
|
39373
39661
|
init_errors();
|
|
39374
39662
|
init_type_checks();
|
|
39375
|
-
|
|
39376
|
-
constructor(jwks) {
|
|
39377
|
-
__privateAdd(this, _jwks);
|
|
39378
|
-
__privateAdd(this, _cached, /* @__PURE__ */ new WeakMap());
|
|
39379
|
-
if (!isJWKSLike(jwks)) {
|
|
39380
|
-
throw new JWKSInvalid("JSON Web Key Set malformed");
|
|
39381
|
-
}
|
|
39382
|
-
__privateSet(this, _jwks, structuredClone(jwks));
|
|
39383
|
-
}
|
|
39384
|
-
jwks() {
|
|
39385
|
-
return __privateGet(this, _jwks);
|
|
39386
|
-
}
|
|
39387
|
-
async getKey(protectedHeader, token) {
|
|
39388
|
-
const { alg, kid } = { ...protectedHeader, ...token?.header };
|
|
39389
|
-
const entry = signatureAlgorithm(alg);
|
|
39390
|
-
const candidates = __privateGet(this, _jwks).keys.filter((jwk2) => entry.kty.includes(jwk2.kty) && (typeof kid !== "string" || kid === jwk2.kid) && (!(typeof jwk2.alg === "string" || jwk2.kty === "AKP") || alg === jwk2.alg) && (typeof jwk2.use !== "string" || jwk2.use === "sig") && (!Array.isArray(jwk2.key_ops) || jwk2.key_ops.includes("verify")) && (!entry.crv || jwk2.crv === entry.crv));
|
|
39391
|
-
const { 0: jwk, length } = candidates;
|
|
39392
|
-
if (length === 0) {
|
|
39393
|
-
throw new JWKSNoMatchingKey();
|
|
39394
|
-
}
|
|
39395
|
-
if (length !== 1) {
|
|
39396
|
-
const error = new JWKSMultipleMatchingKeys();
|
|
39397
|
-
const _cached2 = __privateGet(this, _cached);
|
|
39398
|
-
error[Symbol.asyncIterator] = async function* () {
|
|
39399
|
-
for (const jwk2 of candidates) {
|
|
39400
|
-
try {
|
|
39401
|
-
yield await importWithAlgCache(_cached2, jwk2, entry);
|
|
39402
|
-
} catch {
|
|
39403
|
-
}
|
|
39404
|
-
}
|
|
39405
|
-
};
|
|
39406
|
-
throw error;
|
|
39407
|
-
}
|
|
39408
|
-
return importWithAlgCache(__privateGet(this, _cached), jwk, entry);
|
|
39409
|
-
}
|
|
39410
|
-
};
|
|
39411
|
-
_jwks = new WeakMap();
|
|
39412
|
-
_cached = new WeakMap();
|
|
39663
|
+
init_jwk_metadata();
|
|
39413
39664
|
}
|
|
39414
39665
|
});
|
|
39415
39666
|
|
|
@@ -39438,46 +39689,114 @@ ${newlined}
|
|
|
39438
39689
|
throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
|
|
39439
39690
|
}
|
|
39440
39691
|
}
|
|
39441
|
-
function
|
|
39442
|
-
|
|
39443
|
-
|
|
39444
|
-
|
|
39445
|
-
if (
|
|
39446
|
-
|
|
39447
|
-
}
|
|
39448
|
-
if (!("jwks" in input) || !isObject(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isObject)) {
|
|
39449
|
-
return false;
|
|
39692
|
+
function isFreshFor(timestamp, duration) {
|
|
39693
|
+
return Number.isFinite(timestamp) && Date.now() < timestamp + duration;
|
|
39694
|
+
}
|
|
39695
|
+
function validateDuration(value, fallback, option) {
|
|
39696
|
+
if (Number.isNaN(value)) {
|
|
39697
|
+
throw new TypeError(`"${option}" option must not be NaN`);
|
|
39450
39698
|
}
|
|
39451
|
-
return
|
|
39699
|
+
return typeof value === "number" ? value : fallback;
|
|
39452
39700
|
}
|
|
39453
39701
|
function createRemoteJWKSet(url, options) {
|
|
39454
|
-
|
|
39455
|
-
|
|
39456
|
-
|
|
39702
|
+
if (!(url instanceof URL)) {
|
|
39703
|
+
throw new TypeError("url must be an instance of URL");
|
|
39704
|
+
}
|
|
39705
|
+
const href = new URL(url.href).href;
|
|
39706
|
+
const opts = options ?? {};
|
|
39707
|
+
const timeoutOption = opts.timeoutDuration;
|
|
39708
|
+
if (typeof timeoutOption === "number" && (!Number.isInteger(timeoutOption) || timeoutOption < 0)) {
|
|
39709
|
+
throw new TypeError('"timeoutDuration" option must be a non-negative integer');
|
|
39710
|
+
}
|
|
39711
|
+
const timeoutDuration = typeof timeoutOption === "number" ? timeoutOption : 5e3;
|
|
39712
|
+
const cooldownDuration = validateDuration(opts.cooldownDuration, 3e4, "cooldownDuration");
|
|
39713
|
+
const cacheMaxAge = validateDuration(opts.cacheMaxAge, 6e5, "cacheMaxAge");
|
|
39714
|
+
const headers = new Headers(opts.headers);
|
|
39715
|
+
if (USER_AGENT && !headers.has("User-Agent")) {
|
|
39716
|
+
headers.set("User-Agent", USER_AGENT);
|
|
39717
|
+
}
|
|
39718
|
+
if (!headers.has("accept")) {
|
|
39719
|
+
headers.set("accept", "application/json, application/jwk-set+json");
|
|
39720
|
+
}
|
|
39721
|
+
const fetchImpl = opts[customFetch];
|
|
39722
|
+
const cache2 = opts[jwksCache];
|
|
39723
|
+
let jwksTimestamp;
|
|
39724
|
+
let pendingFetch;
|
|
39725
|
+
let reloadSequence = 0;
|
|
39726
|
+
let appliedSequence = 0;
|
|
39727
|
+
let local;
|
|
39728
|
+
if (cache2 && typeof cache2 === "object") {
|
|
39729
|
+
const { uat, jwks } = cache2;
|
|
39730
|
+
if (isFreshFor(uat, cacheMaxAge) && isJwkSet(jwks)) {
|
|
39731
|
+
jwksTimestamp = uat;
|
|
39732
|
+
local = createLocalJWKSet(jwks);
|
|
39733
|
+
}
|
|
39734
|
+
}
|
|
39735
|
+
const reload = async () => {
|
|
39736
|
+
if (pendingFetch && isCloudflareWorkers()) {
|
|
39737
|
+
pendingFetch = void 0;
|
|
39738
|
+
}
|
|
39739
|
+
if (!pendingFetch) {
|
|
39740
|
+
const sequence = ++reloadSequence;
|
|
39741
|
+
const current = pendingFetch = fetchJwks(href, headers, AbortSignal.timeout(timeoutDuration), fetchImpl).then((json) => {
|
|
39742
|
+
const next = createLocalJWKSet(json);
|
|
39743
|
+
if (sequence <= appliedSequence) {
|
|
39744
|
+
return;
|
|
39745
|
+
}
|
|
39746
|
+
local = next;
|
|
39747
|
+
const updatedAt = Date.now();
|
|
39748
|
+
if (cache2) {
|
|
39749
|
+
cache2.uat = updatedAt;
|
|
39750
|
+
cache2.jwks = json;
|
|
39751
|
+
}
|
|
39752
|
+
jwksTimestamp = updatedAt;
|
|
39753
|
+
appliedSequence = sequence;
|
|
39754
|
+
}).finally(() => {
|
|
39755
|
+
if (pendingFetch === current) {
|
|
39756
|
+
pendingFetch = void 0;
|
|
39757
|
+
}
|
|
39758
|
+
});
|
|
39759
|
+
}
|
|
39760
|
+
await pendingFetch;
|
|
39761
|
+
};
|
|
39762
|
+
const remoteJWKSet = async (protectedHeader, token) => {
|
|
39763
|
+
if (!local || !isFreshFor(jwksTimestamp, cacheMaxAge)) {
|
|
39764
|
+
await reload();
|
|
39765
|
+
}
|
|
39766
|
+
try {
|
|
39767
|
+
return await local(protectedHeader, token);
|
|
39768
|
+
} catch (err) {
|
|
39769
|
+
if (err instanceof JWKSNoMatchingKey && !isFreshFor(jwksTimestamp, cooldownDuration)) {
|
|
39770
|
+
await reload();
|
|
39771
|
+
return local(protectedHeader, token);
|
|
39772
|
+
}
|
|
39773
|
+
throw err;
|
|
39774
|
+
}
|
|
39775
|
+
};
|
|
39776
|
+
return Object.defineProperties(remoteJWKSet, {
|
|
39457
39777
|
coolingDown: {
|
|
39458
|
-
get: () =>
|
|
39778
|
+
get: () => isFreshFor(jwksTimestamp, cooldownDuration),
|
|
39459
39779
|
enumerable: true
|
|
39460
39780
|
},
|
|
39461
39781
|
fresh: {
|
|
39462
|
-
get: () =>
|
|
39782
|
+
get: () => isFreshFor(jwksTimestamp, cacheMaxAge),
|
|
39463
39783
|
enumerable: true
|
|
39464
39784
|
},
|
|
39465
39785
|
reload: {
|
|
39466
|
-
value:
|
|
39786
|
+
value: reload,
|
|
39467
39787
|
enumerable: true
|
|
39468
39788
|
},
|
|
39469
39789
|
reloading: {
|
|
39470
|
-
get: () =>
|
|
39790
|
+
get: () => !!pendingFetch,
|
|
39471
39791
|
enumerable: true
|
|
39472
39792
|
},
|
|
39473
39793
|
jwks: {
|
|
39474
|
-
value: () =>
|
|
39794
|
+
value: () => local?.jwks(),
|
|
39475
39795
|
enumerable: true
|
|
39476
39796
|
}
|
|
39477
39797
|
});
|
|
39478
|
-
return remoteJWKSet;
|
|
39479
39798
|
}
|
|
39480
|
-
var USER_AGENT, customFetch, jwksCache
|
|
39799
|
+
var USER_AGENT, customFetch, jwksCache;
|
|
39481
39800
|
var init_remote = __esm({
|
|
39482
39801
|
"../node_modules/jose/dist/webapi/jwks/remote.js"() {
|
|
39483
39802
|
init_errors();
|
|
@@ -39485,159 +39804,30 @@ ${newlined}
|
|
|
39485
39804
|
init_type_checks();
|
|
39486
39805
|
if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
|
|
39487
39806
|
const NAME = "jose";
|
|
39488
|
-
const VERSION = "v6.2.
|
|
39807
|
+
const VERSION = "v6.2.10";
|
|
39489
39808
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
39490
39809
|
}
|
|
39491
39810
|
customFetch = /* @__PURE__ */ Symbol();
|
|
39492
39811
|
jwksCache = /* @__PURE__ */ Symbol();
|
|
39493
|
-
RemoteJWKSetImpl = class {
|
|
39494
|
-
constructor(url, options) {
|
|
39495
|
-
__privateAdd(this, _RemoteJWKSetImpl_instances);
|
|
39496
|
-
__privateAdd(this, _url);
|
|
39497
|
-
__privateAdd(this, _timeoutDuration);
|
|
39498
|
-
__privateAdd(this, _cooldownDuration);
|
|
39499
|
-
__privateAdd(this, _cacheMaxAge);
|
|
39500
|
-
__privateAdd(this, _jwksTimestamp);
|
|
39501
|
-
__privateAdd(this, _pendingFetch);
|
|
39502
|
-
__privateAdd(this, _headers);
|
|
39503
|
-
__privateAdd(this, _customFetch);
|
|
39504
|
-
__privateAdd(this, _local);
|
|
39505
|
-
__privateAdd(this, _cache);
|
|
39506
|
-
if (!(url instanceof URL)) {
|
|
39507
|
-
throw new TypeError("url must be an instance of URL");
|
|
39508
|
-
}
|
|
39509
|
-
__privateSet(this, _url, new URL(url.href));
|
|
39510
|
-
const opts = options ?? {};
|
|
39511
|
-
__privateSet(this, _timeoutDuration, typeof opts.timeoutDuration === "number" ? opts.timeoutDuration : 5e3);
|
|
39512
|
-
__privateSet(this, _cooldownDuration, typeof opts.cooldownDuration === "number" ? opts.cooldownDuration : 3e4);
|
|
39513
|
-
__privateSet(this, _cacheMaxAge, typeof opts.cacheMaxAge === "number" ? opts.cacheMaxAge : 6e5);
|
|
39514
|
-
__privateSet(this, _headers, new Headers(opts.headers));
|
|
39515
|
-
if (USER_AGENT && !__privateGet(this, _headers).has("User-Agent")) {
|
|
39516
|
-
__privateGet(this, _headers).set("User-Agent", USER_AGENT);
|
|
39517
|
-
}
|
|
39518
|
-
if (!__privateGet(this, _headers).has("accept")) {
|
|
39519
|
-
__privateGet(this, _headers).set("accept", "application/json");
|
|
39520
|
-
__privateGet(this, _headers).append("accept", "application/jwk-set+json");
|
|
39521
|
-
}
|
|
39522
|
-
__privateSet(this, _customFetch, opts[customFetch]);
|
|
39523
|
-
const cache2 = opts[jwksCache];
|
|
39524
|
-
if (cache2 !== void 0) {
|
|
39525
|
-
__privateSet(this, _cache, cache2);
|
|
39526
|
-
if (isFreshJwksCache(cache2, __privateGet(this, _cacheMaxAge))) {
|
|
39527
|
-
__privateSet(this, _jwksTimestamp, __privateGet(this, _cache).uat);
|
|
39528
|
-
__privateSet(this, _local, createLocalJWKSet(__privateGet(this, _cache).jwks));
|
|
39529
|
-
}
|
|
39530
|
-
}
|
|
39531
|
-
}
|
|
39532
|
-
pendingFetch() {
|
|
39533
|
-
return !!__privateGet(this, _pendingFetch);
|
|
39534
|
-
}
|
|
39535
|
-
coolingDown() {
|
|
39536
|
-
return __privateMethod(this, _RemoteJWKSetImpl_instances, validFor_fn).call(this, __privateGet(this, _cooldownDuration));
|
|
39537
|
-
}
|
|
39538
|
-
fresh() {
|
|
39539
|
-
return __privateMethod(this, _RemoteJWKSetImpl_instances, validFor_fn).call(this, __privateGet(this, _cacheMaxAge));
|
|
39540
|
-
}
|
|
39541
|
-
jwks() {
|
|
39542
|
-
return __privateGet(this, _local)?.jwks();
|
|
39543
|
-
}
|
|
39544
|
-
async getKey(protectedHeader, token) {
|
|
39545
|
-
if (!__privateGet(this, _local) || !this.fresh()) {
|
|
39546
|
-
await this.reload();
|
|
39547
|
-
}
|
|
39548
|
-
try {
|
|
39549
|
-
return await __privateGet(this, _local).call(this, protectedHeader, token);
|
|
39550
|
-
} catch (err) {
|
|
39551
|
-
if (err instanceof JWKSNoMatchingKey) {
|
|
39552
|
-
if (this.coolingDown() === false) {
|
|
39553
|
-
await this.reload();
|
|
39554
|
-
return __privateGet(this, _local).call(this, protectedHeader, token);
|
|
39555
|
-
}
|
|
39556
|
-
}
|
|
39557
|
-
throw err;
|
|
39558
|
-
}
|
|
39559
|
-
}
|
|
39560
|
-
async reload() {
|
|
39561
|
-
if (__privateGet(this, _pendingFetch) && isCloudflareWorkers()) {
|
|
39562
|
-
__privateSet(this, _pendingFetch, void 0);
|
|
39563
|
-
}
|
|
39564
|
-
__privateGet(this, _pendingFetch) || __privateSet(this, _pendingFetch, fetchJwks(__privateGet(this, _url).href, __privateGet(this, _headers), AbortSignal.timeout(__privateGet(this, _timeoutDuration)), __privateGet(this, _customFetch)).then((json) => {
|
|
39565
|
-
__privateSet(this, _local, createLocalJWKSet(json));
|
|
39566
|
-
if (__privateGet(this, _cache)) {
|
|
39567
|
-
__privateGet(this, _cache).uat = Date.now();
|
|
39568
|
-
__privateGet(this, _cache).jwks = json;
|
|
39569
|
-
}
|
|
39570
|
-
__privateSet(this, _jwksTimestamp, Date.now());
|
|
39571
|
-
}).finally(() => {
|
|
39572
|
-
__privateSet(this, _pendingFetch, void 0);
|
|
39573
|
-
}));
|
|
39574
|
-
await __privateGet(this, _pendingFetch);
|
|
39575
|
-
}
|
|
39576
|
-
};
|
|
39577
|
-
_url = new WeakMap();
|
|
39578
|
-
_timeoutDuration = new WeakMap();
|
|
39579
|
-
_cooldownDuration = new WeakMap();
|
|
39580
|
-
_cacheMaxAge = new WeakMap();
|
|
39581
|
-
_jwksTimestamp = new WeakMap();
|
|
39582
|
-
_pendingFetch = new WeakMap();
|
|
39583
|
-
_headers = new WeakMap();
|
|
39584
|
-
_customFetch = new WeakMap();
|
|
39585
|
-
_local = new WeakMap();
|
|
39586
|
-
_cache = new WeakMap();
|
|
39587
|
-
_RemoteJWKSetImpl_instances = new WeakSet();
|
|
39588
|
-
validFor_fn = function(duration) {
|
|
39589
|
-
return typeof __privateGet(this, _jwksTimestamp) === "number" && Date.now() < __privateGet(this, _jwksTimestamp) + duration;
|
|
39590
|
-
};
|
|
39591
39812
|
}
|
|
39592
39813
|
});
|
|
39593
39814
|
|
|
39594
39815
|
// ../node_modules/jose/dist/webapi/jwt/unsecured.js
|
|
39595
|
-
var
|
|
39816
|
+
var UnsecuredJWT_base, UnsecuredJWT;
|
|
39596
39817
|
var init_unsecured = __esm({
|
|
39597
39818
|
"../node_modules/jose/dist/webapi/jwt/unsecured.js"() {
|
|
39598
39819
|
init_base64url();
|
|
39599
|
-
init_buffer_utils();
|
|
39600
39820
|
init_helpers();
|
|
39601
39821
|
init_errors();
|
|
39602
39822
|
init_jwt_claims_set();
|
|
39603
|
-
|
|
39604
|
-
|
|
39605
|
-
|
|
39606
|
-
__privateSet(this, _jwt3, new JWTClaimsBuilder(payload));
|
|
39607
|
-
}
|
|
39823
|
+
init_options();
|
|
39824
|
+
UnsecuredJWT_base = JWTClaimsBuilder;
|
|
39825
|
+
UnsecuredJWT = class extends UnsecuredJWT_base {
|
|
39608
39826
|
encode() {
|
|
39609
39827
|
const header = encode2(JSON.stringify({ alg: "none" }));
|
|
39610
|
-
const payload = encode2(
|
|
39828
|
+
const payload = encode2(jwtData(this));
|
|
39611
39829
|
return `${header}.${payload}.`;
|
|
39612
39830
|
}
|
|
39613
|
-
setIssuer(issuer) {
|
|
39614
|
-
__privateGet(this, _jwt3).iss = issuer;
|
|
39615
|
-
return this;
|
|
39616
|
-
}
|
|
39617
|
-
setSubject(subject) {
|
|
39618
|
-
__privateGet(this, _jwt3).sub = subject;
|
|
39619
|
-
return this;
|
|
39620
|
-
}
|
|
39621
|
-
setAudience(audience) {
|
|
39622
|
-
__privateGet(this, _jwt3).aud = audience;
|
|
39623
|
-
return this;
|
|
39624
|
-
}
|
|
39625
|
-
setJti(jwtId) {
|
|
39626
|
-
__privateGet(this, _jwt3).jti = jwtId;
|
|
39627
|
-
return this;
|
|
39628
|
-
}
|
|
39629
|
-
setNotBefore(input) {
|
|
39630
|
-
__privateGet(this, _jwt3).nbf = input;
|
|
39631
|
-
return this;
|
|
39632
|
-
}
|
|
39633
|
-
setExpirationTime(input) {
|
|
39634
|
-
__privateGet(this, _jwt3).exp = input;
|
|
39635
|
-
return this;
|
|
39636
|
-
}
|
|
39637
|
-
setIssuedAt(input) {
|
|
39638
|
-
__privateGet(this, _jwt3).iat = input;
|
|
39639
|
-
return this;
|
|
39640
|
-
}
|
|
39641
39831
|
static decode(jwt, options) {
|
|
39642
39832
|
if (typeof jwt !== "string") {
|
|
39643
39833
|
throw new JWTInvalid("Unsecured JWT must be a string");
|
|
@@ -39647,18 +39837,27 @@ ${newlined}
|
|
|
39647
39837
|
throw new JWTInvalid("Invalid Unsecured JWT");
|
|
39648
39838
|
}
|
|
39649
39839
|
let header;
|
|
39840
|
+
let b64;
|
|
39650
39841
|
try {
|
|
39651
|
-
header =
|
|
39652
|
-
|
|
39653
|
-
|
|
39654
|
-
} catch {
|
|
39842
|
+
header = parseJoseHeader(encodedHeader, JWSInvalid, "JWS Protected Header is invalid");
|
|
39843
|
+
const extensions = validateCrit(JWSInvalid, JWS_RECOGNIZED, void 0, header, header);
|
|
39844
|
+
b64 = validateB64(header, extensions);
|
|
39845
|
+
} catch (cause) {
|
|
39846
|
+
if (!(cause instanceof JWSInvalid)) {
|
|
39847
|
+
throw cause;
|
|
39848
|
+
}
|
|
39849
|
+
throw new JWTInvalid("Invalid Unsecured JWT", { cause });
|
|
39850
|
+
}
|
|
39851
|
+
if (header.alg !== "none") {
|
|
39655
39852
|
throw new JWTInvalid("Invalid Unsecured JWT");
|
|
39656
39853
|
}
|
|
39854
|
+
if (!b64) {
|
|
39855
|
+
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
39856
|
+
}
|
|
39657
39857
|
const payload = validateClaimsSet(header, decodeBase64url(encodedPayload, "payload", JWTInvalid), options);
|
|
39658
39858
|
return { payload, header };
|
|
39659
39859
|
}
|
|
39660
39860
|
};
|
|
39661
|
-
_jwt3 = new WeakMap();
|
|
39662
39861
|
}
|
|
39663
39862
|
});
|
|
39664
39863
|
|
|
@@ -39685,31 +39884,33 @@ ${newlined}
|
|
|
39685
39884
|
if (!isObject(jwk)) {
|
|
39686
39885
|
throw new TypeError("JWK must be an object");
|
|
39687
39886
|
}
|
|
39688
|
-
|
|
39689
|
-
const
|
|
39690
|
-
|
|
39887
|
+
const normalized = normalizeJwk(jwk);
|
|
39888
|
+
const extractable = validateExtractableOption(options?.extractable);
|
|
39889
|
+
const { alg: jwkAlg } = normalized;
|
|
39890
|
+
alg ?? (alg = jwkAlg);
|
|
39891
|
+
const ext = extractable ?? normalized.ext;
|
|
39892
|
+
if (normalized.kty !== "oct" && !alg) {
|
|
39691
39893
|
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
39692
39894
|
}
|
|
39693
|
-
switch (
|
|
39895
|
+
switch (normalized.kty) {
|
|
39694
39896
|
case "oct":
|
|
39695
|
-
if (typeof
|
|
39897
|
+
if (typeof normalized.k !== "string") {
|
|
39696
39898
|
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
39697
39899
|
}
|
|
39698
|
-
return decode(
|
|
39699
|
-
case "RSA":
|
|
39700
|
-
return jwkToKey(keyAlgorithm(alg), { ...jwk, alg, ext });
|
|
39900
|
+
return decode(normalized.k);
|
|
39701
39901
|
case "AKP": {
|
|
39702
|
-
if (typeof
|
|
39902
|
+
if (typeof jwkAlg !== "string" || !jwkAlg) {
|
|
39703
39903
|
throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
39704
39904
|
}
|
|
39705
|
-
if (alg !==
|
|
39905
|
+
if (alg !== jwkAlg) {
|
|
39706
39906
|
throw new TypeError("JWK alg and alg option value mismatch");
|
|
39707
39907
|
}
|
|
39708
|
-
return jwkToKey(keyAlgorithm(
|
|
39908
|
+
return jwkToKey(keyAlgorithm(alg), { ...normalized, ext });
|
|
39709
39909
|
}
|
|
39910
|
+
case "RSA":
|
|
39710
39911
|
case "EC":
|
|
39711
39912
|
case "OKP":
|
|
39712
|
-
return jwkToKey(keyAlgorithm(alg), { ...
|
|
39913
|
+
return jwkToKey(keyAlgorithm(alg), { ...normalized, alg, ext });
|
|
39713
39914
|
default:
|
|
39714
39915
|
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
39715
39916
|
}
|
|
@@ -39722,6 +39923,8 @@ ${newlined}
|
|
|
39722
39923
|
init_key_algorithm();
|
|
39723
39924
|
init_errors();
|
|
39724
39925
|
init_type_checks();
|
|
39926
|
+
init_key_options();
|
|
39927
|
+
init_jwk_metadata();
|
|
39725
39928
|
}
|
|
39726
39929
|
});
|
|
39727
39930
|
|
|
@@ -39792,12 +39995,13 @@ ${newlined}
|
|
|
39792
39995
|
// ../node_modules/jose/dist/webapi/key/generate_key_pair.js
|
|
39793
39996
|
function getModulusLengthOption(options) {
|
|
39794
39997
|
const modulusLength = options?.modulusLength ?? 2048;
|
|
39795
|
-
if (typeof modulusLength !== "number" || modulusLength < 2048) {
|
|
39998
|
+
if (typeof modulusLength !== "number" || !Number.isInteger(modulusLength) || modulusLength < 2048) {
|
|
39796
39999
|
throw new JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");
|
|
39797
40000
|
}
|
|
39798
40001
|
return modulusLength;
|
|
39799
40002
|
}
|
|
39800
40003
|
async function generateKeyPair(alg, options) {
|
|
40004
|
+
const extractable = validateExtractableOption(options?.extractable);
|
|
39801
40005
|
const entry = keyAlgorithm(alg, algArgument);
|
|
39802
40006
|
if (entry.secret) {
|
|
39803
40007
|
unsupportedAlg(algArgument);
|
|
@@ -39827,7 +40031,7 @@ ${newlined}
|
|
|
39827
40031
|
modulusLength: getModulusLengthOption(options)
|
|
39828
40032
|
} : entry.subtle;
|
|
39829
40033
|
}
|
|
39830
|
-
return crypto.subtle.generateKey(algorithm,
|
|
40034
|
+
return crypto.subtle.generateKey(algorithm, extractable ?? false, [
|
|
39831
40035
|
...entry.usages[1],
|
|
39832
40036
|
...entry.usages[0]
|
|
39833
40037
|
]);
|
|
@@ -39835,12 +40039,14 @@ ${newlined}
|
|
|
39835
40039
|
var init_generate_key_pair = __esm({
|
|
39836
40040
|
"../node_modules/jose/dist/webapi/key/generate_key_pair.js"() {
|
|
39837
40041
|
init_errors();
|
|
40042
|
+
init_key_options();
|
|
39838
40043
|
init_key_algorithm();
|
|
39839
40044
|
}
|
|
39840
40045
|
});
|
|
39841
40046
|
|
|
39842
40047
|
// ../node_modules/jose/dist/webapi/key/generate_secret.js
|
|
39843
40048
|
async function generateSecret(alg, options) {
|
|
40049
|
+
const extractable = validateExtractableOption(options?.extractable);
|
|
39844
40050
|
let length;
|
|
39845
40051
|
let algorithm;
|
|
39846
40052
|
let keyUsages;
|
|
@@ -39848,19 +40054,18 @@ ${newlined}
|
|
|
39848
40054
|
case "HS256":
|
|
39849
40055
|
case "HS384":
|
|
39850
40056
|
case "HS512":
|
|
39851
|
-
length =
|
|
40057
|
+
length = +alg.slice(-3);
|
|
39852
40058
|
algorithm = { name: "HMAC", hash: `SHA-${length}`, length };
|
|
39853
40059
|
keyUsages = ["sign", "verify"];
|
|
39854
40060
|
break;
|
|
39855
40061
|
case "A128CBC-HS256":
|
|
39856
40062
|
case "A192CBC-HS384":
|
|
39857
40063
|
case "A256CBC-HS512":
|
|
39858
|
-
|
|
39859
|
-
return crypto.getRandomValues(new Uint8Array(length >> 3));
|
|
40064
|
+
return crypto.getRandomValues(new Uint8Array(+alg.slice(-3) >> 3));
|
|
39860
40065
|
case "A128KW":
|
|
39861
40066
|
case "A192KW":
|
|
39862
40067
|
case "A256KW":
|
|
39863
|
-
length =
|
|
40068
|
+
length = +alg.slice(1, 4);
|
|
39864
40069
|
algorithm = { name: "AES-KW", length };
|
|
39865
40070
|
keyUsages = ["wrapKey", "unwrapKey"];
|
|
39866
40071
|
break;
|
|
@@ -39870,18 +40075,19 @@ ${newlined}
|
|
|
39870
40075
|
case "A128GCM":
|
|
39871
40076
|
case "A192GCM":
|
|
39872
40077
|
case "A256GCM":
|
|
39873
|
-
length =
|
|
40078
|
+
length = +alg.slice(1, 4);
|
|
39874
40079
|
algorithm = { name: "AES-GCM", length };
|
|
39875
40080
|
keyUsages = ["encrypt", "decrypt"];
|
|
39876
40081
|
break;
|
|
39877
40082
|
default:
|
|
39878
40083
|
unsupportedAlg(algArgument);
|
|
39879
40084
|
}
|
|
39880
|
-
return crypto.subtle.generateKey(algorithm,
|
|
40085
|
+
return crypto.subtle.generateKey(algorithm, extractable ?? false, keyUsages);
|
|
39881
40086
|
}
|
|
39882
40087
|
var init_generate_secret = __esm({
|
|
39883
40088
|
"../node_modules/jose/dist/webapi/key/generate_secret.js"() {
|
|
39884
40089
|
init_key_algorithm();
|
|
40090
|
+
init_key_options();
|
|
39885
40091
|
}
|
|
39886
40092
|
});
|
|
39887
40093
|
|
|
@@ -39933,16 +40139,16 @@ ${newlined}
|
|
|
39933
40139
|
init_decrypt();
|
|
39934
40140
|
init_decrypt2();
|
|
39935
40141
|
init_decrypt3();
|
|
39936
|
-
|
|
40142
|
+
init_encrypt();
|
|
39937
40143
|
init_verify();
|
|
39938
40144
|
init_verify2();
|
|
39939
40145
|
init_verify3();
|
|
39940
40146
|
init_verify4();
|
|
39941
40147
|
init_decrypt4();
|
|
40148
|
+
init_encrypt2();
|
|
39942
40149
|
init_encrypt3();
|
|
39943
|
-
init_encrypt();
|
|
39944
|
-
init_sign2();
|
|
39945
40150
|
init_sign();
|
|
40151
|
+
init_sign2();
|
|
39946
40152
|
init_sign3();
|
|
39947
40153
|
init_sign4();
|
|
39948
40154
|
init_encrypt4();
|
|
@@ -42546,7 +42752,7 @@ ${newlined}
|
|
|
42546
42752
|
}))
|
|
42547
42753
|
}
|
|
42548
42754
|
};
|
|
42549
|
-
return { ...service, agents, container };
|
|
42755
|
+
return { ...service, enabled: service.enabled ?? true, agents, container };
|
|
42550
42756
|
}
|
|
42551
42757
|
var ServiceTemplateSpec = class _ServiceTemplateSpec {
|
|
42552
42758
|
constructor(template) {
|
|
@@ -42656,6 +42862,7 @@ ${newlined}
|
|
|
42656
42862
|
};
|
|
42657
42863
|
return pruneUndefinedValues({
|
|
42658
42864
|
...service,
|
|
42865
|
+
enabled: service.enabled ?? true,
|
|
42659
42866
|
container,
|
|
42660
42867
|
agents
|
|
42661
42868
|
});
|
|
@@ -42853,6 +43060,50 @@ ${newlined}
|
|
|
42853
43060
|
annotations: annotations && typeof annotations === "object" ? annotations : {}
|
|
42854
43061
|
};
|
|
42855
43062
|
}
|
|
43063
|
+
parseRoomStatus(data) {
|
|
43064
|
+
if (!data || typeof data !== "object") {
|
|
43065
|
+
throw new requirement_js_1.RoomException("Invalid room status payload");
|
|
43066
|
+
}
|
|
43067
|
+
const { status, allocated_at: allocatedAt, running_for_seconds: runningForSeconds } = data;
|
|
43068
|
+
if (status !== "Allocated" && status !== "Unallocated") {
|
|
43069
|
+
throw new requirement_js_1.RoomException("Invalid room status payload: unknown status");
|
|
43070
|
+
}
|
|
43071
|
+
if (allocatedAt != null && typeof allocatedAt !== "string") {
|
|
43072
|
+
throw new requirement_js_1.RoomException("Invalid room status payload: allocated_at must be a timestamp");
|
|
43073
|
+
}
|
|
43074
|
+
if (runningForSeconds != null && typeof runningForSeconds !== "number") {
|
|
43075
|
+
throw new requirement_js_1.RoomException("Invalid room status payload: running_for_seconds must be a number");
|
|
43076
|
+
}
|
|
43077
|
+
return {
|
|
43078
|
+
status,
|
|
43079
|
+
allocatedAt: allocatedAt == null ? null : new Date(allocatedAt),
|
|
43080
|
+
runningForSeconds: runningForSeconds == null ? null : runningForSeconds
|
|
43081
|
+
};
|
|
43082
|
+
}
|
|
43083
|
+
parseRoomLifecycleEvent(data) {
|
|
43084
|
+
if (!data || typeof data !== "object") {
|
|
43085
|
+
throw new requirement_js_1.RoomException("Invalid room lifecycle event payload");
|
|
43086
|
+
}
|
|
43087
|
+
const { id, room_name: roomName, session_id: sessionId, type, message: message2, severity, created_at: createdAt } = data;
|
|
43088
|
+
if (typeof id !== "string" || typeof roomName !== "string" || typeof type !== "string" || typeof message2 !== "string" || typeof createdAt !== "string") {
|
|
43089
|
+
throw new requirement_js_1.RoomException("Invalid room lifecycle event payload: missing required fields");
|
|
43090
|
+
}
|
|
43091
|
+
if (sessionId != null && typeof sessionId !== "string") {
|
|
43092
|
+
throw new requirement_js_1.RoomException("Invalid room lifecycle event payload: session_id must be a string");
|
|
43093
|
+
}
|
|
43094
|
+
if (severity != null && typeof severity !== "string") {
|
|
43095
|
+
throw new requirement_js_1.RoomException("Invalid room lifecycle event payload: severity must be a string");
|
|
43096
|
+
}
|
|
43097
|
+
return {
|
|
43098
|
+
id,
|
|
43099
|
+
roomName,
|
|
43100
|
+
sessionId: sessionId == null ? null : sessionId,
|
|
43101
|
+
type,
|
|
43102
|
+
message: message2,
|
|
43103
|
+
severity: severity == null ? null : severity,
|
|
43104
|
+
createdAt: new Date(createdAt)
|
|
43105
|
+
};
|
|
43106
|
+
}
|
|
42856
43107
|
parseGroup(data) {
|
|
42857
43108
|
if (!data || typeof data !== "object") {
|
|
42858
43109
|
throw new requirement_js_1.RoomException("Invalid group payload");
|
|
@@ -43010,7 +43261,7 @@ ${newlined}
|
|
|
43010
43261
|
serializeAccessSubject(subject) {
|
|
43011
43262
|
return {
|
|
43012
43263
|
type: subject.type,
|
|
43013
|
-
id: subject.id,
|
|
43264
|
+
...subject.id !== void 0 ? { id: subject.id } : {},
|
|
43014
43265
|
...subject.name !== void 0 ? { name: subject.name } : {},
|
|
43015
43266
|
...subject.firstName !== void 0 ? { first_name: subject.firstName } : {},
|
|
43016
43267
|
...subject.lastName !== void 0 ? { last_name: subject.lastName } : {},
|
|
@@ -43019,6 +43270,22 @@ ${newlined}
|
|
|
43019
43270
|
...subject.relation !== void 0 ? { relation: subject.relation } : {}
|
|
43020
43271
|
};
|
|
43021
43272
|
}
|
|
43273
|
+
parseLlmDelegation(data) {
|
|
43274
|
+
if (!data || typeof data !== "object" || typeof data.id !== "string" || typeof data.token !== "string" || typeof data.expires_at !== "string" || typeof data.project_id !== "string" || typeof data.max_budget !== "string") {
|
|
43275
|
+
throw new requirement_js_1.RoomException("Invalid LLM delegation payload");
|
|
43276
|
+
}
|
|
43277
|
+
return {
|
|
43278
|
+
id: data.id,
|
|
43279
|
+
token: data.token,
|
|
43280
|
+
expiresAt: data.expires_at,
|
|
43281
|
+
projectId: data.project_id,
|
|
43282
|
+
delegator: this.parseAccessSubject(data.delegator),
|
|
43283
|
+
subject: this.parseAccessSubject(data.subject),
|
|
43284
|
+
providers: Array.isArray(data.providers) ? data.providers : null,
|
|
43285
|
+
models: Array.isArray(data.models) ? data.models.filter((value) => typeof value === "string") : null,
|
|
43286
|
+
maxBudget: data.max_budget
|
|
43287
|
+
};
|
|
43288
|
+
}
|
|
43022
43289
|
serializeAccessResource(resource) {
|
|
43023
43290
|
return {
|
|
43024
43291
|
type: resource.type,
|
|
@@ -43067,6 +43334,9 @@ ${newlined}
|
|
|
43067
43334
|
metadata: parsedResource.metadata ?? {},
|
|
43068
43335
|
annotations: parsedResource.annotations ?? {}
|
|
43069
43336
|
};
|
|
43337
|
+
if (!parsedSubject.id) {
|
|
43338
|
+
throw new requirement_js_1.RoomException("Invalid room grant payload: missing subject id");
|
|
43339
|
+
}
|
|
43070
43340
|
return {
|
|
43071
43341
|
resource: parsedResource,
|
|
43072
43342
|
subject: parsedSubject,
|
|
@@ -44105,6 +44375,22 @@ ${newlined}
|
|
|
44105
44375
|
});
|
|
44106
44376
|
return this.parseRoom(data);
|
|
44107
44377
|
}
|
|
44378
|
+
async getRoomStatus(projectId, name) {
|
|
44379
|
+
const roomName = this.encodePathComponent(name);
|
|
44380
|
+
const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/status`, {
|
|
44381
|
+
action: "get room status"
|
|
44382
|
+
});
|
|
44383
|
+
return this.parseRoomStatus(data);
|
|
44384
|
+
}
|
|
44385
|
+
async listRoomEvents(projectId, name, options = {}) {
|
|
44386
|
+
const roomName = this.encodePathComponent(name);
|
|
44387
|
+
const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/events`, {
|
|
44388
|
+
query: { limit: options.limit ?? 100 },
|
|
44389
|
+
action: "list room lifecycle events"
|
|
44390
|
+
});
|
|
44391
|
+
const events = Array.isArray(data?.events) ? data.events : [];
|
|
44392
|
+
return events.map((event) => this.parseRoomLifecycleEvent(event));
|
|
44393
|
+
}
|
|
44108
44394
|
async updateRoom(projectId, roomId, name, options = {}) {
|
|
44109
44395
|
const payload = { name };
|
|
44110
44396
|
if (options.metadata !== void 0) {
|
|
@@ -44228,6 +44514,21 @@ ${newlined}
|
|
|
44228
44514
|
});
|
|
44229
44515
|
return this.parseAgentConnectionInfo(data);
|
|
44230
44516
|
}
|
|
44517
|
+
async connectLlm(params) {
|
|
44518
|
+
const data = await this.request("/llm/connect", {
|
|
44519
|
+
method: "POST",
|
|
44520
|
+
headers: { "Meshagent-Project-Id": params.projectId },
|
|
44521
|
+
json: {
|
|
44522
|
+
subject: this.serializeAccessSubject(params.subject),
|
|
44523
|
+
max_budget: params.maxBudget,
|
|
44524
|
+
...params.providers !== void 0 ? { providers: params.providers } : {},
|
|
44525
|
+
...params.models !== void 0 ? { models: params.models } : {},
|
|
44526
|
+
...params.expiresInSeconds !== void 0 ? { expires_in_seconds: params.expiresInSeconds } : {}
|
|
44527
|
+
},
|
|
44528
|
+
action: "connect LLM delegation"
|
|
44529
|
+
});
|
|
44530
|
+
return this.parseLlmDelegation(data);
|
|
44531
|
+
}
|
|
44231
44532
|
async listRooms(projectId, options = {}) {
|
|
44232
44533
|
const { pageSize = 50, continuationToken, filter, view } = options;
|
|
44233
44534
|
const data = await this.request(`/accounts/projects/${projectId}/rooms`, {
|