@introspection-ai/recipes 0.23.0 → 0.25.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.
Files changed (131) hide show
  1. package/README.md +4 -4
  2. package/dist/channels/config.d.ts +10 -0
  3. package/dist/channels/config.d.ts.map +1 -0
  4. package/dist/channels/config.js +13 -0
  5. package/dist/channels/config.js.map +1 -0
  6. package/dist/channels/index.d.ts +4 -2
  7. package/dist/channels/index.d.ts.map +1 -1
  8. package/dist/channels/index.js +2 -1
  9. package/dist/channels/index.js.map +1 -1
  10. package/dist/channels/module.d.ts +11 -6
  11. package/dist/channels/module.d.ts.map +1 -1
  12. package/dist/channels/module.js +22 -10
  13. package/dist/channels/module.js.map +1 -1
  14. package/dist/channels/refs.d.ts +3 -3
  15. package/dist/channels/refs.d.ts.map +1 -1
  16. package/dist/channels/refs.js +11 -8
  17. package/dist/channels/refs.js.map +1 -1
  18. package/dist/channels/tools.d.ts +15 -22
  19. package/dist/channels/tools.d.ts.map +1 -1
  20. package/dist/channels/tools.js +279 -114
  21. package/dist/channels/tools.js.map +1 -1
  22. package/dist/channels/types.d.ts +34 -29
  23. package/dist/channels/types.d.ts.map +1 -1
  24. package/dist/channels/types.js +4 -17
  25. package/dist/channels/types.js.map +1 -1
  26. package/dist/connector-tools.d.ts +2 -0
  27. package/dist/connector-tools.d.ts.map +1 -1
  28. package/dist/connector-tools.js +17 -15
  29. package/dist/connector-tools.js.map +1 -1
  30. package/dist/mcp-chunks/{auth-command-4OEOMU2V.js → auth-command-4WFRNU2I.js} +24 -24
  31. package/dist/mcp-chunks/call-arguments-4DWPBLQP.js +15 -0
  32. package/dist/mcp-chunks/{call-command-AUEKSBMD.js → call-command-JBIKXOGC.js} +36 -36
  33. package/dist/mcp-chunks/{chunk-L4CUJJI5.js → chunk-36VIJRYY.js} +4 -4
  34. package/dist/mcp-chunks/{chunk-PPIXUCYQ.js → chunk-3JGS7LQB.js} +2 -2
  35. package/dist/mcp-chunks/{chunk-4NDR45CX.js → chunk-3R2WK3NB.js} +28 -9
  36. package/dist/mcp-chunks/{chunk-YX2NKW6O.js → chunk-3Z7MFS6K.js} +23 -6
  37. package/dist/mcp-chunks/{chunk-ACTRQW5L.js → chunk-4ZNBWL65.js} +2 -2
  38. package/dist/mcp-chunks/chunk-53NRFMB3.js +990 -0
  39. package/dist/mcp-chunks/{chunk-6QH47GNE.js → chunk-6YZW3XAE.js} +68 -6
  40. package/dist/mcp-chunks/{chunk-X3FOKZ5C.js → chunk-7WOKCV6Q.js} +1 -1
  41. package/dist/mcp-chunks/{chunk-MOML5C2E.js → chunk-AD3FQ73K.js} +1 -1
  42. package/dist/mcp-chunks/{chunk-HDUKEFBI.js → chunk-AIKLVBYU.js} +2 -2
  43. package/dist/mcp-chunks/{chunk-SQTXZR56.js → chunk-ASG4OY3M.js} +21 -604
  44. package/dist/mcp-chunks/{chunk-V4RYLZM5.js → chunk-B2LNXGAP.js} +1 -1
  45. package/dist/mcp-chunks/{chunk-XVJAASVZ.js → chunk-BWW4XRUC.js} +16 -16
  46. package/dist/mcp-chunks/{chunk-MRXSXBZT.js → chunk-C2KNLFZR.js} +2 -2
  47. package/dist/mcp-chunks/{chunk-KPXFBRTG.js → chunk-CZKDJZER.js} +1 -1
  48. package/dist/mcp-chunks/{chunk-6CYJ6RN3.js → chunk-DTZHEVKC.js} +1 -1
  49. package/dist/mcp-chunks/{chunk-JZDXKYQM.js → chunk-ED2WN5BI.js} +9 -4
  50. package/dist/mcp-chunks/{chunk-OGFFBNIC.js → chunk-ELA77TDC.js} +4 -4
  51. package/dist/mcp-chunks/{chunk-5WGJPYOR.js → chunk-EMSNQHZZ.js} +1 -1
  52. package/dist/mcp-chunks/{chunk-AB7MHBEG.js → chunk-EPT4MYOF.js} +11 -11
  53. package/dist/mcp-chunks/{chunk-HHMWZ2FZ.js → chunk-FAJPJTOC.js} +1 -1
  54. package/dist/mcp-chunks/{chunk-TGJOZDKG.js → chunk-FS5JIKT6.js} +2 -2
  55. package/dist/mcp-chunks/{chunk-IPH6U7SE.js → chunk-FX5NYWBH.js} +3 -3
  56. package/dist/mcp-chunks/{chunk-SCGMRUKI.js → chunk-G6OMDUNG.js} +5 -5
  57. package/dist/mcp-chunks/{chunk-47N2EELW.js → chunk-GQ6NSIDS.js} +30 -30
  58. package/dist/mcp-chunks/{chunk-PPOHGQKM.js → chunk-GUXMP7QB.js} +2 -2
  59. package/dist/mcp-chunks/{chunk-NMFI6AUD.js → chunk-H3JCYHGS.js} +25 -25
  60. package/dist/mcp-chunks/{chunk-3VLPWGJL.js → chunk-HCOKLSOB.js} +4 -4
  61. package/dist/mcp-chunks/{chunk-J6VOMOKI.js → chunk-HLRCUHNO.js} +1 -1
  62. package/dist/mcp-chunks/{chunk-LWVFSQYX.js → chunk-HN7WPMCA.js} +7806 -3454
  63. package/dist/mcp-chunks/chunk-I5GI2A2D.js +92 -0
  64. package/dist/mcp-chunks/{chunk-7KEDX7SE.js → chunk-IME7DGLJ.js} +2 -2
  65. package/dist/mcp-chunks/{chunk-E4YYMOT2.js → chunk-IPNSPKQK.js} +33 -21
  66. package/dist/mcp-chunks/{chunk-ZKFG37TB.js → chunk-IRTJXFWA.js} +2 -2
  67. package/dist/mcp-chunks/{chunk-KMH3PHLA.js → chunk-ITCCROID.js} +13 -7
  68. package/dist/mcp-chunks/{chunk-ADINDBOF.js → chunk-ITR7FQM3.js} +2 -2
  69. package/dist/mcp-chunks/{chunk-JILBFEBD.js → chunk-IYWYVHHD.js} +1 -1
  70. package/dist/mcp-chunks/{chunk-RO2Y34XX.js → chunk-JG4TRUPF.js} +1 -1
  71. package/dist/mcp-chunks/{chunk-DEYKPG4K.js → chunk-KW3ANJ36.js} +4 -4
  72. package/dist/mcp-chunks/{chunk-NWLOPQT7.js → chunk-MOEZ43ZL.js} +1 -1
  73. package/dist/mcp-chunks/{chunk-AFKE4BTR.js → chunk-NTHUNCXJ.js} +21 -21
  74. package/dist/mcp-chunks/{chunk-J3J3NQ4X.js → chunk-OD3MSMXY.js} +1 -1
  75. package/dist/mcp-chunks/{chunk-PRZCYXVO.js → chunk-OP3IW2V6.js} +2 -2
  76. package/dist/mcp-chunks/{chunk-K56RW4HB.js → chunk-PZ323CXI.js} +1 -1
  77. package/dist/mcp-chunks/{chunk-US57PK4B.js → chunk-QZUC2T72.js} +59 -4
  78. package/dist/mcp-chunks/{chunk-Z7O6NF7X.js → chunk-RD7NHCRK.js} +19 -19
  79. package/dist/mcp-chunks/{chunk-756YH7S4.js → chunk-RSTKSBVF.js} +2 -2
  80. package/dist/mcp-chunks/{chunk-6DL2C6V5.js → chunk-SCOMDV54.js} +1 -1
  81. package/dist/mcp-chunks/{chunk-SAK5KCLR.js → chunk-SNKXMWDB.js} +1 -1
  82. package/dist/mcp-chunks/{chunk-LC2CCTQN.js → chunk-TF2YTYE4.js} +1 -1
  83. package/dist/mcp-chunks/chunk-TPHPAEDH.js +3769 -0
  84. package/dist/mcp-chunks/{chunk-AF74TOWM.js → chunk-V5AYEKSL.js} +5 -5
  85. package/dist/mcp-chunks/{chunk-HBDCHBJP.js → chunk-WTMJMM3B.js} +12 -1
  86. package/dist/mcp-chunks/{chunk-ZZSD2JT7.js → chunk-WYLHHXI6.js} +1 -1
  87. package/dist/mcp-chunks/{chunk-MFFE5QSH.js → chunk-Y3EDWN2P.js} +1 -1
  88. package/dist/mcp-chunks/{chunk-ZRZ7C6L3.js → chunk-YIRGLKDA.js} +8 -8
  89. package/dist/mcp-chunks/{chunk-RE4EVQNC.js → chunk-ZOAQDFAO.js} +62 -7
  90. package/dist/mcp-chunks/{cli-B7WQQUME.js → cli-XU26MUCN.js} +67 -67
  91. package/dist/mcp-chunks/client-OT34CKRH.js +21 -0
  92. package/dist/mcp-chunks/{config-command-FF3JPMOP.js → config-command-UQMMIK2U.js} +37 -30
  93. package/dist/mcp-chunks/daemon-command-YCIOZGPZ.js +35 -0
  94. package/dist/mcp-chunks/{dist-V4UB7RTR.js → dist-DM2RXZMU.js} +47 -44
  95. package/dist/mcp-chunks/{emit-ts-command-4X56IZ32.js → emit-ts-command-KAOL6DAN.js} +16 -16
  96. package/dist/mcp-chunks/{generate-cli-runner-MIPF73SJ.js → generate-cli-runner-AK6XNRTK.js} +70 -50
  97. package/dist/mcp-chunks/{inspect-cli-command-GX54ZXKR.js → inspect-cli-command-6FVJO7H2.js} +10 -10
  98. package/dist/mcp-chunks/{launch-E2LWGPZS.js → launch-EIT73HX4.js} +1 -1
  99. package/dist/mcp-chunks/{lifecycle-TONHXXXJ.js → lifecycle-QH4TUI3K.js} +1 -1
  100. package/dist/mcp-chunks/{list-command-YUGRZO4G.js → list-command-UOB2XZK7.js} +30 -30
  101. package/dist/mcp-chunks/{output-utils-AZY6N2VQ.js → output-utils-6YXH23T7.js} +3 -3
  102. package/dist/mcp-chunks/{prompt-CH6TK0bC-NSBYYJZH.js → prompt-CH6TK0bC-ZB6RFAXR.js} +1 -1
  103. package/dist/mcp-chunks/{record-command-25DLELA2.js → record-command-FO5TTERC.js} +5 -5
  104. package/dist/mcp-chunks/{replay-command-6SLDG6PC.js → replay-command-SCBPCGQ7.js} +6 -6
  105. package/dist/mcp-chunks/{resource-command-YVOB4JCU.js → resource-command-S2J7XEMV.js} +10 -10
  106. package/dist/mcp-chunks/{result-utils-ZXB5DM36.js → result-utils-OME6HGS6.js} +4 -4
  107. package/dist/mcp-chunks/runtime-QIPMLIJI.js +39 -0
  108. package/dist/mcp-chunks/runtime-wrapper-X4YFKMJI.js +16 -0
  109. package/dist/mcp-chunks/{serve-command-QYGM2AMB.js → serve-command-DDBZZSG6.js} +28 -28
  110. package/dist/mcp-chunks/{timeouts-P3TBB3AX.js → timeouts-HNGNKDQN.js} +3 -3
  111. package/dist/mcp-chunks/{vault-command-VDMPATIX.js → vault-command-TJZYS3YI.js} +8 -7
  112. package/dist/mcp-chunks/{webapi-BLTNWSB2.js → webapi-4GWO2UBA.js} +887 -703
  113. package/dist/mcp-daemon.js +31 -31
  114. package/dist/mcp-run-worker.js +31 -31
  115. package/dist/recipe-package.d.ts +4 -2
  116. package/dist/recipe-package.d.ts.map +1 -1
  117. package/dist/recipe-package.js +31 -18
  118. package/dist/recipe-package.js.map +1 -1
  119. package/docs/channels.md +174 -60
  120. package/docs/pi-extension.md +1 -1
  121. package/docs/recipe-format.md +14 -9
  122. package/docs/slack.md +55 -59
  123. package/package.json +11 -11
  124. package/dist/mcp-chunks/call-arguments-RPXZJOXL.js +0 -15
  125. package/dist/mcp-chunks/chunk-7CS27CWE.js +0 -431
  126. package/dist/mcp-chunks/chunk-LJCZWKGJ.js +0 -372
  127. package/dist/mcp-chunks/chunk-Q7ESBNJG.js +0 -57
  128. package/dist/mcp-chunks/client-4ZHIBB67.js +0 -21
  129. package/dist/mcp-chunks/daemon-command-FKW6YELL.js +0 -35
  130. package/dist/mcp-chunks/runtime-NOWGTHZ5.js +0 -39
  131. package/dist/mcp-chunks/runtime-wrapper-ZZPAFQE4.js +0 -14
@@ -3,7 +3,7 @@ import {
3
3
  __export
4
4
  } from "./chunk-LRKZP7DJ.js";
5
5
 
6
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/buffer_utils.js
6
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/buffer_utils.js
7
7
  var encoder = new TextEncoder();
8
8
  var decoder = new TextDecoder();
9
9
  var strictDecoder = new TextDecoder("utf-8", { fatal: true });
@@ -49,7 +49,7 @@ function encode(string) {
49
49
  return bytes;
50
50
  }
51
51
 
