@workos-inc/node 12.2.0 → 12.4.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.
@@ -1,20 +1,19 @@
1
- //#region \0rolldown/runtime.js
1
+ // \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
- var __exportAll = (all, no_symbols) => {
4
- let target = {};
3
+ var __exportAll = (all, flags) => {
4
+ let target = Object.setPrototypeOf({}, null);
5
5
  for (var name in all) __defProp(target, name, {
6
6
  get: all[name],
7
7
  enumerable: true
8
8
  });
9
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
- return target;
9
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return flags & 2 ? target : Object.preventExtensions(target);
11
11
  };
12
- //#endregion
13
- //#region node_modules/jose/dist/webapi/lib/buffer_utils.js
12
+ // node_modules/jose/dist/webapi/lib/buffer_utils.js
14
13
  const encoder = new TextEncoder();
15
14
  const decoder = new TextDecoder();
16
15
  const strictDecoder = new TextDecoder("utf-8", { fatal: !0 });
17
- const MAX_INT32 = 2 ** 32;
16
+ const UINT32_RANGE = 2 ** 32;
18
17
  function concat(...buffers) {
19
18
  const size = buffers.reduce((acc, { length }) => acc + length, 0), buf = new Uint8Array(size);
20
19
  let i = 0;
@@ -22,7 +21,7 @@ function concat(...buffers) {
22
21
  return buf;
23
22
  }
24
23
  function writeUInt32BE(buf, value, offset) {
25
- if (value < 0 || value >= MAX_INT32) throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);
24
+ if (value < 0 || value >= UINT32_RANGE) throw new RangeError(`value must be >= 0 and <= ${UINT32_RANGE - 1}. Received ${value}`);
26
25
  buf.set([
27
26
  value >>> 24,
28
27
  value >>> 16,
@@ -31,7 +30,7 @@ function writeUInt32BE(buf, value, offset) {
31
30
  ], offset);
32
31
  }
33
32
  function uint64be(value) {
34
- const high = Math.floor(value / MAX_INT32), low = value % MAX_INT32, buf = /* @__PURE__ */ new Uint8Array(8);
33
+ const high = Math.floor(value / UINT32_RANGE), low = value % UINT32_RANGE, buf = /* @__PURE__ */ new Uint8Array(8);
35
34
  return writeUInt32BE(buf, high, 0), writeUInt32BE(buf, low, 4), buf;
36
35
  }
37
36
  function uint32be(value) {
@@ -76,8 +75,7 @@ async function digest(algorithm, data) {
76
75
  const subtleDigest = `SHA-${algorithm.slice(-3)}`;
77
76
  return new Uint8Array(await crypto.subtle.digest(subtleDigest, data));
78
77
  }
79
- //#endregion
80
- //#region node_modules/jose/dist/webapi/util/errors.js
78
+ // node_modules/jose/dist/webapi/util/errors.js
81
79
  var errors_exports = /* @__PURE__ */ __exportAll({
82
80
  JOSEAlgNotAllowed: () => JOSEAlgNotAllowed,
83
81
  JOSEError: () => JOSEError,
@@ -194,8 +192,7 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
194
192
  super(message, options);
195
193
  }
196
194
  };
197
- //#endregion
198
- //#region node_modules/jose/dist/webapi/util/base64url.js
195
+ // node_modules/jose/dist/webapi/util/base64url.js
199
196
  var base64url_exports = /* @__PURE__ */ __exportAll({
200
197
  decode: () => decode,
201
198
  encode: () => encode
@@ -211,8 +208,7 @@ function decode(input) {
211
208
  function encode(input) {
212
209
  return encodeBase64(typeof input == "string" ? encoder.encode(input) : input, !0);
213
210
  }
214
- //#endregion
215
- //#region node_modules/jose/dist/webapi/lib/validate.js
211
+ // node_modules/jose/dist/webapi/lib/validate.js
216
212
  function assertUint8Array(input, label) {
217
213
  if (!(input instanceof Uint8Array)) throw new TypeError(`${label} must be an instance of Uint8Array`);
218
214
  }
@@ -238,23 +234,23 @@ function assertNotSet(value, name) {
238
234
  function decodeBase64url(value, label, ErrorClass) {
239
235
  try {
240
236
  return decode(value);
241
- } catch {
242
- throw new ErrorClass(`Failed to base64url decode the ${label}`);
237
+ } catch (cause) {
238
+ throw new ErrorClass(`Failed to base64url decode the ${label}`, { cause });
243
239
  }
244
240
  }
245
- function encodeBase64url(value, label, ErrorClass) {
241
+ function encodeAsciiMember(value, label, ErrorClass) {
246
242
  try {
247
243
  return encode$1(value);
248
- } catch {
249
- throw new ErrorClass(`The ${label} is not a valid base64url string`);
244
+ } catch (cause) {
245
+ throw new ErrorClass(`The ${label} is not a valid base64url string`, { cause });
250
246
  }
251
247
  }
252
- function parseJoseHeader(b64, ErrorClass, message) {
248
+ function parseJoseHeader(encodedProtectedHeader, ErrorClass, message) {
253
249
  let parsed;
254
250
  try {
255
- parsed = JSON.parse(strictDecoder.decode(decode(b64)));
256
- } catch {
257
- throw new ErrorClass(message);
251
+ parsed = JSON.parse(strictDecoder.decode(decode(encodedProtectedHeader)));
252
+ } catch (cause) {
253
+ throw new ErrorClass(message, { cause });
258
254
  }
259
255
  if (!isObject(parsed)) throw new ErrorClass(message);
260
256
  return parsed;
@@ -306,8 +302,7 @@ function serializeJoseHeader(Err, header) {
306
302
  if (!isObject(parsed)) throw new Err("JOSE Header is not a JSON object");
307
303
  return [parsed, serialized];
308
304
  }
309
- //#endregion
310
- //#region node_modules/jose/dist/webapi/lib/key.js
305
+ // node_modules/jose/dist/webapi/lib/key.js
311
306
  const tag = (key) => key[Symbol.toStringTag];
312
307
  const jwkMatchesOp = (entry, key, usage) => {
313
308
  const { alg } = entry;
@@ -322,12 +317,12 @@ const jwkMatchesOp = (entry, key, usage) => {
322
317
  }
323
318
  };
324
319
  async function prepareKey(entry, key, usage) {
325
- const { alg, secret } = entry, privateKey = usage === "decrypt" || usage === "sign";
320
+ const { alg, secret } = entry, requiresPrivateKey = usage === "decrypt" || usage === "sign";
326
321
  if (secret && key instanceof Uint8Array) return key;
327
322
  let normalized, keyObject;
328
323
  if (isObject(key)) {
329
324
  if (normalized = normalizeJwk(key), typeof normalized.kty != "string") throw invalidKeyType(alg, key, secret);
330
- if (!(secret ? normalized.kty === "oct" && typeof normalized.k == "string" : normalized.kty !== "oct" && (privateKey ? normalized.kty === "AKP" && typeof normalized.priv == "string" || typeof normalized.d == "string" : normalized.d === void 0 && normalized.priv === void 0))) throw new TypeError(secret ? "JSON Web Key for symmetric algorithms must have JWK \"kty\" (Key Type) equal to \"oct\" and the JWK \"k\" (Key Value) present" : `JSON Web Key for this operation must be a ${privateKey ? "private" : "public"} JWK`);
325
+ if (!(secret ? normalized.kty === "oct" && typeof normalized.k == "string" : normalized.kty !== "oct" && (requiresPrivateKey ? normalized.kty === "AKP" && typeof normalized.priv == "string" || typeof normalized.d == "string" : normalized.d === void 0 && normalized.priv === void 0))) throw new TypeError(secret ? "JSON Web Key for symmetric algorithms must have JWK \"kty\" (Key Type) equal to \"oct\" and the JWK \"k\" (Key Value) present" : `JSON Web Key for this operation must be a ${requiresPrivateKey ? "private" : "public"} JWK`);
331
326
  if (jwkMatchesOp(entry, normalized, usage), normalized.kty === "oct") return decode(normalized.k);
332
327
  if (!Object.isFrozen(key)) {
333
328
  const { key_ops } = key;
@@ -335,7 +330,7 @@ async function prepareKey(entry, key, usage) {
335
330
  }
336
331
  } else {
337
332
  if (!isKeyLike(key)) throw invalidKeyType(alg, key, secret);
338
- const expectedType = secret ? "secret" : privateKey ? "private" : "public";
333
+ const expectedType = secret ? "secret" : requiresPrivateKey ? "private" : "public";
339
334
  if (key.type !== expectedType && (secret || [
340
335
  "secret",
341
336
  "public",
@@ -443,8 +438,7 @@ async function jwkToKey(entry, jwk, extractable) {
443
438
  async function rawKey(key, expected, usage, extractable = !1) {
444
439
  return key instanceof Uint8Array && (key = await crypto.subtle.importKey("raw", key, expected, extractable, [usage])), checkCryptoKey(key, expected, usage), key;
445
440
  }
446
- //#endregion
447
- //#region node_modules/jose/dist/webapi/lib/content_encryption.js
441
+ // node_modules/jose/dist/webapi/lib/content_encryption.js
448
442
  const generateCek = (enc) => crypto.getRandomValues(new Uint8Array(enc.cekBits >> 3));
449
443
  function checkCekLength(cek, expected) {
450
444
  const actual = cek.byteLength << 3;
@@ -456,27 +450,27 @@ function checkIvLength(enc, iv) {
456
450
  }
457
451
  async function cbcKeySetup(enc, cek, usage) {
458
452
  if (!(cek instanceof Uint8Array)) throw new TypeError(invalidKeyInput(cek, "Uint8Array"));
459
- const keySize = enc.cekBits >> 1;
453
+ const keyLengthBits = enc.cekBits >> 1;
460
454
  return [
461
- await crypto.subtle.importKey("raw", cek.subarray(keySize >> 3), "AES-CBC", !1, [usage]),
462
- await crypto.subtle.importKey("raw", cek.subarray(0, keySize >> 3), {
463
- hash: `SHA-${keySize << 1}`,
455
+ await crypto.subtle.importKey("raw", cek.subarray(keyLengthBits >> 3), "AES-CBC", !1, [usage]),
456
+ await crypto.subtle.importKey("raw", cek.subarray(0, keyLengthBits >> 3), {
457
+ hash: `SHA-${keyLengthBits << 1}`,
464
458
  name: "HMAC"
465
459
  }, !1, ["sign"]),
466
- keySize
460
+ keyLengthBits
467
461
  ];
468
462
  }
469
- async function cbcHmacTag(macKey, macData, keySize) {
470
- return new Uint8Array((await crypto.subtle.sign("HMAC", macKey, macData)).slice(0, keySize >> 3));
463
+ async function cbcHmacTag(macKey, macData, keyLengthBits) {
464
+ return new Uint8Array((await crypto.subtle.sign("HMAC", macKey, macData)).slice(0, keyLengthBits >> 3));
471
465
  }
472
466
  async function cbcEncrypt(enc, plaintext, cek, iv, aad) {
473
- const [encKey, macKey, keySize] = await cbcKeySetup(enc, cek, "encrypt"), ciphertext = new Uint8Array(await crypto.subtle.encrypt({
467
+ const [encKey, macKey, keyLengthBits] = await cbcKeySetup(enc, cek, "encrypt"), ciphertext = new Uint8Array(await crypto.subtle.encrypt({
474
468
  iv,
475
469
  name: "AES-CBC"
476
470
  }, encKey, plaintext));
477
471
  return {
478
472
  ciphertext,
479
- tag: await cbcHmacTag(macKey, concat(aad, iv, ciphertext, uint64be(aad.length * 8)), keySize),
473
+ tag: await cbcHmacTag(macKey, concat(aad, iv, ciphertext, uint64be(aad.length * 8)), keyLengthBits),
480
474
  iv
481
475
  };
482
476
  }
@@ -488,7 +482,7 @@ async function timingSafeEqual(a, b) {
488
482
  return crypto.subtle.verify(algorithm, key, aHmac, b);
489
483
  }
490
484
  async function cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) {
491
- const [encKey, macKey, keySize] = await cbcKeySetup(enc, cek, "decrypt"), expectedTag = await cbcHmacTag(macKey, concat(aad, iv, ciphertext, uint64be(aad.length * 8)), keySize);
485
+ const [encKey, macKey, keyLengthBits] = await cbcKeySetup(enc, cek, "decrypt"), expectedTag = await cbcHmacTag(macKey, concat(aad, iv, ciphertext, uint64be(aad.length * 8)), keyLengthBits);
492
486
  try {
493
487
  if (await timingSafeEqual(tag, expectedTag)) return new Uint8Array(await crypto.subtle.decrypt({
494
488
  iv,
@@ -530,8 +524,7 @@ async function decrypt(enc, cek, ciphertext, iv, tag, aad) {
530
524
  throw new JWEDecryptionFailed();
531
525
  }
532
526
  }
533
- //#endregion
534
- //#region node_modules/jose/dist/webapi/lib/key_descriptor.js
527
+ // node_modules/jose/dist/webapi/lib/key_descriptor.js
535
528
  function table(entries) {
536
529
  const out = { __proto__: null };
537
530
  for (const alg in entries) out[alg] = {
@@ -540,8 +533,7 @@ function table(entries) {
540
533
  };
541
534
  return out;
542
535
  }
543
- //#endregion
544
- //#region node_modules/jose/dist/webapi/lib/jwe_algorithms.js
536
+ // node_modules/jose/dist/webapi/lib/jwe_algorithms.js
545
537
  const wrap = [["encrypt", "wrapKey"], ["decrypt", "unwrapKey"]];
546
538
  const derive = [[], ["deriveBits"]];
547
539
  const none = [[], []];
@@ -660,8 +652,7 @@ function isJWECEKTransport(algorithm) {
660
652
  function jweEncryption(enc) {
661
653
  return (typeof enc == "string" ? ENC[enc] : void 0) ?? unsupported("enc", "Encryption Algorithm");
662
654
  }
663
- //#endregion
664
- //#region node_modules/jose/dist/webapi/lib/key_management.js
655
+ // node_modules/jose/dist/webapi/lib/key_management.js
665
656
  function checkEcdhCryptoKey(key, usage) {
666
657
  if (key.algorithm.name !== "ECDH" && key.algorithm.name !== "X25519") throw new TypeError("CryptoKey does not support this operation, its algorithm.name must be ECDH or X25519");
667
658
  checkUsage(key, usage);
@@ -686,32 +677,32 @@ function checkRsaKey(alg, key, usage) {
686
677
  async function deriveKey(p2s, alg, p2c, key) {
687
678
  if (!(p2s instanceof Uint8Array) || p2s.length < 8) throw new JWEInvalid("PBES2 Salt Input must be 8 or more octets");
688
679
  if (!Number.isSafeInteger(p2c) || Math.sign(p2c) !== 1) throw new JWEInvalid("PBES2 Count Input must be a positive integer");
689
- const salt = concat(encode$1(alg), Uint8Array.of(0), p2s), keylen = parseInt(alg.slice(13, 16), 10), subtleAlg = {
680
+ const salt = concat(encode$1(alg), Uint8Array.of(0), p2s), keyLengthBits = parseInt(alg.slice(13, 16), 10), subtleAlg = {
690
681
  hash: `SHA-${alg.slice(8, 11)}`,
691
682
  iterations: p2c,
692
683
  name: "PBKDF2",
693
684
  salt
694
685
  }, cryptoKey = await rawKey(key, jweAlgorithm(alg).subtle, "deriveBits");
695
- return new Uint8Array(await crypto.subtle.deriveBits(subtleAlg, cryptoKey, keylen));
686
+ return new Uint8Array(await crypto.subtle.deriveBits(subtleAlg, cryptoKey, keyLengthBits));
696
687
  }
697
688
  function lengthAndInput(input) {
698
689
  return concat(uint32be(input.length), input);
699
690
  }
700
- async function concatKdf(Z, L, OtherInfo) {
701
- const dkLen = L >> 3, hashLen = 32, reps = Math.ceil(dkLen / hashLen), dk = new Uint8Array(reps * hashLen);
691
+ async function concatKdf(Z, keyDataLength, OtherInfo) {
692
+ const dkLen = keyDataLength >> 3, hashLen = 32, reps = Math.ceil(dkLen / hashLen), dk = new Uint8Array(reps * hashLen);
702
693
  for (let i = 1; i <= reps; i++) {
703
694
  const hashResult = await digest("sha256", concat(uint32be(i), Z, OtherInfo));
704
695
  dk.set(hashResult, (i - 1) * hashLen);
705
696
  }
706
697
  return dk.slice(0, dkLen);
707
698
  }
708
- async function ecdhesDeriveKey(publicKey, privateKey, algorithm, keyLength, apu = /* @__PURE__ */ new Uint8Array(), apv = /* @__PURE__ */ new Uint8Array()) {
699
+ async function ecdhesDeriveKey(publicKey, privateKey, algorithmId, keyDataLength, apu = /* @__PURE__ */ new Uint8Array(), apv = /* @__PURE__ */ new Uint8Array()) {
709
700
  checkEcdhCryptoKey(publicKey), checkEcdhCryptoKey(privateKey, "deriveBits");
710
- const otherInfo = concat(lengthAndInput(encode$1(algorithm)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyLength));
701
+ const otherInfo = concat(lengthAndInput(encode$1(algorithmId)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyDataLength));
711
702
  return concatKdf(new Uint8Array(await crypto.subtle.deriveBits({
712
703
  name: publicKey.algorithm.name,
713
704
  public: publicKey
714
- }, privateKey, publicKey.algorithm.name === "X25519" ? 256 : Math.ceil(parseInt(publicKey.algorithm.namedCurve.slice(-3), 10) / 8) << 3)), keyLength, otherInfo);
705
+ }, privateKey, publicKey.algorithm.name === "X25519" ? 256 : Math.ceil(parseInt(publicKey.algorithm.namedCurve.slice(-3), 10) / 8) << 3)), keyDataLength, otherInfo);
715
706
  }
716
707
  function assertEcdhKey(key) {
717
708
  assertCryptoKey(key);
@@ -761,15 +752,14 @@ async function decryptKeyManagement(entry, enc, key, encryptedKey, joseHeader, m
761
752
  assertEcdhKey(key);
762
753
  const ephemeralPublicKey = await jwkToKey(entry, epk), partyUInfo = partyInfo(joseHeader, "apu"), partyVInfo = partyInfo(joseHeader, "apv");
763
754
  checkPartyInfo(partyUInfo, partyVInfo);
764
- const sharedSecret = await ecdhesDeriveKey(ephemeralPublicKey, key, direct ? enc.alg : alg, direct ? enc.cekBits : parseInt(alg.slice(-5, -2), 10), partyUInfo, partyVInfo);
765
- if (direct) return sharedSecret;
766
- key = sharedSecret;
755
+ const derivedKey = await ecdhesDeriveKey(ephemeralPublicKey, key, direct ? enc.alg : alg, direct ? enc.cekBits : parseInt(alg.slice(-5, -2), 10), partyUInfo, partyVInfo);
756
+ if (direct) return derivedKey;
757
+ key = derivedKey;
767
758
  break;
768
759
  }
769
760
  case "RSA-OAEP": return assertCryptoKey(key), checkRsaKey(alg, key, "decrypt"), new Uint8Array(await crypto.subtle.decrypt("RSA-OAEP", key, encryptedKey));
770
761
  case "PBKDF2": {
771
762
  if (typeof joseHeader.p2c != "number") throw new JWEInvalid("JOSE Header \"p2c\" (PBES2 Count) missing or invalid");
772
- validateMaxPBES2Count(maxPBES2Count);
773
763
  const p2cLimit = maxPBES2Count ?? 1e4;
774
764
  if (joseHeader.p2c > p2cLimit) throw new JWEInvalid("JOSE Header \"p2c\" (PBES2 Count) out is of acceptable bounds");
775
765
  if (typeof joseHeader.p2s != "string") throw new JWEInvalid("JOSE Header \"p2s\" (PBES2 Salt) missing or invalid");
@@ -806,25 +796,25 @@ async function encryptKeyManagement(entry, enc, inputKey, joseHeader, providedCe
806
796
  providedApu !== void 0 && assertUint8Array(providedApu, "\"apu\""), providedApv !== void 0 && assertUint8Array(providedApv, "\"apv\"");
807
797
  const apu = providedApu ?? partyInfo(joseHeader, "apu"), apv = providedApv ?? partyInfo(joseHeader, "apv");
808
798
  checkPartyInfo(apu, apv);
809
- let ephemeralKey;
810
- providedParameters.epk !== void 0 ? ephemeralKey = await prepareKey(entry, providedParameters.epk, "decrypt") : ephemeralKey = (await crypto.subtle.generateKey(key.algorithm, !0, ["deriveBits"])).privateKey;
799
+ let ephemeralPrivateKey;
800
+ providedParameters.epk !== void 0 ? ephemeralPrivateKey = await prepareKey(entry, providedParameters.epk, "decrypt") : ephemeralPrivateKey = (await crypto.subtle.generateKey(key.algorithm, !0, ["deriveBits"])).privateKey;
811
801
  const subtle = crypto.subtle;
812
- let exportableEpk = ephemeralKey;
802
+ let exportableEpk = ephemeralPrivateKey;
813
803
  if (!exportableEpk.extractable) {
814
804
  if (typeof subtle.getPublicKey != "function") throw new TypeError("CryptoKey for \"epk\" must be extractable");
815
- exportableEpk = await subtle.getPublicKey(ephemeralKey, []);
805
+ exportableEpk = await subtle.getPublicKey(ephemeralPrivateKey, []);
816
806
  }
817
- const { x, y, crv, kty } = await subtle.exportKey("jwk", exportableEpk), direct = mode === "direct-key-agreement", sharedSecret = await ecdhesDeriveKey(key, ephemeralKey, direct ? enc.alg : alg, direct ? enc.cekBits : parseInt(alg.slice(-5, -2), 10), apu, apv), epk = {
807
+ const { x, y, crv, kty } = await subtle.exportKey("jwk", exportableEpk), direct = mode === "direct-key-agreement", derivedKey = await ecdhesDeriveKey(key, ephemeralPrivateKey, direct ? enc.alg : alg, direct ? enc.cekBits : parseInt(alg.slice(-5, -2), 10), apu, apv), epk = {
818
808
  x,
819
809
  crv,
820
810
  kty
821
811
  };
822
812
  if (kty === "EC" && (epk.y = y), parameters = { epk }, providedApu !== void 0 && (parameters.apu = encode(providedApu)), providedApv !== void 0 && (parameters.apv = encode(providedApv)), direct) return [
823
- sharedSecret,
813
+ derivedKey,
824
814
  void 0,
825
815
  parameters
826
816
  ];
827
- key = sharedSecret;
817
+ key = derivedKey;
828
818
  break;
829
819
  }
830
820
  case "RSA-OAEP":
@@ -855,8 +845,7 @@ async function encryptKeyManagement(entry, enc, inputKey, joseHeader, providedCe
855
845
  parameters
856
846
  ];
857
847
  }
858
- //#endregion
859
- //#region node_modules/jose/dist/webapi/lib/deflate.js
848
+ // node_modules/jose/dist/webapi/lib/deflate.js
860
849
  function validateZip(joseHeader, protectedHeader) {
861
850
  if (joseHeader.zip !== void 0 && joseHeader.zip !== "DEF") throw new JOSENotSupported("Unsupported JWE \"zip\" (Compression Algorithm) Header Parameter value.");
862
851
  if (joseHeader.zip !== void 0 && !protectedHeader?.zip) throw new JWEInvalid("JWE \"zip\" (Compression Algorithm) Header Parameter MUST be in a protected header.");
@@ -873,7 +862,7 @@ async function transform(stream, input, maxLength = 1 / 0) {
873
862
  for (;;) {
874
863
  const { value, done } = await reader.read();
875
864
  if (done) break;
876
- if (chunks.push(value), length += value.byteLength, maxLength !== 1 / 0 && length > maxLength) throw new JWEInvalid("Decompressed plaintext exceeded the configured limit");
865
+ if (chunks.push(value), length += value.byteLength, maxLength !== 1 / 0 && length > maxLength) throw await reader.cancel().catch(() => {}), new JWEInvalid("Decompressed plaintext exceeded the configured limit");
877
866
  }
878
867
  return concat(...chunks);
879
868
  }
@@ -883,8 +872,7 @@ async function compress(input) {
883
872
  async function decompress(input, maxLength) {
884
873
  return supported("DecompressionStream"), transform(new DecompressionStream("deflate-raw"), input, maxLength);
885
874
  }
886
- //#endregion
887
- //#region node_modules/jose/dist/webapi/lib/jwe_decrypt.js
875
+ // node_modules/jose/dist/webapi/lib/jwe_decrypt.js
888
876
  function snapshotSharedJWE(jwe) {
889
877
  const { aad, ciphertext, iv, protected: encodedProtected, tag, unprotected } = jwe;
890
878
  if (iv !== void 0 && (typeof iv != "string" || !iv)) throw new JWEInvalid("JWE Initialization Vector incorrect type");
@@ -932,37 +920,41 @@ function checkRecipient(jwe) {
932
920
  }
933
921
  function shareJWE(jwe) {
934
922
  const { protected: encodedProtected, ciphertext, iv, tag, aad } = jwe;
935
- let parsedProt;
936
- return encodedProtected !== void 0 && (parsedProt = parseJoseHeader(encodedProtected, JWEInvalid, "JWE Protected Header is invalid")), [
937
- parsedProt,
923
+ let protectedHeader;
924
+ return encodedProtected !== void 0 && (protectedHeader = parseJoseHeader(encodedProtected, JWEInvalid, "JWE Protected Header is invalid")), [
925
+ protectedHeader,
938
926
  decodeBase64url(ciphertext, "ciphertext", JWEInvalid),
939
927
  iv !== void 0 ? decodeBase64url(iv, "iv", JWEInvalid) : void 0,
940
928
  tag !== void 0 ? decodeBase64url(tag, "tag", JWEInvalid) : void 0,
941
- encodeBase64url((encodedProtected ?? "") + (aad !== void 0 ? `.${aad}` : ""), "aad", JWEInvalid)
929
+ encodeAsciiMember((encodedProtected ?? "") + (aad !== void 0 ? `.${aad}` : ""), "aad", JWEInvalid)
942
930
  ];
943
931
  }
944
932
  function prepareDecrypt(options) {
933
+ const keyManagementAlgorithms = options && validateAlgorithms("keyManagementAlgorithms", options.keyManagementAlgorithms), contentEncryptionAlgorithms = options && validateAlgorithms("contentEncryptionAlgorithms", options.contentEncryptionAlgorithms), { crit, maxPBES2Count, maxDecompressedLength } = options ?? {};
934
+ validateMaxPBES2Count(maxPBES2Count);
935
+ const decompressionLimit = maxDecompressedLength ?? 25e4;
936
+ if (decompressionLimit !== 0 && decompressionLimit !== 1 / 0 && (!Number.isSafeInteger(decompressionLimit) || decompressionLimit < 1)) throw new TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");
945
937
  return [
946
- options && validateAlgorithms("keyManagementAlgorithms", options.keyManagementAlgorithms),
947
- options && validateAlgorithms("contentEncryptionAlgorithms", options.contentEncryptionAlgorithms),
948
- options?.crit,
949
- options?.maxPBES2Count,
950
- options?.maxDecompressedLength
938
+ keyManagementAlgorithms,
939
+ contentEncryptionAlgorithms,
940
+ crit,
941
+ maxPBES2Count,
942
+ maxDecompressedLength
951
943
  ];
952
944
  }
953
945
  async function decryptJWE(jwe, shared, key, token = shareJWE(jwe)) {
954
- const [parsedProt, ciphertext, iv, tag, additionalData] = token, { header, unprotected, aad } = jwe;
946
+ const [protectedHeader, ciphertext, iv, tag, additionalAuthenticatedData] = token, { header, unprotected, aad } = jwe;
955
947
  let joseHeader;
956
948
  if (header !== void 0 || unprotected !== void 0) {
957
- if (!isDisjoint(parsedProt, header, unprotected)) throw new JWEInvalid("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");
949
+ if (!isDisjoint(protectedHeader, header, unprotected)) throw new JWEInvalid("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");
958
950
  joseHeader = {
959
- ...parsedProt,
951
+ ...protectedHeader,
960
952
  ...header,
961
953
  ...unprotected
962
954
  };
963
- } else joseHeader = parsedProt ?? {};
955
+ } else joseHeader = protectedHeader ?? {};
964
956
  const [keyManagementAlgorithms, contentEncryptionAlgorithms, crit, maxPBES2Count, maxDecompressedLength] = shared, { encrypted_key: encodedKey } = jwe;
965
- validateCrit(JWEInvalid, JWE_RECOGNIZED, crit, parsedProt, joseHeader), validateZip(joseHeader, parsedProt);
957
+ validateCrit(JWEInvalid, JWE_RECOGNIZED, crit, protectedHeader, joseHeader), validateZip(joseHeader, protectedHeader);
966
958
  const { alg, enc } = joseHeader;
967
959
  if (typeof alg != "string" || !alg) throw new JWEInvalid("missing JWE Algorithm (alg) in JWE Header");
968
960
  const selected = JWE[alg];
@@ -987,12 +979,12 @@ async function decryptJWE(jwe, shared, key, token = shareJWE(jwe)) {
987
979
  encryptedKey = /* @__PURE__ */ new Uint8Array();
988
980
  }
989
981
  let resolvedKey = !1;
990
- typeof key == "function" && (key = await key(parsedProt, jwe), resolvedKey = !0);
982
+ typeof key == "function" && (key = await key(protectedHeader, jwe), resolvedKey = !0);
991
983
  const algEntry = selected ?? jweAlgorithm(alg);
992
984
  isJWECEKTransport(algEntry) && encryptedKey === void 0 && (encryptedKey = /* @__PURE__ */ new Uint8Array());
993
985
  const k = await prepareKey(algEntry.mode === "direct-encryption" ? encEntry : algEntry, key, "decrypt");
994
986
  let plaintext;
995
- if (algEntry.mode === "integrated-encryption") plaintext = await algEntry.decrypt(k, encryptedKey, ciphertext, additionalData, parsedProt, joseHeader);
987
+ if (algEntry.mode === "integrated-encryption") plaintext = await algEntry.decrypt(k, encryptedKey, ciphertext, additionalAuthenticatedData, protectedHeader, joseHeader);
996
988
  else {
997
989
  const encryption = encEntry;
998
990
  let cek;
@@ -1002,19 +994,18 @@ async function decryptJWE(jwe, shared, key, token = shareJWE(jwe)) {
1002
994
  if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) throw err;
1003
995
  cek = generateCek(encryption);
1004
996
  }
1005
- plaintext = await decrypt(encryption, cek, ciphertext, iv, tag, additionalData);
997
+ plaintext = await decrypt(encryption, cek, ciphertext, iv, tag, additionalAuthenticatedData);
1006
998
  }
1007
999
  if (joseHeader.zip === "DEF") {
1008
1000
  const decompressionLimit = maxDecompressedLength ?? 25e4;
1009
1001
  if (decompressionLimit === 0) throw new JOSENotSupported("JWE \"zip\" (Compression Algorithm) Header Parameter is not supported.");
1010
- if (decompressionLimit !== 1 / 0 && (!Number.isSafeInteger(decompressionLimit) || decompressionLimit < 1)) throw new TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");
1011
1002
  plaintext = await decompress(plaintext, decompressionLimit).catch((cause) => {
1012
1003
  throw cause instanceof JWEInvalid ? cause : new JWEInvalid("Failed to decompress plaintext", { cause });
1013
1004
  });
1014
1005
  }
1015
1006
  return {
1016
1007
  plaintext,
1017
- ...parsedProt && { protectedHeader: parsedProt },
1008
+ ...protectedHeader && { protectedHeader },
1018
1009
  ...aad !== void 0 && { additionalAuthenticatedData: decodeBase64url(aad, "aad", JWEInvalid) },
1019
1010
  ...unprotected && { sharedUnprotectedHeader: unprotected },
1020
1011
  ...header && { unprotectedHeader: header },
@@ -1033,13 +1024,11 @@ async function decryptCompact(jwe, shared, key) {
1033
1024
  encrypted_key: encryptedKey || void 0
1034
1025
  }, shared, key);
1035
1026
  }
1036
- //#endregion
1037
- //#region node_modules/jose/dist/webapi/jwe/compact/decrypt.js
1027
+ // node_modules/jose/dist/webapi/jwe/compact/decrypt.js
1038
1028
  async function compactDecrypt(jwe, key, options) {
1039
1029
  return decryptCompact(jwe, prepareDecrypt(options), key);
1040
1030
  }
1041
- //#endregion
1042
- //#region node_modules/jose/dist/webapi/jwe/flattened/decrypt.js
1031
+ // node_modules/jose/dist/webapi/jwe/flattened/decrypt.js
1043
1032
  async function flattenedDecrypt(jwe, key, options) {
1044
1033
  if (!isObject(jwe)) throw new JWEInvalid("Flattened JWE must be an object");
1045
1034
  const shared = snapshotSharedJWE(jwe), [recipient, , error] = snapshotRecipientJWE(jwe);
@@ -1050,8 +1039,7 @@ async function flattenedDecrypt(jwe, key, options) {
1050
1039
  };
1051
1040
  return checkRecipient(snapshot), decryptJWE(snapshot, prepareDecrypt(options), key);
1052
1041
  }
1053
- //#endregion
1054
- //#region node_modules/jose/dist/webapi/jwe/general/decrypt.js
1042
+ // node_modules/jose/dist/webapi/jwe/general/decrypt.js
1055
1043
  async function generalDecrypt(jwe, key, options) {
1056
1044
  if (!isObject(jwe)) throw new JWEInvalid("General JWE must be an object");
1057
1045
  const inputRecipients = jwe.recipients;
@@ -1059,9 +1047,10 @@ async function generalDecrypt(jwe, key, options) {
1059
1047
  const recipients = Array.from(inputRecipients);
1060
1048
  if (!recipients.every(isObject)) throw new JWEInvalid("JWE Recipients missing or incorrect type");
1061
1049
  if (!recipients.length) throw new JWEInvalid("JWE Recipients has no members");
1062
- let shared, sharedJwe, token;
1050
+ const shared = prepareDecrypt(options);
1051
+ let sharedJwe, token;
1063
1052
  try {
1064
- shared = prepareDecrypt(options), sharedJwe = snapshotSharedJWE(jwe), token = shareJWE(sharedJwe);
1053
+ sharedJwe = snapshotSharedJWE(jwe), token = shareJWE(sharedJwe);
1065
1054
  } catch {
1066
1055
  throw new JWEDecryptionFailed();
1067
1056
  }
@@ -1079,8 +1068,7 @@ async function generalDecrypt(jwe, key, options) {
1079
1068
  } catch {}
1080
1069
  throw new JWEDecryptionFailed();
1081
1070
  }
1082
- //#endregion
1083
- //#region node_modules/jose/dist/webapi/lib/jwe_encrypt.js
1071
+ // node_modules/jose/dist/webapi/lib/jwe_encrypt.js
1084
1072
  function checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader) {
1085
1073
  if (!isDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader)) throw new JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");
1086
1074
  }
@@ -1128,15 +1116,15 @@ async function encryptJWE(input, checked, key) {
1128
1116
  ...protectedHeader,
1129
1117
  ...parameters
1130
1118
  } : parameters, checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader));
1131
- const protectedHeaderS = protectedHeader ? encode(JSON.stringify(protectedHeader)) : "", aadMember = aad?.byteLength ? encode(aad) : void 0, additionalData = encode$1(aadMember ? `${protectedHeaderS}.${aadMember}` : protectedHeaderS);
1119
+ const encodedProtectedHeader = protectedHeader ? encode(JSON.stringify(protectedHeader)) : "", encodedAad = aad?.byteLength ? encode(aad) : void 0, additionalAuthenticatedData = encode$1(encodedAad ? `${encodedProtectedHeader}.${encodedAad}` : encodedProtectedHeader);
1132
1120
  let plaintext = inputPlaintext;
1133
1121
  joseHeader.zip === "DEF" && (plaintext = await compress(plaintext).catch((cause) => {
1134
1122
  throw new JWEInvalid("Failed to compress plaintext", { cause });
1135
1123
  }));
1136
1124
  let ciphertext, tag, iv;
1137
- algEntry.mode === "integrated-encryption" ? [encryptedKey, ciphertext] = await algEntry.encrypt(cek, plaintext, additionalData, protectedHeader, joseHeader, keyManagementParameters) : {ciphertext, tag, iv} = await encrypt(encEntry, plaintext, cek, inputIv, additionalData);
1125
+ algEntry.mode === "integrated-encryption" ? [encryptedKey, ciphertext] = await algEntry.encrypt(cek, plaintext, additionalAuthenticatedData, protectedHeader, joseHeader, keyManagementParameters) : {ciphertext, tag, iv} = await encrypt(encEntry, plaintext, cek, inputIv, additionalAuthenticatedData);
1138
1126
  const jwe = { ciphertext: encode(ciphertext) };
1139
- return iv && (jwe.iv = encode(iv)), tag && (jwe.tag = encode(tag)), encryptedKey?.byteLength && (jwe.encrypted_key = encode(encryptedKey)), aadMember && (jwe.aad = aadMember), protectedHeader && (jwe.protected = protectedHeaderS), sharedUnprotectedHeader && (jwe.unprotected = sharedUnprotectedHeader), unprotectedHeader && (jwe.header = unprotectedHeader), jwe;
1127
+ return iv && (jwe.iv = encode(iv)), tag && (jwe.tag = encode(tag)), encryptedKey?.byteLength && (jwe.encrypted_key = encode(encryptedKey)), encodedAad && (jwe.aad = encodedAad), protectedHeader && (jwe.protected = encodedProtectedHeader), sharedUnprotectedHeader && (jwe.unprotected = sharedUnprotectedHeader), unprotectedHeader && (jwe.header = unprotectedHeader), jwe;
1140
1128
  }
1141
1129
  async function createJWE(input, key, options) {
1142
1130
  return encryptJWE(input, checkEncryptHeaders(input, options), key);
@@ -1150,8 +1138,7 @@ function compactJWE(jwe) {
1150
1138
  jwe.tag
1151
1139
  ].join(".");
1152
1140
  }
1153
- //#endregion
1154
- //#region node_modules/jose/dist/webapi/jwe/general/encrypt.js
1141
+ // node_modules/jose/dist/webapi/jwe/general/encrypt.js
1155
1142
  var IndividualRecipient = class {
1156
1143
  #parent;
1157
1144
  state;
@@ -1183,7 +1170,7 @@ var GeneralEncrypt = class {
1183
1170
  #plaintext;
1184
1171
  #recipients = [];
1185
1172
  #protectedHeader;
1186
- #unprotectedHeader;
1173
+ #sharedUnprotectedHeader;
1187
1174
  #aad;
1188
1175
  constructor(plaintext) {
1189
1176
  this.#plaintext = plaintext;
@@ -1196,7 +1183,7 @@ var GeneralEncrypt = class {
1196
1183
  return assertNotSet(this.#protectedHeader, "setProtectedHeader"), this.#protectedHeader = protectedHeader, this;
1197
1184
  }
1198
1185
  setSharedUnprotectedHeader(sharedUnprotectedHeader) {
1199
- return assertNotSet(this.#unprotectedHeader, "setSharedUnprotectedHeader"), this.#unprotectedHeader = sharedUnprotectedHeader, this;
1186
+ return assertNotSet(this.#sharedUnprotectedHeader, "setSharedUnprotectedHeader"), this.#sharedUnprotectedHeader = sharedUnprotectedHeader, this;
1200
1187
  }
1201
1188
  setAdditionalAuthenticatedData(aad) {
1202
1189
  return this.#aad = aad, this;
@@ -1205,7 +1192,7 @@ var GeneralEncrypt = class {
1205
1192
  if (!this.#recipients.length) throw new JWEInvalid("at least one recipient must be added");
1206
1193
  assertUint8Array(this.#plaintext, "plaintext");
1207
1194
  const multiple = this.#recipients.length > 1;
1208
- let enc, protectedHeader = this.#protectedHeader, sharedUnprotectedHeader = this.#unprotectedHeader;
1195
+ let enc, protectedHeader = this.#protectedHeader, sharedUnprotectedHeader = this.#sharedUnprotectedHeader;
1209
1196
  const recipients = [];
1210
1197
  for (const recipient of this.#recipients) {
1211
1198
  const [unprotectedHeader, keyManagementParameters, key, crit] = recipient.state, input = [
@@ -1252,8 +1239,7 @@ var GeneralEncrypt = class {
1252
1239
  return jwe;
1253
1240
  }
1254
1241
  };
1255
- //#endregion
1256
- //#region node_modules/jose/dist/webapi/lib/jws_algorithms.js
1242
+ // node_modules/jose/dist/webapi/lib/jws_algorithms.js
1257
1243
  const sig = [["verify"], ["sign"]];
1258
1244
  function hmac(bits) {
1259
1245
  const subtle = {
@@ -1309,8 +1295,8 @@ function eddsa() {
1309
1295
  usages: sig
1310
1296
  };
1311
1297
  }
1312
- function mldsa(bits) {
1313
- const subtle = { name: `ML-DSA-${bits}` };
1298
+ function mldsa(parameterSet) {
1299
+ const subtle = { name: `ML-DSA-${parameterSet}` };
1314
1300
  return {
1315
1301
  kty: ["AKP"],
1316
1302
  subtle,
@@ -1342,18 +1328,17 @@ function jwsAlgorithm(alg) {
1342
1328
  if (!entry) throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
1343
1329
  return entry;
1344
1330
  }
1345
- //#endregion
1346
- //#region node_modules/jose/dist/webapi/lib/jws_verify.js
1331
+ // node_modules/jose/dist/webapi/lib/jws_verify.js
1347
1332
  function snapshotJws(jws, sharedPayload) {
1348
- const encodedProtected = jws.protected, inputHeader = jws.header, header = isObject(inputHeader) ? { ...inputHeader } : inputHeader;
1333
+ const encodedProtectedHeader = jws.protected, inputHeader = jws.header, header = isObject(inputHeader) ? { ...inputHeader } : inputHeader;
1349
1334
  let payload = sharedPayload ? sharedPayload[0] : jws.payload;
1350
1335
  !sharedPayload && payload instanceof Uint8Array && (payload = new Uint8Array(payload));
1351
1336
  const signature = jws.signature, snapshot = {
1352
1337
  payload,
1353
1338
  signature
1354
1339
  };
1355
- if (encodedProtected !== void 0 && (snapshot.protected = encodedProtected), inputHeader !== void 0 && (snapshot.header = header), encodedProtected === void 0 && header === void 0) throw new JWSInvalid("Flattened JWS must have either of the \"protected\" or \"header\" members");
1356
- if (encodedProtected !== void 0 && typeof encodedProtected != "string") throw new JWSInvalid("JWS Protected Header incorrect type");
1340
+ if (encodedProtectedHeader !== void 0 && (snapshot.protected = encodedProtectedHeader), inputHeader !== void 0 && (snapshot.header = header), encodedProtectedHeader === void 0 && header === void 0) throw new JWSInvalid("Flattened JWS must have either of the \"protected\" or \"header\" members");
1341
+ if (encodedProtectedHeader !== void 0 && typeof encodedProtectedHeader != "string") throw new JWSInvalid("JWS Protected Header incorrect type");
1357
1342
  if (payload === void 0) throw new JWSInvalid("JWS Payload missing");
1358
1343
  if (typeof signature != "string") throw new JWSInvalid("JWS Signature missing or incorrect type");
1359
1344
  if (header !== void 0 && !isObject(header)) throw new JWSInvalid("JWS Unprotected Header incorrect type");
@@ -1362,8 +1347,8 @@ function snapshotJws(jws, sharedPayload) {
1362
1347
  function prepareVerify(options) {
1363
1348
  return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
1364
1349
  }
1365
- function parseProtectedHeader(encodedProtected) {
1366
- return encodedProtected === void 0 ? {} : parseJoseHeader(encodedProtected, JWSInvalid, "JWS Protected Header is invalid");
1350
+ function parseProtectedHeader(encodedProtectedHeader) {
1351
+ return encodedProtectedHeader === void 0 ? {} : parseJoseHeader(encodedProtectedHeader, JWSInvalid, "JWS Protected Header is invalid");
1367
1352
  }
1368
1353
  function encodeJsonUnencodedPayload(payload) {
1369
1354
  const invalid = /[\p{Cs}\p{Cn}]/u.exec(payload)?.[0];
@@ -1373,17 +1358,17 @@ function encodeJsonUnencodedPayload(payload) {
1373
1358
  function encodeCompactUnencodedPayload(payload) {
1374
1359
  try {
1375
1360
  return encode$1(payload);
1376
- } catch {
1377
- throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters");
1361
+ } catch (cause) {
1362
+ throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters", { cause });
1378
1363
  }
1379
1364
  }
1380
1365
  async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedProtected) {
1381
- const { protected: encodedProtected, header, payload: inputPayload } = jws, parsedProt = parsedProtected ?? parseProtectedHeader(encodedProtected);
1382
- if (!isDisjoint(parsedProt, header)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
1366
+ const { protected: encodedProtectedHeader, header, payload: inputPayload } = jws, protectedHeader = parsedProtected ?? parseProtectedHeader(encodedProtectedHeader);
1367
+ if (!isDisjoint(protectedHeader, header)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
1383
1368
  const joseHeader = {
1384
- ...parsedProt,
1369
+ ...protectedHeader,
1385
1370
  ...header
1386
- }, b64 = validateB64(parsedProt, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], parsedProt, joseHeader)), { alg } = joseHeader;
1371
+ }, b64 = validateB64(protectedHeader, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], protectedHeader, joseHeader)), { alg } = joseHeader;
1387
1372
  if (typeof alg != "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
1388
1373
  if (shared[0] && !shared[0].has(alg)) throw new JOSEAlgNotAllowed("\"alg\" (Algorithm) Header Parameter value not allowed");
1389
1374
  if (b64) {
@@ -1391,18 +1376,20 @@ async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedP
1391
1376
  } else if (typeof inputPayload != "string" && !(inputPayload instanceof Uint8Array)) throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
1392
1377
  const signingPayload = b64 || typeof inputPayload != "string" ? inputPayload : encodeUnencodedPayload(inputPayload);
1393
1378
  let resolvedKey = !1;
1394
- typeof key == "function" && (key = await key(parsedProt, jws), resolvedKey = !0);
1395
- const entry = jwsAlgorithm(alg), data = concat(encodedProtected !== void 0 ? encode$1(encodedProtected) : /* @__PURE__ */ new Uint8Array(), encode$1("."), typeof signingPayload == "string" ? shared[2] ??= encodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload), signature = decodeBase64url(jws.signature, "signature", JWSInvalid), k = await prepareKey(entry, key, "verify"), cryptoKey = await rawKey(k, entry.subtle, "verify");
1379
+ typeof key == "function" && (key = await key(protectedHeader, jws), resolvedKey = !0);
1380
+ const entry = jwsAlgorithm(alg), signingInput = concat(encodedProtectedHeader !== void 0 ? encode$1(encodedProtectedHeader) : /* @__PURE__ */ new Uint8Array(), encode$1("."), typeof signingPayload == "string" ? shared[2] ??= encodeAsciiMember(signingPayload, "payload", JWSInvalid) : signingPayload), signature = decodeBase64url(jws.signature, "signature", JWSInvalid), verificationKey = await prepareKey(entry, key, "verify"), cryptoKey = await rawKey(verificationKey, entry.subtle, "verify");
1396
1381
  entry.minRsaBits && checkModulusLength(entry.alg, cryptoKey);
1397
1382
  let verified = !1;
1398
1383
  try {
1399
- verified = await crypto.subtle.verify(entry.signing, cryptoKey, signature, data);
1400
- } catch {}
1384
+ verified = await crypto.subtle.verify(entry.signing, cryptoKey, signature, signingInput);
1385
+ } catch (cause) {
1386
+ throw new JWSSignatureVerificationFailed(void 0, { cause });
1387
+ }
1401
1388
  if (!verified) throw new JWSSignatureVerificationFailed();
1402
1389
  const result = { payload: typeof signingPayload == "string" ? decodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload };
1403
- return encodedProtected !== void 0 && (result.protectedHeader = parsedProt), header !== void 0 && (result.unprotectedHeader = header), resolvedKey ? [{
1390
+ return encodedProtectedHeader !== void 0 && (result.protectedHeader = protectedHeader), header !== void 0 && (result.unprotectedHeader = header), resolvedKey ? [{
1404
1391
  ...result,
1405
- key: k
1392
+ key: verificationKey
1406
1393
  }, b64] : [result, b64];
1407
1394
  }
1408
1395
  async function verifyCompact(jws, shared, key) {
@@ -1415,21 +1402,18 @@ async function verifyCompact(jws, shared, key) {
1415
1402
  signature
1416
1403
  }, shared, key, encodeCompactUnencodedPayload);
1417
1404
  }
1418
- //#endregion
1419
- //#region node_modules/jose/dist/webapi/jws/compact/verify.js
1405
+ // node_modules/jose/dist/webapi/jws/compact/verify.js
1420
1406
  async function compactVerify(jws, key, options) {
1421
1407
  const [result] = await verifyCompact(jws, prepareVerify(options), key);
1422
1408
  return result;
1423
1409
  }
1424
- //#endregion
1425
- //#region node_modules/jose/dist/webapi/jws/flattened/verify.js
1410
+ // node_modules/jose/dist/webapi/jws/flattened/verify.js
1426
1411
  async function flattenedVerify(jws, key, options) {
1427
1412
  if (!isObject(jws)) throw new JWSInvalid("Flattened JWS must be an object");
1428
1413
  const [result] = await verifySignature(snapshotJws(jws), prepareVerify(options), key, encodeJsonUnencodedPayload);
1429
1414
  return result;
1430
1415
  }
1431
- //#endregion
1432
- //#region node_modules/jose/dist/webapi/jws/general/verify.js
1416
+ // node_modules/jose/dist/webapi/jws/general/verify.js
1433
1417
  function snapshotSignature(signature, payload) {
1434
1418
  try {
1435
1419
  const jws = snapshotJws(signature, [payload]), protectedHeader = parseProtectedHeader(jws.protected), { b64, crit } = protectedHeader;
@@ -1448,24 +1432,17 @@ async function generalVerify(jws, key, options) {
1448
1432
  if (!Array.isArray(signatures)) throw new JWSInvalid("JWS Signatures missing or incorrect type");
1449
1433
  const signatureEntries = Array.from(signatures);
1450
1434
  if (!signatureEntries.every(isObject)) throw new JWSInvalid("JWS Signatures missing or incorrect type");
1451
- let shared;
1452
- try {
1453
- if (inputPayload === void 0) throw new Error();
1454
- shared = prepareVerify(options);
1455
- } catch {
1456
- throw new JWSSignatureVerificationFailed();
1457
- }
1458
- const payload = inputPayload instanceof Uint8Array ? new Uint8Array(inputPayload) : inputPayload, candidates = signatureEntries.map((signature) => snapshotSignature(signature, payload)).filter((candidate) => candidate !== void 0);
1459
- let modes = 0;
1460
- for (const [, , mode] of candidates) if (modes |= mode, modes === 3) throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
1435
+ if (inputPayload === void 0) throw new JWSSignatureVerificationFailed();
1436
+ const shared = prepareVerify(options), payload = inputPayload instanceof Uint8Array ? new Uint8Array(inputPayload) : inputPayload, candidates = signatureEntries.map((signature) => snapshotSignature(signature, payload)).filter((candidate) => candidate !== void 0);
1437
+ let payloadEncodings = 0;
1438
+ for (const [, , payloadEncoding] of candidates) if (payloadEncodings |= payloadEncoding, payloadEncodings === 3) throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
1461
1439
  for (const candidate of candidates) try {
1462
1440
  const [result] = await verifySignature(candidate[0], shared, key, encodeJsonUnencodedPayload, candidate[1]);
1463
1441
  return result;
1464
1442
  } catch {}
1465
1443
  throw new JWSSignatureVerificationFailed();
1466
1444
  }
1467
- //#endregion
1468
- //#region node_modules/jose/dist/webapi/lib/jwt_claims_set.js
1445
+ // node_modules/jose/dist/webapi/lib/jwt_claims_set.js
1469
1446
  const epoch = (date) => Math.floor(date.getTime() / 1e3);
1470
1447
  const multipliers = {
1471
1448
  s: 1,
@@ -1484,8 +1461,8 @@ function secs(str) {
1484
1461
  typeof str != "string" && invalidDuration();
1485
1462
  const matched = REGEX.exec(str);
1486
1463
  (!matched || matched[4] && matched[1]) && invalidDuration();
1487
- const value = parseFloat(matched[2]), numericDate2 = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
1488
- return Number.isFinite(numericDate2) || invalidDuration(), matched[1] === "-" || matched[4] === "ago" ? -numericDate2 : numericDate2;
1464
+ const value = parseFloat(matched[2]), durationSeconds = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
1465
+ return Number.isFinite(durationSeconds) || invalidDuration(), matched[1] === "-" || matched[4] === "ago" ? -durationSeconds : durationSeconds;
1489
1466
  }
1490
1467
  function validateInput(label, input) {
1491
1468
  if (!Number.isFinite(input)) throw new TypeError(`Invalid ${label} input`);
@@ -1505,28 +1482,30 @@ const normalizeTyp = (value) => {
1505
1482
  return value.includes("/") ? normalized : `application/${normalized}`;
1506
1483
  };
1507
1484
  const checkAudiencePresence = (audPayload, audOption) => typeof audPayload == "string" ? audOption.includes(audPayload) : Array.isArray(audPayload) ? audOption.some((aud) => audPayload.includes(aud)) : !1;
1508
- function validateNumericDate(payload, claim, required = !1) {
1509
- const value = payload[claim];
1485
+ function validateNumericDate(claimsSet, claim, required = !1) {
1486
+ const value = claimsSet[claim];
1510
1487
  if (!(value === void 0 && !required)) {
1511
- if (typeof value != "number") throw new JWTClaimValidationFailed(`"${claim}" claim must be a number`, payload, claim, "invalid");
1488
+ if (typeof value != "number") throw new JWTClaimValidationFailed(`"${claim}" claim must be a number`, claimsSet, claim, "invalid");
1512
1489
  return value;
1513
1490
  }
1514
1491
  }
1515
- function unexpectedClaim(payload, claim) {
1516
- throw new JWTClaimValidationFailed(`unexpected "${claim}" claim value`, payload, claim, checkFailed);
1492
+ function unexpectedClaim(claimsSet, claim) {
1493
+ throw new JWTClaimValidationFailed(`unexpected "${claim}" claim value`, claimsSet, claim, checkFailed);
1517
1494
  }
1518
- function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
1519
- let payload;
1495
+ function validateClaimsSet(protectedHeader, claimsSetBytes, options = {}) {
1496
+ let claimsSet;
1520
1497
  try {
1521
- payload = JSON.parse(strictDecoder.decode(encodedPayload));
1522
- } catch {}
1523
- if (!isObject(payload)) throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
1498
+ claimsSet = JSON.parse(strictDecoder.decode(claimsSetBytes));
1499
+ } catch (cause) {
1500
+ throw new JWTInvalid("JWT Claims Set must be a top-level JSON object", { cause });
1501
+ }
1502
+ if (!isObject(claimsSet)) throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
1524
1503
  const { typ } = options;
1525
- if (typ !== void 0 && (typeof protectedHeader.typ != "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) throw new JWTClaimValidationFailed("unexpected \"typ\" JWT header value", payload, "typ", checkFailed);
1504
+ if (typ !== void 0 && (typeof protectedHeader.typ != "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) throw new JWTClaimValidationFailed("unexpected \"typ\" JWT header value", claimsSet, "typ", checkFailed);
1526
1505
  const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options, presenceCheck = [...requiredClaims];
1527
1506
  maxTokenAge !== void 0 && presenceCheck.push("iat"), audience !== void 0 && presenceCheck.push("aud"), subject !== void 0 && presenceCheck.push("sub"), issuer !== void 0 && presenceCheck.push("iss");
1528
- for (const claim of new Set(presenceCheck.reverse())) if (!Object.hasOwn(payload, claim)) throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, payload, claim, "missing");
1529
- issuer !== void 0 && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss) && unexpectedClaim(payload, "iss"), subject !== void 0 && payload.sub !== subject && unexpectedClaim(payload, "sub"), audience !== void 0 && !checkAudiencePresence(payload.aud, typeof audience == "string" ? [audience] : audience) && unexpectedClaim(payload, "aud");
1507
+ for (const claim of new Set(presenceCheck.reverse())) if (!Object.hasOwn(claimsSet, claim)) throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, claimsSet, claim, "missing");
1508
+ issuer !== void 0 && !(Array.isArray(issuer) ? issuer : [issuer]).includes(claimsSet.iss) && unexpectedClaim(claimsSet, "iss"), subject !== void 0 && claimsSet.sub !== subject && unexpectedClaim(claimsSet, "sub"), audience !== void 0 && !checkAudiencePresence(claimsSet.aud, typeof audience == "string" ? [audience] : audience) && unexpectedClaim(claimsSet, "aud");
1530
1509
  const { clockTolerance } = options;
1531
1510
  let tolerance = 0;
1532
1511
  if (typeof clockTolerance == "string") tolerance = secs(clockTolerance);
@@ -1534,67 +1513,66 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
1534
1513
  if (typeof clockTolerance != "number") throw new TypeError("Invalid clockTolerance option type");
1535
1514
  tolerance = clockTolerance;
1536
1515
  }
1537
- validateInput("clockTolerance option", tolerance);
1538
- const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(payload, "iat", maxTokenAge !== void 0), nbf = validateNumericDate(payload, "nbf");
1539
- if (nbf !== void 0 && nbf > now + tolerance) throw new JWTClaimValidationFailed("\"nbf\" claim timestamp check failed", payload, "nbf", checkFailed);
1540
- const exp = validateNumericDate(payload, "exp");
1541
- if (exp !== void 0 && exp <= now - tolerance) throw new JWTExpired("\"exp\" claim timestamp check failed", payload, "exp", checkFailed);
1516
+ if (validateInput("clockTolerance option", tolerance), tolerance < 0) throw new TypeError("Invalid clockTolerance option input");
1517
+ const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(claimsSet, "iat", maxTokenAge !== void 0), nbf = validateNumericDate(claimsSet, "nbf");
1518
+ if (nbf !== void 0 && nbf > now + tolerance) throw new JWTClaimValidationFailed("\"nbf\" claim timestamp check failed", claimsSet, "nbf", checkFailed);
1519
+ const exp = validateNumericDate(claimsSet, "exp");
1520
+ if (exp !== void 0 && exp <= now - tolerance) throw new JWTExpired("\"exp\" claim timestamp check failed", claimsSet, "exp", checkFailed);
1542
1521
  if (maxTokenAge !== void 0) {
1543
1522
  const age = now - iat, max = validateInput("maxTokenAge option", typeof maxTokenAge == "number" ? maxTokenAge : secs(maxTokenAge));
1544
- if (age - tolerance > max) throw new JWTExpired("\"iat\" claim timestamp check failed (too far in the past)", payload, "iat", checkFailed);
1545
- if (age < -tolerance) throw new JWTClaimValidationFailed("\"iat\" claim timestamp check failed (it should be in the past)", payload, "iat", checkFailed);
1523
+ if (age - tolerance > max) throw new JWTExpired("\"iat\" claim timestamp check failed (too far in the past)", claimsSet, "iat", checkFailed);
1524
+ if (age < -tolerance) throw new JWTClaimValidationFailed("\"iat\" claim timestamp check failed (it should be in the past)", claimsSet, "iat", checkFailed);
1546
1525
  }
1547
- return payload;
1526
+ return claimsSet;
1548
1527
  }
1549
- let producerPayloads;
1550
- function producerPayload(producer) {
1551
- return producerPayloads.get(producer);
1528
+ let producerClaimsSets;
1529
+ function producerClaimsSet(producer) {
1530
+ return producerClaimsSets.get(producer);
1552
1531
  }
1553
- function jwtData(producer) {
1554
- const payload = producerPayload(producer);
1532
+ function jwtClaimsSetBytes(producer) {
1533
+ const claimsSet = producerClaimsSet(producer);
1555
1534
  for (const claim of [
1556
1535
  "iat",
1557
1536
  "nbf",
1558
1537
  "exp"
1559
1538
  ]) {
1560
- const value = payload[claim];
1539
+ const value = claimsSet[claim];
1561
1540
  if (typeof value == "number" && !Number.isFinite(value)) throw new TypeError(`"${claim}" claim must be a finite number`);
1562
1541
  }
1563
- return encoder.encode(JSON.stringify(payload));
1542
+ return encoder.encode(JSON.stringify(claimsSet));
1564
1543
  }
1565
1544
  function jwtClaim(producer, claim) {
1566
- return producerPayload(producer)[claim];
1545
+ return producerClaimsSet(producer)[claim];
1567
1546
  }
1568
1547
  var JWTClaimsBuilder = class {
1569
- constructor(payload = {}) {
1570
- if (!isObject(payload)) throw new TypeError("JWT Claims Set MUST be an object");
1571
- (producerPayloads ||= /* @__PURE__ */ new WeakMap()).set(this, structuredClone(payload));
1548
+ constructor(claimsSet = {}) {
1549
+ if (!isObject(claimsSet)) throw new TypeError("JWT Claims Set MUST be an object");
1550
+ (producerClaimsSets ||= /* @__PURE__ */ new WeakMap()).set(this, structuredClone(claimsSet));
1572
1551
  }
1573
1552
  setIssuer(value) {
1574
- return validateStringClaim("iss", value), producerPayload(this).iss = value, this;
1553
+ return validateStringClaim("iss", value), producerClaimsSet(this).iss = value, this;
1575
1554
  }
1576
1555
  setSubject(value) {
1577
- return validateStringClaim("sub", value), producerPayload(this).sub = value, this;
1556
+ return validateStringClaim("sub", value), producerClaimsSet(this).sub = value, this;
1578
1557
  }
1579
1558
  setAudience(value) {
1580
- return validateAudienceClaim(value), producerPayload(this).aud = value, this;
1559
+ return validateAudienceClaim(value), producerClaimsSet(this).aud = value, this;
1581
1560
  }
1582
1561
  setJti(value) {
1583
- return validateStringClaim("jti", value), producerPayload(this).jti = value, this;
1562
+ return validateStringClaim("jti", value), producerClaimsSet(this).jti = value, this;
1584
1563
  }
1585
1564
  setNotBefore(value) {
1586
- return producerPayload(this).nbf = numericDate(value, "setNotBefore"), this;
1565
+ return producerClaimsSet(this).nbf = numericDate(value, "setNotBefore"), this;
1587
1566
  }
1588
1567
  setExpirationTime(value) {
1589
- return producerPayload(this).exp = numericDate(value, "setExpirationTime"), this;
1568
+ return producerClaimsSet(this).exp = numericDate(value, "setExpirationTime"), this;
1590
1569
  }
1591
1570
  setIssuedAt(value) {
1592
- const payload = producerPayload(this);
1593
- return value === void 0 ? payload.iat = epoch(/* @__PURE__ */ new Date()) : typeof value == "string" ? payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value)) : payload.iat = numericDate(value, "setIssuedAt"), this;
1571
+ const claimsSet = producerClaimsSet(this);
1572
+ return value === void 0 ? claimsSet.iat = epoch(/* @__PURE__ */ new Date()) : typeof value == "string" ? claimsSet.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value)) : claimsSet.iat = numericDate(value, "setIssuedAt"), this;
1594
1573
  }
1595
1574
  };
1596
- //#endregion
1597
- //#region node_modules/jose/dist/webapi/jwt/verify.js
1575
+ // node_modules/jose/dist/webapi/jwt/verify.js
1598
1576
  async function jwtVerify(jwt, key, options) {
1599
1577
  const [verified, b64] = await verifyCompact(jwt, prepareVerify(options), key);
1600
1578
  if (!b64) throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
@@ -1604,8 +1582,7 @@ async function jwtVerify(jwt, key, options) {
1604
1582
  payload
1605
1583
  };
1606
1584
  }
1607
- //#endregion
1608
- //#region node_modules/jose/dist/webapi/jwt/decrypt.js
1585
+ // node_modules/jose/dist/webapi/jwt/decrypt.js
1609
1586
  async function jwtDecrypt(jwt, key, options) {
1610
1587
  const { plaintext, ...result } = await decryptCompact(jwt, prepareDecrypt(options), key), { protectedHeader } = result, payload = validateClaimsSet(protectedHeader, plaintext, options);
1611
1588
  for (const claim of [
@@ -1618,8 +1595,7 @@ async function jwtDecrypt(jwt, key, options) {
1618
1595
  ...result
1619
1596
  };
1620
1597
  }
1621
- //#endregion
1622
- //#region node_modules/jose/dist/webapi/jwe/compact/encrypt.js
1598
+ // node_modules/jose/dist/webapi/jwe/compact/encrypt.js
1623
1599
  var CompactEncrypt = class {
1624
1600
  #input;
1625
1601
  constructor(plaintext) {
@@ -1641,8 +1617,7 @@ var CompactEncrypt = class {
1641
1617
  return compactJWE(await createJWE([...this.#input], key, options));
1642
1618
  }
1643
1619
  };
1644
- //#endregion
1645
- //#region node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
1620
+ // node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
1646
1621
  var FlattenedEncrypt = class {
1647
1622
  #input;
1648
1623
  constructor(plaintext) {
@@ -1673,13 +1648,12 @@ var FlattenedEncrypt = class {
1673
1648
  return createJWE([...this.#input], key, options);
1674
1649
  }
1675
1650
  };
1676
- //#endregion
1677
- //#region node_modules/jose/dist/webapi/lib/jws_sign.js
1651
+ // node_modules/jose/dist/webapi/lib/jws_sign.js
1678
1652
  async function createSignature(input, key, rejectUnencoded) {
1679
- let [payload, protectedHeader, unprotectedHeader, crit] = input, protectedHeaderString = "";
1653
+ let [payload, protectedHeader, unprotectedHeader, crit] = input, encodedProtectedHeader = "";
1680
1654
  if (protectedHeader !== void 0) {
1681
1655
  const normalized = serializeJoseHeader(JWSInvalid, protectedHeader);
1682
- protectedHeader = normalized[0], protectedHeaderString = encode(normalized[1]);
1656
+ protectedHeader = normalized[0], encodedProtectedHeader = encode(normalized[1]);
1683
1657
  }
1684
1658
  if (unprotectedHeader !== void 0 && (unprotectedHeader = serializeJoseHeader(JWSInvalid, unprotectedHeader)[0]), !protectedHeader && !unprotectedHeader) throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
1685
1659
  if (!isDisjoint(protectedHeader, unprotectedHeader)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
@@ -1693,19 +1667,19 @@ async function createSignature(input, key, rejectUnencoded) {
1693
1667
  const { alg } = joseHeader;
1694
1668
  if (typeof alg != "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
1695
1669
  const entry = jwsAlgorithm(alg);
1696
- let payloadS = "", payloadB = payload, data;
1670
+ let encodedPayload = "", signingPayload = payload, signingInput;
1697
1671
  if (b64) {
1698
- const encoded = input[4];
1699
- encoded ? (payloadS = encoded[0] ??= encode(payload), payloadB = encoded[1] ??= encode$1(payloadS)) : (payloadS = encode(payload), data = encoder.encode(`${protectedHeaderString}.${payloadS}`));
1672
+ const encodedPayloadCache = input[4];
1673
+ encodedPayloadCache ? (encodedPayload = encodedPayloadCache[0] ??= encode(payload), signingPayload = encodedPayloadCache[1] ??= encode$1(encodedPayload)) : (encodedPayload = encode(payload), signingInput = encoder.encode(`${encodedProtectedHeader}.${encodedPayload}`));
1700
1674
  }
1701
- data ??= concat(encode$1(protectedHeaderString), encode$1("."), payloadB);
1702
- const k = await rawKey(await prepareKey(entry, key, "sign"), entry.subtle, "sign");
1703
- entry.minRsaBits && checkModulusLength(entry.alg, k);
1675
+ signingInput ??= concat(encode$1(encodedProtectedHeader), encode$1("."), signingPayload);
1676
+ const signingKey = await rawKey(await prepareKey(entry, key, "sign"), entry.subtle, "sign");
1677
+ entry.minRsaBits && checkModulusLength(entry.alg, signingKey);
1704
1678
  const jws = {
1705
- signature: encode(new Uint8Array(await crypto.subtle.sign(entry.signing, k, data))),
1706
- payload: payloadS
1679
+ signature: encode(new Uint8Array(await crypto.subtle.sign(entry.signing, signingKey, signingInput))),
1680
+ payload: encodedPayload
1707
1681
  };
1708
- return protectedHeader && (jws.protected = protectedHeaderString), unprotectedHeader && (jws.header = unprotectedHeader), [jws, b64];
1682
+ return protectedHeader && (jws.protected = encodedProtectedHeader), unprotectedHeader && (jws.header = unprotectedHeader), [jws, b64];
1709
1683
  }
1710
1684
  async function createCompactSignature(payload, protectedHeader, crit, key, rejectUnencoded) {
1711
1685
  const [jws] = await createSignature([
@@ -1716,8 +1690,7 @@ async function createCompactSignature(payload, protectedHeader, crit, key, rejec
1716
1690
  ], key, rejectUnencoded);
1717
1691
  return `${jws.protected}.${jws.payload}.${jws.signature}`;
1718
1692
  }
1719
- //#endregion
1720
- //#region node_modules/jose/dist/webapi/jws/compact/sign.js
1693
+ // node_modules/jose/dist/webapi/jws/compact/sign.js
1721
1694
  var CompactSign = class {
1722
1695
  #payload;
1723
1696
  #protectedHeader;
@@ -1733,8 +1706,7 @@ var CompactSign = class {
1733
1706
  });
1734
1707
  }
1735
1708
  };
1736
- //#endregion
1737
- //#region node_modules/jose/dist/webapi/jws/flattened/sign.js
1709
+ // node_modules/jose/dist/webapi/jws/flattened/sign.js
1738
1710
  var FlattenedSign = class {
1739
1711
  #input;
1740
1712
  constructor(payload) {
@@ -1753,8 +1725,7 @@ var FlattenedSign = class {
1753
1725
  return jws;
1754
1726
  }
1755
1727
  };
1756
- //#endregion
1757
- //#region node_modules/jose/dist/webapi/jws/general/sign.js
1728
+ // node_modules/jose/dist/webapi/jws/general/sign.js
1758
1729
  var IndividualSignature = class {
1759
1730
  #parent;
1760
1731
  state;
@@ -1798,25 +1769,24 @@ var GeneralSign = class {
1798
1769
  const jws = {
1799
1770
  signatures: [],
1800
1771
  payload: ""
1801
- }, encoded = [];
1772
+ }, encodedPayloadCache = [];
1802
1773
  let b64;
1803
1774
  for (const signature of this.#signatures) {
1804
- const [protectedHeader, unprotectedHeader, key, crit] = signature.state, [{ payload, ...rest }, signatureB64] = await createSignature([
1775
+ const [protectedHeader, unprotectedHeader, key, crit] = signature.state, [{ payload, ...signatureMembers }, signatureB64] = await createSignature([
1805
1776
  this.#payload,
1806
1777
  protectedHeader,
1807
1778
  unprotectedHeader,
1808
1779
  crit,
1809
- encoded
1780
+ encodedPayloadCache
1810
1781
  ], key);
1811
1782
  if (b64 === void 0) b64 = signatureB64, jws.payload = payload;
1812
1783
  else if (b64 !== signatureB64) throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
1813
- jws.signatures.push(rest);
1784
+ jws.signatures.push(signatureMembers);
1814
1785
  }
1815
1786
  return jws;
1816
1787
  }
1817
1788
  };
1818
- //#endregion
1819
- //#region node_modules/jose/dist/webapi/jwt/sign.js
1789
+ // node_modules/jose/dist/webapi/jwt/sign.js
1820
1790
  const SignJWT_base = JWTClaimsBuilder;
1821
1791
  var SignJWT = class extends SignJWT_base {
1822
1792
  #protectedHeader;
@@ -1824,13 +1794,12 @@ var SignJWT = class extends SignJWT_base {
1824
1794
  return assertNotSet(this.#protectedHeader, "setProtectedHeader"), this.#protectedHeader = protectedHeader, this;
1825
1795
  }
1826
1796
  async sign(key, options) {
1827
- return createCompactSignature(jwtData(this), this.#protectedHeader, options?.crit, key, () => {
1797
+ return createCompactSignature(jwtClaimsSetBytes(this), this.#protectedHeader, options?.crit, key, () => {
1828
1798
  throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
1829
1799
  });
1830
1800
  }
1831
1801
  };
1832
- //#endregion
1833
- //#region node_modules/jose/dist/webapi/jwt/encrypt.js
1802
+ // node_modules/jose/dist/webapi/jwt/encrypt.js
1834
1803
  const EncryptJWT_base = JWTClaimsBuilder;
1835
1804
  var EncryptJWT = class extends EncryptJWT_base {
1836
1805
  #input = [void 0];
@@ -1859,7 +1828,7 @@ var EncryptJWT = class extends EncryptJWT_base {
1859
1828
  return this.#replicateAudienceAsHeader = !0, this;
1860
1829
  }
1861
1830
  async encrypt(key, options) {
1862
- const plaintext = jwtData(this);
1831
+ const plaintext = jwtClaimsSetBytes(this);
1863
1832
  this.#input[1] && (this.#replicateIssuerAsHeader || this.#replicateSubjectAsHeader || this.#replicateAudienceAsHeader) && (this.#input[1] = {
1864
1833
  ...this.#input[1],
1865
1834
  iss: this.#replicateIssuerAsHeader ? jwtClaim(this, "iss") : void 0,
@@ -1870,8 +1839,7 @@ var EncryptJWT = class extends EncryptJWT_base {
1870
1839
  return input[0] = plaintext, compactJWE(await createJWE(input, key, options));
1871
1840
  }
1872
1841
  };
1873
- //#endregion
1874
- //#region node_modules/jose/dist/webapi/lib/key_algorithm.js
1842
+ // node_modules/jose/dist/webapi/lib/key_algorithm.js
1875
1843
  const algArgument = "\"alg\" (Algorithm)";
1876
1844
  function unsupportedAlg(source = "JWK \"alg\" (Algorithm) Parameter") {
1877
1845
  throw new JOSENotSupported(`Invalid or unsupported ${source} value`);
@@ -1879,8 +1847,7 @@ function unsupportedAlg(source = "JWK \"alg\" (Algorithm) Parameter") {
1879
1847
  function keyAlgorithm(alg, source) {
1880
1848
  return (typeof alg == "string" ? JWS[alg] ?? JWE[alg] : void 0) ?? unsupportedAlg(source);
1881
1849
  }
1882
- //#endregion
1883
- //#region node_modules/jose/dist/webapi/lib/asn1.js
1850
+ // node_modules/jose/dist/webapi/lib/asn1.js
1884
1851
  const formatPEM = (b64, descriptor) => {
1885
1852
  return `-----BEGIN ${descriptor}-----
1886
1853
  ${(b64.match(/.{1,64}/g) || []).join(`
@@ -2006,8 +1973,8 @@ const genericImport = async (keyFormat, keyData, alg, options) => {
2006
1973
  if (entry.resolve) try {
2007
1974
  const state = createASN1State(keyData);
2008
1975
  parseKeyHeader(state, keyFormat), algorithm = entry.resolve({ crv: parseECAlgorithmIdentifier(state) });
2009
- } catch {
2010
- throw new JOSENotSupported("Invalid or unsupported key format");
1976
+ } catch (cause) {
1977
+ throw new JOSENotSupported("Invalid or unsupported key format", { cause });
2011
1978
  }
2012
1979
  else algorithm = entry.subtle;
2013
1980
  return crypto.subtle.importKey(keyFormat, keyData, algorithm, extractable ?? isPublic, entry.usages[isPublic ? 0 : 1]);
@@ -2041,8 +2008,7 @@ const fromX509 = (pem, alg, options) => {
2041
2008
  }
2042
2009
  return genericImport("spki", spki, alg, options);
2043
2010
  };
2044
- //#endregion
2045
- //#region node_modules/jose/dist/webapi/key/export.js
2011
+ // node_modules/jose/dist/webapi/key/export.js
2046
2012
  function exportSPKI(key) {
2047
2013
  return toSPKI(key);
2048
2014
  }
@@ -2063,8 +2029,7 @@ async function exportJWK(key) {
2063
2029
  for (const parameter of Object.keys(jwk)) jwk[parameter] === void 0 && delete jwk[parameter];
2064
2030
  return jwk;
2065
2031
  }
2066
- //#endregion
2067
- //#region node_modules/jose/dist/webapi/jwk/thumbprint.js
2032
+ // node_modules/jose/dist/webapi/jwk/thumbprint.js
2068
2033
  const check = (value, description) => {
2069
2034
  if (typeof value != "string" || !value) throw new JWKInvalid(`${description} missing or invalid`);
2070
2035
  };
@@ -2075,17 +2040,17 @@ async function calculateJwkThumbprint(key, digestAlgorithm) {
2075
2040
  } else if (isKeyLike(key)) jwk = snapshotJwk(await exportJWK(key));
2076
2041
  else throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
2077
2042
  if (digestAlgorithm ??= "sha256", digestAlgorithm !== "sha256" && digestAlgorithm !== "sha384" && digestAlgorithm !== "sha512") throw new TypeError("digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"");
2078
- let components;
2043
+ let requiredMembers;
2079
2044
  switch (jwk.kty) {
2080
2045
  case "AKP":
2081
- check(jwk.alg, "\"alg\" (Algorithm) Parameter"), check(jwk.pub, "\"pub\" (Public key) Parameter"), components = {
2046
+ check(jwk.alg, "\"alg\" (Algorithm) Parameter"), check(jwk.pub, "\"pub\" (Public key) Parameter"), requiredMembers = {
2082
2047
  alg: jwk.alg,
2083
2048
  kty: jwk.kty,
2084
2049
  pub: jwk.pub
2085
2050
  };
2086
2051
  break;
2087
2052
  case "EC":
2088
- check(jwk.crv, "\"crv\" (Curve) Parameter"), check(jwk.x, "\"x\" (X Coordinate) Parameter"), check(jwk.y, "\"y\" (Y Coordinate) Parameter"), components = {
2053
+ check(jwk.crv, "\"crv\" (Curve) Parameter"), check(jwk.x, "\"x\" (X Coordinate) Parameter"), check(jwk.y, "\"y\" (Y Coordinate) Parameter"), requiredMembers = {
2089
2054
  crv: jwk.crv,
2090
2055
  kty: jwk.kty,
2091
2056
  x: jwk.x,
@@ -2093,14 +2058,14 @@ async function calculateJwkThumbprint(key, digestAlgorithm) {
2093
2058
  };
2094
2059
  break;
2095
2060
  case "OKP":
2096
- check(jwk.crv, "\"crv\" (Subtype of Key Pair) Parameter"), check(jwk.x, "\"x\" (Public Key) Parameter"), components = {
2061
+ check(jwk.crv, "\"crv\" (Subtype of Key Pair) Parameter"), check(jwk.x, "\"x\" (Public Key) Parameter"), requiredMembers = {
2097
2062
  crv: jwk.crv,
2098
2063
  kty: jwk.kty,
2099
2064
  x: jwk.x
2100
2065
  };
2101
2066
  break;
2102
2067
  case "RSA":
2103
- check(jwk.e, "\"e\" (Exponent) Parameter"), check(jwk.n, "\"n\" (Modulus) Parameter"), components = {
2068
+ check(jwk.e, "\"e\" (Exponent) Parameter"), check(jwk.n, "\"n\" (Modulus) Parameter"), requiredMembers = {
2104
2069
  e: jwk.e,
2105
2070
  kty: jwk.kty,
2106
2071
  n: jwk.n
@@ -2108,23 +2073,22 @@ async function calculateJwkThumbprint(key, digestAlgorithm) {
2108
2073
  break;
2109
2074
  case "oct":
2110
2075
  if (typeof jwk.k != "string") throw new JWKInvalid("\"k\" (Key Value) Parameter missing or invalid");
2111
- components = {
2076
+ requiredMembers = {
2112
2077
  k: jwk.k,
2113
2078
  kty: jwk.kty
2114
2079
  };
2115
2080
  break;
2116
2081
  default: throw new JOSENotSupported("\"kty\" (Key Type) Parameter missing or unsupported");
2117
2082
  }
2118
- const data = encode$1(JSON.stringify(components));
2119
- return encode(await digest(digestAlgorithm, data));
2083
+ const thumbprintInput = encode$1(JSON.stringify(requiredMembers));
2084
+ return encode(await digest(digestAlgorithm, thumbprintInput));
2120
2085
  }
2121
2086
  async function calculateJwkThumbprintUri(key, digestAlgorithm) {
2122
2087
  digestAlgorithm ??= "sha256";
2123
2088
  const thumbprint = await calculateJwkThumbprint(key, digestAlgorithm);
2124
2089
  return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
2125
2090
  }
2126
- //#endregion
2127
- //#region node_modules/jose/dist/webapi/jwk/embedded.js
2091
+ // node_modules/jose/dist/webapi/jwk/embedded.js
2128
2092
  async function EmbeddedJWK(protectedHeader, token) {
2129
2093
  const joseHeader = {
2130
2094
  ...protectedHeader,
@@ -2144,8 +2108,7 @@ async function EmbeddedJWK(protectedHeader, token) {
2144
2108
  if (key.type !== "public") throw new JWSInvalid("\"jwk\" (JSON Web Key) Header Parameter must be a public key");
2145
2109
  return key;
2146
2110
  }
2147
- //#endregion
2148
- //#region node_modules/jose/dist/webapi/jwks/local.js
2111
+ // node_modules/jose/dist/webapi/jwks/local.js
2149
2112
  function isUsableJWK(jwk, entry, alg, kid) {
2150
2113
  const { kty, key_ops: keyOps, ext, kid: jwkKid, alg: jwkAlg, use, crv } = jwk;
2151
2114
  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);
@@ -2167,7 +2130,9 @@ function createLocalJWKSet(jwks) {
2167
2130
  let snapshot;
2168
2131
  try {
2169
2132
  snapshot = structuredClone(jwks);
2170
- } catch {}
2133
+ } catch (cause) {
2134
+ throw new JWKSInvalid("JSON Web Key Set malformed", { cause });
2135
+ }
2171
2136
  if (!isJwkSet(snapshot)) throw new JWKSInvalid("JSON Web Key Set malformed");
2172
2137
  const metadata = snapshot.keys.map((jwk) => {
2173
2138
  const normalized = snapshotJwk(jwk);
@@ -2192,13 +2157,12 @@ function createLocalJWKSet(jwks) {
2192
2157
  return importWithAlgCache(cached, jwk, entry);
2193
2158
  }, "jwks", { value: () => structuredClone(snapshot) });
2194
2159
  }
2195
- //#endregion
2196
- //#region node_modules/jose/dist/webapi/jwks/remote.js
2160
+ // node_modules/jose/dist/webapi/jwks/remote.js
2197
2161
  function isCloudflareWorkers() {
2198
2162
  return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
2199
2163
  }
2200
2164
  let USER_AGENT;
2201
- (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.12");
2165
+ (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.16");
2202
2166
  const customFetch = /* @__PURE__ */ Symbol();
2203
2167
  async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
2204
2168
  const response = await fetchImpl(url, {
@@ -2207,13 +2171,13 @@ async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
2207
2171
  redirect: "manual",
2208
2172
  headers
2209
2173
  }).catch((err) => {
2210
- throw err.name === "TimeoutError" ? new JWKSTimeout() : err;
2174
+ throw err.name === "TimeoutError" ? new JWKSTimeout(void 0, { cause: err }) : err;
2211
2175
  });
2212
2176
  if (response.status !== 200) throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
2213
2177
  try {
2214
2178
  return await response.json();
2215
- } catch {
2216
- throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
2179
+ } catch (cause) {
2180
+ throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON", { cause });
2217
2181
  }
2218
2182
  }
2219
2183
  const jwksCache = /* @__PURE__ */ Symbol();
@@ -2222,6 +2186,7 @@ function isFreshFor(timestamp, duration) {
2222
2186
  }
2223
2187
  function validateDuration(value, fallback, option) {
2224
2188
  if (Number.isNaN(value)) throw new TypeError(`"${option}" option must not be NaN`);
2189
+ if (typeof value == "number" && value < 0) throw new TypeError(`"${option}" option must not be negative`);
2225
2190
  return typeof value == "number" ? value : fallback;
2226
2191
  }
2227
2192
  function createRemoteJWKSet(url, options) {
@@ -2281,12 +2246,11 @@ function createRemoteJWKSet(url, options) {
2281
2246
  }
2282
2247
  });
2283
2248
  }
2284
- //#endregion
2285
- //#region node_modules/jose/dist/webapi/jwt/unsecured.js
2249
+ // node_modules/jose/dist/webapi/jwt/unsecured.js
2286
2250
  const UnsecuredJWT_base = JWTClaimsBuilder;
2287
2251
  var UnsecuredJWT = class extends UnsecuredJWT_base {
2288
2252
  encode() {
2289
- return `${encode(JSON.stringify({ alg: "none" }))}.${encode(jwtData(this))}.`;
2253
+ return `${encode(JSON.stringify({ alg: "none" }))}.${encode(jwtClaimsSetBytes(this))}.`;
2290
2254
  }
2291
2255
  static decode(jwt, options) {
2292
2256
  if (typeof jwt != "string") throw new JWTInvalid("Unsecured JWT must be a string");
@@ -2308,8 +2272,7 @@ var UnsecuredJWT = class extends UnsecuredJWT_base {
2308
2272
  };
2309
2273
  }
2310
2274
  };
2311
- //#endregion
2312
- //#region node_modules/jose/dist/webapi/key/import.js
2275
+ // node_modules/jose/dist/webapi/key/import.js
2313
2276
  async function importSPKI(spki, alg, options) {
2314
2277
  if (typeof spki != "string" || spki.indexOf("-----BEGIN PUBLIC KEY-----") !== 0) throw new TypeError("\"spki\" must be SPKI formatted string");
2315
2278
  return fromSPKI(spki, alg, options);
@@ -2340,44 +2303,41 @@ async function importJWK(jwk, alg, options) {
2340
2303
  default: throw new JOSENotSupported("Unsupported \"kty\" (Key Type) Parameter value");
2341
2304
  }
2342
2305
  }
2343
- //#endregion
2344
- //#region node_modules/jose/dist/webapi/util/decode_protected_header.js
2306
+ // node_modules/jose/dist/webapi/util/decode_protected_header.js
2345
2307
  function decodeProtectedHeader(token) {
2346
- let protectedB64u;
2308
+ let encodedProtectedHeader;
2347
2309
  if (typeof token == "string") {
2348
2310
  const parts = token.split(".");
2349
- (parts.length === 3 || parts.length === 5) && ([protectedB64u] = parts);
2350
- } else if (typeof token == "object" && token) if ("protected" in token) protectedB64u = token.protected;
2311
+ (parts.length === 3 || parts.length === 5) && ([encodedProtectedHeader] = parts);
2312
+ } else if (typeof token == "object" && token) if ("protected" in token) encodedProtectedHeader = token.protected;
2351
2313
  else throw new TypeError("Token does not contain a Protected Header");
2352
2314
  const invalid = "Invalid Token or Protected Header formatting";
2353
- if (typeof protectedB64u != "string" || !protectedB64u) throw new TypeError(invalid);
2354
- return parseJoseHeader(protectedB64u, TypeError, invalid);
2315
+ if (typeof encodedProtectedHeader != "string" || !encodedProtectedHeader) throw new TypeError(invalid);
2316
+ return parseJoseHeader(encodedProtectedHeader, TypeError, invalid);
2355
2317
  }
2356
- //#endregion
2357
- //#region node_modules/jose/dist/webapi/util/decode_jwt.js
2318
+ // node_modules/jose/dist/webapi/util/decode_jwt.js
2358
2319
  function decodeJwt(jwt) {
2359
2320
  if (typeof jwt != "string") throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
2360
- const { 1: payload, length } = jwt.split(".");
2321
+ const { 1: encodedPayload, length } = jwt.split(".");
2361
2322
  if (length === 5) throw new JWTInvalid("Only JWTs using Compact JWS serialization can be decoded");
2362
2323
  if (length !== 3) throw new JWTInvalid("Invalid JWT");
2363
- if (!payload) throw new JWTInvalid("JWTs must contain a payload");
2364
- let decoded;
2324
+ if (!encodedPayload) throw new JWTInvalid("JWTs must contain a payload");
2325
+ let claimsSetBytes;
2365
2326
  try {
2366
- decoded = decode(payload);
2367
- } catch {
2368
- throw new JWTInvalid("Failed to base64url decode the payload");
2327
+ claimsSetBytes = decode(encodedPayload);
2328
+ } catch (cause) {
2329
+ throw new JWTInvalid("Failed to base64url decode the payload", { cause });
2369
2330
  }
2370
- let result;
2331
+ let claimsSet;
2371
2332
  try {
2372
- result = JSON.parse(strictDecoder.decode(decoded));
2373
- } catch {
2374
- throw new JWTInvalid("Failed to parse the decoded payload as JSON");
2333
+ claimsSet = JSON.parse(strictDecoder.decode(claimsSetBytes));
2334
+ } catch (cause) {
2335
+ throw new JWTInvalid("Failed to parse the decoded payload as JSON", { cause });
2375
2336
  }
2376
- if (!isObject(result)) throw new JWTInvalid("Invalid JWT Claims Set");
2377
- return result;
2337
+ if (!isObject(claimsSet)) throw new JWTInvalid("Invalid JWT Claims Set");
2338
+ return claimsSet;
2378
2339
  }
2379
- //#endregion
2380
- //#region node_modules/jose/dist/webapi/key/generate_key_pair.js
2340
+ // node_modules/jose/dist/webapi/key/generate_key_pair.js
2381
2341
  function getModulusLengthOption(options) {
2382
2342
  const modulusLength = options?.modulusLength ?? 2048;
2383
2343
  if (typeof modulusLength != "number" || !Number.isInteger(modulusLength) || modulusLength < 2048) throw new JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");
@@ -2406,19 +2366,18 @@ async function generateKeyPair(alg, options) {
2406
2366
  }
2407
2367
  return crypto.subtle.generateKey(algorithm, extractable ?? !1, [...entry.usages[1], ...entry.usages[0]]);
2408
2368
  }
2409
- //#endregion
2410
- //#region node_modules/jose/dist/webapi/key/generate_secret.js
2369
+ // node_modules/jose/dist/webapi/key/generate_secret.js
2411
2370
  async function generateSecret(alg, options) {
2412
2371
  const extractable = validateExtractableOption(options?.extractable);
2413
- let length, algorithm, keyUsages;
2372
+ let keyLengthBits, algorithm, keyUsages;
2414
2373
  switch (alg) {
2415
2374
  case "HS256":
2416
2375
  case "HS384":
2417
2376
  case "HS512":
2418
- length = +alg.slice(-3), algorithm = {
2377
+ keyLengthBits = +alg.slice(-3), algorithm = {
2419
2378
  name: "HMAC",
2420
- hash: `SHA-${length}`,
2421
- length
2379
+ hash: `SHA-${keyLengthBits}`,
2380
+ length: keyLengthBits
2422
2381
  }, keyUsages = ["sign", "verify"];
2423
2382
  break;
2424
2383
  case "A128CBC-HS256":
@@ -2427,9 +2386,9 @@ async function generateSecret(alg, options) {
2427
2386
  case "A128KW":
2428
2387
  case "A192KW":
2429
2388
  case "A256KW":
2430
- length = +alg.slice(1, 4), algorithm = {
2389
+ keyLengthBits = +alg.slice(1, 4), algorithm = {
2431
2390
  name: "AES-KW",
2432
- length
2391
+ length: keyLengthBits
2433
2392
  }, keyUsages = ["wrapKey", "unwrapKey"];
2434
2393
  break;
2435
2394
  case "A128GCMKW":
@@ -2438,19 +2397,17 @@ async function generateSecret(alg, options) {
2438
2397
  case "A128GCM":
2439
2398
  case "A192GCM":
2440
2399
  case "A256GCM":
2441
- length = +alg.slice(1, 4), algorithm = {
2400
+ keyLengthBits = +alg.slice(1, 4), algorithm = {
2442
2401
  name: "AES-GCM",
2443
- length
2402
+ length: keyLengthBits
2444
2403
  }, keyUsages = ["encrypt", "decrypt"];
2445
2404
  break;
2446
2405
  default: unsupportedAlg(algArgument);
2447
2406
  }
2448
2407
  return crypto.subtle.generateKey(algorithm, extractable ?? !1, keyUsages);
2449
2408
  }
2450
- //#endregion
2451
- //#region node_modules/jose/dist/webapi/index.js
2409
+ // node_modules/jose/dist/webapi/index.js
2452
2410
  const cryptoRuntime = "WebCryptoAPI";
2453
- //#endregion
2454
2411
  exports.CompactEncrypt = CompactEncrypt;
2455
2412
  exports.CompactSign = CompactSign;
2456
2413
  exports.EmbeddedJWK = EmbeddedJWK;
@@ -2500,4 +2457,4 @@ exports.jwksCache = jwksCache;
2500
2457
  exports.jwtDecrypt = jwtDecrypt;
2501
2458
  exports.jwtVerify = jwtVerify;
2502
2459
 
2503
- //# sourceMappingURL=webapi-MD5xmNba.cjs.map
2460
+ //# sourceMappingURL=webapi-rpGT44g1.cjs.map