52
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/crypto_key.js
52
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/crypto_key.js
53
53
  var unusable = (name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
54
54
  function checkUsage(key, usage) {
55
55
  if (usage && !key.usages.includes(usage)) {
@@ -79,7 +79,7 @@ function checkCryptoKey(key, expected, usage) {
79
79
  checkUsage(key, usage);
80
80
  }
81
81
 
82
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/invalid_key_input.js
82
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/invalid_key_input.js
83
83
  function message(msg, actual, ...types) {
84
84
  if (types.length > 2) {
85
85
  const last = types.pop();
@@ -103,7 +103,7 @@ function message(msg, actual, ...types) {
103
103
  var invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types);
104
104
  var withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
105
105
 
106
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/util/errors.js
106
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/util/errors.js
107
107
  var errors_exports = {};
108
108
  __export(errors_exports, {
109
109
  JOSEAlgNotAllowed: () => JOSEAlgNotAllowed,
@@ -223,7 +223,7 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
223
223
  }
224
224
  };
225
225
 
226
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/is_key_like.js
226
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/is_key_like.js
227
227
  function assertCryptoKey(key) {
228
228
  if (!isCryptoKey(key)) {
229
229
  throw new Error("CryptoKey instance expected");
@@ -241,7 +241,7 @@ var isCryptoKey = (key) => {
241
241
  var isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
242
242
  var isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
243
243
 
244
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/content_encryption.js
244
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/content_encryption.js
245
245
  var generateCek = (enc) => crypto.getRandomValues(new Uint8Array(enc.cekBits >> 3));
246
246
  function checkCekLength(cek, expected) {
247
247
  const actual = cek.byteLength << 3;
@@ -290,23 +290,13 @@ async function cbcDecrypt(enc, cek, ciphertext, iv, tag2, aad) {
290
290
  const [encKey, macKey, keySize] = await cbcKeySetup(enc, cek, "decrypt");
291
291
  const macData = concat(aad, iv, ciphertext, uint64be(aad.length * 8));
292
292
  const expectedTag = await cbcHmacTag(macKey, macData, keySize);
293
- let macCheckPassed;
294
293
  try {
295
- macCheckPassed = await timingSafeEqual(tag2, expectedTag);
296
- } catch {
297
- }
298
- if (!macCheckPassed) {
299
- throw new JWEDecryptionFailed();
300
- }
301
- let plaintext;
302
- try {
303
- plaintext = new Uint8Array(await crypto.subtle.decrypt({ iv, name: "AES-CBC" }, encKey, ciphertext));
294
+ if (await timingSafeEqual(tag2, expectedTag)) {
295
+ return new Uint8Array(await crypto.subtle.decrypt({ iv, name: "AES-CBC" }, encKey, ciphertext));
296
+ }
304
297
  } catch {
305
298
  }
306
- if (!plaintext) {
307
- throw new JWEDecryptionFailed();
308
- }
309
- return plaintext;
299
+ throw new JWEDecryptionFailed();
310
300
  }
311
301
  async function gcmEncrypt(enc, plaintext, cek, iv, aad) {
312
302
  const encKey = cek instanceof Uint8Array ? await crypto.subtle.importKey("raw", cek, "AES-GCM", false, [
@@ -361,6 +351,9 @@ async function decrypt(enc, cek, ciphertext, iv, tag2, aad) {
361
351
  if (!tag2) {
362
352
  throw new JWEInvalid("JWE Authentication Tag missing");
363
353
  }
354
+ if (!enc.cbc && tag2.length !== 16) {
355
+ throw new JWEInvalid("Invalid Authentication Tag length");
356
+ }
364
357
  checkIvLength(enc, iv);
365
358
  if (cek instanceof Uint8Array) {
366
359
  checkCekLength(cek, enc.cekBits);
@@ -368,14 +361,14 @@ async function decrypt(enc, cek, ciphertext, iv, tag2, aad) {
368
361
  return enc.cbc ? cbcDecrypt(enc, cek, ciphertext, iv, tag2, aad) : gcmDecrypt(enc, cek, ciphertext, iv, tag2, aad);
369
362
  }
370
363
 
371
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/util/base64url.js
364
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/util/base64url.js
372
365
  var base64url_exports = {};
373
366
  __export(base64url_exports, {
374
367
  decode: () => decode,
375
368
  encode: () => encode2
376
369
  });
377
370
 
378
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/base64.js
371
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/base64.js
379
372
  function encodeBase64(input) {
380
373
  if (Uint8Array.prototype.toBase64) {
381
374
  return input.toBase64();
@@ -399,7 +392,7 @@ function decodeBase64(encoded) {
399
392
  return bytes;
400
393
  }
401
394
 
402
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/util/base64url.js
395
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/util/base64url.js
403
396
  var invalid = "The input to be decoded is not correctly encoded.";
404
397
  function decode(input) {
405
398
  if (Uint8Array.fromBase64) {
@@ -436,20 +429,21 @@ function encode2(input) {
436
429
  return encodeBase64(unencoded).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
437
430
  }
438
431
 
439
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/type_checks.js
432
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/type_checks.js
433
+ function assertUint8Array(input, label) {
434
+ if (!(input instanceof Uint8Array)) {
435
+ throw new TypeError(`${label} must be an instance of Uint8Array`);
436
+ }
437
+ }
440
438
  function isObject(input) {
441
439
  if (typeof input !== "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]") {
442
440
  return false;
443
441
  }
444
442
  const prototype = Object.getPrototypeOf(input);
445
- if (prototype === null) {
446
- return true;
447
- }
448
- let proto = prototype;
449
- while (Object.getPrototypeOf(proto) !== null) {
450
- proto = Object.getPrototypeOf(proto);
451
- }
452
- return prototype === proto;
443
+ return prototype === null || Object.getPrototypeOf(prototype) === null;
444
+ }
445
+ function isJwkSet(input) {
446
+ return isObject(input) && Array.isArray(input.keys) && Array.from(input.keys).every(isObject);
453
447
  }
454
448
  function isDisjoint(...headers) {
455
449
  const parameters = /* @__PURE__ */ new Set();
@@ -465,15 +459,11 @@ function isDisjoint(...headers) {
465
459
  }
466
460
  return true;
467
461
  }
468
- var isJWK = (key) => isObject(key) && typeof key.kty === "string";
469
- var isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
470
- var isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
471
- var isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
472
462
 
473
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/helpers.js
463
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/helpers.js
474
464
  var unprotected = /* @__PURE__ */ Symbol();
475
465
  function assertNotSet(value, name) {
476
- if (value) {
466
+ if (value !== void 0) {
477
467
  throw new TypeError(`${name} can only be called once`);
478
468
  }
479
469
  }
@@ -508,7 +498,7 @@ function parseJoseHeader(b64, ErrorClass, message2) {
508
498
  return parsed;
509
499
  }
510
500
 
511
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/jwk_to_key.js
501
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jwk_to_key.js
512
502
  async function jwkToKey(entry, jwk) {
513
503
  if (jwk.kty === "RSA" && "oth" in jwk && jwk.oth !== void 0) {
514
504
  throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
@@ -526,7 +516,27 @@ async function jwkToKey(entry, jwk) {
526
516
  return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? !isPrivate, jwk.key_ops ?? entry.usages[isPrivate ? 1 : 0]);
527
517
  }
528
518
 
529
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/key.js
519
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jwk_metadata.js
520
+ function snapshotJwk(jwk) {
521
+ return { __proto__: null, ...jwk };
522
+ }
523
+ function normalizeJwk(jwk) {
524
+ const normalized = snapshotJwk(jwk);
525
+ if (normalized.ext !== void 0 && typeof normalized.ext !== "boolean") {
526
+ throw new TypeError('"ext" (Extractable) Parameter must be a boolean');
527
+ }
528
+ if (normalized.key_ops !== void 0) {
529
+ const value = normalized.key_ops;
530
+ const keyOps = Array.isArray(value) ? [...value] : void 0;
531
+ if (!keyOps || keyOps.some((operation) => typeof operation !== "string") || new Set(keyOps).size !== keyOps.length) {
532
+ throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');
533
+ }
534
+ normalized.key_ops = keyOps;
535
+ }
536
+ return normalized;
537
+ }
538
+
539
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/key.js
530
540
  var tag = (key) => key[Symbol.toStringTag];
531
541
  var jwkMatchesOp = (entry, key, usage) => {
532
542
  const { alg } = entry;
@@ -551,12 +561,17 @@ function checkKeyType(entry, key, usage) {
551
561
  const privateKey = usage === "decrypt" || usage === "sign";
552
562
  if (secret && key instanceof Uint8Array)
553
563
  return [BYTES, key];
554
- if (isJWK(key)) {
555
- if (secret ? !isSecretJWK(key) : !(privateKey ? isPrivateJWK(key) : isPublicJWK(key))) {
564
+ if (isObject(key)) {
565
+ const normalized = normalizeJwk(key);
566
+ if (typeof normalized.kty !== "string") {
567
+ throw new TypeError(secret ? withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array") : withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
568
+ }
569
+ 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);
570
+ if (!valid) {
556
571
  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`);
557
572
  }
558
- jwkMatchesOp(entry, key, usage);
559
- return [JWK, key];
573
+ jwkMatchesOp(entry, normalized, usage);
574
+ return [JWK, key, normalized];
560
575
  }
561
576
  if (!isKeyLike(key)) {
562
577
  throw new TypeError(secret ? withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array") : withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
@@ -595,7 +610,7 @@ function cached(key, alg, value) {
595
610
  if (entry) {
596
611
  entry[alg] = value;
597
612
  } else {
598
- cache.set(key, { __proto__: null, [alg]: value });
613
+ cache.set(key, { [alg]: value });
599
614
  }
600
615
  }
601
616
  return value ?? entry?.[alg];
@@ -620,8 +635,9 @@ async function prepareKey(entry, key, usage) {
620
635
  return tagged[1];
621
636
  case JWK: {
622
637
  const key2 = tagged[1];
623
- if (key2.k) {
624
- return decode(key2.k);
638
+ const normalized = tagged[2];
639
+ if (normalized.kty === "oct") {
640
+ return decode(normalized.k);
625
641
  }
626
642
  if (!Object.isFrozen(key2)) {
627
643
  const { key_ops } = key2;
@@ -629,7 +645,7 @@ async function prepareKey(entry, key, usage) {
629
645
  Object.freeze(key_ops);
630
646
  Object.freeze(key2);
631
647
  }
632
- return handleJWK(key2, key2, entry);
648
+ return handleJWK(key2, normalized, entry);
633
649
  }
634
650
  case KEYOBJECT: {
635
651
  const keyObject = tagged[1];
@@ -644,7 +660,7 @@ async function prepareKey(entry, key, usage) {
644
660
  }
645
661
  }
646
662
 
647
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/key_descriptor.js
663
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/key_descriptor.js
648
664
  function table(entries) {
649
665
  const out = { __proto__: null };
650
666
  for (const alg in entries) {
@@ -653,7 +669,7 @@ function table(entries) {
653
669
  return out;
654
670
  }
655
671
 
656
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/jwe_algorithms.js
672
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jwe_algorithms.js
657
673
  var wrap = [
658
674
  ["encrypt", "wrapKey"],
659
675
  ["decrypt", "unwrapKey"]
@@ -760,7 +776,7 @@ function jweEncryption(enc) {
760
776
  return (typeof enc === "string" ? ENC[enc] : void 0) ?? unsupported("enc", "Encryption Algorithm");
761
777
  }
762
778
 
763
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/key_management.js
779
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/key_management.js
764
780
  function checkEcdhCryptoKey(key, usage) {
765
781
  if (key.algorithm.name !== "ECDH" && key.algorithm.name !== "X25519") {
766
782
  throw new TypeError("CryptoKey does not support this operation, its algorithm.name must be ECDH or X25519");
@@ -855,7 +871,7 @@ function assertNoEncryptedKey(encryptedKey) {
855
871
  if (encryptedKey !== void 0)
856
872
  throw new JWEInvalid("Encountered unexpected JWE Encrypted Key");
857
873
  }
858
- async function decryptKeyManagement(alg, enc, key, encryptedKey, joseHeader, options) {
874
+ async function decryptKeyManagement(alg, enc, key, encryptedKey, joseHeader, maxPBES2Count) {
859
875
  const entry = jweAlgorithm(alg);
860
876
  if (alg === "dir") {
861
877
  assertNoEncryptedKey(encryptedKey);
@@ -897,7 +913,7 @@ async function decryptKeyManagement(alg, enc, key, encryptedKey, joseHeader, opt
897
913
  assertEncryptedKey(encryptedKey);
898
914
  if (typeof joseHeader.p2c !== "number")
899
915
  throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
900
- const p2cLimit = options?.maxPBES2Count || 1e4;
916
+ const p2cLimit = maxPBES2Count || 1e4;
901
917
  if (joseHeader.p2c > p2cLimit)
902
918
  throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
903
919
  if (typeof joseHeader.p2s !== "string")
@@ -935,8 +951,14 @@ async function encryptKeyManagement(alg, enc, key, providedCek, providedParamete
935
951
  case "ECDH": {
936
952
  assertEcdhKey(key);
937
953
  const { apu, apv } = providedParameters;
954
+ if (apu !== void 0) {
955
+ assertUint8Array(apu, '"apu"');
956
+ }
957
+ if (apv !== void 0) {
958
+ assertUint8Array(apv, '"apv"');
959
+ }
938
960
  let ephemeralKey;
939
- if (providedParameters.epk) {
961
+ if (providedParameters.epk !== void 0) {
940
962
  ephemeralKey = await prepareKey(entry, providedParameters.epk, "decrypt");
941
963
  } else {
942
964
  ephemeralKey = (await crypto.subtle.generateKey(key.algorithm, true, ["deriveBits"])).privateKey;
@@ -999,7 +1021,7 @@ async function encryptKeyManagement(alg, enc, key, providedCek, providedParamete
999
1021
  return [cek, encryptedKey, parameters];
1000
1022
  }
1001
1023
 
1002
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/options.js
1024
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/options.js
1003
1025
  var JWS_RECOGNIZED = { __proto__: null, b64: true };
1004
1026
  var JWE_RECOGNIZED = { __proto__: null };
1005
1027
  function validateAlgorithms(option, algorithms) {
@@ -1041,8 +1063,40 @@ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader,
1041
1063
  }
1042
1064
  return protectedHeader.crit;
1043
1065
  }
1066
+ function validateB64(protectedHeader, extensions) {
1067
+ if (extensions.includes("b64")) {
1068
+ const b64 = protectedHeader.b64;
1069
+ if (typeof b64 !== "boolean") {
1070
+ throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
1071
+ }
1072
+ return b64;
1073
+ }
1074
+ return true;
1075
+ }
1076
+ function serializeJoseHeader(Err, header) {
1077
+ let serialized;
1078
+ let parsed;
1079
+ try {
1080
+ serialized = JSON.stringify(header);
1081
+ parsed = JSON.parse(serialized);
1082
+ } catch (cause) {
1083
+ throw new Err("JOSE Header is not valid JSON", { cause });
1084
+ }
1085
+ if (!isObject(parsed)) {
1086
+ throw new Err("JOSE Header is not a JSON object");
1087
+ }
1088
+ return [parsed, serialized];
1089
+ }
1044
1090
 
1045
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/deflate.js
1091
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/deflate.js
1092
+ function validateZip(joseHeader, protectedHeader) {
1093
+ if (joseHeader.zip !== void 0 && joseHeader.zip !== "DEF") {
1094
+ throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');
1095
+ }
1096
+ if (joseHeader.zip !== void 0 && !protectedHeader?.zip) {
1097
+ throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');
1098
+ }
1099
+ }
1046
1100
  function supported(name) {
1047
1101
  if (typeof globalThis[name] === "undefined") {
1048
1102
  throw new JOSENotSupported(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${name} API.`);
@@ -1090,35 +1144,72 @@ async function decompress(input, maxLength) {
1090
1144
  return concat(...chunks);
1091
1145
  }
1092
1146
 
1093
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/jwe_decrypt.js
1094
- function checkShared(jwe) {
1095
- const { ciphertext, protected: encodedProtected, unprotected: unprotected2 } = jwe;
1096
- if (jwe.iv !== void 0 && typeof jwe.iv !== "string") {
1147
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jwe_decrypt.js
1148
+ function snapshotSharedJWE(jwe) {
1149
+ const { aad, ciphertext, iv, protected: encodedProtected, tag: tag2, unprotected: unprotected2 } = jwe;
1150
+ if (iv !== void 0 && typeof iv !== "string") {
1097
1151
  throw new JWEInvalid("JWE Initialization Vector incorrect type");
1098
1152
  }
1099
1153
  if (typeof ciphertext !== "string") {
1100
1154
  throw new JWEInvalid("JWE Ciphertext missing or incorrect type");
1101
1155
  }
1102
- if (jwe.tag !== void 0 && typeof jwe.tag !== "string") {
1156
+ if (tag2 !== void 0 && typeof tag2 !== "string") {
1103
1157
  throw new JWEInvalid("JWE Authentication Tag incorrect type");
1104
1158
  }
1105
1159
  if (encodedProtected !== void 0 && typeof encodedProtected !== "string") {
1106
1160
  throw new JWEInvalid("JWE Protected Header incorrect type");
1107
1161
  }
1108
- if (jwe.aad !== void 0 && typeof jwe.aad !== "string") {
1162
+ if (aad !== void 0 && (typeof aad !== "string" || !aad)) {
1109
1163
  throw new JWEInvalid("JWE AAD incorrect type");
1110
1164
  }
1111
1165
  if (unprotected2 !== void 0 && !isObject(unprotected2)) {
1112
1166
  throw new JWEInvalid("JWE Shared Unprotected Header incorrect type");
1113
1167
  }
1168
+ return {
1169
+ aad,
1170
+ ciphertext,
1171
+ iv,
1172
+ protected: encodedProtected,
1173
+ tag: tag2,
1174
+ unprotected: unprotected2 === void 0 ? void 0 : { ...unprotected2 }
1175
+ };
1176
+ }
1177
+ function snapshotRecipientJWE(recipient) {
1178
+ let header;
1179
+ let headerAlg;
1180
+ try {
1181
+ const { header: inputHeader } = recipient;
1182
+ if (isObject(inputHeader)) {
1183
+ headerAlg = inputHeader.alg;
1184
+ const parameters = Object.keys(inputHeader);
1185
+ if (!parameters.includes("alg"))
1186
+ headerAlg = void 0;
1187
+ header = Object.fromEntries(parameters.map((parameter) => [
1188
+ parameter,
1189
+ parameter === "alg" ? headerAlg : inputHeader[parameter]
1190
+ ]));
1191
+ } else {
1192
+ header = inputHeader;
1193
+ }
1194
+ } catch (error) {
1195
+ return [void 0, headerAlg, error];
1196
+ }
1197
+ try {
1198
+ const { encrypted_key: encryptedKey } = recipient;
1199
+ return [{ encrypted_key: encryptedKey, header }, headerAlg];
1200
+ } catch (error) {
1201
+ return [void 0, headerAlg, error];
1202
+ }
1114
1203
  }
1115
1204
  function checkRecipient(jwe) {
1116
1205
  const { encrypted_key: encryptedKey, header } = jwe;
1117
1206
  if (encryptedKey !== void 0 && typeof encryptedKey !== "string") {
1118
1207
  throw new JWEInvalid("JWE Encrypted Key incorrect type");
1119
1208
  }
1120
- if (header !== void 0 && !isObject(header)) {
1121
- throw new JWEInvalid("JWE Per-Recipient Unprotected Header incorrect type");
1209
+ if (header !== void 0) {
1210
+ if (!isObject(header)) {
1211
+ throw new JWEInvalid("JWE Per-Recipient Unprotected Header incorrect type");
1212
+ }
1122
1213
  }
1123
1214
  if (jwe.protected === void 0 && header === void 0 && jwe.unprotected === void 0) {
1124
1215
  throw new JWEInvalid("JOSE Header missing");
@@ -1127,7 +1218,7 @@ function checkRecipient(jwe) {
1127
1218
  function shareJWE(jwe) {
1128
1219
  const { protected: encodedProtected, ciphertext, iv, tag: tag2, aad } = jwe;
1129
1220
  let parsedProt;
1130
- if (encodedProtected) {
1221
+ if (encodedProtected !== void 0) {
1131
1222
  parsedProt = parseJoseHeader(encodedProtected, JWEInvalid, "JWE Protected Header is invalid");
1132
1223
  }
1133
1224
  const protectedHeader = encodedProtected !== void 0 ? encode(encodedProtected) : new Uint8Array();
@@ -1164,13 +1255,14 @@ function prepareDecrypt(options) {
1164
1255
  return [
1165
1256
  options && validateAlgorithms("keyManagementAlgorithms", options.keyManagementAlgorithms),
1166
1257
  options && validateAlgorithms("contentEncryptionAlgorithms", options.contentEncryptionAlgorithms),
1167
- options
1258
+ options?.crit,
1259
+ options?.maxPBES2Count,
1260
+ options?.maxDecompressedLength
1168
1261
  ];
1169
1262
  }
1170
1263
  async function decryptRecipient(jwe, token, shared, key) {
1171
- const [keyManagementAlgorithms, contentEncryptionAlgorithms, options] = shared;
1172
- const [parsedProt, ciphertext, iv, tag2, additionalData] = token;
1173
- const { encrypted_key: encodedKey, header, unprotected: unprotected2 } = jwe;
1264
+ const [parsedProt] = token;
1265
+ const { header, unprotected: unprotected2 } = jwe;
1174
1266
  let joseHeader;
1175
1267
  if (header !== void 0 || unprotected2 !== void 0) {
1176
1268
  if (!isDisjoint(parsedProt, header, unprotected2)) {
@@ -1180,13 +1272,14 @@ async function decryptRecipient(jwe, token, shared, key) {
1180
1272
  } else {
1181
1273
  joseHeader = parsedProt ?? {};
1182
1274
  }
1183
- validateCrit(JWEInvalid, JWE_RECOGNIZED, options?.crit, parsedProt, joseHeader);
1184
- if (joseHeader.zip !== void 0 && joseHeader.zip !== "DEF") {
1185
- throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');
1186
- }
1187
- if (joseHeader.zip !== void 0 && !parsedProt?.zip) {
1188
- throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');
1189
- }
1275
+ return decryptRecipientCore(jwe, token, shared, key, joseHeader);
1276
+ }
1277
+ async function decryptRecipientCore(jwe, token, shared, key, joseHeader) {
1278
+ const [keyManagementAlgorithms, contentEncryptionAlgorithms, crit, maxPBES2Count, maxDecompressedLength] = shared;
1279
+ const [parsedProt, ciphertext, iv, tag2, additionalData] = token;
1280
+ const { encrypted_key: encodedKey } = jwe;
1281
+ validateCrit(JWEInvalid, JWE_RECOGNIZED, crit, parsedProt, joseHeader);
1282
+ validateZip(joseHeader, parsedProt);
1190
1283
  const { alg, enc } = joseHeader;
1191
1284
  if (typeof alg !== "string" || !alg) {
1192
1285
  throw new JWEInvalid("missing JWE Algorithm (alg) in JWE Header");
@@ -1214,7 +1307,10 @@ async function decryptRecipient(jwe, token, shared, key) {
1214
1307
  const k = await prepareKey(alg === "dir" ? encEntry : algEntry, key, "decrypt");
1215
1308
  let cek;
1216
1309
  try {
1217
- cek = await decryptKeyManagement(alg, encEntry, k, encryptedKey, joseHeader, options);
1310
+ cek = await decryptKeyManagement(alg, encEntry, k, encryptedKey, joseHeader, maxPBES2Count);
1311
+ if (encodedKey !== void 0 && cek instanceof Uint8Array && cek.byteLength << 3 !== encEntry.cekBits) {
1312
+ cek = generateCek(encEntry);
1313
+ }
1218
1314
  } catch (err) {
1219
1315
  if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {
1220
1316
  throw err;
@@ -1223,14 +1319,14 @@ async function decryptRecipient(jwe, token, shared, key) {
1223
1319
  }
1224
1320
  let plaintext = await decrypt(encEntry, cek, ciphertext, iv, tag2, additionalData);
1225
1321
  if (joseHeader.zip === "DEF") {
1226
- const maxDecompressedLength = options?.maxDecompressedLength ?? 25e4;
1227
- if (maxDecompressedLength === 0) {
1322
+ const decompressionLimit = maxDecompressedLength ?? 25e4;
1323
+ if (decompressionLimit === 0) {
1228
1324
  throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
1229
1325
  }
1230
- if (maxDecompressedLength !== Infinity && (!Number.isSafeInteger(maxDecompressedLength) || maxDecompressedLength < 1)) {
1326
+ if (decompressionLimit !== Infinity && (!Number.isSafeInteger(decompressionLimit) || decompressionLimit < 1)) {
1231
1327
  throw new TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");
1232
1328
  }
1233
- plaintext = await decompress(plaintext, maxDecompressedLength).catch((cause) => {
1329
+ plaintext = await decompress(plaintext, decompressionLimit).catch((cause) => {
1234
1330
  if (cause instanceof JWEInvalid)
1235
1331
  throw cause;
1236
1332
  throw new JWEInvalid("Failed to decompress plaintext", { cause });
@@ -1252,16 +1348,26 @@ async function decryptCompact(jwe, shared, key) {
1252
1348
  if (length !== 5) {
1253
1349
  throw new JWEInvalid("Invalid Compact JWE");
1254
1350
  }
1255
- return decryptJWE({
1351
+ const flattened = {
1256
1352
  ciphertext,
1257
1353
  iv: iv || void 0,
1258
1354
  protected: protectedHeader,
1259
1355
  tag: tag2 || void 0,
1260
1356
  encrypted_key: encryptedKey || void 0
1261
- }, shared, key);
1357
+ };
1358
+ const parsedProt = parseJoseHeader(protectedHeader, JWEInvalid, "JWE Protected Header is invalid");
1359
+ const protectedBytes = encode(protectedHeader);
1360
+ const token = [
1361
+ parsedProt,
1362
+ decodeBase64url(ciphertext, "ciphertext", JWEInvalid),
1363
+ iv ? decodeBase64url(iv, "iv", JWEInvalid) : void 0,
1364
+ tag2 ? decodeBase64url(tag2, "tag", JWEInvalid) : void 0,
1365
+ protectedBytes
1366
+ ];
1367
+ return decryptRecipientCore(flattened, token, shared, key, parsedProt);
1262
1368
  }
1263
1369
 
1264
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwe/compact/decrypt.js
1370
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwe/compact/decrypt.js
1265
1371
  async function compactDecrypt(jwe, key, options) {
1266
1372
  const decrypted = await decryptCompact(jwe, prepareDecrypt(options), key);
1267
1373
  const result = { plaintext: decrypted[0], protectedHeader: decrypted[1] };
@@ -1271,56 +1377,60 @@ async function compactDecrypt(jwe, key, options) {
1271
1377
  return result;
1272
1378
  }
1273
1379
 
1274
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js
1380
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js
1275
1381
  async function flattenedDecrypt(jwe, key, options) {
1276
1382
  if (!isObject(jwe)) {
1277
1383
  throw new JWEInvalid("Flattened JWE must be an object");
1278
1384
  }
1279
- checkShared(jwe);
1280
- checkRecipient(jwe);
1281
- return decryptResult(jwe, await decryptJWE(jwe, prepareDecrypt(options), key));
1385
+ const shared = snapshotSharedJWE(jwe);
1386
+ const [recipient, , error] = snapshotRecipientJWE(jwe);
1387
+ if (!recipient)
1388
+ throw error;
1389
+ const snapshot = { ...shared, ...recipient };
1390
+ checkRecipient(snapshot);
1391
+ return decryptResult(snapshot, await decryptJWE(snapshot, prepareDecrypt(options), key));
1282
1392
  }
1283
1393
 
1284
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwe/general/decrypt.js
1394
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwe/general/decrypt.js
1285
1395
  async function generalDecrypt(jwe, key, options) {
1286
1396
  if (!isObject(jwe)) {
1287
1397
  throw new JWEInvalid("General JWE must be an object");
1288
1398
  }
1289
- if (!Array.isArray(jwe.recipients) || !jwe.recipients.every(isObject)) {
1399
+ const inputRecipients = jwe.recipients;
1400
+ if (!Array.isArray(inputRecipients)) {
1401
+ throw new JWEInvalid("JWE Recipients missing or incorrect type");
1402
+ }
1403
+ const recipients = Array.from(inputRecipients);
1404
+ if (!recipients.every(isObject)) {
1290
1405
  throw new JWEInvalid("JWE Recipients missing or incorrect type");
1291
1406
  }
1292
- if (!jwe.recipients.length) {
1407
+ if (!recipients.length) {
1293
1408
  throw new JWEInvalid("JWE Recipients has no members");
1294
1409
  }
1295
1410
  let shared;
1411
+ let sharedJwe;
1296
1412
  let token;
1297
1413
  try {
1298
- checkShared(jwe);
1299
1414
  shared = prepareDecrypt(options);
1300
- token = shareJWE(jwe);
1415
+ sharedJwe = snapshotSharedJWE(jwe);
1416
+ token = shareJWE(sharedJwe);
1301
1417
  } catch {
1302
1418
  throw new JWEDecryptionFailed();
1303
1419
  }
1304
- if (jwe.recipients.length > 1) {
1305
- for (const { header } of jwe.recipients) {
1306
- const alg = token[0]?.alg ?? header?.alg ?? jwe.unprotected?.alg;
1420
+ const recipientSnapshots = recipients.map((recipient) => snapshotRecipientJWE(recipient));
1421
+ if (recipients.length > 1) {
1422
+ for (const [, headerAlg] of recipientSnapshots) {
1423
+ const alg = token[0]?.alg ?? headerAlg ?? sharedJwe.unprotected?.alg;
1307
1424
  if (alg === "dir" || alg === "ECDH-ES") {
1308
1425
  throw new JWEInvalid(`"${alg}" alg may only have a single recipient`);
1309
1426
  }
1310
1427
  }
1311
1428
  }
1312
- for (const recipient of jwe.recipients) {
1429
+ for (const [recipient] of recipientSnapshots) {
1430
+ if (!recipient)
1431
+ continue;
1313
1432
  try {
1314
- const flattened = {
1315
- aad: jwe.aad,
1316
- ciphertext: jwe.ciphertext,
1317
- encrypted_key: recipient.encrypted_key,
1318
- header: recipient.header,
1319
- iv: jwe.iv,
1320
- protected: jwe.protected,
1321
- tag: jwe.tag,
1322
- unprotected: jwe.unprotected
1323
- };
1433
+ const flattened = { ...sharedJwe, ...recipient };
1324
1434
  checkRecipient(flattened);
1325
1435
  return decryptResult(flattened, await decryptRecipient(flattened, token, shared, key));
1326
1436
  } catch {
@@ -1329,27 +1439,47 @@ async function generalDecrypt(jwe, key, options) {
1329
1439
  throw new JWEDecryptionFailed();
1330
1440
  }
1331
1441
 
1332
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/jwe_encrypt.js
1442
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jwe_encrypt.js
1333
1443
  function checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader) {
1334
1444
  if (!isDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader)) {
1335
1445
  throw new JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");
1336
1446
  }
1337
1447
  }
1338
1448
  function checkEncryptHeaders(input) {
1339
- const [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, , , , , crit] = input;
1449
+ let [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, aad, cek, iv, keyManagementParameters, crit] = input;
1450
+ if (aad !== void 0) {
1451
+ assertUint8Array(aad, "JWE Additional Authenticated Data");
1452
+ }
1453
+ if (cek !== void 0) {
1454
+ assertUint8Array(cek, "JWE Content Encryption Key");
1455
+ }
1456
+ if (iv !== void 0) {
1457
+ assertUint8Array(iv, "JWE Initialization Vector");
1458
+ }
1459
+ if (protectedHeader !== void 0) {
1460
+ protectedHeader = serializeJoseHeader(JWEInvalid, protectedHeader)[0];
1461
+ input[1] = protectedHeader;
1462
+ }
1463
+ if (unprotectedHeader !== void 0) {
1464
+ unprotectedHeader = serializeJoseHeader(JWEInvalid, unprotectedHeader)[0];
1465
+ input[2] = unprotectedHeader;
1466
+ }
1467
+ if (sharedUnprotectedHeader !== void 0) {
1468
+ sharedUnprotectedHeader = serializeJoseHeader(JWEInvalid, sharedUnprotectedHeader)[0];
1469
+ input[3] = sharedUnprotectedHeader;
1470
+ }
1471
+ if (keyManagementParameters !== void 0 && !isObject(keyManagementParameters)) {
1472
+ throw new TypeError("JWE Key Management Parameters must be an object");
1473
+ }
1340
1474
  checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
1341
1475
  const joseHeader = {
1342
1476
  ...protectedHeader,
1343
1477
  ...unprotectedHeader,
1344
1478
  ...sharedUnprotectedHeader
1345
1479
  };
1480
+ validateCritDuplicates(JWEInvalid, protectedHeader);
1346
1481
  validateCrit(JWEInvalid, JWE_RECOGNIZED, crit, protectedHeader, joseHeader);
1347
- if (joseHeader.zip !== void 0 && joseHeader.zip !== "DEF") {
1348
- throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');
1349
- }
1350
- if (joseHeader.zip !== void 0 && !protectedHeader?.zip) {
1351
- throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');
1352
- }
1482
+ validateZip(joseHeader, protectedHeader);
1353
1483
  const { alg, enc } = joseHeader;
1354
1484
  if (typeof alg !== "string" || !alg) {
1355
1485
  throw new JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');
@@ -1428,81 +1558,18 @@ async function encryptJWE(input, checked, key) {
1428
1558
  }
1429
1559
  return jwe;
1430
1560
  }
1431
- async function createJWE(input, key) {
1432
- return encryptJWE(input, checkEncryptHeaders(input), key);
1433
- }
1434
-
1435
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
1436
- var FlattenedEncrypt = class {
1437
- #plaintext;
1438
- #protectedHeader;
1439
- #sharedUnprotectedHeader;
1440
- #unprotectedHeader;
1441
- #aad;
1442
- #cek;
1443
- #iv;
1444
- #keyManagementParameters;
1445
- constructor(plaintext) {
1446
- if (!(plaintext instanceof Uint8Array)) {
1447
- throw new TypeError("plaintext must be an instance of Uint8Array");
1448
- }
1449
- this.#plaintext = plaintext;
1450
- }
1451
- setKeyManagementParameters(parameters) {
1452
- assertNotSet(this.#keyManagementParameters, "setKeyManagementParameters");
1453
- this.#keyManagementParameters = parameters;
1454
- return this;
1455
- }
1456
- setProtectedHeader(protectedHeader) {
1457
- assertNotSet(this.#protectedHeader, "setProtectedHeader");
1458
- this.#protectedHeader = protectedHeader;
1459
- return this;
1460
- }
1461
- setSharedUnprotectedHeader(sharedUnprotectedHeader) {
1462
- assertNotSet(this.#sharedUnprotectedHeader, "setSharedUnprotectedHeader");
1463
- this.#sharedUnprotectedHeader = sharedUnprotectedHeader;
1464
- return this;
1465
- }
1466
- setUnprotectedHeader(unprotectedHeader) {
1467
- assertNotSet(this.#unprotectedHeader, "setUnprotectedHeader");
1468
- this.#unprotectedHeader = unprotectedHeader;
1469
- return this;
1470
- }
1471
- setAdditionalAuthenticatedData(aad) {
1472
- this.#aad = aad;
1473
- return this;
1474
- }
1475
- setContentEncryptionKey(cek) {
1476
- assertNotSet(this.#cek, "setContentEncryptionKey");
1477
- this.#cek = cek;
1478
- return this;
1561
+ async function createJWE(input, key, options) {
1562
+ if (!input[1] && !input[2] && !input[3]) {
1563
+ throw new JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");
1479
1564
  }
1480
- setInitializationVector(iv) {
1481
- assertNotSet(this.#iv, "setInitializationVector");
1482
- this.#iv = iv;
1483
- return this;
1484
- }
1485
- async encrypt(key, options) {
1486
- if (!this.#protectedHeader && !this.#unprotectedHeader && !this.#sharedUnprotectedHeader) {
1487
- throw new JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");
1488
- }
1489
- validateCritDuplicates(JWEInvalid, this.#protectedHeader);
1490
- return createJWE([
1491
- this.#plaintext,
1492
- this.#protectedHeader,
1493
- this.#unprotectedHeader,
1494
- this.#sharedUnprotectedHeader,
1495
- this.#aad,
1496
- this.#cek,
1497
- this.#iv,
1498
- this.#keyManagementParameters,
1499
- options?.crit,
1500
- options ? unprotected in options : false
1501
- ], key);
1565
+ if (options !== void 0) {
1566
+ input[8] = options?.crit;
1567
+ input[9] = options ? unprotected in options : false;
1502
1568
  }
1503
- };
1569
+ return encryptJWE(input, checkEncryptHeaders(input), key);
1570
+ }
1504
1571
 
1505
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwe/general/encrypt.js
1572
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwe/general/encrypt.js
1506
1573
  var IndividualRecipient = class {
1507
1574
  #parent;
1508
1575
  state;
@@ -1573,13 +1640,21 @@ var GeneralEncrypt = class {
1573
1640
  if (!this.#recipients.length) {
1574
1641
  throw new JWEInvalid("at least one recipient must be added");
1575
1642
  }
1576
- if (!(this.#plaintext instanceof Uint8Array)) {
1577
- throw new TypeError("plaintext must be an instance of Uint8Array");
1578
- }
1643
+ assertUint8Array(this.#plaintext, "plaintext");
1579
1644
  if (this.#recipients.length === 1) {
1580
- const [recipient] = this.#recipients;
1581
- const [unprotectedHeader, keyManagementParameters, key, crit] = recipient.state;
1582
- const flattened = await new FlattenedEncrypt(this.#plaintext).setAdditionalAuthenticatedData(this.#aad).setProtectedHeader(this.#protectedHeader).setSharedUnprotectedHeader(this.#unprotectedHeader).setUnprotectedHeader(unprotectedHeader).setKeyManagementParameters(keyManagementParameters).encrypt(key, { crit });
1645
+ const [unprotectedHeader, keyManagementParameters, key, crit] = this.#recipients[0].state;
1646
+ const flattened = await createJWE([
1647
+ this.#plaintext,
1648
+ this.#protectedHeader,
1649
+ unprotectedHeader,
1650
+ this.#unprotectedHeader,
1651
+ this.#aad,
1652
+ void 0,
1653
+ void 0,
1654
+ keyManagementParameters,
1655
+ crit,
1656
+ false
1657
+ ], key);
1583
1658
  const jwe2 = {
1584
1659
  ciphertext: flattened.ciphertext,
1585
1660
  iv: flattened.iv,
@@ -1591,8 +1666,9 @@ var GeneralEncrypt = class {
1591
1666
  copyOptionalMembers(flattened, jwe2, jwe2.recipients[0]);
1592
1667
  return jwe2;
1593
1668
  }
1594
- validateCritDuplicates(JWEInvalid, this.#protectedHeader);
1595
1669
  let enc;
1670
+ let protectedHeader = this.#protectedHeader;
1671
+ let sharedUnprotectedHeader = this.#unprotectedHeader;
1596
1672
  const inputs = [];
1597
1673
  const checked = [];
1598
1674
  for (let i = 0; i < this.#recipients.length; i++) {
@@ -1600,9 +1676,9 @@ var GeneralEncrypt = class {
1600
1676
  const [unprotectedHeader, keyManagementParameters, , crit] = recipient.state;
1601
1677
  const input = [
1602
1678
  this.#plaintext,
1603
- this.#protectedHeader,
1679
+ protectedHeader,
1604
1680
  unprotectedHeader,
1605
- this.#unprotectedHeader,
1681
+ sharedUnprotectedHeader,
1606
1682
  this.#aad,
1607
1683
  void 0,
1608
1684
  void 0,
@@ -1613,6 +1689,10 @@ var GeneralEncrypt = class {
1613
1689
  const headers = checkEncryptHeaders(input);
1614
1690
  inputs.push(input);
1615
1691
  checked.push(headers);
1692
+ if (i === 0) {
1693
+ protectedHeader = input[1];
1694
+ sharedUnprotectedHeader = input[3];
1695
+ }
1616
1696
  if (headers[1] === "dir" || headers[1] === "ECDH-ES") {
1617
1697
  throw new JWEInvalid(`"${headers[1]}" alg may only have a single recipient`);
1618
1698
  }
@@ -1629,7 +1709,7 @@ var GeneralEncrypt = class {
1629
1709
  };
1630
1710
  for (let i = 0; i < this.#recipients.length; i++) {
1631
1711
  const recipient = this.#recipients[i];
1632
- const [unprotectedHeader, keyManagementParameters, key] = recipient.state;
1712
+ const [, keyManagementParameters, key] = recipient.state;
1633
1713
  const target = {};
1634
1714
  jwe.recipients.push(target);
1635
1715
  if (i === 0) {
@@ -1643,13 +1723,14 @@ var GeneralEncrypt = class {
1643
1723
  continue;
1644
1724
  }
1645
1725
  const [, alg, , encEntry] = checked[i];
1726
+ const unprotectedHeader = inputs[i][2];
1646
1727
  const k = await prepareKey(jweAlgorithm(alg), key, "encrypt");
1647
1728
  const [, encryptedKey, parameters] = await encryptKeyManagement(alg, encEntry, k, cek, keyManagementParameters);
1648
1729
  target.encrypted_key = encode2(encryptedKey);
1649
1730
  if (unprotectedHeader || parameters) {
1650
1731
  const header = { ...unprotectedHeader, ...parameters };
1651
1732
  if (parameters)
1652
- checkDisjoint(this.#protectedHeader, header, this.#unprotectedHeader);
1733
+ checkDisjoint(inputs[i][1], header, inputs[i][3]);
1653
1734
  target.header = header;
1654
1735
  }
1655
1736
  }
@@ -1657,7 +1738,7 @@ var GeneralEncrypt = class {
1657
1738
  }
1658
1739
  };
1659
1740
 
1660
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/signing.js
1741
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/signing.js
1661
1742
  async function getSigKey(entry, key, usage) {
1662
1743
  if (key instanceof Uint8Array) {
1663
1744
  return crypto.subtle.importKey("raw", key, entry.subtle, false, [
@@ -1683,7 +1764,7 @@ async function verify(entry, key, signature, data) {
1683
1764
  }
1684
1765
  }
1685
1766
 
1686
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/jws_algorithms.js
1767
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jws_algorithms.js
1687
1768
  var sig = [["verify"], ["sign"]];
1688
1769
  function hmac(bits) {
1689
1770
  const subtle = { name: "HMAC", hash: `SHA-${bits}` };
@@ -1756,7 +1837,23 @@ function jwsAlgorithm(alg) {
1756
1837
  return entry;
1757
1838
  }
1758
1839
 
1759
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/jws_verify.js
1840
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jws_verify.js
1841
+ function snapshotJws(jws, sharedPayload) {
1842
+ const encodedProtected = jws.protected;
1843
+ const inputHeader = jws.header;
1844
+ const header = isObject(inputHeader) ? { ...inputHeader } : inputHeader;
1845
+ let payload = sharedPayload ? sharedPayload[0] : jws.payload;
1846
+ if (!sharedPayload && payload instanceof Uint8Array) {
1847
+ payload = new Uint8Array(payload);
1848
+ }
1849
+ const signature = jws.signature;
1850
+ const snapshot = { payload, signature };
1851
+ if (encodedProtected !== void 0)
1852
+ snapshot.protected = encodedProtected;
1853
+ if (inputHeader !== void 0)
1854
+ snapshot.header = header;
1855
+ return snapshot;
1856
+ }
1760
1857
  function verifyResult(jws, verified) {
1761
1858
  const [payload, parsedProt, , key, resolvedKey] = verified;
1762
1859
  const result = { payload };
@@ -1774,12 +1871,22 @@ function verifyResult(jws, verified) {
1774
1871
  function prepareVerify(options) {
1775
1872
  return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
1776
1873
  }
1777
- async function verifySignature(jws, shared, key) {
1778
- const { protected: encodedProtected, header, payload: inputPayload } = jws;
1779
- let parsedProt = {};
1780
- if (encodedProtected) {
1781
- parsedProt = parseJoseHeader(encodedProtected, JWSInvalid, "JWS Protected Header is invalid");
1874
+ function parseProtectedHeader(encodedProtected, parsedProtected = encodedProtected === void 0 ? {} : parseJoseHeader(encodedProtected, JWSInvalid, "JWS Protected Header is invalid")) {
1875
+ return parsedProtected;
1876
+ }
1877
+ function validateJwsHeaders(parsedProt, joseHeader, shared) {
1878
+ const b64 = validateB64(parsedProt, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], parsedProt, joseHeader));
1879
+ const alg = joseHeader.alg;
1880
+ if (typeof alg !== "string" || !alg) {
1881
+ throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
1882
+ }
1883
+ if (shared[0] && !shared[0].has(alg)) {
1884
+ throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
1782
1885
  }
1886
+ return [b64, alg];
1887
+ }
1888
+ function parseJwsHeaders(encodedProtected, header, shared, parsedProtected) {
1889
+ const parsedProt = parseProtectedHeader(encodedProtected, parsedProtected);
1783
1890
  let joseHeader;
1784
1891
  if (header !== void 0) {
1785
1892
  if (!isDisjoint(parsedProt, header)) {
@@ -1789,50 +1896,51 @@ async function verifySignature(jws, shared, key) {
1789
1896
  } else {
1790
1897
  joseHeader = parsedProt;
1791
1898
  }
1792
- const extensions = validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], parsedProt, joseHeader);
1793
- let b64 = true;
1794
- if (extensions.includes("b64")) {
1795
- b64 = parsedProt.b64;
1796
- if (typeof b64 !== "boolean") {
1797
- throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
1798
- }
1799
- }
1800
- const { alg } = joseHeader;
1801
- if (typeof alg !== "string" || !alg) {
1802
- throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
1803
- }
1804
- if (shared[0] && !shared[0].has(alg)) {
1805
- throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
1899
+ return [parsedProt, joseHeader, ...validateJwsHeaders(parsedProt, joseHeader, shared)];
1900
+ }
1901
+ function encodeJsonUnencodedPayload(payload) {
1902
+ const invalid2 = /[\p{Cs}\p{Cn}]/u.exec(payload)?.[0];
1903
+ if (invalid2 !== void 0) {
1904
+ throw new JWSInvalid(new RegExp("\\p{Cs}", "u").test(invalid2) ? "JWS Payload must be a well-formed Unicode string" : "JWS Payload must not contain unassigned Unicode code points");
1806
1905
  }
1807
- if (b64) {
1808
- if (typeof inputPayload !== "string") {
1809
- throw new JWSInvalid("JWS Payload must be a string");
1810
- }
1811
- } else if (typeof inputPayload !== "string" && !(inputPayload instanceof Uint8Array)) {
1812
- throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
1906
+ return encoder.encode(payload);
1907
+ }
1908
+ function encodeCompactUnencodedPayload(payload) {
1909
+ try {
1910
+ return encode(payload);
1911
+ } catch {
1912
+ throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters");
1813
1913
  }
1914
+ }
1915
+ async function verifyPrepared(jws, shared, key, encodedProtected, parsedProt, alg, signingPayload) {
1814
1916
  let resolvedKey = false;
1815
1917
  if (typeof key === "function") {
1816
1918
  key = await key(parsedProt, jws);
1817
1919
  resolvedKey = true;
1818
1920
  }
1921
+ const b64 = typeof signingPayload === "string";
1819
1922
  const entry = jwsAlgorithm(alg);
1820
- const data = concat(encodedProtected !== void 0 ? encode(encodedProtected) : new Uint8Array(), encode("."), typeof inputPayload === "string" ? b64 ? shared[2] ??= encodeBase64url(inputPayload, "payload", JWSInvalid) : encoder.encode(inputPayload) : inputPayload);
1923
+ const data = concat(encodedProtected !== void 0 ? encode(encodedProtected) : new Uint8Array(), encode("."), b64 ? shared[2] ??= encodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload);
1821
1924
  const signature = decodeBase64url(jws.signature, "signature", JWSInvalid);
1822
1925
  const k = await prepareKey(entry, key, "verify");
1823
- const verified = await verify(entry, k, signature, data);
1824
- if (!verified) {
1926
+ if (!await verify(entry, k, signature, data)) {
1825
1927
  throw new JWSSignatureVerificationFailed();
1826
1928
  }
1827
- let payload;
1929
+ const payload = b64 ? decodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload;
1930
+ return [payload, parsedProt, b64, k, resolvedKey];
1931
+ }
1932
+ async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedProtected) {
1933
+ const { protected: encodedProtected, header, payload: inputPayload } = jws;
1934
+ const [parsedProt, , b64, alg] = parseJwsHeaders(encodedProtected, header, shared, parsedProtected);
1828
1935
  if (b64) {
1829
- payload = decodeBase64url(inputPayload, "payload", JWSInvalid);
1830
- } else if (typeof inputPayload === "string") {
1831
- payload = encoder.encode(inputPayload);
1832
- } else {
1833
- payload = inputPayload;
1936
+ if (typeof inputPayload !== "string") {
1937
+ throw new JWSInvalid("JWS Payload must be a string");
1938
+ }
1939
+ } else if (typeof inputPayload !== "string" && !(inputPayload instanceof Uint8Array)) {
1940
+ throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
1834
1941
  }
1835
- return [payload, parsedProt, b64, k, resolvedKey];
1942
+ const signingPayload = b64 || typeof inputPayload !== "string" ? inputPayload : encodeUnencodedPayload(inputPayload);
1943
+ return verifyPrepared(jws, shared, key, encodedProtected, parsedProt, alg, signingPayload);
1836
1944
  }
1837
1945
  async function verifyCompact(jws, shared, key) {
1838
1946
  if (jws instanceof Uint8Array) {
@@ -1845,10 +1953,14 @@ async function verifyCompact(jws, shared, key) {
1845
1953
  if (length !== 3) {
1846
1954
  throw new JWSInvalid("Invalid Compact JWS");
1847
1955
  }
1848
- return verifySignature({ payload, protected: protectedHeader, signature }, shared, key);
1956
+ const compactJws = { payload, protected: protectedHeader, signature };
1957
+ const parsedProt = parseProtectedHeader(protectedHeader);
1958
+ const [b64, alg] = validateJwsHeaders(parsedProt, parsedProt, shared);
1959
+ const signingPayload = b64 ? payload : encodeCompactUnencodedPayload(payload);
1960
+ return verifyPrepared(compactJws, shared, key, protectedHeader, parsedProt, alg, signingPayload);
1849
1961
  }
1850
1962
 
1851
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jws/compact/verify.js
1963
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jws/compact/verify.js
1852
1964
  async function compactVerify(jws, key, options) {
1853
1965
  const verified = await verifyCompact(jws, prepareVerify(options), key);
1854
1966
  const result = { payload: verified[0], protectedHeader: verified[1] };
@@ -1858,71 +1970,93 @@ async function compactVerify(jws, key, options) {
1858
1970
  return result;
1859
1971
  }
1860
1972
 
1861
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jws/flattened/verify.js
1973
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jws/flattened/verify.js
1862
1974
  async function flattenedVerify(jws, key, options) {
1863
1975
  if (!isObject(jws)) {
1864
1976
  throw new JWSInvalid("Flattened JWS must be an object");
1865
1977
  }
1866
- if (jws.protected === void 0 && jws.header === void 0) {
1978
+ const snapshot = snapshotJws(jws);
1979
+ if (snapshot.protected === void 0 && snapshot.header === void 0) {
1867
1980
  throw new JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');
1868
1981
  }
1869
- if (jws.protected !== void 0 && typeof jws.protected !== "string") {
1982
+ if (snapshot.protected !== void 0 && typeof snapshot.protected !== "string") {
1870
1983
  throw new JWSInvalid("JWS Protected Header incorrect type");
1871
1984
  }
1872
- if (jws.payload === void 0) {
1985
+ if (snapshot.payload === void 0) {
1873
1986
  throw new JWSInvalid("JWS Payload missing");
1874
1987
  }
1875
- if (typeof jws.signature !== "string") {
1988
+ if (typeof snapshot.signature !== "string") {
1876
1989
  throw new JWSInvalid("JWS Signature missing or incorrect type");
1877
1990
  }
1878
- if (jws.header !== void 0 && !isObject(jws.header)) {
1991
+ if (snapshot.header !== void 0 && !isObject(snapshot.header)) {
1879
1992
  throw new JWSInvalid("JWS Unprotected Header incorrect type");
1880
1993
  }
1881
- return verifyResult(jws, await verifySignature(jws, prepareVerify(options), key));
1994
+ return verifyResult(snapshot, await verifySignature(snapshot, prepareVerify(options), key, encodeJsonUnencodedPayload));
1882
1995
  }
1883
1996
 
1884
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jws/general/verify.js
1997
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jws/general/verify.js
1998
+ function snapshotSignature(signature, payload) {
1999
+ try {
2000
+ const jws = snapshotJws(signature, [payload]);
2001
+ const { protected: encodedProtected, header, signature: encodedSignature } = jws;
2002
+ if (encodedProtected === void 0 && header === void 0)
2003
+ return void 0;
2004
+ if (encodedProtected !== void 0 && typeof encodedProtected !== "string")
2005
+ return void 0;
2006
+ if (typeof encodedSignature !== "string")
2007
+ return void 0;
2008
+ if (header !== void 0 && !isObject(header))
2009
+ return void 0;
2010
+ const protectedHeader = parseProtectedHeader(encodedProtected);
2011
+ const { b64, crit } = protectedHeader;
2012
+ return [
2013
+ jws,
2014
+ protectedHeader,
2015
+ Array.isArray(crit) && crit.includes("b64") ? typeof b64 === "boolean" ? b64 ? 1 : 2 : 0 : 1
2016
+ ];
2017
+ } catch {
2018
+ return void 0;
2019
+ }
2020
+ }
1885
2021
  async function generalVerify(jws, key, options) {
1886
2022
  if (!isObject(jws)) {
1887
2023
  throw new JWSInvalid("General JWS must be an object");
1888
2024
  }
1889
- const { signatures, payload } = jws;
1890
- if (!Array.isArray(signatures) || !signatures.every(isObject)) {
2025
+ const { signatures, payload: inputPayload } = jws;
2026
+ if (!Array.isArray(signatures)) {
2027
+ throw new JWSInvalid("JWS Signatures missing or incorrect type");
2028
+ }
2029
+ const signatureEntries = Array.from(signatures);
2030
+ if (!signatureEntries.every(isObject)) {
1891
2031
  throw new JWSInvalid("JWS Signatures missing or incorrect type");
1892
2032
  }
1893
2033
  let shared;
1894
2034
  try {
1895
- if (payload === void 0)
2035
+ if (inputPayload === void 0)
1896
2036
  throw new Error();
1897
2037
  shared = prepareVerify(options);
1898
2038
  } catch {
1899
2039
  throw new JWSSignatureVerificationFailed();
1900
2040
  }
1901
- for (const signature of signatures) {
2041
+ const payload = inputPayload instanceof Uint8Array ? new Uint8Array(inputPayload) : inputPayload;
2042
+ const candidates = signatureEntries.map((signature) => snapshotSignature(signature, payload)).filter((candidate) => candidate !== void 0);
2043
+ let modes = 0;
2044
+ for (const [, , mode] of candidates) {
2045
+ modes |= mode;
2046
+ if (modes === 3) {
2047
+ throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
2048
+ }
2049
+ }
2050
+ for (const candidate of candidates) {
1902
2051
  try {
1903
- const { protected: encodedProtected, header, signature: encodedSignature } = signature;
1904
- if (encodedProtected === void 0 && header === void 0)
1905
- throw new Error();
1906
- if (encodedProtected !== void 0 && typeof encodedProtected !== "string") {
1907
- throw new Error();
1908
- }
1909
- if (typeof encodedSignature !== "string")
1910
- throw new Error();
1911
- if (header !== void 0 && !isObject(header))
1912
- throw new Error();
1913
- return verifyResult(signature, await verifySignature({
1914
- header,
1915
- payload,
1916
- protected: encodedProtected,
1917
- signature: encodedSignature
1918
- }, shared, key));
2052
+ return verifyResult(candidate[0], await verifySignature(candidate[0], shared, key, encodeJsonUnencodedPayload, candidate[1]));
1919
2053
  } catch {
1920
2054
  }
1921
2055
  }
1922
2056
  throw new JWSSignatureVerificationFailed();
1923
2057
  }
1924
2058
 
1925
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
2059
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
1926
2060
  var epoch = (date) => Math.floor(date.getTime() / 1e3);
1927
2061
  var multipliers = {
1928
2062
  s: 1,
@@ -1934,13 +2068,22 @@ var multipliers = {
1934
2068
  };
1935
2069
  var REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
1936
2070
  var checkFailed = "check_failed";
2071
+ function invalidDuration() {
2072
+ throw new TypeError("Invalid time period format");
2073
+ }
1937
2074
  function secs(str) {
2075
+ if (typeof str !== "string") {
2076
+ invalidDuration();
2077
+ }
1938
2078
  const matched = REGEX.exec(str);
1939
2079
  if (!matched || matched[4] && matched[1]) {
1940
- throw new TypeError("Invalid time period format");
2080
+ invalidDuration();
1941
2081
  }
1942
2082
  const value = parseFloat(matched[2]);
1943
2083
  const numericDate2 = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
2084
+ if (!Number.isFinite(numericDate2)) {
2085
+ invalidDuration();
2086
+ }
1944
2087
  if (matched[1] === "-" || matched[4] === "ago") {
1945
2088
  return -numericDate2;
1946
2089
  }
@@ -1952,6 +2095,16 @@ function validateInput(label, input) {
1952
2095
  }
1953
2096
  return input;
1954
2097
  }
2098
+ function validateStringClaim(claim, value) {
2099
+ if (typeof value !== "string") {
2100
+ throw new TypeError(`"${claim}" claim must be a string`);
2101
+ }
2102
+ }
2103
+ function validateAudienceClaim(value) {
2104
+ if (typeof value !== "string" && (!Array.isArray(value) || Array.from(value).some((member) => typeof member !== "string"))) {
2105
+ throw new TypeError('"aud" claim must be a string or an array of strings');
2106
+ }
2107
+ }
1955
2108
  function numericDate(value, label) {
1956
2109
  if (typeof value === "number")
1957
2110
  return validateInput(label, value);
@@ -1960,10 +2113,8 @@ function numericDate(value, label) {
1960
2113
  return epoch(/* @__PURE__ */ new Date()) + secs(value);
1961
2114
  }
1962
2115
  var normalizeTyp = (value) => {
1963
- if (value.includes("/")) {
1964
- return value.toLowerCase();
1965
- }
1966
- return `application/${value.toLowerCase()}`;
2116
+ const normalized = value.toLowerCase();
2117
+ return value.includes("/") ? normalized : `application/${normalized}`;
1967
2118
  };
1968
2119
  var checkAudiencePresence = (audPayload, audOption) => {
1969
2120
  if (typeof audPayload === "string") {
@@ -1996,7 +2147,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
1996
2147
  throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
1997
2148
  }
1998
2149
  const { typ } = options;
1999
- if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
2150
+ if (typ !== void 0 && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
2000
2151
  throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', payload, "typ", checkFailed);
2001
2152
  }
2002
2153
  const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
@@ -2035,7 +2186,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
2035
2186
  }
2036
2187
  validateInput("clockTolerance option", tolerance);
2037
2188
  const { currentDate } = options;
2038
- const now = validateInput("currentDate option", epoch(currentDate || /* @__PURE__ */ new Date()));
2189
+ const now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate));
2039
2190
  const iat = validateNumericDate(payload, "iat", maxTokenAge !== void 0);
2040
2191
  const nbf = validateNumericDate(payload, "nbf");
2041
2192
  if (nbf !== void 0) {
@@ -2051,66 +2202,83 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
2051
2202
  }
2052
2203
  if (maxTokenAge !== void 0) {
2053
2204
  const age = now - iat;
2054
- const max = typeof maxTokenAge === "number" ? maxTokenAge : secs(maxTokenAge);
2205
+ const max = validateInput("maxTokenAge option", typeof maxTokenAge === "number" ? maxTokenAge : secs(maxTokenAge));
2055
2206
  if (age - tolerance > max) {
2056
2207
  throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', payload, "iat", checkFailed);
2057
2208
  }
2058
- if (age < 0 - tolerance) {
2209
+ if (age < -tolerance) {
2059
2210
  throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', payload, "iat", checkFailed);
2060
2211
  }
2061
2212
  }
2062
2213
  return payload;
2063
2214
  }
2215
+ var producerPayloads;
2216
+ function producerPayload(producer) {
2217
+ return producerPayloads.get(producer);
2218
+ }
2219
+ function jwtData(producer) {
2220
+ const payload = producerPayload(producer);
2221
+ for (const claim of ["iat", "nbf", "exp"]) {
2222
+ const value = payload[claim];
2223
+ if (typeof value === "number" && !Number.isFinite(value)) {
2224
+ throw new TypeError(`"${claim}" claim must be a finite number`);
2225
+ }
2226
+ }
2227
+ return encoder.encode(JSON.stringify(payload));
2228
+ }
2229
+ function jwtClaim(producer, claim) {
2230
+ return producerPayload(producer)[claim];
2231
+ }
2064
2232
  var JWTClaimsBuilder = class {
2065
- #payload;
2066
- constructor(payload) {
2233
+ constructor(payload = {}) {
2067
2234
  if (!isObject(payload)) {
2068
2235
  throw new TypeError("JWT Claims Set MUST be an object");
2069
2236
  }
2070
- this.#payload = structuredClone(payload);
2071
- }
2072
- data() {
2073
- return encoder.encode(JSON.stringify(this.#payload));
2074
- }
2075
- get iss() {
2076
- return this.#payload.iss;
2077
- }
2078
- set iss(value) {
2079
- this.#payload.iss = value;
2080
- }
2081
- get sub() {
2082
- return this.#payload.sub;
2237
+ ;
2238
+ (producerPayloads ||= /* @__PURE__ */ new WeakMap()).set(this, structuredClone(payload));
2083
2239
  }
2084
- set sub(value) {
2085
- this.#payload.sub = value;
2240
+ setIssuer(value) {
2241
+ validateStringClaim("iss", value);
2242
+ producerPayload(this).iss = value;
2243
+ return this;
2086
2244
  }
2087
- get aud() {
2088
- return this.#payload.aud;
2245
+ setSubject(value) {
2246
+ validateStringClaim("sub", value);
2247
+ producerPayload(this).sub = value;
2248
+ return this;
2089
2249
  }
2090
- set aud(value) {
2091
- this.#payload.aud = value;
2250
+ setAudience(value) {
2251
+ validateAudienceClaim(value);
2252
+ producerPayload(this).aud = value;
2253
+ return this;
2092
2254
  }
2093
- set jti(value) {
2094
- this.#payload.jti = value;
2255
+ setJti(value) {
2256
+ validateStringClaim("jti", value);
2257
+ producerPayload(this).jti = value;
2258
+ return this;
2095
2259
  }
2096
- set nbf(value) {
2097
- this.#payload.nbf = numericDate(value, "setNotBefore");
2260
+ setNotBefore(value) {
2261
+ producerPayload(this).nbf = numericDate(value, "setNotBefore");
2262
+ return this;
2098
2263
  }
2099
- set exp(value) {
2100
- this.#payload.exp = numericDate(value, "setExpirationTime");
2264
+ setExpirationTime(value) {
2265
+ producerPayload(this).exp = numericDate(value, "setExpirationTime");
2266
+ return this;
2101
2267
  }
2102
- set iat(value) {
2268
+ setIssuedAt(value) {
2269
+ const payload = producerPayload(this);
2103
2270
  if (value === void 0) {
2104
- this.#payload.iat = epoch(/* @__PURE__ */ new Date());
2271
+ payload.iat = epoch(/* @__PURE__ */ new Date());
2105
2272
  } else if (typeof value === "string") {
2106
- this.#payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value));
2273
+ payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value));
2107
2274
  } else {
2108
- this.#payload.iat = numericDate(value, "setIssuedAt");
2275
+ payload.iat = numericDate(value, "setIssuedAt");
2109
2276
  }
2277
+ return this;
2110
2278
  }
2111
2279
  };
2112
2280
 
2113
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwt/verify.js
2281
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwt/verify.js
2114
2282
  async function jwtVerify(jwt, key, options) {
2115
2283
  const verified = await verifyCompact(jwt, prepareVerify(options), key);
2116
2284
  if (!verified[2]) {
@@ -2124,19 +2292,15 @@ async function jwtVerify(jwt, key, options) {
2124
2292
  return result;
2125
2293
  }
2126
2294
 
2127
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwt/decrypt.js
2295
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwt/decrypt.js
2128
2296
  async function jwtDecrypt(jwt, key, options) {
2129
2297
  const decrypted = await decryptCompact(jwt, prepareDecrypt(options), key);
2130
2298
  const protectedHeader = decrypted[1];
2131
2299
  const payload = validateClaimsSet(protectedHeader, decrypted[0], options);
2132
- if (protectedHeader.iss !== void 0 && protectedHeader.iss !== payload.iss) {
2133
- throw new JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch', payload, "iss", "mismatch");
2134
- }
2135
- if (protectedHeader.sub !== void 0 && protectedHeader.sub !== payload.sub) {
2136
- throw new JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch', payload, "sub", "mismatch");
2137
- }
2138
- if (protectedHeader.aud !== void 0 && JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)) {
2139
- throw new JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch', payload, "aud", "mismatch");
2300
+ for (const claim of ["iss", "sub", "aud"]) {
2301
+ if (protectedHeader[claim] !== void 0 && (claim === "aud" ? JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud) : protectedHeader[claim] !== payload[claim])) {
2302
+ throw new JWTClaimValidationFailed(`replicated "${claim}" claim header parameter mismatch`, payload, claim, "mismatch");
2303
+ }
2140
2304
  }
2141
2305
  const result = { payload, protectedHeader };
2142
2306
  if (typeof key === "function") {
@@ -2145,40 +2309,148 @@ async function jwtDecrypt(jwt, key, options) {
2145
2309
  return result;
2146
2310
  }
2147
2311
 
2148
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwe/compact/encrypt.js
2312
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwe/compact/encrypt.js
2149
2313
  var CompactEncrypt = class {
2150
- #flattened;
2151
- constructor(plaintext) {
2152
- this.#flattened = new FlattenedEncrypt(plaintext);
2153
- }
2154
- setContentEncryptionKey(cek) {
2155
- this.#flattened.setContentEncryptionKey(cek);
2156
- return this;
2314
+ #plaintext;
2315
+ #protectedHeader;
2316
+ #cek;
2317
+ #iv;
2318
+ #keyManagementParameters;
2319
+ constructor(plaintext) {
2320
+ assertUint8Array(plaintext, "plaintext");
2321
+ this.#plaintext = plaintext;
2322
+ }
2323
+ setContentEncryptionKey(cek) {
2324
+ assertNotSet(this.#cek, "setContentEncryptionKey");
2325
+ this.#cek = cek;
2326
+ return this;
2157
2327
  }
2158
2328
  setInitializationVector(iv) {
2159
- this.#flattened.setInitializationVector(iv);
2329
+ assertNotSet(this.#iv, "setInitializationVector");
2330
+ this.#iv = iv;
2160
2331
  return this;
2161
2332
  }
2162
2333
  setProtectedHeader(protectedHeader) {
2163
- this.#flattened.setProtectedHeader(protectedHeader);
2334
+ assertNotSet(this.#protectedHeader, "setProtectedHeader");
2335
+ this.#protectedHeader = protectedHeader;
2164
2336
  return this;
2165
2337
  }
2166
2338
  setKeyManagementParameters(parameters) {
2167
- this.#flattened.setKeyManagementParameters(parameters);
2339
+ assertNotSet(this.#keyManagementParameters, "setKeyManagementParameters");
2340
+ this.#keyManagementParameters = parameters;
2168
2341
  return this;
2169
2342
  }
2170
2343
  async encrypt(key, options) {
2171
- const jwe = await this.#flattened.encrypt(key, options);
2344
+ const jwe = await createJWE([
2345
+ this.#plaintext,
2346
+ this.#protectedHeader,
2347
+ void 0,
2348
+ void 0,
2349
+ void 0,
2350
+ this.#cek,
2351
+ this.#iv,
2352
+ this.#keyManagementParameters,
2353
+ void 0,
2354
+ false
2355
+ ], key, options);
2172
2356
  return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join(".");
2173
2357
  }
2174
2358
  };
2175
2359
 
2176
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/jws_sign.js
2177
- function unencodedPayload(protectedHeader) {
2178
- return protectedHeader?.b64 === false && Array.isArray(protectedHeader.crit) && protectedHeader.crit.includes("b64");
2360
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
2361
+ var FlattenedEncrypt = class {
2362
+ #plaintext;
2363
+ #protectedHeader;
2364
+ #sharedUnprotectedHeader;
2365
+ #unprotectedHeader;
2366
+ #aad;
2367
+ #cek;
2368
+ #iv;
2369
+ #keyManagementParameters;
2370
+ constructor(plaintext) {
2371
+ assertUint8Array(plaintext, "plaintext");
2372
+ this.#plaintext = plaintext;
2373
+ }
2374
+ setKeyManagementParameters(parameters) {
2375
+ assertNotSet(this.#keyManagementParameters, "setKeyManagementParameters");
2376
+ this.#keyManagementParameters = parameters;
2377
+ return this;
2378
+ }
2379
+ setProtectedHeader(protectedHeader) {
2380
+ assertNotSet(this.#protectedHeader, "setProtectedHeader");
2381
+ this.#protectedHeader = protectedHeader;
2382
+ return this;
2383
+ }
2384
+ setSharedUnprotectedHeader(sharedUnprotectedHeader) {
2385
+ assertNotSet(this.#sharedUnprotectedHeader, "setSharedUnprotectedHeader");
2386
+ this.#sharedUnprotectedHeader = sharedUnprotectedHeader;
2387
+ return this;
2388
+ }
2389
+ setUnprotectedHeader(unprotectedHeader) {
2390
+ assertNotSet(this.#unprotectedHeader, "setUnprotectedHeader");
2391
+ this.#unprotectedHeader = unprotectedHeader;
2392
+ return this;
2393
+ }
2394
+ setAdditionalAuthenticatedData(aad) {
2395
+ this.#aad = aad;
2396
+ return this;
2397
+ }
2398
+ setContentEncryptionKey(cek) {
2399
+ assertNotSet(this.#cek, "setContentEncryptionKey");
2400
+ this.#cek = cek;
2401
+ return this;
2402
+ }
2403
+ setInitializationVector(iv) {
2404
+ assertNotSet(this.#iv, "setInitializationVector");
2405
+ this.#iv = iv;
2406
+ return this;
2407
+ }
2408
+ async encrypt(key, options) {
2409
+ return createJWE([
2410
+ this.#plaintext,
2411
+ this.#protectedHeader,
2412
+ this.#unprotectedHeader,
2413
+ this.#sharedUnprotectedHeader,
2414
+ this.#aad,
2415
+ this.#cek,
2416
+ this.#iv,
2417
+ this.#keyManagementParameters,
2418
+ void 0,
2419
+ false
2420
+ ], key, options);
2421
+ }
2422
+ };
2423
+
2424
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/jws_sign.js
2425
+ function serializeProtectedHeader(protectedHeader) {
2426
+ if (protectedHeader === void 0)
2427
+ return [void 0, ""];
2428
+ const normalized = serializeJoseHeader(JWSInvalid, protectedHeader);
2429
+ return [normalized[0], encode2(normalized[1])];
2430
+ }
2431
+ function validateSignatureHeader(protectedHeader, joseHeader, crit) {
2432
+ validateCritDuplicates(JWSInvalid, protectedHeader);
2433
+ return validateB64(protectedHeader, validateCrit(JWSInvalid, JWS_RECOGNIZED, crit, protectedHeader, joseHeader));
2434
+ }
2435
+ function signatureAlgorithm(joseHeader) {
2436
+ const alg = joseHeader.alg;
2437
+ if (typeof alg !== "string" || !alg) {
2438
+ throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
2439
+ }
2440
+ return jwsAlgorithm(alg);
2441
+ }
2442
+ async function signSignature(protectedHeader, payload, entry, key) {
2443
+ const data = concat(encode(protectedHeader), encode("."), payload);
2444
+ const k = await prepareKey(entry, key, "sign");
2445
+ return encode2(await sign(entry, k, data));
2179
2446
  }
2180
- async function createSignature(input, key) {
2181
- const { protectedHeader, unprotectedHeader } = input;
2447
+ async function createSignature(input, key, assertB64) {
2448
+ let { protectedHeader, unprotectedHeader } = input;
2449
+ let protectedHeaderString;
2450
+ [protectedHeader, protectedHeaderString] = serializeProtectedHeader(protectedHeader);
2451
+ if (unprotectedHeader !== void 0) {
2452
+ unprotectedHeader = serializeJoseHeader(JWSInvalid, unprotectedHeader)[0];
2453
+ }
2182
2454
  if (!protectedHeader && !unprotectedHeader) {
2183
2455
  throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
2184
2456
  }
@@ -2186,20 +2458,9 @@ async function createSignature(input, key) {
2186
2458
  throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
2187
2459
  }
2188
2460
  const joseHeader = { ...protectedHeader, ...unprotectedHeader };
2189
- validateCritDuplicates(JWSInvalid, protectedHeader);
2190
- const extensions = validateCrit(JWSInvalid, JWS_RECOGNIZED, input.crit, protectedHeader, joseHeader);
2191
- let b64 = true;
2192
- if (extensions.includes("b64")) {
2193
- b64 = protectedHeader.b64;
2194
- if (typeof b64 !== "boolean") {
2195
- throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
2196
- }
2197
- }
2198
- const { alg } = joseHeader;
2199
- if (typeof alg !== "string" || !alg) {
2200
- throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
2201
- }
2202
- const entry = jwsAlgorithm(alg);
2461
+ const b64 = validateSignatureHeader(protectedHeader, joseHeader, input.crit);
2462
+ assertB64?.(b64);
2463
+ const entry = signatureAlgorithm(joseHeader);
2203
2464
  let payloadS;
2204
2465
  let payloadB;
2205
2466
  if (b64) {
@@ -2212,20 +2473,8 @@ async function createSignature(input, key) {
2212
2473
  payloadB = input.payload;
2213
2474
  payloadS = "";
2214
2475
  }
2215
- let protectedHeaderString;
2216
- let protectedHeaderBytes;
2217
- if (protectedHeader) {
2218
- protectedHeaderString = encode2(JSON.stringify(protectedHeader));
2219
- protectedHeaderBytes = encode(protectedHeaderString);
2220
- } else {
2221
- protectedHeaderString = "";
2222
- protectedHeaderBytes = new Uint8Array();
2223
- }
2224
- const data = concat(protectedHeaderBytes, encode("."), payloadB);
2225
- const k = await prepareKey(entry, key, "sign");
2226
- const signature = await sign(entry, k, data);
2227
2476
  const jws = {
2228
- signature: encode2(signature),
2477
+ signature: await signSignature(protectedHeaderString, payloadB, entry, key),
2229
2478
  payload: payloadS
2230
2479
  };
2231
2480
  if (protectedHeader) {
@@ -2234,10 +2483,45 @@ async function createSignature(input, key) {
2234
2483
  if (unprotectedHeader) {
2235
2484
  jws.header = unprotectedHeader;
2236
2485
  }
2237
- return jws;
2486
+ return [jws, b64];
2487
+ }
2488
+ async function createCompactSignature(payload, inputProtectedHeader, inputCrit, key, rejectUnencoded) {
2489
+ const [protectedHeader, protectedHeaderString] = serializeProtectedHeader(inputProtectedHeader);
2490
+ if (!protectedHeader) {
2491
+ throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
2492
+ }
2493
+ const b64 = validateSignatureHeader(protectedHeader, protectedHeader, inputCrit);
2494
+ if (!b64)
2495
+ rejectUnencoded();
2496
+ const entry = signatureAlgorithm(protectedHeader);
2497
+ const encodedPayload = encode2(payload);
2498
+ const signature = await signSignature(protectedHeaderString, encode(encodedPayload), entry, key);
2499
+ return `${protectedHeaderString}.${encodedPayload}.${signature}`;
2238
2500
  }
2239
2501
 
2240
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jws/flattened/sign.js
2502
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jws/compact/sign.js
2503
+ var CompactSign = class {
2504
+ #payload;
2505
+ #protectedHeader;
2506
+ constructor(payload) {
2507
+ if (!(payload instanceof Uint8Array)) {
2508
+ throw new TypeError("payload must be an instance of Uint8Array");
2509
+ }
2510
+ this.#payload = payload;
2511
+ }
2512
+ setProtectedHeader(protectedHeader) {
2513
+ assertNotSet(this.#protectedHeader, "setProtectedHeader");
2514
+ this.#protectedHeader = protectedHeader;
2515
+ return this;
2516
+ }
2517
+ async sign(key, options) {
2518
+ return createCompactSignature(this.#payload, this.#protectedHeader, options?.crit, key, () => {
2519
+ throw new TypeError("use the flattened module for creating JWS with b64: false");
2520
+ });
2521
+ }
2522
+ };
2523
+
2524
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jws/flattened/sign.js
2241
2525
  var FlattenedSign = class {
2242
2526
  #payload;
2243
2527
  #protectedHeader;
@@ -2259,37 +2543,17 @@ var FlattenedSign = class {
2259
2543
  return this;
2260
2544
  }
2261
2545
  async sign(key, options) {
2262
- return createSignature({
2546
+ const [jws] = await createSignature({
2263
2547
  payload: this.#payload,
2264
2548
  protectedHeader: this.#protectedHeader,
2265
2549
  unprotectedHeader: this.#unprotectedHeader,
2266
2550
  crit: options?.crit
2267
2551
  }, key);
2552
+ return jws;
2268
2553
  }
2269
2554
  };
2270
2555
 
2271
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jws/compact/sign.js
2272
- var CompactSign = class {
2273
- #flattened;
2274
- #protectedHeader;
2275
- constructor(payload) {
2276
- this.#flattened = new FlattenedSign(payload);
2277
- }
2278
- setProtectedHeader(protectedHeader) {
2279
- this.#flattened.setProtectedHeader(protectedHeader);
2280
- this.#protectedHeader = protectedHeader;
2281
- return this;
2282
- }
2283
- async sign(key, options) {
2284
- if (unencodedPayload(this.#protectedHeader)) {
2285
- throw new TypeError("use the flattened module for creating JWS with b64: false");
2286
- }
2287
- const jws = await this.#flattened.sign(key, options);
2288
- return `${jws.protected}.${jws.payload}.${jws.signature}`;
2289
- }
2290
- };
2291
-
2292
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jws/general/sign.js
2556
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jws/general/sign.js
2293
2557
  var IndividualSignature = class {
2294
2558
  #parent;
2295
2559
  state;
@@ -2340,19 +2604,21 @@ var GeneralSign = class {
2340
2604
  payload: ""
2341
2605
  };
2342
2606
  const encoded = [];
2607
+ let b64;
2343
2608
  for (let i = 0; i < this.#signatures.length; i++) {
2344
2609
  const signature = this.#signatures[i];
2345
2610
  const [protectedHeader, unprotectedHeader, key, crit] = signature.state;
2346
- const { payload, ...rest } = await createSignature({
2611
+ const [{ payload, ...rest }, signatureB64] = await createSignature({
2347
2612
  payload: this.#payload,
2348
2613
  protectedHeader,
2349
2614
  unprotectedHeader,
2350
2615
  crit,
2351
2616
  encoded
2352
2617
  }, key);
2353
- if (i === 0) {
2618
+ if (b64 === void 0) {
2619
+ b64 = signatureB64;
2354
2620
  jws.payload = payload;
2355
- } else if (jws.payload !== payload) {
2621
+ } else if (b64 !== signatureB64) {
2356
2622
  throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
2357
2623
  }
2358
2624
  jws.signatures.push(rest);
@@ -2361,57 +2627,25 @@ var GeneralSign = class {
2361
2627
  }
2362
2628
  };
2363
2629
 
2364
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwt/sign.js
2365
- var SignJWT = class {
2630
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwt/sign.js
2631
+ var SignJWT_base = JWTClaimsBuilder;
2632
+ var SignJWT = class extends SignJWT_base {
2366
2633
  #protectedHeader;
2367
- #jwt;
2368
- constructor(payload = {}) {
2369
- this.#jwt = new JWTClaimsBuilder(payload);
2370
- }
2371
- setIssuer(issuer) {
2372
- this.#jwt.iss = issuer;
2373
- return this;
2374
- }
2375
- setSubject(subject) {
2376
- this.#jwt.sub = subject;
2377
- return this;
2378
- }
2379
- setAudience(audience) {
2380
- this.#jwt.aud = audience;
2381
- return this;
2382
- }
2383
- setJti(jwtId) {
2384
- this.#jwt.jti = jwtId;
2385
- return this;
2386
- }
2387
- setNotBefore(input) {
2388
- this.#jwt.nbf = input;
2389
- return this;
2390
- }
2391
- setExpirationTime(input) {
2392
- this.#jwt.exp = input;
2393
- return this;
2394
- }
2395
- setIssuedAt(input) {
2396
- this.#jwt.iat = input;
2397
- return this;
2398
- }
2399
2634
  setProtectedHeader(protectedHeader) {
2635
+ assertNotSet(this.#protectedHeader, "setProtectedHeader");
2400
2636
  this.#protectedHeader = protectedHeader;
2401
2637
  return this;
2402
2638
  }
2403
2639
  async sign(key, options) {
2404
- const sig2 = new CompactSign(this.#jwt.data());
2405
- sig2.setProtectedHeader(this.#protectedHeader);
2406
- if (unencodedPayload(this.#protectedHeader)) {
2640
+ return createCompactSignature(jwtData(this), this.#protectedHeader, options?.crit, key, () => {
2407
2641
  throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
2408
- }
2409
- return sig2.sign(key, options);
2642
+ });
2410
2643
  }
2411
2644
  };
2412
2645
 
2413
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwt/encrypt.js
2414
- var EncryptJWT = class {
2646
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwt/encrypt.js
2647
+ var EncryptJWT_base = JWTClaimsBuilder;
2648
+ var EncryptJWT = class extends EncryptJWT_base {
2415
2649
  #cek;
2416
2650
  #iv;
2417
2651
  #keyManagementParameters;
@@ -2419,38 +2653,6 @@ var EncryptJWT = class {
2419
2653
  #replicateIssuerAsHeader;
2420
2654
  #replicateSubjectAsHeader;
2421
2655
  #replicateAudienceAsHeader;
2422
- #jwt;
2423
- constructor(payload = {}) {
2424
- this.#jwt = new JWTClaimsBuilder(payload);
2425
- }
2426
- setIssuer(issuer) {
2427
- this.#jwt.iss = issuer;
2428
- return this;
2429
- }
2430
- setSubject(subject) {
2431
- this.#jwt.sub = subject;
2432
- return this;
2433
- }
2434
- setAudience(audience) {
2435
- this.#jwt.aud = audience;
2436
- return this;
2437
- }
2438
- setJti(jwtId) {
2439
- this.#jwt.jti = jwtId;
2440
- return this;
2441
- }
2442
- setNotBefore(input) {
2443
- this.#jwt.nbf = input;
2444
- return this;
2445
- }
2446
- setExpirationTime(input) {
2447
- this.#jwt.exp = input;
2448
- return this;
2449
- }
2450
- setIssuedAt(input) {
2451
- this.#jwt.iat = input;
2452
- return this;
2453
- }
2454
2656
  setProtectedHeader(protectedHeader) {
2455
2657
  assertNotSet(this.#protectedHeader, "setProtectedHeader");
2456
2658
  this.#protectedHeader = protectedHeader;
@@ -2484,30 +2686,32 @@ var EncryptJWT = class {
2484
2686
  return this;
2485
2687
  }
2486
2688
  async encrypt(key, options) {
2487
- const enc = new CompactEncrypt(this.#jwt.data());
2689
+ const plaintext = jwtData(this);
2488
2690
  if (this.#protectedHeader && (this.#replicateIssuerAsHeader || this.#replicateSubjectAsHeader || this.#replicateAudienceAsHeader)) {
2489
2691
  this.#protectedHeader = {
2490
2692
  ...this.#protectedHeader,
2491
- iss: this.#replicateIssuerAsHeader ? this.#jwt.iss : void 0,
2492
- sub: this.#replicateSubjectAsHeader ? this.#jwt.sub : void 0,
2493
- aud: this.#replicateAudienceAsHeader ? this.#jwt.aud : void 0
2693
+ iss: this.#replicateIssuerAsHeader ? jwtClaim(this, "iss") : void 0,
2694
+ sub: this.#replicateSubjectAsHeader ? jwtClaim(this, "sub") : void 0,
2695
+ aud: this.#replicateAudienceAsHeader ? jwtClaim(this, "aud") : void 0
2494
2696
  };
2495
2697
  }
2496
- enc.setProtectedHeader(this.#protectedHeader);
2497
- if (this.#iv) {
2498
- enc.setInitializationVector(this.#iv);
2499
- }
2500
- if (this.#cek) {
2501
- enc.setContentEncryptionKey(this.#cek);
2502
- }
2503
- if (this.#keyManagementParameters) {
2504
- enc.setKeyManagementParameters(this.#keyManagementParameters);
2505
- }
2506
- return enc.encrypt(key, options);
2698
+ const jwe = await createJWE([
2699
+ plaintext,
2700
+ this.#protectedHeader,
2701
+ void 0,
2702
+ void 0,
2703
+ void 0,
2704
+ this.#cek,
2705
+ this.#iv,
2706
+ this.#keyManagementParameters,
2707
+ void 0,
2708
+ false
2709
+ ], key, options);
2710
+ return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join(".");
2507
2711
  }
2508
2712
  };
2509
2713
 
2510
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/key_algorithm.js
2714
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/key_algorithm.js
2511
2715
  var algArgument = '"alg" (Algorithm)';
2512
2716
  function unsupportedAlg(source = 'JWK "alg" (Algorithm) Parameter') {
2513
2717
  throw new JOSENotSupported(`Invalid or unsupported ${source} value`);
@@ -2516,7 +2720,15 @@ function keyAlgorithm(alg, source) {
2516
2720
  return (typeof alg === "string" ? JWS[alg] ?? JWE[alg] : void 0) ?? unsupportedAlg(source);
2517
2721
  }
2518
2722
 
2519
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/lib/asn1.js
2723
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/key_options.js
2724
+ function validateExtractableOption(extractable) {
2725
+ if (extractable !== void 0 && typeof extractable !== "boolean") {
2726
+ throw new TypeError('"extractable" option must be a boolean');
2727
+ }
2728
+ return extractable;
2729
+ }
2730
+
2731
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/lib/asn1.js
2520
2732
  var formatPEM = (b64, descriptor) => {
2521
2733
  const newlined = (b64.match(/.{1,64}/g) || []).join("\n");
2522
2734
  return `-----BEGIN ${descriptor}-----
@@ -2628,6 +2840,7 @@ var parseECAlgorithmIdentifier = (state) => {
2628
2840
  throw new Error("Unsupported named curve");
2629
2841
  };
2630
2842
  var genericImport = async (keyFormat, keyData, alg, options) => {
2843
+ const extractable = validateExtractableOption(options?.extractable);
2631
2844
  const entry = keyAlgorithm(alg, algArgument);
2632
2845
  if (entry.secret) {
2633
2846
  unsupportedAlg(algArgument);
@@ -2645,7 +2858,7 @@ var genericImport = async (keyFormat, keyData, alg, options) => {
2645
2858
  } else {
2646
2859
  algorithm = entry.subtle;
2647
2860
  }
2648
- return crypto.subtle.importKey(keyFormat, keyData, algorithm, options?.extractable ?? isPublic, entry.usages[isPublic ? 0 : 1]);
2861
+ return crypto.subtle.importKey(keyFormat, keyData, algorithm, extractable ?? isPublic, entry.usages[isPublic ? 0 : 1]);
2649
2862
  };
2650
2863
  var processPEMData = (pem, pattern) => {
2651
2864
  return decodeBase64(pem.replace(pattern, ""));
@@ -2661,7 +2874,10 @@ var fromSPKI = (pem, alg, options) => {
2661
2874
  function spkiFromX509(buf) {
2662
2875
  const state = createASN1State(buf);
2663
2876
  expectTag(state, 48, "Invalid certificate structure");
2664
- parseLength(state);
2877
+ const certificateLength = parseLength(state);
2878
+ if (certificateLength < 0 || state.pos + certificateLength > state.data.length) {
2879
+ throw new Error("Unexpected end of ASN.1 input");
2880
+ }
2665
2881
  expectTag(state, 48, "Invalid tbsCertificate structure");
2666
2882
  parseLength(state);
2667
2883
  if (buf[state.pos] === 160) {
@@ -2685,7 +2901,7 @@ var fromX509 = (pem, alg, options) => {
2685
2901
  return genericImport("spki", spki, alg, options);
2686
2902
  };
2687
2903
 
2688
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/key/export.js
2904
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/key/export.js
2689
2905
  function omitUndefinedProperties(jwk) {
2690
2906
  return Object.fromEntries(Object.entries(jwk).filter(([, value]) => value !== void 0));
2691
2907
  }
@@ -2726,7 +2942,7 @@ function exportJWK(key) {
2726
2942
  return keyToJWK(key);
2727
2943
  }
2728
2944
 
2729
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwk/thumbprint.js
2945
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwk/thumbprint.js
2730
2946
  var check = (value, description) => {
2731
2947
  if (typeof value !== "string" || !value) {
2732
2948
  throw new JWKInvalid(`${description} missing or invalid`);
@@ -2734,10 +2950,13 @@ var check = (value, description) => {
2734
2950
  };
2735
2951
  async function calculateJwkThumbprint(key, digestAlgorithm) {
2736
2952
  let jwk;
2737
- if (isJWK(key)) {
2738
- jwk = key;
2953
+ if (isObject(key)) {
2954
+ jwk = snapshotJwk(key);
2955
+ if (typeof jwk.kty !== "string") {
2956
+ throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
2957
+ }
2739
2958
  } else if (isKeyLike(key)) {
2740
- jwk = await exportJWK(key);
2959
+ jwk = snapshotJwk(await exportJWK(key));
2741
2960
  } else {
2742
2961
  throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
2743
2962
  }
@@ -2769,7 +2988,9 @@ async function calculateJwkThumbprint(key, digestAlgorithm) {
2769
2988
  components = { e: jwk.e, kty: jwk.kty, n: jwk.n };
2770
2989
  break;
2771
2990
  case "oct":
2772
- check(jwk.k, '"k" (Key Value) Parameter');
2991
+ if (typeof jwk.k !== "string") {
2992
+ throw new JWKInvalid('"k" (Key Value) Parameter missing or invalid');
2993
+ }
2773
2994
  components = { k: jwk.k, kty: jwk.kty };
2774
2995
  break;
2775
2996
  default:
@@ -2784,7 +3005,7 @@ async function calculateJwkThumbprintUri(key, digestAlgorithm) {
2784
3005
  return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
2785
3006
  }
2786
3007
 
2787
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwk/embedded.js
3008
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwk/embedded.js
2788
3009
  async function EmbeddedJWK(protectedHeader, token) {
2789
3010
  const joseHeader = {
2790
3011
  ...protectedHeader,
@@ -2793,93 +3014,92 @@ async function EmbeddedJWK(protectedHeader, token) {
2793
3014
  if (!isObject(joseHeader.jwk)) {
2794
3015
  throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
2795
3016
  }
3017
+ let jwk;
3018
+ try {
3019
+ jwk = normalizeJwk(joseHeader.jwk);
3020
+ } catch (cause) {
3021
+ throw new JWSInvalid("Invalid Embedded JWK", { cause });
3022
+ }
2796
3023
  const entry = jwsAlgorithm(joseHeader.alg);
2797
- const key = await jwkToKey(entry, { ...joseHeader.jwk, ext: true });
3024
+ if (jwk.use !== void 0 && jwk.use !== "sig") {
3025
+ throw new JWSInvalid('Invalid Embedded JWK, its "use" must be "sig" when present');
3026
+ }
3027
+ if (jwk.alg !== void 0 && jwk.alg !== entry.alg) {
3028
+ throw new JWSInvalid(`Invalid Embedded JWK, its "alg" must be "${entry.alg}" when present`);
3029
+ }
3030
+ const key = await jwkToKey(entry, { ...jwk, ext: true });
2798
3031
  if (key.type !== "public") {
2799
3032
  throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');
2800
3033
  }
2801
3034
  return key;
2802
3035
  }
2803
3036
 
2804
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwks/local.js
2805
- function signatureAlgorithm(alg) {
2806
- const entry = typeof alg === "string" ? JWS[alg] : void 0;
2807
- if (!entry || entry.secret) {
2808
- throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
2809
- }
2810
- return entry;
3037
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwks/local.js
3038
+ function isUsableJWK(jwk, entry, alg, kid) {
3039
+ const { kty, key_ops, ext, kid: jwkKid, alg: jwkAlg, use, crv } = snapshotJwk(jwk);
3040
+ const keyOps = Array.isArray(key_ops) ? [...key_ops] : key_ops;
3041
+ 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);
2811
3042
  }
2812
- function isJWKSLike(jwks) {
2813
- if (!jwks || typeof jwks !== "object") {
2814
- return false;
3043
+ async function importWithAlgCache(cache2, jwk, entry) {
3044
+ const cached2 = cache2.get(jwk) || cache2.set(jwk, {}).get(jwk);
3045
+ const { alg } = entry;
3046
+ if (cached2[alg] === void 0) {
3047
+ const key = await jwkToKey(entry, { ...jwk, alg, ext: true });
3048
+ if (key.type !== "public") {
3049
+ throw new JWKSInvalid("JSON Web Key Set members must be public keys");
3050
+ }
3051
+ cached2[alg] = key;
2815
3052
  }
2816
- const { keys } = jwks;
2817
- return Array.isArray(keys) && keys.every(isObject);
3053
+ return cached2[alg];
2818
3054
  }
2819
- var LocalJWKSetImpl = class {
2820
- #jwks;
2821
- #cached = /* @__PURE__ */ new WeakMap();
2822
- constructor(jwks) {
2823
- if (!isJWKSLike(jwks)) {
2824
- throw new JWKSInvalid("JSON Web Key Set malformed");
2825
- }
2826
- this.#jwks = structuredClone(jwks);
3055
+ function createLocalJWKSet(jwks) {
3056
+ let snapshot;
3057
+ try {
3058
+ snapshot = structuredClone(jwks);
3059
+ } catch {
2827
3060
  }
2828
- jwks() {
2829
- return this.#jwks;
3061
+ if (!isJwkSet(snapshot)) {
3062
+ throw new JWKSInvalid("JSON Web Key Set malformed");
2830
3063
  }
2831
- async getKey(protectedHeader, token) {
3064
+ const cached2 = /* @__PURE__ */ new WeakMap();
3065
+ const localJWKSet = async (protectedHeader, token) => {
2832
3066
  const { alg, kid } = { ...protectedHeader, ...token?.header };
2833
- const entry = signatureAlgorithm(alg);
2834
- const candidates = 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));
3067
+ const entry = typeof alg === "string" ? JWS[alg] : void 0;
3068
+ if (!entry || entry.secret) {
3069
+ throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
3070
+ }
3071
+ const candidates = snapshot.keys.filter((jwk2) => isUsableJWK(jwk2, entry, alg, kid));
2835
3072
  const { 0: jwk, length } = candidates;
2836
- if (length === 0) {
3073
+ if (!length) {
2837
3074
  throw new JWKSNoMatchingKey();
2838
3075
  }
2839
3076
  if (length !== 1) {
2840
3077
  const error = new JWKSMultipleMatchingKeys();
2841
- const _cached = this.#cached;
2842
3078
  error[Symbol.asyncIterator] = async function* () {
2843
3079
  for (const jwk2 of candidates) {
2844
3080
  try {
2845
- yield await importWithAlgCache(_cached, jwk2, entry);
3081
+ yield await importWithAlgCache(cached2, jwk2, entry);
2846
3082
  } catch {
2847
3083
  }
2848
3084
  }
2849
3085
  };
2850
3086
  throw error;
2851
3087
  }
2852
- return importWithAlgCache(this.#cached, jwk, entry);
2853
- }
2854
- };
2855
- async function importWithAlgCache(cache2, jwk, entry) {
2856
- const cached2 = cache2.get(jwk) || cache2.set(jwk, { __proto__: null }).get(jwk);
2857
- if (cached2[entry.alg] === void 0) {
2858
- const key = await jwkToKey(entry, { ...jwk, alg: entry.alg, ext: true });
2859
- if (key.type !== "public") {
2860
- throw new JWKSInvalid("JSON Web Key Set members must be public keys");
2861
- }
2862
- cached2[entry.alg] = key;
2863
- }
2864
- return cached2[entry.alg];
2865
- }
2866
- function createLocalJWKSet(jwks) {
2867
- const set = new LocalJWKSetImpl(jwks);
2868
- const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
2869
- Object.defineProperty(localJWKSet, "jwks", {
2870
- value: () => structuredClone(set.jwks())
3088
+ return importWithAlgCache(cached2, jwk, entry);
3089
+ };
3090
+ return Object.defineProperty(localJWKSet, "jwks", {
3091
+ value: () => structuredClone(snapshot)
2871
3092
  });
2872
- return localJWKSet;
2873
3093
  }
2874
3094
 
2875
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwks/remote.js
3095
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwks/remote.js
2876
3096
  function isCloudflareWorkers() {
2877
3097
  return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
2878
3098
  }
2879
3099
  var USER_AGENT;
2880
3100
  if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
2881
3101
  const NAME = "jose";
2882
- const VERSION = "v6.2.9";
3102
+ const VERSION = "v6.2.10";
2883
3103
  USER_AGENT = `${NAME}/${VERSION}`;
2884
3104
  }
2885
3105
  var customFetch = /* @__PURE__ */ Symbol();
@@ -2905,171 +3125,122 @@ async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
2905
3125
  }
2906
3126
  }
2907
3127
  var jwksCache = /* @__PURE__ */ Symbol();
2908
- function isFreshJwksCache(input, cacheMaxAge) {
2909
- if (typeof input !== "object" || input === null) {
2910
- return false;
2911
- }
2912
- if (!("uat" in input) || typeof input.uat !== "number" || Date.now() - input.uat >= cacheMaxAge) {
2913
- return false;
2914
- }
2915
- if (!("jwks" in input) || !isObject(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isObject)) {
2916
- return false;
3128
+ function isFreshFor(timestamp, duration) {
3129
+ return Number.isFinite(timestamp) && Date.now() < timestamp + duration;
3130
+ }
3131
+ function validateDuration(value, fallback, option) {
3132
+ if (Number.isNaN(value)) {
3133
+ throw new TypeError(`"${option}" option must not be NaN`);
2917
3134
  }
2918
- return true;
3135
+ return typeof value === "number" ? value : fallback;
2919
3136
  }
2920
- var RemoteJWKSetImpl = class {
2921
- #url;
2922
- #timeoutDuration;
2923
- #cooldownDuration;
2924
- #cacheMaxAge;
2925
- #jwksTimestamp;
2926
- #pendingFetch;
2927
- #headers;
2928
- #customFetch;
2929
- #local;
2930
- #cache;
2931
- constructor(url, options) {
2932
- if (!(url instanceof URL)) {
2933
- throw new TypeError("url must be an instance of URL");
2934
- }
2935
- this.#url = new URL(url.href);
2936
- const opts = options ?? {};
2937
- this.#timeoutDuration = typeof opts.timeoutDuration === "number" ? opts.timeoutDuration : 5e3;
2938
- this.#cooldownDuration = typeof opts.cooldownDuration === "number" ? opts.cooldownDuration : 3e4;
2939
- this.#cacheMaxAge = typeof opts.cacheMaxAge === "number" ? opts.cacheMaxAge : 6e5;
2940
- this.#headers = new Headers(opts.headers);
2941
- if (USER_AGENT && !this.#headers.has("User-Agent")) {
2942
- this.#headers.set("User-Agent", USER_AGENT);
2943
- }
2944
- if (!this.#headers.has("accept")) {
2945
- this.#headers.set("accept", "application/json");
2946
- this.#headers.append("accept", "application/jwk-set+json");
2947
- }
2948
- this.#customFetch = opts[customFetch];
2949
- const cache2 = opts[jwksCache];
2950
- if (cache2 !== void 0) {
2951
- this.#cache = cache2;
2952
- if (isFreshJwksCache(cache2, this.#cacheMaxAge)) {
2953
- this.#jwksTimestamp = this.#cache.uat;
2954
- this.#local = createLocalJWKSet(this.#cache.jwks);
2955
- }
3137
+ function createRemoteJWKSet(url, options) {
3138
+ if (!(url instanceof URL)) {
3139
+ throw new TypeError("url must be an instance of URL");
3140
+ }
3141
+ const href = new URL(url.href).href;
3142
+ const opts = options ?? {};
3143
+ const timeoutOption = opts.timeoutDuration;
3144
+ if (typeof timeoutOption === "number" && (!Number.isInteger(timeoutOption) || timeoutOption < 0)) {
3145
+ throw new TypeError('"timeoutDuration" option must be a non-negative integer');
3146
+ }
3147
+ const timeoutDuration = typeof timeoutOption === "number" ? timeoutOption : 5e3;
3148
+ const cooldownDuration = validateDuration(opts.cooldownDuration, 3e4, "cooldownDuration");
3149
+ const cacheMaxAge = validateDuration(opts.cacheMaxAge, 6e5, "cacheMaxAge");
3150
+ const headers = new Headers(opts.headers);
3151
+ if (USER_AGENT && !headers.has("User-Agent")) {
3152
+ headers.set("User-Agent", USER_AGENT);
3153
+ }
3154
+ if (!headers.has("accept")) {
3155
+ headers.set("accept", "application/json, application/jwk-set+json");
3156
+ }
3157
+ const fetchImpl = opts[customFetch];
3158
+ const cache2 = opts[jwksCache];
3159
+ let jwksTimestamp;
3160
+ let pendingFetch;
3161
+ let reloadSequence = 0;
3162
+ let appliedSequence = 0;
3163
+ let local;
3164
+ if (cache2 && typeof cache2 === "object") {
3165
+ const { uat, jwks } = cache2;
3166
+ if (isFreshFor(uat, cacheMaxAge) && isJwkSet(jwks)) {
3167
+ jwksTimestamp = uat;
3168
+ local = createLocalJWKSet(jwks);
3169
+ }
3170
+ }
3171
+ const reload = async () => {
3172
+ if (pendingFetch && isCloudflareWorkers()) {
3173
+ pendingFetch = void 0;
3174
+ }
3175
+ if (!pendingFetch) {
3176
+ const sequence = ++reloadSequence;
3177
+ const current = pendingFetch = fetchJwks(href, headers, AbortSignal.timeout(timeoutDuration), fetchImpl).then((json) => {
3178
+ const next = createLocalJWKSet(json);
3179
+ if (sequence <= appliedSequence) {
3180
+ return;
3181
+ }
3182
+ local = next;
3183
+ const updatedAt = Date.now();
3184
+ if (cache2) {
3185
+ cache2.uat = updatedAt;
3186
+ cache2.jwks = json;
3187
+ }
3188
+ jwksTimestamp = updatedAt;
3189
+ appliedSequence = sequence;
3190
+ }).finally(() => {
3191
+ if (pendingFetch === current) {
3192
+ pendingFetch = void 0;
3193
+ }
3194
+ });
2956
3195
  }
2957
- }
2958
- pendingFetch() {
2959
- return !!this.#pendingFetch;
2960
- }
2961
- #validFor(duration) {
2962
- return typeof this.#jwksTimestamp === "number" && Date.now() < this.#jwksTimestamp + duration;
2963
- }
2964
- coolingDown() {
2965
- return this.#validFor(this.#cooldownDuration);
2966
- }
2967
- fresh() {
2968
- return this.#validFor(this.#cacheMaxAge);
2969
- }
2970
- jwks() {
2971
- return this.#local?.jwks();
2972
- }
2973
- async getKey(protectedHeader, token) {
2974
- if (!this.#local || !this.fresh()) {
2975
- await this.reload();
3196
+ await pendingFetch;
3197
+ };
3198
+ const remoteJWKSet = async (protectedHeader, token) => {
3199
+ if (!local || !isFreshFor(jwksTimestamp, cacheMaxAge)) {
3200
+ await reload();
2976
3201
  }
2977
3202
  try {
2978
- return await this.#local(protectedHeader, token);
3203
+ return await local(protectedHeader, token);
2979
3204
  } catch (err) {
2980
- if (err instanceof JWKSNoMatchingKey) {
2981
- if (this.coolingDown() === false) {
2982
- await this.reload();
2983
- return this.#local(protectedHeader, token);
2984
- }
3205
+ if (err instanceof JWKSNoMatchingKey && !isFreshFor(jwksTimestamp, cooldownDuration)) {
3206
+ await reload();
3207
+ return local(protectedHeader, token);
2985
3208
  }
2986
3209
  throw err;
2987
3210
  }
2988
- }
2989
- async reload() {
2990
- if (this.#pendingFetch && isCloudflareWorkers()) {
2991
- this.#pendingFetch = void 0;
2992
- }
2993
- this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch).then((json) => {
2994
- this.#local = createLocalJWKSet(json);
2995
- if (this.#cache) {
2996
- this.#cache.uat = Date.now();
2997
- this.#cache.jwks = json;
2998
- }
2999
- this.#jwksTimestamp = Date.now();
3000
- }).finally(() => {
3001
- this.#pendingFetch = void 0;
3002
- });
3003
- await this.#pendingFetch;
3004
- }
3005
- };
3006
- function createRemoteJWKSet(url, options) {
3007
- const set = new RemoteJWKSetImpl(url, options);
3008
- const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
3009
- Object.defineProperties(remoteJWKSet, {
3211
+ };
3212
+ return Object.defineProperties(remoteJWKSet, {
3010
3213
  coolingDown: {
3011
- get: () => set.coolingDown(),
3214
+ get: () => isFreshFor(jwksTimestamp, cooldownDuration),
3012
3215
  enumerable: true
3013
3216
  },
3014
3217
  fresh: {
3015
- get: () => set.fresh(),
3218
+ get: () => isFreshFor(jwksTimestamp, cacheMaxAge),
3016
3219
  enumerable: true
3017
3220
  },
3018
3221
  reload: {
3019
- value: () => set.reload(),
3222
+ value: reload,
3020
3223
  enumerable: true
3021
3224
  },
3022
3225
  reloading: {
3023
- get: () => set.pendingFetch(),
3226
+ get: () => !!pendingFetch,
3024
3227
  enumerable: true
3025
3228
  },
3026
3229
  jwks: {
3027
- value: () => set.jwks(),
3230
+ value: () => local?.jwks(),
3028
3231
  enumerable: true
3029
3232
  }
3030
3233
  });
3031
- return remoteJWKSet;
3032
3234
  }
3033
3235
 
3034
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/jwt/unsecured.js
3035
- var UnsecuredJWT = class {
3036
- #jwt;
3037
- constructor(payload = {}) {
3038
- this.#jwt = new JWTClaimsBuilder(payload);
3039
- }
3236
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/jwt/unsecured.js
3237
+ var UnsecuredJWT_base = JWTClaimsBuilder;
3238
+ var UnsecuredJWT = class extends UnsecuredJWT_base {
3040
3239
  encode() {
3041
3240
  const header = encode2(JSON.stringify({ alg: "none" }));
3042
- const payload = encode2(this.#jwt.data());
3241
+ const payload = encode2(jwtData(this));
3043
3242
  return `${header}.${payload}.`;
3044
3243
  }
3045
- setIssuer(issuer) {
3046
- this.#jwt.iss = issuer;
3047
- return this;
3048
- }
3049
- setSubject(subject) {
3050
- this.#jwt.sub = subject;
3051
- return this;
3052
- }
3053
- setAudience(audience) {
3054
- this.#jwt.aud = audience;
3055
- return this;
3056
- }
3057
- setJti(jwtId) {
3058
- this.#jwt.jti = jwtId;
3059
- return this;
3060
- }
3061
- setNotBefore(input) {
3062
- this.#jwt.nbf = input;
3063
- return this;
3064
- }
3065
- setExpirationTime(input) {
3066
- this.#jwt.exp = input;
3067
- return this;
3068
- }
3069
- setIssuedAt(input) {
3070
- this.#jwt.iat = input;
3071
- return this;
3072
- }
3073
3244
  static decode(jwt, options) {
3074
3245
  if (typeof jwt !== "string") {
3075
3246
  throw new JWTInvalid("Unsecured JWT must be a string");
@@ -3079,19 +3250,29 @@ var UnsecuredJWT = class {
3079
3250
  throw new JWTInvalid("Invalid Unsecured JWT");
3080
3251
  }
3081
3252
  let header;
3253
+ let b64;
3082
3254
  try {
3083
- header = JSON.parse(strictDecoder.decode(decode(encodedHeader)));
3084
- if (header.alg !== "none")
3085
- throw new Error();
3086
- } catch {
3255
+ header = parseJoseHeader(encodedHeader, JWSInvalid, "JWS Protected Header is invalid");
3256
+ const extensions = validateCrit(JWSInvalid, JWS_RECOGNIZED, void 0, header, header);
3257
+ b64 = validateB64(header, extensions);
3258
+ } catch (cause) {
3259
+ if (!(cause instanceof JWSInvalid)) {
3260
+ throw cause;
3261
+ }
3262
+ throw new JWTInvalid("Invalid Unsecured JWT", { cause });
3263
+ }
3264
+ if (header.alg !== "none") {
3087
3265
  throw new JWTInvalid("Invalid Unsecured JWT");
3088
3266
  }
3267
+ if (!b64) {
3268
+ throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
3269
+ }
3089
3270
  const payload = validateClaimsSet(header, decodeBase64url(encodedPayload, "payload", JWTInvalid), options);
3090
3271
  return { payload, header };
3091
3272
  }
3092
3273
  };
3093
3274
 
3094
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/key/import.js
3275
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/key/import.js
3095
3276
  async function importSPKI(spki, alg, options) {
3096
3277
  if (typeof spki !== "string" || spki.indexOf("-----BEGIN PUBLIC KEY-----") !== 0) {
3097
3278
  throw new TypeError('"spki" must be SPKI formatted string');
@@ -3114,37 +3295,39 @@ async function importJWK(jwk, alg, options) {
3114
3295
  if (!isObject(jwk)) {
3115
3296
  throw new TypeError("JWK must be an object");
3116
3297
  }
3117
- alg ??= jwk.alg;
3118
- const ext = options?.extractable ?? jwk.ext;
3119
- if (jwk.kty !== "oct" && !alg) {
3298
+ const normalized = normalizeJwk(jwk);
3299
+ const extractable = validateExtractableOption(options?.extractable);
3300
+ const { alg: jwkAlg } = normalized;
3301
+ alg ??= jwkAlg;
3302
+ const ext = extractable ?? normalized.ext;
3303
+ if (normalized.kty !== "oct" && !alg) {
3120
3304
  throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
3121
3305
  }
3122
- switch (jwk.kty) {
3306
+ switch (normalized.kty) {
3123
3307
  case "oct":
3124
- if (typeof jwk.k !== "string" || !jwk.k) {
3308
+ if (typeof normalized.k !== "string") {
3125
3309
  throw new TypeError('missing "k" (Key Value) Parameter value');
3126
3310
  }
3127
- return decode(jwk.k);
3128
- case "RSA":
3129
- return jwkToKey(keyAlgorithm(alg), { ...jwk, alg, ext });
3311
+ return decode(normalized.k);
3130
3312
  case "AKP": {
3131
- if (typeof jwk.alg !== "string" || !jwk.alg) {
3313
+ if (typeof jwkAlg !== "string" || !jwkAlg) {
3132
3314
  throw new TypeError('missing "alg" (Algorithm) Parameter value');
3133
3315
  }
3134
- if (alg !== void 0 && alg !== jwk.alg) {
3316
+ if (alg !== jwkAlg) {
3135
3317
  throw new TypeError("JWK alg and alg option value mismatch");
3136
3318
  }
3137
- return jwkToKey(keyAlgorithm(jwk.alg), { ...jwk, ext });
3319
+ return jwkToKey(keyAlgorithm(alg), { ...normalized, ext });
3138
3320
  }
3321
+ case "RSA":
3139
3322
  case "EC":
3140
3323
  case "OKP":
3141
- return jwkToKey(keyAlgorithm(alg), { ...jwk, alg, ext });
3324
+ return jwkToKey(keyAlgorithm(alg), { ...normalized, alg, ext });
3142
3325
  default:
3143
3326
  throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
3144
3327
  }
3145
3328
  }
3146
3329
 
3147
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/util/decode_protected_header.js
3330
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/util/decode_protected_header.js
3148
3331
  function decodeProtectedHeader(token) {
3149
3332
  let protectedB64u;
3150
3333
  if (typeof token === "string") {
@@ -3167,7 +3350,7 @@ function decodeProtectedHeader(token) {
3167
3350
  return parseJoseHeader(protectedB64u, TypeError, invalid2);
3168
3351
  }
3169
3352
 
3170
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/util/decode_jwt.js
3353
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/util/decode_jwt.js
3171
3354
  function decodeJwt(jwt) {
3172
3355
  if (typeof jwt !== "string")
3173
3356
  throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
@@ -3195,15 +3378,16 @@ function decodeJwt(jwt) {
3195
3378
  return result;
3196
3379
  }
3197
3380
 
3198
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/key/generate_key_pair.js
3381
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/key/generate_key_pair.js
3199
3382
  function getModulusLengthOption(options) {
3200
3383
  const modulusLength = options?.modulusLength ?? 2048;
3201
- if (typeof modulusLength !== "number" || modulusLength < 2048) {
3384
+ if (typeof modulusLength !== "number" || !Number.isInteger(modulusLength) || modulusLength < 2048) {
3202
3385
  throw new JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");
3203
3386
  }
3204
3387
  return modulusLength;
3205
3388
  }
3206
3389
  async function generateKeyPair(alg, options) {
3390
+ const extractable = validateExtractableOption(options?.extractable);
3207
3391
  const entry = keyAlgorithm(alg, algArgument);
3208
3392
  if (entry.secret) {
3209
3393
  unsupportedAlg(algArgument);
@@ -3233,14 +3417,15 @@ async function generateKeyPair(alg, options) {
3233
3417
  modulusLength: getModulusLengthOption(options)
3234
3418
  } : entry.subtle;
3235
3419
  }
3236
- return crypto.subtle.generateKey(algorithm, options?.extractable ?? false, [
3420
+ return crypto.subtle.generateKey(algorithm, extractable ?? false, [
3237
3421
  ...entry.usages[1],
3238
3422
  ...entry.usages[0]
3239
3423
  ]);
3240
3424
  }
3241
3425
 
3242
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/key/generate_secret.js
3426
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/key/generate_secret.js
3243
3427
  async function generateSecret(alg, options) {
3428
+ const extractable = validateExtractableOption(options?.extractable);
3244
3429
  let length;
3245
3430
  let algorithm;
3246
3431
  let keyUsages;
@@ -3248,19 +3433,18 @@ async function generateSecret(alg, options) {
3248
3433
  case "HS256":
3249
3434
  case "HS384":
3250
3435
  case "HS512":
3251
- length = parseInt(alg.slice(-3), 10);
3436
+ length = +alg.slice(-3);
3252
3437
  algorithm = { name: "HMAC", hash: `SHA-${length}`, length };
3253
3438
  keyUsages = ["sign", "verify"];
3254
3439
  break;
3255
3440
  case "A128CBC-HS256":
3256
3441
  case "A192CBC-HS384":
3257
3442
  case "A256CBC-HS512":
3258
- length = parseInt(alg.slice(-3), 10);
3259
- return crypto.getRandomValues(new Uint8Array(length >> 3));
3443
+ return crypto.getRandomValues(new Uint8Array(+alg.slice(-3) >> 3));
3260
3444
  case "A128KW":
3261
3445
  case "A192KW":
3262
3446
  case "A256KW":
3263
- length = parseInt(alg.slice(1, 4), 10);
3447
+ length = +alg.slice(1, 4);
3264
3448
  algorithm = { name: "AES-KW", length };
3265
3449
  keyUsages = ["wrapKey", "unwrapKey"];
3266
3450
  break;
@@ -3270,17 +3454,17 @@ async function generateSecret(alg, options) {
3270
3454
  case "A128GCM":
3271
3455
  case "A192GCM":
3272
3456
  case "A256GCM":
3273
- length = parseInt(alg.slice(1, 4), 10);
3457
+ length = +alg.slice(1, 4);
3274
3458
  algorithm = { name: "AES-GCM", length };
3275
3459
  keyUsages = ["encrypt", "decrypt"];
3276
3460
  break;
3277
3461
  default:
3278
3462
  unsupportedAlg(algArgument);
3279
3463
  }
3280
- return crypto.subtle.generateKey(algorithm, options?.extractable ?? false, keyUsages);
3464
+ return crypto.subtle.generateKey(algorithm, extractable ?? false, keyUsages);
3281
3465
  }
3282
3466
 
3283
- // node_modules/.pnpm/jose@6.2.9/node_modules/jose/dist/webapi/index.js
3467
+ // node_modules/.pnpm/jose@6.2.10/node_modules/jose/dist/webapi/index.js
3284
3468
  var cryptoRuntime = "WebCryptoAPI";
3285
3469
  export {
3286
3470
  CompactEncrypt,