@qwen-code/qwen-code 0.22.0 → 0.22.2-preview.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 (449) hide show
  1. package/bundled/computer-use/SKILL.md +229 -0
  2. package/bundled/computer-use/agents/openai.yaml +4 -0
  3. package/bundled/coordinate/SKILL.md +5 -5
  4. package/bundled/qc-helper/docs/configuration/auth.md +7 -7
  5. package/bundled/qc-helper/docs/configuration/model-providers.md +70 -9
  6. package/bundled/qc-helper/docs/configuration/settings.md +40 -40
  7. package/bundled/qc-helper/docs/extension/introduction.md +3 -1
  8. package/bundled/qc-helper/docs/features/channels/_meta.ts +1 -0
  9. package/bundled/qc-helper/docs/features/channels/dingtalk.md +12 -0
  10. package/bundled/qc-helper/docs/features/channels/dws.md +120 -0
  11. package/bundled/qc-helper/docs/features/channels/overview.md +3 -3
  12. package/bundled/qc-helper/docs/features/code-review.md +25 -21
  13. package/bundled/qc-helper/docs/features/commands.md +2 -2
  14. package/bundled/qc-helper/docs/features/computer-use.md +57 -51
  15. package/bundled/qc-helper/docs/features/mcp.md +35 -12
  16. package/bundled/qc-helper/docs/features/sub-agents.md +1 -1
  17. package/bundled/qc-helper/docs/features/worktree.md +1 -1
  18. package/bundled/qc-helper/docs/overview.md +1 -1
  19. package/bundled/qc-helper/docs/quickstart.md +1 -1
  20. package/bundled/qc-helper/docs/qwen-serve.md +29 -6
  21. package/bundled/review/SKILL.md +119 -417
  22. package/bundled/review/references/aone.md +18 -0
  23. package/bundled/review/references/persistence.md +105 -0
  24. package/bundled/review/references/posting.md +270 -0
  25. package/chunks/MaxSizedBox-XYQOMOBE.js +112 -0
  26. package/chunks/{StandaloneSessionPicker-KTHPCSR6.js → StandaloneSessionPicker-KFMJILVY.js} +87 -86
  27. package/chunks/{acp-startup-profiler-T4GEAPLX.js → acp-startup-profiler-GNYAL6LI.js} +2 -2
  28. package/chunks/{acpAgent-CRY3JZ5O.js → acpAgent-KNFTTDWL.js} +2216 -1931
  29. package/chunks/agent-6V6MZOA7.js +97 -0
  30. package/chunks/agent-headless-3ZC4LX3E.js +87 -0
  31. package/chunks/{anthropicContentGenerator-Y2OX6LS4.js → anthropicContentGenerator-U76GTVB6.js} +128 -58
  32. package/chunks/{artifact-tool-SBXMTVCB.js → artifact-tool-XDJCZZCF.js} +2 -2
  33. package/chunks/{askUserQuestion-KEQJRFD6.js → askUserQuestion-ZXXERLEV.js} +2 -2
  34. package/chunks/bridge-LFFLHLU5.js +119 -0
  35. package/chunks/{ca-D3F4S6NG.js → ca-7HPYOYSZ.js} +3 -0
  36. package/chunks/{channel-management-service-IRTT7RNE.js → channel-management-service-HXXS3HOZ.js} +4 -4
  37. package/chunks/channel-settings-store-CAL2HWAH.js +117 -0
  38. package/chunks/{channel-worker-group-BJNMR2MP.js → channel-worker-group-EVDC2P4K.js} +8 -7
  39. package/chunks/{channel-worker-manager-EMA7CQDJ.js → channel-worker-manager-IJJZHGEI.js} +8 -7
  40. package/chunks/{channel-worker-supervisor-F6I6WSWW.js → channel-worker-supervisor-YSKB5GVB.js} +12 -7
  41. package/chunks/{chunk-2TRNCJK4.js → chunk-27ONXAFY.js} +1 -1
  42. package/chunks/{read-package-up-UXSW3YPB.js → chunk-2EAZ43JQ.js} +1 -0
  43. package/chunks/{chunk-DB2OKNTU.js → chunk-2FN2HNTI.js} +2 -2
  44. package/chunks/{chunk-KM73TBQ4.js → chunk-2LD5U7Q3.js} +31 -0
  45. package/chunks/{chunk-QJHPWLZC.js → chunk-2MHGD7EE.js} +1 -1
  46. package/chunks/{chunk-A5F2YNO6.js → chunk-2NNTE2ED.js} +245 -10
  47. package/chunks/{chunk-Z3JMO2CH.js → chunk-2SERYG4T.js} +1 -1
  48. package/chunks/{chunk-4J7OPYNS.js → chunk-2YDYDDE2.js} +6 -6
  49. package/chunks/{chunk-SE55HQGF.js → chunk-3B5DCAQU.js} +74 -52
  50. package/chunks/{chunk-UIRLQ3N7.js → chunk-3BV7TZNQ.js} +3 -3
  51. package/chunks/{chunk-2Z6LSQMF.js → chunk-3FSBMAYD.js} +1 -1
  52. package/chunks/{chunk-S4C4JJKE.js → chunk-3UXJFOB3.js} +5 -5
  53. package/chunks/{chunk-DJEHYM4H.js → chunk-3UZCLCXR.js} +3 -3
  54. package/chunks/{chunk-BUGYW6FB.js → chunk-4IDJQOCO.js} +1 -1
  55. package/chunks/chunk-4K7NQDCG.js +104 -0
  56. package/chunks/{chunk-WS7PAXXR.js → chunk-4N6UAPD3.js} +18 -13
  57. package/chunks/{chunk-VYC7XFYV.js → chunk-4PLAO7FS.js} +5 -5
  58. package/chunks/{chunk-UZPYR3EV.js → chunk-4TPAG3O7.js} +1 -1
  59. package/chunks/{chunk-2E3V7G6Y.js → chunk-4X5GYZFO.js} +55 -50
  60. package/chunks/{chunk-XYQHT3AW.js → chunk-4Z3PSHN4.js} +2 -2
  61. package/chunks/{chunk-PDL6LKB5.js → chunk-5AFPOEY3.js} +1 -1
  62. package/chunks/{chunk-BB5IMQCV.js → chunk-5CW26JIE.js} +2 -2
  63. package/chunks/{chunk-7KOFLDEP.js → chunk-5JTIYALA.js} +1 -1
  64. package/chunks/{chunk-U2UYQMM6.js → chunk-5NV2AN56.js} +3 -3
  65. package/chunks/{chunk-CXJHQVEK.js → chunk-5PA6UEYA.js} +4 -0
  66. package/chunks/{chunk-IBJ5S45N.js → chunk-5T4LWWNX.js} +2 -2
  67. package/chunks/{chunk-VUMLT7E5.js → chunk-5Y2JCJAH.js} +2 -2
  68. package/chunks/{chunk-BEGIBJAZ.js → chunk-6HOU52QX.js} +4 -4
  69. package/chunks/{chunk-GAHYKJPV.js → chunk-6US7BF3G.js} +7 -59
  70. package/chunks/{chunk-3CLIDIVQ.js → chunk-73WFGVIZ.js} +3 -3
  71. package/chunks/{chunk-ZZUVC6RI.js → chunk-76WGY6LW.js} +3 -3
  72. package/chunks/{chunk-XLDFW44M.js → chunk-77TOMRBG.js} +3 -3
  73. package/chunks/{chunk-ND7NOI4P.js → chunk-7CWEZQ6T.js} +0 -15
  74. package/chunks/{chunk-DWCKACFL.js → chunk-7DPKPBOQ.js} +2 -2
  75. package/chunks/{chunk-X7V3N6YH.js → chunk-7JJUFI36.js} +218 -37
  76. package/chunks/{chunk-45NQKMYB.js → chunk-7JPW6IYH.js} +1 -1
  77. package/chunks/{chunk-HDKCKCYO.js → chunk-7QGEJI7M.js} +1 -1
  78. package/chunks/{chunk-PHJJ3RVO.js → chunk-7XKW4CVK.js} +7 -15
  79. package/chunks/{chunk-O5Z7EB6Y.js → chunk-AYHQZBJ4.js} +170 -207
  80. package/chunks/{chunk-7DYNJFES.js → chunk-AYVIGUUK.js} +6 -1
  81. package/chunks/{chunk-43T5WDQ7.js → chunk-BFSFJR3D.js} +1 -1
  82. package/chunks/{chunk-OARZJFZX.js → chunk-BGWT7VBV.js} +4 -4
  83. package/chunks/{chunk-AP3B7LKD.js → chunk-BKDAF7ES.js} +2 -2
  84. package/chunks/{chunk-B6UBOIFE.js → chunk-BQBUZDDH.js} +14 -11
  85. package/chunks/{chunk-6PCOVQO2.js → chunk-BU7OUDQB.js} +8 -8
  86. package/chunks/{chunk-VLRBJ24J.js → chunk-BVE5EMIG.js} +2 -2
  87. package/chunks/{chunk-6UQSU7CQ.js → chunk-C2BAEV64.js} +58 -107
  88. package/chunks/{chunk-QKBYFU2Q.js → chunk-CFKIH3D3.js} +21 -1
  89. package/chunks/{chunk-URN2JIAQ.js → chunk-CITGRGCM.js} +2 -1
  90. package/chunks/{chunk-WU5E4HMO.js → chunk-CPPYZHBN.js} +1 -1
  91. package/chunks/{chunk-T6XLJRQY.js → chunk-D6XO27Z5.js} +36509 -5182
  92. package/chunks/{chunk-Q54XG7IX.js → chunk-DEYPMJPD.js} +1 -1
  93. package/chunks/{chunk-KSPRQSB4.js → chunk-DIMEPKCW.js} +52 -12
  94. package/chunks/{chunk-I432KXWD.js → chunk-DP7LABIB.js} +1 -1
  95. package/chunks/{chunk-P47E4SJC.js → chunk-DWRFOH3G.js} +3 -3
  96. package/chunks/{chunk-J5ZDDUKM.js → chunk-DX5FZGHZ.js} +4 -4
  97. package/chunks/{chunk-36OF5PRW.js → chunk-E4I5MVBR.js} +7 -3
  98. package/chunks/{chunk-AW27A43Y.js → chunk-E55H6BZ7.js} +93 -1
  99. package/chunks/{chunk-K623ENWT.js → chunk-E6FGMDFQ.js} +4 -0
  100. package/chunks/{chunk-YZBDKFRQ.js → chunk-EADEZDPO.js} +993 -895
  101. package/chunks/{chunk-5XUTPXQU.js → chunk-EAV3TENS.js} +6 -9
  102. package/chunks/{chunk-LI4YHTQK.js → chunk-EB4VDXNI.js} +1 -1
  103. package/chunks/{chunk-JOLJTKIG.js → chunk-EC5BONC3.js} +1 -1
  104. package/chunks/{chunk-W4CRPSC5.js → chunk-ELY4QVIB.js} +1 -1
  105. package/chunks/{chunk-AVCCKIZ6.js → chunk-EWBY3PFB.js} +1 -1
  106. package/chunks/chunk-FBX2SDQ4.js +48 -0
  107. package/chunks/{chunk-C72BXMJ5.js → chunk-FJWICLG7.js} +1 -1
  108. package/chunks/{chunk-LDGWX737.js → chunk-FN5C6C7G.js} +160 -59
  109. package/chunks/{chunk-3ZFJUBTP.js → chunk-FPH6TXD3.js} +1 -1
  110. package/chunks/{chunk-WRT324N6.js → chunk-FVDQ5E67.js} +3 -3
  111. package/chunks/{chunk-2A4C2MEG.js → chunk-FY62MBPS.js} +35 -12
  112. package/chunks/{chunk-VFACN2CE.js → chunk-GNMJNDZE.js} +1 -1
  113. package/chunks/{chunk-6QSA4JHL.js → chunk-GQAIZL3H.js} +2772 -814
  114. package/chunks/{chunk-PZRUV52H.js → chunk-GTUKW3I6.js} +20 -2
  115. package/chunks/{chunk-7DMTAQJ6.js → chunk-GXWY24QS.js} +132 -49
  116. package/chunks/chunk-GYTKQYDB.js +23 -0
  117. package/chunks/{chunk-VMJL7RH6.js → chunk-GZJUCMH4.js} +4 -4
  118. package/chunks/{chunk-2GXYDNXP.js → chunk-H2MDBYLL.js} +8 -8
  119. package/chunks/{chunk-RDG44S5I.js → chunk-H4JK2A2V.js} +2 -2
  120. package/chunks/{chunk-FVBVJEBG.js → chunk-HOANA6GC.js} +10 -8
  121. package/chunks/{chunk-AO4M6NMD.js → chunk-I6HWGOWD.js} +60 -20
  122. package/chunks/{chunk-7IV52LTO.js → chunk-I6VVOZDK.js} +2 -2
  123. package/chunks/{chunk-SQS55KR4.js → chunk-IJVDHPKD.js} +2 -2
  124. package/chunks/{chunk-QS4ENGVF.js → chunk-IKN3IUJP.js} +9 -8
  125. package/chunks/{chunk-2UZJWSVD.js → chunk-ILPXSKGQ.js} +2 -2
  126. package/chunks/{chunk-OVH5Y7KS.js → chunk-IN66KO3N.js} +19 -3
  127. package/chunks/{chunk-ZRYQMWEP.js → chunk-IPQA4SR5.js} +2 -2
  128. package/chunks/{chunk-AZF6SME3.js → chunk-JECO75XD.js} +3 -3
  129. package/chunks/{chunk-MQP3MHWN.js → chunk-JJJD6QCC.js} +21 -15
  130. package/chunks/chunk-JLGFGPZJ.js +346 -0
  131. package/chunks/{chunk-WZDM44SB.js → chunk-JUIJ3FXC.js} +7 -7
  132. package/chunks/{chunk-A6NRNRKE.js → chunk-JVPFTDBK.js} +1 -1
  133. package/chunks/{chunk-2J3OJGTL.js → chunk-K2OJUPOE.js} +1 -21
  134. package/chunks/{chunk-GHY5OIYP.js → chunk-K5PNJ6VL.js} +13 -13
  135. package/chunks/{chunk-NW35NVFN.js → chunk-K6FURWIX.js} +4 -4
  136. package/chunks/{chunk-6NFAEG54.js → chunk-KOJ6MHD5.js} +24 -13
  137. package/chunks/{chunk-A5F63FEW.js → chunk-L436XFLJ.js} +1 -1
  138. package/chunks/{chunk-GIWB5QLV.js → chunk-LJP2BBMK.js} +4 -4
  139. package/chunks/{chunk-FYZMB6DB.js → chunk-LKOSBI2M.js} +11 -11
  140. package/chunks/{create-sub-session-XBCVGNFU.js → chunk-LRKMQPMD.js} +4 -6
  141. package/chunks/{chunk-5HJUPACR.js → chunk-LRLMDV5X.js} +2 -2
  142. package/chunks/{chunk-MHG6NDS6.js → chunk-MB4OCRQ2.js} +2 -2
  143. package/chunks/{chunk-IIWGSX4L.js → chunk-MI7CMXPU.js} +1 -1
  144. package/chunks/{chunk-ZLCT4C5A.js → chunk-MZS7GEC7.js} +1 -1
  145. package/chunks/{chunk-WWUSHZ7M.js → chunk-N4B7VPXK.js} +5 -5
  146. package/chunks/{chunk-BMCSKS37.js → chunk-NUHCXGAD.js} +6 -6
  147. package/chunks/{chunk-XZJKSETB.js → chunk-O3BUXIPM.js} +3 -3
  148. package/chunks/{chunk-4XPSVIED.js → chunk-O5YGAEQS.js} +6 -6
  149. package/chunks/{chunk-ZRFUT5VV.js → chunk-OAAPGZVH.js} +7 -7
  150. package/chunks/{chunk-UU4WC7DK.js → chunk-OGZAQWJP.js} +82 -12
  151. package/chunks/{chunk-5XHAOUWD.js → chunk-OI2DR6QB.js} +3 -3
  152. package/chunks/{chunk-EFB657PR.js → chunk-OX44MOAN.js} +3 -3
  153. package/chunks/{chunk-LURJYO2T.js → chunk-OZ6KS6KW.js} +4 -0
  154. package/chunks/{chunk-4F5WV4RF.js → chunk-PAJGKZAA.js} +281 -10
  155. package/chunks/{chunk-HIK2OF33.js → chunk-PVBT5QPD.js} +1 -1
  156. package/chunks/{chunk-MPHLIJYL.js → chunk-QB5DD75E.js} +14 -8
  157. package/chunks/chunk-QHMLYMMS.js +32 -0
  158. package/chunks/{chunk-4CWDWDL6.js → chunk-RCDXSEJ5.js} +1 -1
  159. package/chunks/{chunk-L4HVF7LM.js → chunk-RQ5ASDFQ.js} +3 -3
  160. package/chunks/{chunk-PXOJLJ5W.js → chunk-RQAMNZ4Y.js} +333 -184
  161. package/chunks/{chunk-K52PZNU4.js → chunk-RRKNX553.js} +2 -2
  162. package/chunks/{chunk-RPJQ3O4M.js → chunk-RUJTCU46.js} +31 -41
  163. package/chunks/{chunk-62JOGZL5.js → chunk-RUQBJS34.js} +199 -87
  164. package/chunks/chunk-RXFQM6FQ.js +42 -0
  165. package/chunks/{chunk-SJ4HB27T.js → chunk-SDVF6A42.js} +3 -3
  166. package/chunks/{chunk-TBVSALA3.js → chunk-SKNVVYIJ.js} +3 -3
  167. package/chunks/{chunk-JGUBDRBC.js → chunk-SLEWBQWM.js} +3 -3
  168. package/chunks/{chunk-UUQFJILB.js → chunk-SQPOJ4ZI.js} +15 -3
  169. package/chunks/{chunk-ISJMN3ML.js → chunk-T2CRBIDJ.js} +1 -1
  170. package/chunks/{chunk-MZKWFWVG.js → chunk-T2HMXHYA.js} +6 -6
  171. package/chunks/{chunk-FEMQ6Y7W.js → chunk-T6OODF2U.js} +47 -126
  172. package/chunks/{chunk-KVGR4MCF.js → chunk-TOF4UZHH.js} +3 -3
  173. package/chunks/{chunk-7HFULI45.js → chunk-TQYZG5DU.js} +3 -3
  174. package/chunks/{chunk-LD5VIJ7S.js → chunk-TWSKM647.js} +1 -1
  175. package/chunks/{chunk-25NESM4G.js → chunk-TWUA5EIL.js} +29 -5
  176. package/chunks/{chunk-6FRJEE2S.js → chunk-U66FXEH2.js} +5 -5
  177. package/chunks/{chunk-7NBVNAJJ.js → chunk-UCSV2IZW.js} +3 -3
  178. package/chunks/chunk-UVDOONRU.js +20 -0
  179. package/chunks/{chunk-FDD2IUEL.js → chunk-UX3IFLJM.js} +229 -21
  180. package/chunks/{chunk-YDJRMQU4.js → chunk-V3GINY6K.js} +3 -3
  181. package/chunks/{chunk-XL5K4SVK.js → chunk-VL4YX3FH.js} +1 -1
  182. package/chunks/{chunk-ZS5BHEPD.js → chunk-VLY6XOBY.js} +1 -1
  183. package/chunks/{chunk-KIVGVFMM.js → chunk-VUZY6MEQ.js} +16 -4
  184. package/chunks/{chunk-OE52YHCZ.js → chunk-W2WRNJKX.js} +11 -11
  185. package/chunks/{chunk-YLFLHKDL.js → chunk-W3N5XAZ6.js} +1 -1
  186. package/chunks/{chunk-IWOWEENB.js → chunk-WBT3STGU.js} +385 -25
  187. package/chunks/{chunk-S3G6YFQC.js → chunk-WEGXPP5E.js} +1 -1
  188. package/chunks/{chunk-RDQ7QB4Y.js → chunk-XJS54K4A.js} +2 -2
  189. package/chunks/{chunk-7JBHIQS2.js → chunk-XO4NGYRP.js} +7 -13
  190. package/chunks/{chunk-F6WFNA7U.js → chunk-XZA32HII.js} +3 -6
  191. package/chunks/{chunk-VEND4KA4.js → chunk-YT5XN3HV.js} +1 -1
  192. package/chunks/{chunk-NUGZAFR2.js → chunk-ZEADBZLO.js} +147 -6
  193. package/chunks/chunk-ZELCTN6Y.js +29 -0
  194. package/chunks/{chunk-TQOF5KBL.js → chunk-ZEZKIS2K.js} +0 -31
  195. package/chunks/{chunk-IOSEW6KP.js → chunk-ZJG323IA.js} +5 -4
  196. package/chunks/{chunk-VSNPOSDN.js → chunk-ZKAZP2ZG.js} +107 -12
  197. package/chunks/{chunk-YMVFIYHV.js → chunk-ZLTEQYNC.js} +2 -2
  198. package/chunks/{chunk-O5BDEWBC.js → chunk-ZWKGZB2K.js} +3 -3
  199. package/chunks/chunk-ZYNTSXWK.js +32 -0
  200. package/chunks/config-utils-YMJNA25D.js +113 -0
  201. package/chunks/contextCommand-WMPSNKPG.js +108 -0
  202. package/chunks/{core-runtime-CES6JSVV.js → core-runtime-6TBMEULI.js} +63 -58
  203. package/chunks/create-sub-session-RVHSWVAP.js +17 -0
  204. package/chunks/{create-sub-session-UJTPMVOG.js → create-sub-session-SAOMTP62.js} +60 -58
  205. package/chunks/{cron-create-IKA56DAF.js → cron-create-IJGVR5R2.js} +4 -4
  206. package/chunks/{cron-delete-K5Q62EGH.js → cron-delete-4N5BI6GL.js} +4 -4
  207. package/chunks/{cron-list-QBFGAMP7.js → cron-list-2CATIPUX.js} +4 -4
  208. package/chunks/{daemon-RZZUPGOJ.js → daemon-NAYK4XXU.js} +51 -24
  209. package/chunks/{daemon-git-worktree-guard-3QY2BQYB.js → daemon-git-worktree-guard-TYLESM6G.js} +338 -92
  210. package/chunks/daemon-status-provider-YBQAZD3G.js +118 -0
  211. package/chunks/daemon-trust-policy-O75ZSIJN.js +114 -0
  212. package/chunks/{daemon-trust-policy-monitor-TK4K7M63.js → daemon-trust-policy-monitor-WWX7I7P6.js} +68 -66
  213. package/chunks/{de-RYUHH2C6.js → de-X6HLSIFE.js} +1 -0
  214. package/chunks/deferred-core-runtime-MGCCR6LA.js +116 -0
  215. package/chunks/{display-image-OEJMJV3S.js → display-image-DR55LL6M.js} +5 -5
  216. package/chunks/dist-4Q7NTUNB.js +2512 -0
  217. package/chunks/{dist-ESS34DHC.js → dist-6H6RZ5H6.js} +2 -2
  218. package/chunks/{dist-LZO24N3E.js → dist-7CKN54NL.js} +1 -1
  219. package/chunks/{dist-5EV2G6MC.js → dist-DJBNNPLN.js} +1 -1
  220. package/chunks/{dist-J6P3C52Z.js → dist-FVJZSIO4.js} +28 -7
  221. package/chunks/{dist-K7IQB53U.js → dist-SATKXKUR.js} +1 -1
  222. package/chunks/{dist-ES6HNUW2.js → dist-TJUDJTCB.js} +246 -17
  223. package/chunks/{dist-VVQBOKDH.js → dist-UQUFZDIY.js} +1 -1
  224. package/chunks/{dist-2OG3PGKO.js → dist-ZBVOXSKF.js} +3 -3
  225. package/chunks/earlyInputCapture-2EJKJET3.js +109 -0
  226. package/chunks/{edit-A2633SLR.js → edit-GBDKI5DZ.js} +48 -48
  227. package/chunks/{en-3RHLPITS.js → en-6MDBWMTG.js} +3 -0
  228. package/chunks/{enter-worktree-OIAHE2TB.js → enter-worktree-UOZ6ZTP7.js} +7 -8
  229. package/chunks/{enterPlanMode-SUGIKLR7.js → enterPlanMode-2KTIPPM3.js} +47 -47
  230. package/chunks/environment-XJ75LJ6N.js +131 -0
  231. package/chunks/errors-XEI3SJRV.js +115 -0
  232. package/chunks/{exit-worktree-3UT3SSWT.js → exit-worktree-G2QATUCV.js} +7 -8
  233. package/chunks/exitPlanMode-AUMYTFIQ.js +85 -0
  234. package/chunks/{fast-path-3AVP3G35.js → fast-path-TU7U2ETU.js} +28 -7
  235. package/chunks/{fast-path-settings-WHX3J3ZI.js → fast-path-settings-XMFBYFUH.js} +2 -2
  236. package/chunks/{fr-4PL5GHG4.js → fr-FTZWF462.js} +1 -0
  237. package/chunks/{gemini-7PVQWHTH.js → gemini-FKMYDP64.js} +129 -123
  238. package/chunks/{geminiContentGenerator-B2FOJJDJ.js → geminiContentGenerator-WSHP7CSR.js} +16 -13
  239. package/chunks/{glob-7YGXE6OV.js → glob-EOM6XK7H.js} +47 -47
  240. package/chunks/{goal-tools-TLJCE7YZ.js → goal-tools-CNVXMSZD.js} +72 -28
  241. package/chunks/{grep-6DV6LTON.js → grep-3NLSS32D.js} +6 -6
  242. package/chunks/handleAutoUpdate-S4CLP36D.js +111 -0
  243. package/chunks/i18n-XX7U2Q3X.js +126 -0
  244. package/chunks/{image-gen-7CSCJ73T.js → image-gen-63NN2H5N.js} +9 -11
  245. package/chunks/initializer-D3CA3272.js +115 -0
  246. package/chunks/installationInfo-HVDQOSIE.js +109 -0
  247. package/chunks/{ja-HZ7X7PQO.js → ja-2GL5FKYJ.js} +1 -0
  248. package/chunks/{keychain-token-storage-MTFTAESK.js → keychain-token-storage-3MGFRYGM.js} +2 -2
  249. package/chunks/list-XUDSTGT3.js +118 -0
  250. package/chunks/{list-agents-43XUEXJV.js → list-agents-EXRSHIDJ.js} +2 -2
  251. package/chunks/loadedSettingsAdapter-ZOJ4QEID.js +112 -0
  252. package/chunks/{loggingContentGenerator-RNE66CKK.js → loggingContentGenerator-TUDGCVUG.js} +27 -30
  253. package/chunks/{loop-wakeup-E54KDUXC.js → loop-wakeup-XBPB2BRO.js} +5 -5
  254. package/chunks/{ls-CGL2UC3H.js → ls-WFONAND2.js} +4 -4
  255. package/chunks/{lsp-5IKUO5DX.js → lsp-DUKPDUXN.js} +2 -2
  256. package/chunks/{managed-npm-update-Y3SC3GLJ.js → managed-npm-update-5K4FWFX2.js} +61 -59
  257. package/chunks/mcp-QJ6AUYE5.js +112 -0
  258. package/chunks/{monitor-PXYSGSUN.js → monitor-UUHIAGT7.js} +47 -47
  259. package/chunks/nonInteractiveCli-PAWO75YO.js +185 -0
  260. package/chunks/{notebook-edit-ISIBJVBR.js → notebook-edit-GZPB3Q57.js} +48 -48
  261. package/chunks/open-with-auth-4UI3KHUR.js +55 -0
  262. package/chunks/{openaiContentGenerator-6TBOPEGT.js → openaiContentGenerator-RPP6YBS3.js} +29 -30
  263. package/chunks/pidfile-RF3WUFKR.js +113 -0
  264. package/chunks/{processUtils-YK2TDTTU.js → processUtils-ENAY2GSA.js} +2 -2
  265. package/chunks/prompt-terminal-ledger-4CCXZ2LF.js +107 -0
  266. package/chunks/{pt-QT5N2Q6Q.js → pt-XN2YWJVM.js} +1 -0
  267. package/chunks/{qwenContentGenerator-CLDMA2Y4.js → qwenContentGenerator-GLUZVJAU.js} +53 -59
  268. package/chunks/{qwenOAuth2-DLDR6UC5.js → qwenOAuth2-JIYAWXTW.js} +8 -10
  269. package/chunks/{read-file-2HOD2ATO.js → read-file-75R5LUWQ.js} +13 -14
  270. package/chunks/{read-mcp-resource-XYES2B42.js → read-mcp-resource-7A7NFSFL.js} +2 -2
  271. package/chunks/read-package-up-6T6ICKR7.js +13 -0
  272. package/chunks/{record-artifact-W3IBTGL7.js → record-artifact-CPJ4IJSD.js} +4 -5
  273. package/chunks/report-findings-VFM5DENC.js +33 -0
  274. package/chunks/request-shutdown-AXVOFN5C.js +133 -0
  275. package/chunks/resumeHistoryUtils-GFPJD2XB.js +120 -0
  276. package/chunks/ripGrep-FNLXQYBS.js +39 -0
  277. package/chunks/{ru-STMG5BPD.js → ru-OLTMFJEW.js} +1 -0
  278. package/chunks/{run-qwen-serve-XJHOW2NY.js → run-qwen-serve-FJD4VMI2.js} +622 -79
  279. package/chunks/{runtime-J4SPTJRQ.js → runtime-INDSJB4K.js} +73 -71
  280. package/chunks/{scheduler-VRAEZZ4E.js → scheduler-Z52TCSUG.js} +62 -60
  281. package/chunks/{sdk-exporters-http-RSIOP3G2.js → sdk-exporters-http-XXSKBD2C.js} +5 -5
  282. package/chunks/{sdk-impl-CB3KARSK.js → sdk-impl-VPNBLV7I.js} +7 -7
  283. package/chunks/{send-message-J4VT46OI.js → send-message-A2GXDX3B.js} +10 -31
  284. package/chunks/serve-GVD2WXVL.js +120 -0
  285. package/chunks/{server-74ONDK62.js → server-PSN5OOSX.js} +965 -405
  286. package/chunks/{session-BO6VBWJP.js → session-JPE34X6Q.js} +151 -140
  287. package/chunks/{settings-35QZNFDG.js → settings-IVGC4UYK.js} +71 -69
  288. package/chunks/shell-A5PZGPBR.js +95 -0
  289. package/chunks/{skill-DKEMQSNJ.js → skill-UUXQPDEH.js} +108 -25
  290. package/chunks/skill-settings-WVRXLTK4.js +120 -0
  291. package/chunks/spawnChannel-KTURLD4B.js +113 -0
  292. package/chunks/standalone-update-IRFRNGAA.js +120 -0
  293. package/chunks/{startInteractiveUI-J2QSGWPU.js → startInteractiveUI-MC4GLL6G.js} +381 -293
  294. package/chunks/{syntheticOutput-JAXMIMZP.js → syntheticOutput-5AJ444QT.js} +3 -3
  295. package/chunks/{task-create-I2H322E4.js → task-create-CDJSOEQD.js} +11 -11
  296. package/chunks/{task-list-3OLIWFTQ.js → task-list-BELMPA75.js} +5 -5
  297. package/chunks/{task-stop-JAUY6MSY.js → task-stop-U3S3KZG2.js} +2 -2
  298. package/chunks/{task-update-B3XO4CPI.js → task-update-77VCFDDZ.js} +11 -11
  299. package/chunks/{team-create-W534PMGX.js → team-create-WO5ZBCFW.js} +48 -48
  300. package/chunks/{team-delete-Q7GE7RRI.js → team-delete-YWFXX77L.js} +5 -5
  301. package/chunks/{team-plan-approval-WNV6P6NG.js → team-plan-approval-KAVKRN7U.js} +47 -47
  302. package/chunks/terminal-image-renderer-SMRRNI6Z.js +116 -0
  303. package/chunks/theme-manager-A7CPN7F4.js +104 -0
  304. package/chunks/{todoWrite-FJJTY2TI.js → todoWrite-435EO2CS.js} +4 -4
  305. package/chunks/{tool-search-Y4KL3LRE.js → tool-search-FBN6OC6U.js} +18 -19
  306. package/chunks/total-session-admission-B7U6UWKQ.js +114 -0
  307. package/chunks/trustedFolders-B4LPJBFK.js +124 -0
  308. package/chunks/{update-relaunch-OHVFN6KF.js → update-relaunch-X5TJVKVG.js} +6 -6
  309. package/chunks/updateCheck-JCLP5JFT.js +120 -0
  310. package/chunks/useAutoAcceptIndicator-VBT3NKDM.js +122 -0
  311. package/chunks/{validateNonInterActiveAuth-WJXH426F.js → validateNonInterActiveAuth-W7HYH5ZN.js} +113 -106
  312. package/chunks/{version-QMDRADXM.js → version-JG4J76GL.js} +2 -2
  313. package/chunks/{web-fetch-ROS6P4LP.js → web-fetch-SPLMEDWF.js} +25 -242
  314. package/chunks/{web-search-JS3E76O6.js → web-search-PNW6OEH6.js} +11 -11
  315. package/chunks/{web-shell-static-3NUTRHAH.js → web-shell-static-A6QMUNNV.js} +11 -4
  316. package/chunks/webapi-Z5OM224P.js +4118 -0
  317. package/chunks/{workflow-2FCMBTBZ.js → workflow-QHOIIXJO.js} +635 -94
  318. package/chunks/workspace-providers-status-653DTR35.js +116 -0
  319. package/chunks/{workspace-registration-store-SU4EJKSD.js → workspace-registration-store-H375IYR2.js} +1 -1
  320. package/chunks/workspace-registry-XTLCD7Z2.js +123 -0
  321. package/chunks/workspace-service-KVJWACCS.js +131 -0
  322. package/chunks/workspace-skills-status-TRJ2VWGU.js +115 -0
  323. package/chunks/{workspace-trust-reconciler-4Y4F7XIX.js → workspace-trust-reconciler-6SC6RKQE.js} +74 -73
  324. package/chunks/write-file-EAZSJZKR.js +90 -0
  325. package/chunks/{zh-TW-NX43Z2S2.js → zh-TW-MV4FWFB6.js} +3 -0
  326. package/chunks/{zh-3JQ75KFU.js → zh-X3WGU6SI.js} +3 -0
  327. package/chunks/{zoom-image-DNBKCGGF.js → zoom-image-WGNPZ572.js} +13 -14
  328. package/cli.js +15 -15
  329. package/locales/ca.js +3 -0
  330. package/locales/de.js +1 -0
  331. package/locales/en.js +3 -0
  332. package/locales/fr.js +1 -0
  333. package/locales/ja.js +1 -0
  334. package/locales/pt.js +1 -0
  335. package/locales/ru.js +1 -0
  336. package/locales/zh-TW.js +3 -0
  337. package/locales/zh.js +3 -0
  338. package/package.json +3 -3
  339. package/web-shell/assets/{abnfDiagram-VCTEODGH-DWHXEVlf.js → abnfDiagram-VCTEODGH-yq7z7Anb.js} +1 -1
  340. package/web-shell/assets/{arc-CXKjm86V.js → arc-CbJO0xnT.js} +1 -1
  341. package/web-shell/assets/{architectureDiagram-5GKGNRK7-B_ynI0cX.js → architectureDiagram-5GKGNRK7-CRh89421.js} +1 -1
  342. package/web-shell/assets/{blockDiagram-NRAW4CY4-DMebd9X0.js → blockDiagram-NRAW4CY4-C75KAhKv.js} +1 -1
  343. package/web-shell/assets/{c4Diagram-UCG6FXSJ-BZ5BlxS-.js → c4Diagram-UCG6FXSJ-BzlMveFB.js} +1 -1
  344. package/web-shell/assets/channel-B3sGR79J.js +1 -0
  345. package/web-shell/assets/{chunk-2Q5K7J3B-CluJKopE.js → chunk-2Q5K7J3B-DA8QDX3a.js} +1 -1
  346. package/web-shell/assets/{chunk-5VM5RSS4-hzDAPFOo.js → chunk-5VM5RSS4-Bgu7gQ7Y.js} +1 -1
  347. package/web-shell/assets/{chunk-F27PBJKO-6vHioKJe.js → chunk-F27PBJKO-BOew7pIK.js} +1 -1
  348. package/web-shell/assets/{chunk-G27WJ6UU-B_5hKTGo.js → chunk-G27WJ6UU-DHx1I-hO.js} +1 -1
  349. package/web-shell/assets/{chunk-JWPE2WC7-CO9VoFCH.js → chunk-JWPE2WC7-SarFW0WU.js} +1 -1
  350. package/web-shell/assets/{chunk-LCL6LL3I-7L5JpxYu.js → chunk-LCL6LL3I-BLzP083Z.js} +1 -1
  351. package/web-shell/assets/{chunk-POPQ4Y6H-DHLJMAqj.js → chunk-POPQ4Y6H-Bmkv_iKm.js} +1 -1
  352. package/web-shell/assets/{chunk-SVP7TREG-Dt-4Cqdl.js → chunk-SVP7TREG-MPx9r1N2.js} +1 -1
  353. package/web-shell/assets/{chunk-XXDRQBXY-QlSQ3ssG.js → chunk-XXDRQBXY-Ck-09rKG.js} +1 -1
  354. package/web-shell/assets/classDiagram-DTDB5LWJ-sTGo0K3v.js +1 -0
  355. package/web-shell/assets/classDiagram-v2-JRS7N3AN-sTGo0K3v.js +1 -0
  356. package/web-shell/assets/{cose-bilkent-JH36ORCC-DMw3EOxl.js → cose-bilkent-JH36ORCC-DWm6lfOG.js} +1 -1
  357. package/web-shell/assets/{cynefin-OW5HDTMX-s6vEA7RQ.js → cynefin-OW5HDTMX-DcBUyr5R.js} +1 -1
  358. package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-AOKsvYLt.js → cynefinDiagram-5FMLGOSQ-Df8qmd_p.js} +1 -1
  359. package/web-shell/assets/{dagre-3AP2YEHR-9QAZn3m7.js → dagre-3AP2YEHR-DDmGspD7.js} +1 -1
  360. package/web-shell/assets/{diagram-S7CK7UJ4-CWpnu4FN.js → diagram-S7CK7UJ4-BK_qFvbi.js} +1 -1
  361. package/web-shell/assets/{diagram-UQ7AKVKN-9l0jXD8q.js → diagram-UQ7AKVKN-Uw3AP_bi.js} +1 -1
  362. package/web-shell/assets/{diagram-VSXAHHWV-BMUHroj4.js → diagram-VSXAHHWV-CJOQKxY7.js} +1 -1
  363. package/web-shell/assets/{diagram-VX7I27RA-Co9x27vm.js → diagram-VX7I27RA-DhdvZna5.js} +1 -1
  364. package/web-shell/assets/{diagram-Z3DM3KII-BKnTeOER.js → diagram-Z3DM3KII-edQU0nlP.js} +1 -1
  365. package/web-shell/assets/{ebnfDiagram-PWID7BFC-QBZD9CKG.js → ebnfDiagram-PWID7BFC-4kugBEsO.js} +1 -1
  366. package/web-shell/assets/{erDiagram-SSCWMZ5O-dKWAEGun.js → erDiagram-SSCWMZ5O-BMkFivWO.js} +1 -1
  367. package/web-shell/assets/{flowDiagram-A5DVABFB-CR_UgVqj.js → flowDiagram-A5DVABFB-BM1ea8g-.js} +1 -1
  368. package/web-shell/assets/{ganttDiagram-EL5Y4UJY-DQUnjWO6.js → ganttDiagram-EL5Y4UJY-CXj_cKRf.js} +1 -1
  369. package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-C4j59wPL.js → gitGraphDiagram-WWUBYQGX-D0nEqwqu.js} +1 -1
  370. package/web-shell/assets/{index-tYXRIPz4.js → index-B6JN54Pd.js} +1 -1
  371. package/web-shell/assets/{index-BN_m_uHJ.css → index-C-XlQn24.css} +1 -1
  372. package/web-shell/assets/index-DLjXM0dn.js +1860 -0
  373. package/web-shell/assets/{infoDiagram-RXCK75RN-mzqbt50w.js → infoDiagram-RXCK75RN-DF7aGGbQ.js} +1 -1
  374. package/web-shell/assets/{ishikawaDiagram-5VMMS53U-ChLOqhGl.js → ishikawaDiagram-5VMMS53U-CZYNX1lL.js} +1 -1
  375. package/web-shell/assets/{journeyDiagram-EYS64GPL-SifZE-R8.js → journeyDiagram-EYS64GPL-CvrqMUz1.js} +1 -1
  376. package/web-shell/assets/{kanban-definition-3QL26DDD-Sft2qlbc.js → kanban-definition-3QL26DDD-BZNJQZBj.js} +1 -1
  377. package/web-shell/assets/{layout-O2uHVkPd.js → layout-Bf83x7D6.js} +1 -1
  378. package/web-shell/assets/{linear-BVqYgjSc.js → linear-Bkc3ES2f.js} +1 -1
  379. package/web-shell/assets/{mermaid.core-CZ9MQaJ6.js → mermaid.core-C6xuovwz.js} +6 -6
  380. package/web-shell/assets/{mindmap-definition-FBJOCRG2-BNQYjBqM.js → mindmap-definition-FBJOCRG2-DzH6gVRg.js} +1 -1
  381. package/web-shell/assets/{pegDiagram-XKGWAZYB-rh1J8uv6.js → pegDiagram-XKGWAZYB-DCvLh2fa.js} +1 -1
  382. package/web-shell/assets/{pieDiagram-E7YTZNPT-BQHR5mn9.js → pieDiagram-E7YTZNPT-BtjVlx_6.js} +1 -1
  383. package/web-shell/assets/{quadrantDiagram-AXDQQJYC-CLCbP7mK.js → quadrantDiagram-AXDQQJYC-IbroqxFe.js} +1 -1
  384. package/web-shell/assets/{railroadDiagram-O6MQD6OU-CDQhrkbm.js → railroadDiagram-O6MQD6OU-BvMykiWW.js} +1 -1
  385. package/web-shell/assets/{requirementDiagram-EFPCY7ZU-BdP9uswg.js → requirementDiagram-EFPCY7ZU-D-HHMyrh.js} +1 -1
  386. package/web-shell/assets/{sankeyDiagram-P5KCCOFB-CFZDFBXF.js → sankeyDiagram-P5KCCOFB-C0XXhB6d.js} +1 -1
  387. package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-BW9WOJXI.js → sequenceDiagram-WJ2MYXX4-DseAXj5d.js} +1 -1
  388. package/web-shell/assets/{sizeCapture-X5ZJPWSS-CPMia32z.js → sizeCapture-X5ZJPWSS-Cek2EweK.js} +1 -1
  389. package/web-shell/assets/{stateDiagram-HBIQ2CUA-BANp9p7F.js → stateDiagram-HBIQ2CUA-yLv8wafW.js} +1 -1
  390. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-DeThXnol.js +1 -0
  391. package/web-shell/assets/{swimlanes-XN3QIQJK-JroXksK-.js → swimlanes-XN3QIQJK-Cwz-opvE.js} +1 -1
  392. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-GW0R1ZSv.js +8 -0
  393. package/web-shell/assets/{timeline-definition-24CTP7MA-DfuVIfYY.js → timeline-definition-24CTP7MA-BJuFD7OG.js} +1 -1
  394. package/web-shell/assets/{vennDiagram-4TSXK5OY-BZXoSjRB.js → vennDiagram-4TSXK5OY-CNAavdoV.js} +1 -1
  395. package/web-shell/assets/{wardleyDiagram-VM6X3IG4-BdiY8avC.js → wardleyDiagram-VM6X3IG4-DaIjAidq.js} +1 -1
  396. package/web-shell/assets/{xychartDiagram-S5SC5T6Z-DcXh_U4H.js → xychartDiagram-S5SC5T6Z-DkcQXjTy.js} +1 -1
  397. package/web-shell/index.html +19 -4
  398. package/chunks/MaxSizedBox-3OZJCC3J.js +0 -110
  399. package/chunks/agent-BFE3DQM3.js +0 -93
  400. package/chunks/agent-headless-LLVKZZ4P.js +0 -87
  401. package/chunks/bridge-EBYO4SYM.js +0 -118
  402. package/chunks/channel-settings-store-5VP2Y2YM.js +0 -115
  403. package/chunks/chunk-AXMWHKXA.js +0 -42
  404. package/chunks/chunk-IO257NUD.js +0 -623
  405. package/chunks/chunk-YHC2EYYG.js +0 -125
  406. package/chunks/computer-use-EGPWFEX6.js +0 -2142
  407. package/chunks/config-utils-WZ43VOBS.js +0 -25
  408. package/chunks/contextCommand-5DSEQI6S.js +0 -106
  409. package/chunks/daemon-status-provider-EYMLPYJU.js +0 -116
  410. package/chunks/daemon-trust-policy-CQYKZ7VO.js +0 -112
  411. package/chunks/deferred-core-runtime-WFEPUXZR.js +0 -114
  412. package/chunks/earlyInputCapture-PN4PP7V5.js +0 -107
  413. package/chunks/environment-WUPHLPKZ.js +0 -127
  414. package/chunks/errors-WPMPVIAT.js +0 -113
  415. package/chunks/exitPlanMode-MLFHYZNB.js +0 -85
  416. package/chunks/handleAutoUpdate-F5OTWUT5.js +0 -109
  417. package/chunks/i18n-C562S6KN.js +0 -124
  418. package/chunks/initializer-7YPGOFP4.js +0 -113
  419. package/chunks/installationInfo-ARU5Q2H7.js +0 -107
  420. package/chunks/list-KTSK275C.js +0 -116
  421. package/chunks/loadedSettingsAdapter-F3T2EQ5J.js +0 -110
  422. package/chunks/mcp-6ONTVPAY.js +0 -110
  423. package/chunks/nonInteractiveCli-KZDWFAN6.js +0 -178
  424. package/chunks/pidfile-IO7ALSZF.js +0 -111
  425. package/chunks/prompt-terminal-ledger-TCE7PMCE.js +0 -105
  426. package/chunks/resumeHistoryUtils-DDSBAQJS.js +0 -118
  427. package/chunks/ripGrep-E7P6K4QR.js +0 -40
  428. package/chunks/serve-KEAWV4TI.js +0 -118
  429. package/chunks/shell-H6K63WG3.js +0 -95
  430. package/chunks/skill-settings-TCKLXIXM.js +0 -118
  431. package/chunks/spawnChannel-2K6NKWM5.js +0 -111
  432. package/chunks/standalone-update-LSCGOEFP.js +0 -118
  433. package/chunks/terminal-image-renderer-UHX3UD66.js +0 -114
  434. package/chunks/theme-manager-6B47ZPIF.js +0 -102
  435. package/chunks/total-session-admission-NSCFWGJH.js +0 -113
  436. package/chunks/trustedFolders-7XMJWGQ3.js +0 -122
  437. package/chunks/updateCheck-EOVLHD4T.js +0 -118
  438. package/chunks/useAutoAcceptIndicator-ZNMIGBTN.js +0 -120
  439. package/chunks/workspace-providers-status-GPGU5YMT.js +0 -113
  440. package/chunks/workspace-registry-BQISXT6Y.js +0 -122
  441. package/chunks/workspace-service-LLY6HCUC.js +0 -129
  442. package/chunks/workspace-skills-status-L5N2Y3ZP.js +0 -113
  443. package/chunks/write-file-EJHU2Z3E.js +0 -90
  444. package/web-shell/assets/channel-Zg3WHgq_.js +0 -1
  445. package/web-shell/assets/classDiagram-DTDB5LWJ-C16l9jQz.js +0 -1
  446. package/web-shell/assets/classDiagram-v2-JRS7N3AN-C16l9jQz.js +0 -1
  447. package/web-shell/assets/index-DrlJu79f.js +0 -1792
  448. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-NZYAoQLU.js +0 -1
  449. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-3YdVX3vj.js +0 -8
@@ -0,0 +1,4118 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import {
4
+ init_esbuild_shims
5
+ } from "./chunk-5O2XNYP6.js";
6
+ import {
7
+ __export,
8
+ __name
9
+ } from "./chunk-J2S4EL5Y.js";
10
+
11
+ // node_modules/jose/dist/webapi/index.js
12
+ init_esbuild_shims();
13
+
14
+ // node_modules/jose/dist/webapi/jwe/compact/decrypt.js
15
+ init_esbuild_shims();
16
+
17
+ // node_modules/jose/dist/webapi/jwe/flattened/decrypt.js
18
+ init_esbuild_shims();
19
+
20
+ // node_modules/jose/dist/webapi/util/base64url.js
21
+ var base64url_exports = {};
22
+ __export(base64url_exports, {
23
+ decode: () => decode,
24
+ encode: () => encode2
25
+ });
26
+ init_esbuild_shims();
27
+
28
+ // node_modules/jose/dist/webapi/lib/buffer_utils.js
29
+ init_esbuild_shims();
30
+ var encoder = new TextEncoder();
31
+ var decoder = new TextDecoder();
32
+ var MAX_INT32 = 2 ** 32;
33
+ function concat(...buffers) {
34
+ const size = buffers.reduce((acc, { length }) => acc + length, 0);
35
+ const buf = new Uint8Array(size);
36
+ let i = 0;
37
+ for (const buffer of buffers) {
38
+ buf.set(buffer, i);
39
+ i += buffer.length;
40
+ }
41
+ return buf;
42
+ }
43
+ __name(concat, "concat");
44
+ function writeUInt32BE(buf, value, offset) {
45
+ if (value < 0 || value >= MAX_INT32) {
46
+ throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);
47
+ }
48
+ buf.set([value >>> 24, value >>> 16, value >>> 8, value & 255], offset);
49
+ }
50
+ __name(writeUInt32BE, "writeUInt32BE");
51
+ function uint64be(value) {
52
+ const high = Math.floor(value / MAX_INT32);
53
+ const low = value % MAX_INT32;
54
+ const buf = new Uint8Array(8);
55
+ writeUInt32BE(buf, high, 0);
56
+ writeUInt32BE(buf, low, 4);
57
+ return buf;
58
+ }
59
+ __name(uint64be, "uint64be");
60
+ function uint32be(value) {
61
+ const buf = new Uint8Array(4);
62
+ writeUInt32BE(buf, value);
63
+ return buf;
64
+ }
65
+ __name(uint32be, "uint32be");
66
+ function encode(string) {
67
+ const bytes = new Uint8Array(string.length);
68
+ for (let i = 0; i < string.length; i++) {
69
+ const code = string.charCodeAt(i);
70
+ if (code > 127) {
71
+ throw new TypeError("non-ASCII string encountered in encode()");
72
+ }
73
+ bytes[i] = code;
74
+ }
75
+ return bytes;
76
+ }
77
+ __name(encode, "encode");
78
+
79
+ // node_modules/jose/dist/webapi/lib/base64.js
80
+ init_esbuild_shims();
81
+ function encodeBase64(input) {
82
+ if (Uint8Array.prototype.toBase64) {
83
+ return input.toBase64();
84
+ }
85
+ const CHUNK_SIZE = 32768;
86
+ const arr = [];
87
+ for (let i = 0; i < input.length; i += CHUNK_SIZE) {
88
+ arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
89
+ }
90
+ return btoa(arr.join(""));
91
+ }
92
+ __name(encodeBase64, "encodeBase64");
93
+ function decodeBase64(encoded) {
94
+ if (Uint8Array.fromBase64) {
95
+ return Uint8Array.fromBase64(encoded);
96
+ }
97
+ const binary = atob(encoded);
98
+ const bytes = new Uint8Array(binary.length);
99
+ for (let i = 0; i < binary.length; i++) {
100
+ bytes[i] = binary.charCodeAt(i);
101
+ }
102
+ return bytes;
103
+ }
104
+ __name(decodeBase64, "decodeBase64");
105
+
106
+ // node_modules/jose/dist/webapi/util/base64url.js
107
+ function decode(input) {
108
+ if (Uint8Array.fromBase64) {
109
+ return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
110
+ alphabet: "base64url"
111
+ });
112
+ }
113
+ let encoded = input;
114
+ if (encoded instanceof Uint8Array) {
115
+ encoded = decoder.decode(encoded);
116
+ }
117
+ encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
118
+ try {
119
+ return decodeBase64(encoded);
120
+ } catch {
121
+ throw new TypeError("The input to be decoded is not correctly encoded.");
122
+ }
123
+ }
124
+ __name(decode, "decode");
125
+ function encode2(input) {
126
+ let unencoded = input;
127
+ if (typeof unencoded === "string") {
128
+ unencoded = encoder.encode(unencoded);
129
+ }
130
+ if (Uint8Array.prototype.toBase64) {
131
+ return unencoded.toBase64({ alphabet: "base64url", omitPadding: true });
132
+ }
133
+ return encodeBase64(unencoded).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
134
+ }
135
+ __name(encode2, "encode");
136
+
137
+ // node_modules/jose/dist/webapi/lib/decrypt.js
138
+ init_esbuild_shims();
139
+
140
+ // node_modules/jose/dist/webapi/lib/check_iv_length.js
141
+ init_esbuild_shims();
142
+
143
+ // node_modules/jose/dist/webapi/util/errors.js
144
+ var errors_exports = {};
145
+ __export(errors_exports, {
146
+ JOSEAlgNotAllowed: () => JOSEAlgNotAllowed,
147
+ JOSEError: () => JOSEError,
148
+ JOSENotSupported: () => JOSENotSupported,
149
+ JWEDecryptionFailed: () => JWEDecryptionFailed,
150
+ JWEInvalid: () => JWEInvalid,
151
+ JWKInvalid: () => JWKInvalid,
152
+ JWKSInvalid: () => JWKSInvalid,
153
+ JWKSMultipleMatchingKeys: () => JWKSMultipleMatchingKeys,
154
+ JWKSNoMatchingKey: () => JWKSNoMatchingKey,
155
+ JWKSTimeout: () => JWKSTimeout,
156
+ JWSInvalid: () => JWSInvalid,
157
+ JWSSignatureVerificationFailed: () => JWSSignatureVerificationFailed,
158
+ JWTClaimValidationFailed: () => JWTClaimValidationFailed,
159
+ JWTExpired: () => JWTExpired,
160
+ JWTInvalid: () => JWTInvalid
161
+ });
162
+ init_esbuild_shims();
163
+ var JOSEError = class extends Error {
164
+ static {
165
+ __name(this, "JOSEError");
166
+ }
167
+ static code = "ERR_JOSE_GENERIC";
168
+ code = "ERR_JOSE_GENERIC";
169
+ constructor(message2, options) {
170
+ super(message2, options);
171
+ this.name = this.constructor.name;
172
+ Error.captureStackTrace?.(this, this.constructor);
173
+ }
174
+ };
175
+ var JWTClaimValidationFailed = class extends JOSEError {
176
+ static {
177
+ __name(this, "JWTClaimValidationFailed");
178
+ }
179
+ static code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
180
+ code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
181
+ claim;
182
+ reason;
183
+ payload;
184
+ constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
185
+ super(message2, { cause: { claim, reason, payload } });
186
+ this.claim = claim;
187
+ this.reason = reason;
188
+ this.payload = payload;
189
+ }
190
+ };
191
+ var JWTExpired = class extends JOSEError {
192
+ static {
193
+ __name(this, "JWTExpired");
194
+ }
195
+ static code = "ERR_JWT_EXPIRED";
196
+ code = "ERR_JWT_EXPIRED";
197
+ claim;
198
+ reason;
199
+ payload;
200
+ constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
201
+ super(message2, { cause: { claim, reason, payload } });
202
+ this.claim = claim;
203
+ this.reason = reason;
204
+ this.payload = payload;
205
+ }
206
+ };
207
+ var JOSEAlgNotAllowed = class extends JOSEError {
208
+ static {
209
+ __name(this, "JOSEAlgNotAllowed");
210
+ }
211
+ static code = "ERR_JOSE_ALG_NOT_ALLOWED";
212
+ code = "ERR_JOSE_ALG_NOT_ALLOWED";
213
+ };
214
+ var JOSENotSupported = class extends JOSEError {
215
+ static {
216
+ __name(this, "JOSENotSupported");
217
+ }
218
+ static code = "ERR_JOSE_NOT_SUPPORTED";
219
+ code = "ERR_JOSE_NOT_SUPPORTED";
220
+ };
221
+ var JWEDecryptionFailed = class extends JOSEError {
222
+ static {
223
+ __name(this, "JWEDecryptionFailed");
224
+ }
225
+ static code = "ERR_JWE_DECRYPTION_FAILED";
226
+ code = "ERR_JWE_DECRYPTION_FAILED";
227
+ constructor(message2 = "decryption operation failed", options) {
228
+ super(message2, options);
229
+ }
230
+ };
231
+ var JWEInvalid = class extends JOSEError {
232
+ static {
233
+ __name(this, "JWEInvalid");
234
+ }
235
+ static code = "ERR_JWE_INVALID";
236
+ code = "ERR_JWE_INVALID";
237
+ };
238
+ var JWSInvalid = class extends JOSEError {
239
+ static {
240
+ __name(this, "JWSInvalid");
241
+ }
242
+ static code = "ERR_JWS_INVALID";
243
+ code = "ERR_JWS_INVALID";
244
+ };
245
+ var JWTInvalid = class extends JOSEError {
246
+ static {
247
+ __name(this, "JWTInvalid");
248
+ }
249
+ static code = "ERR_JWT_INVALID";
250
+ code = "ERR_JWT_INVALID";
251
+ };
252
+ var JWKInvalid = class extends JOSEError {
253
+ static {
254
+ __name(this, "JWKInvalid");
255
+ }
256
+ static code = "ERR_JWK_INVALID";
257
+ code = "ERR_JWK_INVALID";
258
+ };
259
+ var JWKSInvalid = class extends JOSEError {
260
+ static {
261
+ __name(this, "JWKSInvalid");
262
+ }
263
+ static code = "ERR_JWKS_INVALID";
264
+ code = "ERR_JWKS_INVALID";
265
+ };
266
+ var JWKSNoMatchingKey = class extends JOSEError {
267
+ static {
268
+ __name(this, "JWKSNoMatchingKey");
269
+ }
270
+ static code = "ERR_JWKS_NO_MATCHING_KEY";
271
+ code = "ERR_JWKS_NO_MATCHING_KEY";
272
+ constructor(message2 = "no applicable key found in the JSON Web Key Set", options) {
273
+ super(message2, options);
274
+ }
275
+ };
276
+ var JWKSMultipleMatchingKeys = class extends JOSEError {
277
+ static {
278
+ __name(this, "JWKSMultipleMatchingKeys");
279
+ }
280
+ [Symbol.asyncIterator];
281
+ static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
282
+ code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
283
+ constructor(message2 = "multiple matching keys found in the JSON Web Key Set", options) {
284
+ super(message2, options);
285
+ }
286
+ };
287
+ var JWKSTimeout = class extends JOSEError {
288
+ static {
289
+ __name(this, "JWKSTimeout");
290
+ }
291
+ static code = "ERR_JWKS_TIMEOUT";
292
+ code = "ERR_JWKS_TIMEOUT";
293
+ constructor(message2 = "request timed out", options) {
294
+ super(message2, options);
295
+ }
296
+ };
297
+ var JWSSignatureVerificationFailed = class extends JOSEError {
298
+ static {
299
+ __name(this, "JWSSignatureVerificationFailed");
300
+ }
301
+ static code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
302
+ code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
303
+ constructor(message2 = "signature verification failed", options) {
304
+ super(message2, options);
305
+ }
306
+ };
307
+
308
+ // node_modules/jose/dist/webapi/lib/iv.js
309
+ init_esbuild_shims();
310
+ function bitLength(alg) {
311
+ switch (alg) {
312
+ case "A128GCM":
313
+ case "A128GCMKW":
314
+ case "A192GCM":
315
+ case "A192GCMKW":
316
+ case "A256GCM":
317
+ case "A256GCMKW":
318
+ return 96;
319
+ case "A128CBC-HS256":
320
+ case "A192CBC-HS384":
321
+ case "A256CBC-HS512":
322
+ return 128;
323
+ default:
324
+ throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);
325
+ }
326
+ }
327
+ __name(bitLength, "bitLength");
328
+ var generateIv = /* @__PURE__ */ __name((alg) => crypto.getRandomValues(new Uint8Array(bitLength(alg) >> 3)), "generateIv");
329
+
330
+ // node_modules/jose/dist/webapi/lib/check_iv_length.js
331
+ function checkIvLength(enc, iv) {
332
+ if (iv.length << 3 !== bitLength(enc)) {
333
+ throw new JWEInvalid("Invalid Initialization Vector length");
334
+ }
335
+ }
336
+ __name(checkIvLength, "checkIvLength");
337
+
338
+ // node_modules/jose/dist/webapi/lib/check_cek_length.js
339
+ init_esbuild_shims();
340
+ function checkCekLength(cek, expected) {
341
+ const actual = cek.byteLength << 3;
342
+ if (actual !== expected) {
343
+ throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
344
+ }
345
+ }
346
+ __name(checkCekLength, "checkCekLength");
347
+
348
+ // node_modules/jose/dist/webapi/lib/crypto_key.js
349
+ init_esbuild_shims();
350
+ var unusable = /* @__PURE__ */ __name((name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`), "unusable");
351
+ var isAlgorithm = /* @__PURE__ */ __name((algorithm, name) => algorithm.name === name, "isAlgorithm");
352
+ function getHashLength(hash) {
353
+ return parseInt(hash.name.slice(4), 10);
354
+ }
355
+ __name(getHashLength, "getHashLength");
356
+ function getNamedCurve(alg) {
357
+ switch (alg) {
358
+ case "ES256":
359
+ return "P-256";
360
+ case "ES384":
361
+ return "P-384";
362
+ case "ES512":
363
+ return "P-521";
364
+ default:
365
+ throw new Error("unreachable");
366
+ }
367
+ }
368
+ __name(getNamedCurve, "getNamedCurve");
369
+ function checkUsage(key, usage) {
370
+ if (usage && !key.usages.includes(usage)) {
371
+ throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
372
+ }
373
+ }
374
+ __name(checkUsage, "checkUsage");
375
+ function checkSigCryptoKey(key, alg, usage) {
376
+ switch (alg) {
377
+ case "HS256":
378
+ case "HS384":
379
+ case "HS512": {
380
+ if (!isAlgorithm(key.algorithm, "HMAC"))
381
+ throw unusable("HMAC");
382
+ const expected = parseInt(alg.slice(2), 10);
383
+ const actual = getHashLength(key.algorithm.hash);
384
+ if (actual !== expected)
385
+ throw unusable(`SHA-${expected}`, "algorithm.hash");
386
+ break;
387
+ }
388
+ case "RS256":
389
+ case "RS384":
390
+ case "RS512": {
391
+ if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
392
+ throw unusable("RSASSA-PKCS1-v1_5");
393
+ const expected = parseInt(alg.slice(2), 10);
394
+ const actual = getHashLength(key.algorithm.hash);
395
+ if (actual !== expected)
396
+ throw unusable(`SHA-${expected}`, "algorithm.hash");
397
+ break;
398
+ }
399
+ case "PS256":
400
+ case "PS384":
401
+ case "PS512": {
402
+ if (!isAlgorithm(key.algorithm, "RSA-PSS"))
403
+ throw unusable("RSA-PSS");
404
+ const expected = parseInt(alg.slice(2), 10);
405
+ const actual = getHashLength(key.algorithm.hash);
406
+ if (actual !== expected)
407
+ throw unusable(`SHA-${expected}`, "algorithm.hash");
408
+ break;
409
+ }
410
+ case "Ed25519":
411
+ case "EdDSA": {
412
+ if (!isAlgorithm(key.algorithm, "Ed25519"))
413
+ throw unusable("Ed25519");
414
+ break;
415
+ }
416
+ case "ML-DSA-44":
417
+ case "ML-DSA-65":
418
+ case "ML-DSA-87": {
419
+ if (!isAlgorithm(key.algorithm, alg))
420
+ throw unusable(alg);
421
+ break;
422
+ }
423
+ case "ES256":
424
+ case "ES384":
425
+ case "ES512": {
426
+ if (!isAlgorithm(key.algorithm, "ECDSA"))
427
+ throw unusable("ECDSA");
428
+ const expected = getNamedCurve(alg);
429
+ const actual = key.algorithm.namedCurve;
430
+ if (actual !== expected)
431
+ throw unusable(expected, "algorithm.namedCurve");
432
+ break;
433
+ }
434
+ default:
435
+ throw new TypeError("CryptoKey does not support this operation");
436
+ }
437
+ checkUsage(key, usage);
438
+ }
439
+ __name(checkSigCryptoKey, "checkSigCryptoKey");
440
+ function checkEncCryptoKey(key, alg, usage) {
441
+ switch (alg) {
442
+ case "A128GCM":
443
+ case "A192GCM":
444
+ case "A256GCM": {
445
+ if (!isAlgorithm(key.algorithm, "AES-GCM"))
446
+ throw unusable("AES-GCM");
447
+ const expected = parseInt(alg.slice(1, 4), 10);
448
+ const actual = key.algorithm.length;
449
+ if (actual !== expected)
450
+ throw unusable(expected, "algorithm.length");
451
+ break;
452
+ }
453
+ case "A128KW":
454
+ case "A192KW":
455
+ case "A256KW": {
456
+ if (!isAlgorithm(key.algorithm, "AES-KW"))
457
+ throw unusable("AES-KW");
458
+ const expected = parseInt(alg.slice(1, 4), 10);
459
+ const actual = key.algorithm.length;
460
+ if (actual !== expected)
461
+ throw unusable(expected, "algorithm.length");
462
+ break;
463
+ }
464
+ case "ECDH": {
465
+ switch (key.algorithm.name) {
466
+ case "ECDH":
467
+ case "X25519":
468
+ break;
469
+ default:
470
+ throw unusable("ECDH or X25519");
471
+ }
472
+ break;
473
+ }
474
+ case "PBES2-HS256+A128KW":
475
+ case "PBES2-HS384+A192KW":
476
+ case "PBES2-HS512+A256KW":
477
+ if (!isAlgorithm(key.algorithm, "PBKDF2"))
478
+ throw unusable("PBKDF2");
479
+ break;
480
+ case "RSA-OAEP":
481
+ case "RSA-OAEP-256":
482
+ case "RSA-OAEP-384":
483
+ case "RSA-OAEP-512": {
484
+ if (!isAlgorithm(key.algorithm, "RSA-OAEP"))
485
+ throw unusable("RSA-OAEP");
486
+ const expected = parseInt(alg.slice(9), 10) || 1;
487
+ const actual = getHashLength(key.algorithm.hash);
488
+ if (actual !== expected)
489
+ throw unusable(`SHA-${expected}`, "algorithm.hash");
490
+ break;
491
+ }
492
+ default:
493
+ throw new TypeError("CryptoKey does not support this operation");
494
+ }
495
+ checkUsage(key, usage);
496
+ }
497
+ __name(checkEncCryptoKey, "checkEncCryptoKey");
498
+
499
+ // node_modules/jose/dist/webapi/lib/invalid_key_input.js
500
+ init_esbuild_shims();
501
+ function message(msg, actual, ...types) {
502
+ types = types.filter(Boolean);
503
+ if (types.length > 2) {
504
+ const last = types.pop();
505
+ msg += `one of type ${types.join(", ")}, or ${last}.`;
506
+ } else if (types.length === 2) {
507
+ msg += `one of type ${types[0]} or ${types[1]}.`;
508
+ } else {
509
+ msg += `of type ${types[0]}.`;
510
+ }
511
+ if (actual == null) {
512
+ msg += ` Received ${actual}`;
513
+ } else if (typeof actual === "function" && actual.name) {
514
+ msg += ` Received function ${actual.name}`;
515
+ } else if (typeof actual === "object" && actual != null) {
516
+ if (actual.constructor?.name) {
517
+ msg += ` Received an instance of ${actual.constructor.name}`;
518
+ }
519
+ }
520
+ return msg;
521
+ }
522
+ __name(message, "message");
523
+ var invalidKeyInput = /* @__PURE__ */ __name((actual, ...types) => message("Key must be ", actual, ...types), "invalidKeyInput");
524
+ var withAlg = /* @__PURE__ */ __name((alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types), "withAlg");
525
+
526
+ // node_modules/jose/dist/webapi/lib/is_key_like.js
527
+ init_esbuild_shims();
528
+ function assertCryptoKey(key) {
529
+ if (!isCryptoKey(key)) {
530
+ throw new Error("CryptoKey instance expected");
531
+ }
532
+ }
533
+ __name(assertCryptoKey, "assertCryptoKey");
534
+ var isCryptoKey = /* @__PURE__ */ __name((key) => {
535
+ if (key?.[Symbol.toStringTag] === "CryptoKey")
536
+ return true;
537
+ try {
538
+ return key instanceof CryptoKey;
539
+ } catch {
540
+ return false;
541
+ }
542
+ }, "isCryptoKey");
543
+ var isKeyObject = /* @__PURE__ */ __name((key) => key?.[Symbol.toStringTag] === "KeyObject", "isKeyObject");
544
+ var isKeyLike = /* @__PURE__ */ __name((key) => isCryptoKey(key) || isKeyObject(key), "isKeyLike");
545
+
546
+ // node_modules/jose/dist/webapi/lib/decrypt.js
547
+ async function timingSafeEqual(a, b) {
548
+ if (!(a instanceof Uint8Array)) {
549
+ throw new TypeError("First argument must be a buffer");
550
+ }
551
+ if (!(b instanceof Uint8Array)) {
552
+ throw new TypeError("Second argument must be a buffer");
553
+ }
554
+ const algorithm = { name: "HMAC", hash: "SHA-256" };
555
+ const key = await crypto.subtle.generateKey(algorithm, false, ["sign"]);
556
+ const aHmac = new Uint8Array(await crypto.subtle.sign(algorithm, key, a));
557
+ const bHmac = new Uint8Array(await crypto.subtle.sign(algorithm, key, b));
558
+ let out = 0;
559
+ let i = -1;
560
+ while (++i < 32) {
561
+ out |= aHmac[i] ^ bHmac[i];
562
+ }
563
+ return out === 0;
564
+ }
565
+ __name(timingSafeEqual, "timingSafeEqual");
566
+ async function cbcDecrypt(enc, cek, ciphertext, iv, tag2, aad) {
567
+ if (!(cek instanceof Uint8Array)) {
568
+ throw new TypeError(invalidKeyInput(cek, "Uint8Array"));
569
+ }
570
+ const keySize = parseInt(enc.slice(1, 4), 10);
571
+ const encKey = await crypto.subtle.importKey("raw", cek.subarray(keySize >> 3), "AES-CBC", false, ["decrypt"]);
572
+ const macKey = await crypto.subtle.importKey("raw", cek.subarray(0, keySize >> 3), {
573
+ hash: `SHA-${keySize << 1}`,
574
+ name: "HMAC"
575
+ }, false, ["sign"]);
576
+ const macData = concat(aad, iv, ciphertext, uint64be(aad.length << 3));
577
+ const expectedTag = new Uint8Array((await crypto.subtle.sign("HMAC", macKey, macData)).slice(0, keySize >> 3));
578
+ let macCheckPassed;
579
+ try {
580
+ macCheckPassed = await timingSafeEqual(tag2, expectedTag);
581
+ } catch {
582
+ }
583
+ if (!macCheckPassed) {
584
+ throw new JWEDecryptionFailed();
585
+ }
586
+ let plaintext;
587
+ try {
588
+ plaintext = new Uint8Array(await crypto.subtle.decrypt({ iv, name: "AES-CBC" }, encKey, ciphertext));
589
+ } catch {
590
+ }
591
+ if (!plaintext) {
592
+ throw new JWEDecryptionFailed();
593
+ }
594
+ return plaintext;
595
+ }
596
+ __name(cbcDecrypt, "cbcDecrypt");
597
+ async function gcmDecrypt(enc, cek, ciphertext, iv, tag2, aad) {
598
+ let encKey;
599
+ if (cek instanceof Uint8Array) {
600
+ encKey = await crypto.subtle.importKey("raw", cek, "AES-GCM", false, ["decrypt"]);
601
+ } else {
602
+ checkEncCryptoKey(cek, enc, "decrypt");
603
+ encKey = cek;
604
+ }
605
+ try {
606
+ return new Uint8Array(await crypto.subtle.decrypt({
607
+ additionalData: aad,
608
+ iv,
609
+ name: "AES-GCM",
610
+ tagLength: 128
611
+ }, encKey, concat(ciphertext, tag2)));
612
+ } catch {
613
+ throw new JWEDecryptionFailed();
614
+ }
615
+ }
616
+ __name(gcmDecrypt, "gcmDecrypt");
617
+ async function decrypt(enc, cek, ciphertext, iv, tag2, aad) {
618
+ if (!isCryptoKey(cek) && !(cek instanceof Uint8Array)) {
619
+ throw new TypeError(invalidKeyInput(cek, "CryptoKey", "KeyObject", "Uint8Array", "JSON Web Key"));
620
+ }
621
+ if (!iv) {
622
+ throw new JWEInvalid("JWE Initialization Vector missing");
623
+ }
624
+ if (!tag2) {
625
+ throw new JWEInvalid("JWE Authentication Tag missing");
626
+ }
627
+ checkIvLength(enc, iv);
628
+ switch (enc) {
629
+ case "A128CBC-HS256":
630
+ case "A192CBC-HS384":
631
+ case "A256CBC-HS512":
632
+ if (cek instanceof Uint8Array)
633
+ checkCekLength(cek, parseInt(enc.slice(-3), 10));
634
+ return cbcDecrypt(enc, cek, ciphertext, iv, tag2, aad);
635
+ case "A128GCM":
636
+ case "A192GCM":
637
+ case "A256GCM":
638
+ if (cek instanceof Uint8Array)
639
+ checkCekLength(cek, parseInt(enc.slice(1, 4), 10));
640
+ return gcmDecrypt(enc, cek, ciphertext, iv, tag2, aad);
641
+ default:
642
+ throw new JOSENotSupported("Unsupported JWE Content Encryption Algorithm");
643
+ }
644
+ }
645
+ __name(decrypt, "decrypt");
646
+
647
+ // node_modules/jose/dist/webapi/lib/is_disjoint.js
648
+ init_esbuild_shims();
649
+ function isDisjoint(...headers) {
650
+ const sources = headers.filter(Boolean);
651
+ if (sources.length === 0 || sources.length === 1) {
652
+ return true;
653
+ }
654
+ let acc;
655
+ for (const header of sources) {
656
+ const parameters = Object.keys(header);
657
+ if (!acc || acc.size === 0) {
658
+ acc = new Set(parameters);
659
+ continue;
660
+ }
661
+ for (const parameter of parameters) {
662
+ if (acc.has(parameter)) {
663
+ return false;
664
+ }
665
+ acc.add(parameter);
666
+ }
667
+ }
668
+ return true;
669
+ }
670
+ __name(isDisjoint, "isDisjoint");
671
+
672
+ // node_modules/jose/dist/webapi/lib/is_object.js
673
+ init_esbuild_shims();
674
+ var isObjectLike = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null, "isObjectLike");
675
+ function isObject(input) {
676
+ if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
677
+ return false;
678
+ }
679
+ if (Object.getPrototypeOf(input) === null) {
680
+ return true;
681
+ }
682
+ let proto = input;
683
+ while (Object.getPrototypeOf(proto) !== null) {
684
+ proto = Object.getPrototypeOf(proto);
685
+ }
686
+ return Object.getPrototypeOf(input) === proto;
687
+ }
688
+ __name(isObject, "isObject");
689
+
690
+ // node_modules/jose/dist/webapi/lib/decrypt_key_management.js
691
+ init_esbuild_shims();
692
+
693
+ // node_modules/jose/dist/webapi/lib/aeskw.js
694
+ init_esbuild_shims();
695
+ function checkKeySize(key, alg) {
696
+ if (key.algorithm.length !== parseInt(alg.slice(1, 4), 10)) {
697
+ throw new TypeError(`Invalid key size for alg: ${alg}`);
698
+ }
699
+ }
700
+ __name(checkKeySize, "checkKeySize");
701
+ function getCryptoKey(key, alg, usage) {
702
+ if (key instanceof Uint8Array) {
703
+ return crypto.subtle.importKey("raw", key, "AES-KW", true, [usage]);
704
+ }
705
+ checkEncCryptoKey(key, alg, usage);
706
+ return key;
707
+ }
708
+ __name(getCryptoKey, "getCryptoKey");
709
+ async function wrap(alg, key, cek) {
710
+ const cryptoKey = await getCryptoKey(key, alg, "wrapKey");
711
+ checkKeySize(cryptoKey, alg);
712
+ const cryptoKeyCek = await crypto.subtle.importKey("raw", cek, { hash: "SHA-256", name: "HMAC" }, true, ["sign"]);
713
+ return new Uint8Array(await crypto.subtle.wrapKey("raw", cryptoKeyCek, cryptoKey, "AES-KW"));
714
+ }
715
+ __name(wrap, "wrap");
716
+ async function unwrap(alg, key, encryptedKey) {
717
+ const cryptoKey = await getCryptoKey(key, alg, "unwrapKey");
718
+ checkKeySize(cryptoKey, alg);
719
+ const cryptoKeyCek = await crypto.subtle.unwrapKey("raw", encryptedKey, cryptoKey, "AES-KW", { hash: "SHA-256", name: "HMAC" }, true, ["sign"]);
720
+ return new Uint8Array(await crypto.subtle.exportKey("raw", cryptoKeyCek));
721
+ }
722
+ __name(unwrap, "unwrap");
723
+
724
+ // node_modules/jose/dist/webapi/lib/ecdhes.js
725
+ init_esbuild_shims();
726
+
727
+ // node_modules/jose/dist/webapi/lib/digest.js
728
+ init_esbuild_shims();
729
+ async function digest(algorithm, data) {
730
+ const subtleDigest = `SHA-${algorithm.slice(-3)}`;
731
+ return new Uint8Array(await crypto.subtle.digest(subtleDigest, data));
732
+ }
733
+ __name(digest, "digest");
734
+
735
+ // node_modules/jose/dist/webapi/lib/ecdhes.js
736
+ function lengthAndInput(input) {
737
+ return concat(uint32be(input.length), input);
738
+ }
739
+ __name(lengthAndInput, "lengthAndInput");
740
+ async function concatKdf(Z, L, OtherInfo) {
741
+ const dkLen = L >> 3;
742
+ const hashLen = 32;
743
+ const reps = Math.ceil(dkLen / hashLen);
744
+ const dk = new Uint8Array(reps * hashLen);
745
+ for (let i = 1; i <= reps; i++) {
746
+ const hashInput = new Uint8Array(4 + Z.length + OtherInfo.length);
747
+ hashInput.set(uint32be(i), 0);
748
+ hashInput.set(Z, 4);
749
+ hashInput.set(OtherInfo, 4 + Z.length);
750
+ const hashResult = await digest("sha256", hashInput);
751
+ dk.set(hashResult, (i - 1) * hashLen);
752
+ }
753
+ return dk.slice(0, dkLen);
754
+ }
755
+ __name(concatKdf, "concatKdf");
756
+ async function deriveKey(publicKey, privateKey, algorithm, keyLength, apu = new Uint8Array(), apv = new Uint8Array()) {
757
+ checkEncCryptoKey(publicKey, "ECDH");
758
+ checkEncCryptoKey(privateKey, "ECDH", "deriveBits");
759
+ const algorithmID = lengthAndInput(encode(algorithm));
760
+ const partyUInfo = lengthAndInput(apu);
761
+ const partyVInfo = lengthAndInput(apv);
762
+ const suppPubInfo = uint32be(keyLength);
763
+ const suppPrivInfo = new Uint8Array();
764
+ const otherInfo = concat(algorithmID, partyUInfo, partyVInfo, suppPubInfo, suppPrivInfo);
765
+ const Z = new Uint8Array(await crypto.subtle.deriveBits({
766
+ name: publicKey.algorithm.name,
767
+ public: publicKey
768
+ }, privateKey, getEcdhBitLength(publicKey)));
769
+ return concatKdf(Z, keyLength, otherInfo);
770
+ }
771
+ __name(deriveKey, "deriveKey");
772
+ function getEcdhBitLength(publicKey) {
773
+ if (publicKey.algorithm.name === "X25519") {
774
+ return 256;
775
+ }
776
+ return Math.ceil(parseInt(publicKey.algorithm.namedCurve.slice(-3), 10) / 8) << 3;
777
+ }
778
+ __name(getEcdhBitLength, "getEcdhBitLength");
779
+ function allowed(key) {
780
+ switch (key.algorithm.namedCurve) {
781
+ case "P-256":
782
+ case "P-384":
783
+ case "P-521":
784
+ return true;
785
+ default:
786
+ return key.algorithm.name === "X25519";
787
+ }
788
+ }
789
+ __name(allowed, "allowed");
790
+
791
+ // node_modules/jose/dist/webapi/lib/pbes2kw.js
792
+ init_esbuild_shims();
793
+ function getCryptoKey2(key, alg) {
794
+ if (key instanceof Uint8Array) {
795
+ return crypto.subtle.importKey("raw", key, "PBKDF2", false, [
796
+ "deriveBits"
797
+ ]);
798
+ }
799
+ checkEncCryptoKey(key, alg, "deriveBits");
800
+ return key;
801
+ }
802
+ __name(getCryptoKey2, "getCryptoKey");
803
+ var concatSalt = /* @__PURE__ */ __name((alg, p2sInput) => concat(encode(alg), Uint8Array.of(0), p2sInput), "concatSalt");
804
+ async function deriveKey2(p2s, alg, p2c, key) {
805
+ if (!(p2s instanceof Uint8Array) || p2s.length < 8) {
806
+ throw new JWEInvalid("PBES2 Salt Input must be 8 or more octets");
807
+ }
808
+ const salt = concatSalt(alg, p2s);
809
+ const keylen = parseInt(alg.slice(13, 16), 10);
810
+ const subtleAlg = {
811
+ hash: `SHA-${alg.slice(8, 11)}`,
812
+ iterations: p2c,
813
+ name: "PBKDF2",
814
+ salt
815
+ };
816
+ const cryptoKey = await getCryptoKey2(key, alg);
817
+ return new Uint8Array(await crypto.subtle.deriveBits(subtleAlg, cryptoKey, keylen));
818
+ }
819
+ __name(deriveKey2, "deriveKey");
820
+ async function wrap2(alg, key, cek, p2c = 2048, p2s = crypto.getRandomValues(new Uint8Array(16))) {
821
+ const derived = await deriveKey2(p2s, alg, p2c, key);
822
+ const encryptedKey = await wrap(alg.slice(-6), derived, cek);
823
+ return { encryptedKey, p2c, p2s: encode2(p2s) };
824
+ }
825
+ __name(wrap2, "wrap");
826
+ async function unwrap2(alg, key, encryptedKey, p2c, p2s) {
827
+ const derived = await deriveKey2(p2s, alg, p2c, key);
828
+ return unwrap(alg.slice(-6), derived, encryptedKey);
829
+ }
830
+ __name(unwrap2, "unwrap");
831
+
832
+ // node_modules/jose/dist/webapi/lib/rsaes.js
833
+ init_esbuild_shims();
834
+
835
+ // node_modules/jose/dist/webapi/lib/check_key_length.js
836
+ init_esbuild_shims();
837
+ function checkKeyLength(alg, key) {
838
+ if (alg.startsWith("RS") || alg.startsWith("PS")) {
839
+ const { modulusLength } = key.algorithm;
840
+ if (typeof modulusLength !== "number" || modulusLength < 2048) {
841
+ throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
842
+ }
843
+ }
844
+ }
845
+ __name(checkKeyLength, "checkKeyLength");
846
+
847
+ // node_modules/jose/dist/webapi/lib/rsaes.js
848
+ var subtleAlgorithm = /* @__PURE__ */ __name((alg) => {
849
+ switch (alg) {
850
+ case "RSA-OAEP":
851
+ case "RSA-OAEP-256":
852
+ case "RSA-OAEP-384":
853
+ case "RSA-OAEP-512":
854
+ return "RSA-OAEP";
855
+ default:
856
+ throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
857
+ }
858
+ }, "subtleAlgorithm");
859
+ async function encrypt(alg, key, cek) {
860
+ checkEncCryptoKey(key, alg, "encrypt");
861
+ checkKeyLength(alg, key);
862
+ return new Uint8Array(await crypto.subtle.encrypt(subtleAlgorithm(alg), key, cek));
863
+ }
864
+ __name(encrypt, "encrypt");
865
+ async function decrypt2(alg, key, encryptedKey) {
866
+ checkEncCryptoKey(key, alg, "decrypt");
867
+ checkKeyLength(alg, key);
868
+ return new Uint8Array(await crypto.subtle.decrypt(subtleAlgorithm(alg), key, encryptedKey));
869
+ }
870
+ __name(decrypt2, "decrypt");
871
+
872
+ // node_modules/jose/dist/webapi/lib/cek.js
873
+ init_esbuild_shims();
874
+ function cekLength(alg) {
875
+ switch (alg) {
876
+ case "A128GCM":
877
+ return 128;
878
+ case "A192GCM":
879
+ return 192;
880
+ case "A256GCM":
881
+ case "A128CBC-HS256":
882
+ return 256;
883
+ case "A192CBC-HS384":
884
+ return 384;
885
+ case "A256CBC-HS512":
886
+ return 512;
887
+ default:
888
+ throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);
889
+ }
890
+ }
891
+ __name(cekLength, "cekLength");
892
+ var generateCek = /* @__PURE__ */ __name((alg) => crypto.getRandomValues(new Uint8Array(cekLength(alg) >> 3)), "generateCek");
893
+
894
+ // node_modules/jose/dist/webapi/key/import.js
895
+ init_esbuild_shims();
896
+
897
+ // node_modules/jose/dist/webapi/lib/asn1.js
898
+ init_esbuild_shims();
899
+ var formatPEM = /* @__PURE__ */ __name((b64, descriptor) => {
900
+ const newlined = (b64.match(/.{1,64}/g) || []).join("\n");
901
+ return `-----BEGIN ${descriptor}-----
902
+ ${newlined}
903
+ -----END ${descriptor}-----`;
904
+ }, "formatPEM");
905
+ var genericExport = /* @__PURE__ */ __name(async (keyType, keyFormat, key) => {
906
+ if (isKeyObject(key)) {
907
+ if (key.type !== keyType) {
908
+ throw new TypeError(`key is not a ${keyType} key`);
909
+ }
910
+ return key.export({ format: "pem", type: keyFormat });
911
+ }
912
+ if (!isCryptoKey(key)) {
913
+ throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject"));
914
+ }
915
+ if (!key.extractable) {
916
+ throw new TypeError("CryptoKey is not extractable");
917
+ }
918
+ if (key.type !== keyType) {
919
+ throw new TypeError(`key is not a ${keyType} key`);
920
+ }
921
+ return formatPEM(encodeBase64(new Uint8Array(await crypto.subtle.exportKey(keyFormat, key))), `${keyType.toUpperCase()} KEY`);
922
+ }, "genericExport");
923
+ var toSPKI = /* @__PURE__ */ __name((key) => genericExport("public", "spki", key), "toSPKI");
924
+ var toPKCS8 = /* @__PURE__ */ __name((key) => genericExport("private", "pkcs8", key), "toPKCS8");
925
+ var bytesEqual = /* @__PURE__ */ __name((a, b) => {
926
+ if (a.byteLength !== b.length)
927
+ return false;
928
+ for (let i = 0; i < a.byteLength; i++) {
929
+ if (a[i] !== b[i])
930
+ return false;
931
+ }
932
+ return true;
933
+ }, "bytesEqual");
934
+ var createASN1State = /* @__PURE__ */ __name((data) => ({ data, pos: 0 }), "createASN1State");
935
+ var parseLength = /* @__PURE__ */ __name((state) => {
936
+ const first = state.data[state.pos++];
937
+ if (first & 128) {
938
+ const lengthOfLen = first & 127;
939
+ let length = 0;
940
+ for (let i = 0; i < lengthOfLen; i++) {
941
+ length = length << 8 | state.data[state.pos++];
942
+ }
943
+ return length;
944
+ }
945
+ return first;
946
+ }, "parseLength");
947
+ var skipElement = /* @__PURE__ */ __name((state, count = 1) => {
948
+ if (count <= 0)
949
+ return;
950
+ state.pos++;
951
+ const length = parseLength(state);
952
+ state.pos += length;
953
+ if (count > 1) {
954
+ skipElement(state, count - 1);
955
+ }
956
+ }, "skipElement");
957
+ var expectTag = /* @__PURE__ */ __name((state, expectedTag, errorMessage) => {
958
+ if (state.data[state.pos++] !== expectedTag) {
959
+ throw new Error(errorMessage);
960
+ }
961
+ }, "expectTag");
962
+ var getSubarray = /* @__PURE__ */ __name((state, length) => {
963
+ const result = state.data.subarray(state.pos, state.pos + length);
964
+ state.pos += length;
965
+ return result;
966
+ }, "getSubarray");
967
+ var parseAlgorithmOID = /* @__PURE__ */ __name((state) => {
968
+ expectTag(state, 6, "Expected algorithm OID");
969
+ const oidLen = parseLength(state);
970
+ return getSubarray(state, oidLen);
971
+ }, "parseAlgorithmOID");
972
+ function parsePKCS8Header(state) {
973
+ expectTag(state, 48, "Invalid PKCS#8 structure");
974
+ parseLength(state);
975
+ expectTag(state, 2, "Expected version field");
976
+ const verLen = parseLength(state);
977
+ state.pos += verLen;
978
+ expectTag(state, 48, "Expected algorithm identifier");
979
+ const algIdLen = parseLength(state);
980
+ const algIdStart = state.pos;
981
+ return { algIdStart, algIdLength: algIdLen };
982
+ }
983
+ __name(parsePKCS8Header, "parsePKCS8Header");
984
+ function parseSPKIHeader(state) {
985
+ expectTag(state, 48, "Invalid SPKI structure");
986
+ parseLength(state);
987
+ expectTag(state, 48, "Expected algorithm identifier");
988
+ const algIdLen = parseLength(state);
989
+ const algIdStart = state.pos;
990
+ return { algIdStart, algIdLength: algIdLen };
991
+ }
992
+ __name(parseSPKIHeader, "parseSPKIHeader");
993
+ var parseECAlgorithmIdentifier = /* @__PURE__ */ __name((state) => {
994
+ const algOid = parseAlgorithmOID(state);
995
+ if (bytesEqual(algOid, [43, 101, 110])) {
996
+ return "X25519";
997
+ }
998
+ if (!bytesEqual(algOid, [42, 134, 72, 206, 61, 2, 1])) {
999
+ throw new Error("Unsupported key algorithm");
1000
+ }
1001
+ expectTag(state, 6, "Expected curve OID");
1002
+ const curveOidLen = parseLength(state);
1003
+ const curveOid = getSubarray(state, curveOidLen);
1004
+ for (const { name, oid } of [
1005
+ { name: "P-256", oid: [42, 134, 72, 206, 61, 3, 1, 7] },
1006
+ { name: "P-384", oid: [43, 129, 4, 0, 34] },
1007
+ { name: "P-521", oid: [43, 129, 4, 0, 35] }
1008
+ ]) {
1009
+ if (bytesEqual(curveOid, oid)) {
1010
+ return name;
1011
+ }
1012
+ }
1013
+ throw new Error("Unsupported named curve");
1014
+ }, "parseECAlgorithmIdentifier");
1015
+ var genericImport = /* @__PURE__ */ __name(async (keyFormat, keyData, alg, options) => {
1016
+ let algorithm;
1017
+ let keyUsages;
1018
+ const isPublic = keyFormat === "spki";
1019
+ const getSigUsages = /* @__PURE__ */ __name(() => isPublic ? ["verify"] : ["sign"], "getSigUsages");
1020
+ const getEncUsages = /* @__PURE__ */ __name(() => isPublic ? ["encrypt", "wrapKey"] : ["decrypt", "unwrapKey"], "getEncUsages");
1021
+ switch (alg) {
1022
+ case "PS256":
1023
+ case "PS384":
1024
+ case "PS512":
1025
+ algorithm = { name: "RSA-PSS", hash: `SHA-${alg.slice(-3)}` };
1026
+ keyUsages = getSigUsages();
1027
+ break;
1028
+ case "RS256":
1029
+ case "RS384":
1030
+ case "RS512":
1031
+ algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${alg.slice(-3)}` };
1032
+ keyUsages = getSigUsages();
1033
+ break;
1034
+ case "RSA-OAEP":
1035
+ case "RSA-OAEP-256":
1036
+ case "RSA-OAEP-384":
1037
+ case "RSA-OAEP-512":
1038
+ algorithm = {
1039
+ name: "RSA-OAEP",
1040
+ hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`
1041
+ };
1042
+ keyUsages = getEncUsages();
1043
+ break;
1044
+ case "ES256":
1045
+ case "ES384":
1046
+ case "ES512": {
1047
+ const curveMap = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
1048
+ algorithm = { name: "ECDSA", namedCurve: curveMap[alg] };
1049
+ keyUsages = getSigUsages();
1050
+ break;
1051
+ }
1052
+ case "ECDH-ES":
1053
+ case "ECDH-ES+A128KW":
1054
+ case "ECDH-ES+A192KW":
1055
+ case "ECDH-ES+A256KW": {
1056
+ try {
1057
+ const namedCurve = options.getNamedCurve(keyData);
1058
+ algorithm = namedCurve === "X25519" ? { name: "X25519" } : { name: "ECDH", namedCurve };
1059
+ } catch (cause) {
1060
+ throw new JOSENotSupported("Invalid or unsupported key format");
1061
+ }
1062
+ keyUsages = isPublic ? [] : ["deriveBits"];
1063
+ break;
1064
+ }
1065
+ case "Ed25519":
1066
+ case "EdDSA":
1067
+ algorithm = { name: "Ed25519" };
1068
+ keyUsages = getSigUsages();
1069
+ break;
1070
+ case "ML-DSA-44":
1071
+ case "ML-DSA-65":
1072
+ case "ML-DSA-87":
1073
+ algorithm = { name: alg };
1074
+ keyUsages = getSigUsages();
1075
+ break;
1076
+ default:
1077
+ throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
1078
+ }
1079
+ return crypto.subtle.importKey(keyFormat, keyData, algorithm, options?.extractable ?? (isPublic ? true : false), keyUsages);
1080
+ }, "genericImport");
1081
+ var processPEMData = /* @__PURE__ */ __name((pem, pattern) => {
1082
+ return decodeBase64(pem.replace(pattern, ""));
1083
+ }, "processPEMData");
1084
+ var fromPKCS8 = /* @__PURE__ */ __name((pem, alg, options) => {
1085
+ const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
1086
+ let opts = options;
1087
+ if (alg?.startsWith?.("ECDH-ES")) {
1088
+ opts ||= {};
1089
+ opts.getNamedCurve = (keyData2) => {
1090
+ const state = createASN1State(keyData2);
1091
+ parsePKCS8Header(state);
1092
+ return parseECAlgorithmIdentifier(state);
1093
+ };
1094
+ }
1095
+ return genericImport("pkcs8", keyData, alg, opts);
1096
+ }, "fromPKCS8");
1097
+ var fromSPKI = /* @__PURE__ */ __name((pem, alg, options) => {
1098
+ const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g);
1099
+ let opts = options;
1100
+ if (alg?.startsWith?.("ECDH-ES")) {
1101
+ opts ||= {};
1102
+ opts.getNamedCurve = (keyData2) => {
1103
+ const state = createASN1State(keyData2);
1104
+ parseSPKIHeader(state);
1105
+ return parseECAlgorithmIdentifier(state);
1106
+ };
1107
+ }
1108
+ return genericImport("spki", keyData, alg, opts);
1109
+ }, "fromSPKI");
1110
+ function spkiFromX509(buf) {
1111
+ const state = createASN1State(buf);
1112
+ expectTag(state, 48, "Invalid certificate structure");
1113
+ parseLength(state);
1114
+ expectTag(state, 48, "Invalid tbsCertificate structure");
1115
+ parseLength(state);
1116
+ if (buf[state.pos] === 160) {
1117
+ skipElement(state, 6);
1118
+ } else {
1119
+ skipElement(state, 5);
1120
+ }
1121
+ const spkiStart = state.pos;
1122
+ expectTag(state, 48, "Invalid SPKI structure");
1123
+ const spkiContentLen = parseLength(state);
1124
+ return buf.subarray(spkiStart, spkiStart + spkiContentLen + (state.pos - spkiStart));
1125
+ }
1126
+ __name(spkiFromX509, "spkiFromX509");
1127
+ function extractX509SPKI(x509) {
1128
+ const derBytes = processPEMData(x509, /(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g);
1129
+ return spkiFromX509(derBytes);
1130
+ }
1131
+ __name(extractX509SPKI, "extractX509SPKI");
1132
+ var fromX509 = /* @__PURE__ */ __name((pem, alg, options) => {
1133
+ let spki;
1134
+ try {
1135
+ spki = extractX509SPKI(pem);
1136
+ } catch (cause) {
1137
+ throw new TypeError("Failed to parse the X.509 certificate", { cause });
1138
+ }
1139
+ return fromSPKI(formatPEM(encodeBase64(spki), "PUBLIC KEY"), alg, options);
1140
+ }, "fromX509");
1141
+
1142
+ // node_modules/jose/dist/webapi/lib/jwk_to_key.js
1143
+ init_esbuild_shims();
1144
+ function subtleMapping(jwk) {
1145
+ let algorithm;
1146
+ let keyUsages;
1147
+ switch (jwk.kty) {
1148
+ case "AKP": {
1149
+ switch (jwk.alg) {
1150
+ case "ML-DSA-44":
1151
+ case "ML-DSA-65":
1152
+ case "ML-DSA-87":
1153
+ algorithm = { name: jwk.alg };
1154
+ keyUsages = jwk.priv ? ["sign"] : ["verify"];
1155
+ break;
1156
+ default:
1157
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1158
+ }
1159
+ break;
1160
+ }
1161
+ case "RSA": {
1162
+ switch (jwk.alg) {
1163
+ case "PS256":
1164
+ case "PS384":
1165
+ case "PS512":
1166
+ algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
1167
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1168
+ break;
1169
+ case "RS256":
1170
+ case "RS384":
1171
+ case "RS512":
1172
+ algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
1173
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1174
+ break;
1175
+ case "RSA-OAEP":
1176
+ case "RSA-OAEP-256":
1177
+ case "RSA-OAEP-384":
1178
+ case "RSA-OAEP-512":
1179
+ algorithm = {
1180
+ name: "RSA-OAEP",
1181
+ hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
1182
+ };
1183
+ keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
1184
+ break;
1185
+ default:
1186
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1187
+ }
1188
+ break;
1189
+ }
1190
+ case "EC": {
1191
+ switch (jwk.alg) {
1192
+ case "ES256":
1193
+ algorithm = { name: "ECDSA", namedCurve: "P-256" };
1194
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1195
+ break;
1196
+ case "ES384":
1197
+ algorithm = { name: "ECDSA", namedCurve: "P-384" };
1198
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1199
+ break;
1200
+ case "ES512":
1201
+ algorithm = { name: "ECDSA", namedCurve: "P-521" };
1202
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1203
+ break;
1204
+ case "ECDH-ES":
1205
+ case "ECDH-ES+A128KW":
1206
+ case "ECDH-ES+A192KW":
1207
+ case "ECDH-ES+A256KW":
1208
+ algorithm = { name: "ECDH", namedCurve: jwk.crv };
1209
+ keyUsages = jwk.d ? ["deriveBits"] : [];
1210
+ break;
1211
+ default:
1212
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1213
+ }
1214
+ break;
1215
+ }
1216
+ case "OKP": {
1217
+ switch (jwk.alg) {
1218
+ case "Ed25519":
1219
+ case "EdDSA":
1220
+ algorithm = { name: "Ed25519" };
1221
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1222
+ break;
1223
+ case "ECDH-ES":
1224
+ case "ECDH-ES+A128KW":
1225
+ case "ECDH-ES+A192KW":
1226
+ case "ECDH-ES+A256KW":
1227
+ algorithm = { name: jwk.crv };
1228
+ keyUsages = jwk.d ? ["deriveBits"] : [];
1229
+ break;
1230
+ default:
1231
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1232
+ }
1233
+ break;
1234
+ }
1235
+ default:
1236
+ throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
1237
+ }
1238
+ return { algorithm, keyUsages };
1239
+ }
1240
+ __name(subtleMapping, "subtleMapping");
1241
+ async function jwkToKey(jwk) {
1242
+ if (!jwk.alg) {
1243
+ throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
1244
+ }
1245
+ const { algorithm, keyUsages } = subtleMapping(jwk);
1246
+ const keyData = { ...jwk };
1247
+ if (keyData.kty !== "AKP") {
1248
+ delete keyData.alg;
1249
+ }
1250
+ delete keyData.use;
1251
+ return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
1252
+ }
1253
+ __name(jwkToKey, "jwkToKey");
1254
+
1255
+ // node_modules/jose/dist/webapi/key/import.js
1256
+ async function importSPKI(spki, alg, options) {
1257
+ if (typeof spki !== "string" || spki.indexOf("-----BEGIN PUBLIC KEY-----") !== 0) {
1258
+ throw new TypeError('"spki" must be SPKI formatted string');
1259
+ }
1260
+ return fromSPKI(spki, alg, options);
1261
+ }
1262
+ __name(importSPKI, "importSPKI");
1263
+ async function importX509(x509, alg, options) {
1264
+ if (typeof x509 !== "string" || x509.indexOf("-----BEGIN CERTIFICATE-----") !== 0) {
1265
+ throw new TypeError('"x509" must be X.509 formatted string');
1266
+ }
1267
+ return fromX509(x509, alg, options);
1268
+ }
1269
+ __name(importX509, "importX509");
1270
+ async function importPKCS8(pkcs8, alg, options) {
1271
+ if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
1272
+ throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
1273
+ }
1274
+ return fromPKCS8(pkcs8, alg, options);
1275
+ }
1276
+ __name(importPKCS8, "importPKCS8");
1277
+ async function importJWK(jwk, alg, options) {
1278
+ if (!isObject(jwk)) {
1279
+ throw new TypeError("JWK must be an object");
1280
+ }
1281
+ let ext;
1282
+ alg ??= jwk.alg;
1283
+ ext ??= options?.extractable ?? jwk.ext;
1284
+ switch (jwk.kty) {
1285
+ case "oct":
1286
+ if (typeof jwk.k !== "string" || !jwk.k) {
1287
+ throw new TypeError('missing "k" (Key Value) Parameter value');
1288
+ }
1289
+ return decode(jwk.k);
1290
+ case "RSA":
1291
+ if ("oth" in jwk && jwk.oth !== void 0) {
1292
+ throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
1293
+ }
1294
+ return jwkToKey({ ...jwk, alg, ext });
1295
+ case "AKP": {
1296
+ if (typeof jwk.alg !== "string" || !jwk.alg) {
1297
+ throw new TypeError('missing "alg" (Algorithm) Parameter value');
1298
+ }
1299
+ if (alg !== void 0 && alg !== jwk.alg) {
1300
+ throw new TypeError("JWK alg and alg option value mismatch");
1301
+ }
1302
+ return jwkToKey({ ...jwk, ext });
1303
+ }
1304
+ case "EC":
1305
+ case "OKP":
1306
+ return jwkToKey({ ...jwk, alg, ext });
1307
+ default:
1308
+ throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
1309
+ }
1310
+ }
1311
+ __name(importJWK, "importJWK");
1312
+
1313
+ // node_modules/jose/dist/webapi/lib/aesgcmkw.js
1314
+ init_esbuild_shims();
1315
+
1316
+ // node_modules/jose/dist/webapi/lib/encrypt.js
1317
+ init_esbuild_shims();
1318
+ async function cbcEncrypt(enc, plaintext, cek, iv, aad) {
1319
+ if (!(cek instanceof Uint8Array)) {
1320
+ throw new TypeError(invalidKeyInput(cek, "Uint8Array"));
1321
+ }
1322
+ const keySize = parseInt(enc.slice(1, 4), 10);
1323
+ const encKey = await crypto.subtle.importKey("raw", cek.subarray(keySize >> 3), "AES-CBC", false, ["encrypt"]);
1324
+ const macKey = await crypto.subtle.importKey("raw", cek.subarray(0, keySize >> 3), {
1325
+ hash: `SHA-${keySize << 1}`,
1326
+ name: "HMAC"
1327
+ }, false, ["sign"]);
1328
+ const ciphertext = new Uint8Array(await crypto.subtle.encrypt({
1329
+ iv,
1330
+ name: "AES-CBC"
1331
+ }, encKey, plaintext));
1332
+ const macData = concat(aad, iv, ciphertext, uint64be(aad.length << 3));
1333
+ const tag2 = new Uint8Array((await crypto.subtle.sign("HMAC", macKey, macData)).slice(0, keySize >> 3));
1334
+ return { ciphertext, tag: tag2, iv };
1335
+ }
1336
+ __name(cbcEncrypt, "cbcEncrypt");
1337
+ async function gcmEncrypt(enc, plaintext, cek, iv, aad) {
1338
+ let encKey;
1339
+ if (cek instanceof Uint8Array) {
1340
+ encKey = await crypto.subtle.importKey("raw", cek, "AES-GCM", false, ["encrypt"]);
1341
+ } else {
1342
+ checkEncCryptoKey(cek, enc, "encrypt");
1343
+ encKey = cek;
1344
+ }
1345
+ const encrypted = new Uint8Array(await crypto.subtle.encrypt({
1346
+ additionalData: aad,
1347
+ iv,
1348
+ name: "AES-GCM",
1349
+ tagLength: 128
1350
+ }, encKey, plaintext));
1351
+ const tag2 = encrypted.slice(-16);
1352
+ const ciphertext = encrypted.slice(0, -16);
1353
+ return { ciphertext, tag: tag2, iv };
1354
+ }
1355
+ __name(gcmEncrypt, "gcmEncrypt");
1356
+ async function encrypt2(enc, plaintext, cek, iv, aad) {
1357
+ if (!isCryptoKey(cek) && !(cek instanceof Uint8Array)) {
1358
+ throw new TypeError(invalidKeyInput(cek, "CryptoKey", "KeyObject", "Uint8Array", "JSON Web Key"));
1359
+ }
1360
+ if (iv) {
1361
+ checkIvLength(enc, iv);
1362
+ } else {
1363
+ iv = generateIv(enc);
1364
+ }
1365
+ switch (enc) {
1366
+ case "A128CBC-HS256":
1367
+ case "A192CBC-HS384":
1368
+ case "A256CBC-HS512":
1369
+ if (cek instanceof Uint8Array) {
1370
+ checkCekLength(cek, parseInt(enc.slice(-3), 10));
1371
+ }
1372
+ return cbcEncrypt(enc, plaintext, cek, iv, aad);
1373
+ case "A128GCM":
1374
+ case "A192GCM":
1375
+ case "A256GCM":
1376
+ if (cek instanceof Uint8Array) {
1377
+ checkCekLength(cek, parseInt(enc.slice(1, 4), 10));
1378
+ }
1379
+ return gcmEncrypt(enc, plaintext, cek, iv, aad);
1380
+ default:
1381
+ throw new JOSENotSupported("Unsupported JWE Content Encryption Algorithm");
1382
+ }
1383
+ }
1384
+ __name(encrypt2, "encrypt");
1385
+
1386
+ // node_modules/jose/dist/webapi/lib/aesgcmkw.js
1387
+ async function wrap3(alg, key, cek, iv) {
1388
+ const jweAlgorithm = alg.slice(0, 7);
1389
+ const wrapped = await encrypt2(jweAlgorithm, cek, key, iv, new Uint8Array());
1390
+ return {
1391
+ encryptedKey: wrapped.ciphertext,
1392
+ iv: encode2(wrapped.iv),
1393
+ tag: encode2(wrapped.tag)
1394
+ };
1395
+ }
1396
+ __name(wrap3, "wrap");
1397
+ async function unwrap3(alg, key, encryptedKey, iv, tag2) {
1398
+ const jweAlgorithm = alg.slice(0, 7);
1399
+ return decrypt(jweAlgorithm, key, encryptedKey, iv, tag2, new Uint8Array());
1400
+ }
1401
+ __name(unwrap3, "unwrap");
1402
+
1403
+ // node_modules/jose/dist/webapi/lib/decrypt_key_management.js
1404
+ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
1405
+ switch (alg) {
1406
+ case "dir": {
1407
+ if (encryptedKey !== void 0)
1408
+ throw new JWEInvalid("Encountered unexpected JWE Encrypted Key");
1409
+ return key;
1410
+ }
1411
+ case "ECDH-ES":
1412
+ if (encryptedKey !== void 0)
1413
+ throw new JWEInvalid("Encountered unexpected JWE Encrypted Key");
1414
+ case "ECDH-ES+A128KW":
1415
+ case "ECDH-ES+A192KW":
1416
+ case "ECDH-ES+A256KW": {
1417
+ if (!isObject(joseHeader.epk))
1418
+ throw new JWEInvalid(`JOSE Header "epk" (Ephemeral Public Key) missing or invalid`);
1419
+ assertCryptoKey(key);
1420
+ if (!allowed(key))
1421
+ throw new JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime");
1422
+ const epk = await importJWK(joseHeader.epk, alg);
1423
+ assertCryptoKey(epk);
1424
+ let partyUInfo;
1425
+ let partyVInfo;
1426
+ if (joseHeader.apu !== void 0) {
1427
+ if (typeof joseHeader.apu !== "string")
1428
+ throw new JWEInvalid(`JOSE Header "apu" (Agreement PartyUInfo) invalid`);
1429
+ try {
1430
+ partyUInfo = decode(joseHeader.apu);
1431
+ } catch {
1432
+ throw new JWEInvalid("Failed to base64url decode the apu");
1433
+ }
1434
+ }
1435
+ if (joseHeader.apv !== void 0) {
1436
+ if (typeof joseHeader.apv !== "string")
1437
+ throw new JWEInvalid(`JOSE Header "apv" (Agreement PartyVInfo) invalid`);
1438
+ try {
1439
+ partyVInfo = decode(joseHeader.apv);
1440
+ } catch {
1441
+ throw new JWEInvalid("Failed to base64url decode the apv");
1442
+ }
1443
+ }
1444
+ const sharedSecret = await deriveKey(epk, key, alg === "ECDH-ES" ? joseHeader.enc : alg, alg === "ECDH-ES" ? cekLength(joseHeader.enc) : parseInt(alg.slice(-5, -2), 10), partyUInfo, partyVInfo);
1445
+ if (alg === "ECDH-ES")
1446
+ return sharedSecret;
1447
+ if (encryptedKey === void 0)
1448
+ throw new JWEInvalid("JWE Encrypted Key missing");
1449
+ return unwrap(alg.slice(-6), sharedSecret, encryptedKey);
1450
+ }
1451
+ case "RSA-OAEP":
1452
+ case "RSA-OAEP-256":
1453
+ case "RSA-OAEP-384":
1454
+ case "RSA-OAEP-512": {
1455
+ if (encryptedKey === void 0)
1456
+ throw new JWEInvalid("JWE Encrypted Key missing");
1457
+ assertCryptoKey(key);
1458
+ return decrypt2(alg, key, encryptedKey);
1459
+ }
1460
+ case "PBES2-HS256+A128KW":
1461
+ case "PBES2-HS384+A192KW":
1462
+ case "PBES2-HS512+A256KW": {
1463
+ if (encryptedKey === void 0)
1464
+ throw new JWEInvalid("JWE Encrypted Key missing");
1465
+ if (typeof joseHeader.p2c !== "number")
1466
+ throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
1467
+ const p2cLimit = options?.maxPBES2Count || 1e4;
1468
+ if (joseHeader.p2c > p2cLimit)
1469
+ throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
1470
+ if (typeof joseHeader.p2s !== "string")
1471
+ throw new JWEInvalid(`JOSE Header "p2s" (PBES2 Salt) missing or invalid`);
1472
+ let p2s;
1473
+ try {
1474
+ p2s = decode(joseHeader.p2s);
1475
+ } catch {
1476
+ throw new JWEInvalid("Failed to base64url decode the p2s");
1477
+ }
1478
+ return unwrap2(alg, key, encryptedKey, joseHeader.p2c, p2s);
1479
+ }
1480
+ case "A128KW":
1481
+ case "A192KW":
1482
+ case "A256KW": {
1483
+ if (encryptedKey === void 0)
1484
+ throw new JWEInvalid("JWE Encrypted Key missing");
1485
+ return unwrap(alg, key, encryptedKey);
1486
+ }
1487
+ case "A128GCMKW":
1488
+ case "A192GCMKW":
1489
+ case "A256GCMKW": {
1490
+ if (encryptedKey === void 0)
1491
+ throw new JWEInvalid("JWE Encrypted Key missing");
1492
+ if (typeof joseHeader.iv !== "string")
1493
+ throw new JWEInvalid(`JOSE Header "iv" (Initialization Vector) missing or invalid`);
1494
+ if (typeof joseHeader.tag !== "string")
1495
+ throw new JWEInvalid(`JOSE Header "tag" (Authentication Tag) missing or invalid`);
1496
+ let iv;
1497
+ try {
1498
+ iv = decode(joseHeader.iv);
1499
+ } catch {
1500
+ throw new JWEInvalid("Failed to base64url decode the iv");
1501
+ }
1502
+ let tag2;
1503
+ try {
1504
+ tag2 = decode(joseHeader.tag);
1505
+ } catch {
1506
+ throw new JWEInvalid("Failed to base64url decode the tag");
1507
+ }
1508
+ return unwrap3(alg, key, encryptedKey, iv, tag2);
1509
+ }
1510
+ default: {
1511
+ throw new JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value');
1512
+ }
1513
+ }
1514
+ }
1515
+ __name(decryptKeyManagement, "decryptKeyManagement");
1516
+
1517
+ // node_modules/jose/dist/webapi/lib/validate_crit.js
1518
+ init_esbuild_shims();
1519
+ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
1520
+ if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) {
1521
+ throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
1522
+ }
1523
+ if (!protectedHeader || protectedHeader.crit === void 0) {
1524
+ return /* @__PURE__ */ new Set();
1525
+ }
1526
+ if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
1527
+ throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
1528
+ }
1529
+ let recognized;
1530
+ if (recognizedOption !== void 0) {
1531
+ recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
1532
+ } else {
1533
+ recognized = recognizedDefault;
1534
+ }
1535
+ for (const parameter of protectedHeader.crit) {
1536
+ if (!recognized.has(parameter)) {
1537
+ throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
1538
+ }
1539
+ if (joseHeader[parameter] === void 0) {
1540
+ throw new Err(`Extension Header Parameter "${parameter}" is missing`);
1541
+ }
1542
+ if (recognized.get(parameter) && protectedHeader[parameter] === void 0) {
1543
+ throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
1544
+ }
1545
+ }
1546
+ return new Set(protectedHeader.crit);
1547
+ }
1548
+ __name(validateCrit, "validateCrit");
1549
+
1550
+ // node_modules/jose/dist/webapi/lib/validate_algorithms.js
1551
+ init_esbuild_shims();
1552
+ function validateAlgorithms(option, algorithms) {
1553
+ if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
1554
+ throw new TypeError(`"${option}" option must be an array of strings`);
1555
+ }
1556
+ if (!algorithms) {
1557
+ return void 0;
1558
+ }
1559
+ return new Set(algorithms);
1560
+ }
1561
+ __name(validateAlgorithms, "validateAlgorithms");
1562
+
1563
+ // node_modules/jose/dist/webapi/lib/normalize_key.js
1564
+ init_esbuild_shims();
1565
+
1566
+ // node_modules/jose/dist/webapi/lib/is_jwk.js
1567
+ init_esbuild_shims();
1568
+ var isJWK = /* @__PURE__ */ __name((key) => isObject(key) && typeof key.kty === "string", "isJWK");
1569
+ var isPrivateJWK = /* @__PURE__ */ __name((key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string"), "isPrivateJWK");
1570
+ var isPublicJWK = /* @__PURE__ */ __name((key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0, "isPublicJWK");
1571
+ var isSecretJWK = /* @__PURE__ */ __name((key) => key.kty === "oct" && typeof key.k === "string", "isSecretJWK");
1572
+
1573
+ // node_modules/jose/dist/webapi/lib/normalize_key.js
1574
+ var cache;
1575
+ var handleJWK = /* @__PURE__ */ __name(async (key, jwk, alg, freeze = false) => {
1576
+ cache ||= /* @__PURE__ */ new WeakMap();
1577
+ let cached = cache.get(key);
1578
+ if (cached?.[alg]) {
1579
+ return cached[alg];
1580
+ }
1581
+ const cryptoKey = await jwkToKey({ ...jwk, alg });
1582
+ if (freeze)
1583
+ Object.freeze(key);
1584
+ if (!cached) {
1585
+ cache.set(key, { [alg]: cryptoKey });
1586
+ } else {
1587
+ cached[alg] = cryptoKey;
1588
+ }
1589
+ return cryptoKey;
1590
+ }, "handleJWK");
1591
+ var handleKeyObject = /* @__PURE__ */ __name((keyObject, alg) => {
1592
+ cache ||= /* @__PURE__ */ new WeakMap();
1593
+ let cached = cache.get(keyObject);
1594
+ if (cached?.[alg]) {
1595
+ return cached[alg];
1596
+ }
1597
+ const isPublic = keyObject.type === "public";
1598
+ const extractable = isPublic ? true : false;
1599
+ let cryptoKey;
1600
+ if (keyObject.asymmetricKeyType === "x25519") {
1601
+ switch (alg) {
1602
+ case "ECDH-ES":
1603
+ case "ECDH-ES+A128KW":
1604
+ case "ECDH-ES+A192KW":
1605
+ case "ECDH-ES+A256KW":
1606
+ break;
1607
+ default:
1608
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1609
+ }
1610
+ cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
1611
+ }
1612
+ if (keyObject.asymmetricKeyType === "ed25519") {
1613
+ if (alg !== "EdDSA" && alg !== "Ed25519") {
1614
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1615
+ }
1616
+ cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
1617
+ isPublic ? "verify" : "sign"
1618
+ ]);
1619
+ }
1620
+ switch (keyObject.asymmetricKeyType) {
1621
+ case "ml-dsa-44":
1622
+ case "ml-dsa-65":
1623
+ case "ml-dsa-87": {
1624
+ if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
1625
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1626
+ }
1627
+ cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
1628
+ isPublic ? "verify" : "sign"
1629
+ ]);
1630
+ }
1631
+ }
1632
+ if (keyObject.asymmetricKeyType === "rsa") {
1633
+ let hash;
1634
+ switch (alg) {
1635
+ case "RSA-OAEP":
1636
+ hash = "SHA-1";
1637
+ break;
1638
+ case "RS256":
1639
+ case "PS256":
1640
+ case "RSA-OAEP-256":
1641
+ hash = "SHA-256";
1642
+ break;
1643
+ case "RS384":
1644
+ case "PS384":
1645
+ case "RSA-OAEP-384":
1646
+ hash = "SHA-384";
1647
+ break;
1648
+ case "RS512":
1649
+ case "PS512":
1650
+ case "RSA-OAEP-512":
1651
+ hash = "SHA-512";
1652
+ break;
1653
+ default:
1654
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1655
+ }
1656
+ if (alg.startsWith("RSA-OAEP")) {
1657
+ return keyObject.toCryptoKey({
1658
+ name: "RSA-OAEP",
1659
+ hash
1660
+ }, extractable, isPublic ? ["encrypt"] : ["decrypt"]);
1661
+ }
1662
+ cryptoKey = keyObject.toCryptoKey({
1663
+ name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
1664
+ hash
1665
+ }, extractable, [isPublic ? "verify" : "sign"]);
1666
+ }
1667
+ if (keyObject.asymmetricKeyType === "ec") {
1668
+ const nist = /* @__PURE__ */ new Map([
1669
+ ["prime256v1", "P-256"],
1670
+ ["secp384r1", "P-384"],
1671
+ ["secp521r1", "P-521"]
1672
+ ]);
1673
+ const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
1674
+ if (!namedCurve) {
1675
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1676
+ }
1677
+ if (alg === "ES256" && namedCurve === "P-256") {
1678
+ cryptoKey = keyObject.toCryptoKey({
1679
+ name: "ECDSA",
1680
+ namedCurve
1681
+ }, extractable, [isPublic ? "verify" : "sign"]);
1682
+ }
1683
+ if (alg === "ES384" && namedCurve === "P-384") {
1684
+ cryptoKey = keyObject.toCryptoKey({
1685
+ name: "ECDSA",
1686
+ namedCurve
1687
+ }, extractable, [isPublic ? "verify" : "sign"]);
1688
+ }
1689
+ if (alg === "ES512" && namedCurve === "P-521") {
1690
+ cryptoKey = keyObject.toCryptoKey({
1691
+ name: "ECDSA",
1692
+ namedCurve
1693
+ }, extractable, [isPublic ? "verify" : "sign"]);
1694
+ }
1695
+ if (alg.startsWith("ECDH-ES")) {
1696
+ cryptoKey = keyObject.toCryptoKey({
1697
+ name: "ECDH",
1698
+ namedCurve
1699
+ }, extractable, isPublic ? [] : ["deriveBits"]);
1700
+ }
1701
+ }
1702
+ if (!cryptoKey) {
1703
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1704
+ }
1705
+ if (!cached) {
1706
+ cache.set(keyObject, { [alg]: cryptoKey });
1707
+ } else {
1708
+ cached[alg] = cryptoKey;
1709
+ }
1710
+ return cryptoKey;
1711
+ }, "handleKeyObject");
1712
+ async function normalizeKey(key, alg) {
1713
+ if (key instanceof Uint8Array) {
1714
+ return key;
1715
+ }
1716
+ if (isCryptoKey(key)) {
1717
+ return key;
1718
+ }
1719
+ if (isKeyObject(key)) {
1720
+ if (key.type === "secret") {
1721
+ return key.export();
1722
+ }
1723
+ if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") {
1724
+ try {
1725
+ return handleKeyObject(key, alg);
1726
+ } catch (err) {
1727
+ if (err instanceof TypeError) {
1728
+ throw err;
1729
+ }
1730
+ }
1731
+ }
1732
+ let jwk = key.export({ format: "jwk" });
1733
+ return handleJWK(key, jwk, alg);
1734
+ }
1735
+ if (isJWK(key)) {
1736
+ if (key.k) {
1737
+ return decode(key.k);
1738
+ }
1739
+ return handleJWK(key, key, alg, true);
1740
+ }
1741
+ throw new Error("unreachable");
1742
+ }
1743
+ __name(normalizeKey, "normalizeKey");
1744
+
1745
+ // node_modules/jose/dist/webapi/lib/check_key_type.js
1746
+ init_esbuild_shims();
1747
+ var tag = /* @__PURE__ */ __name((key) => key?.[Symbol.toStringTag], "tag");
1748
+ var jwkMatchesOp = /* @__PURE__ */ __name((alg, key, usage) => {
1749
+ if (key.use !== void 0) {
1750
+ let expected;
1751
+ switch (usage) {
1752
+ case "sign":
1753
+ case "verify":
1754
+ expected = "sig";
1755
+ break;
1756
+ case "encrypt":
1757
+ case "decrypt":
1758
+ expected = "enc";
1759
+ break;
1760
+ }
1761
+ if (key.use !== expected) {
1762
+ throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
1763
+ }
1764
+ }
1765
+ if (key.alg !== void 0 && key.alg !== alg) {
1766
+ throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
1767
+ }
1768
+ if (Array.isArray(key.key_ops)) {
1769
+ let expectedKeyOp;
1770
+ switch (true) {
1771
+ case (usage === "sign" || usage === "verify"):
1772
+ case alg === "dir":
1773
+ case alg.includes("CBC-HS"):
1774
+ expectedKeyOp = usage;
1775
+ break;
1776
+ case alg.startsWith("PBES2"):
1777
+ expectedKeyOp = "deriveBits";
1778
+ break;
1779
+ case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
1780
+ if (!alg.includes("GCM") && alg.endsWith("KW")) {
1781
+ expectedKeyOp = usage === "encrypt" ? "wrapKey" : "unwrapKey";
1782
+ } else {
1783
+ expectedKeyOp = usage;
1784
+ }
1785
+ break;
1786
+ case (usage === "encrypt" && alg.startsWith("RSA")):
1787
+ expectedKeyOp = "wrapKey";
1788
+ break;
1789
+ case usage === "decrypt":
1790
+ expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
1791
+ break;
1792
+ }
1793
+ if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {
1794
+ throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
1795
+ }
1796
+ }
1797
+ return true;
1798
+ }, "jwkMatchesOp");
1799
+ var symmetricTypeCheck = /* @__PURE__ */ __name((alg, key, usage) => {
1800
+ if (key instanceof Uint8Array)
1801
+ return;
1802
+ if (isJWK(key)) {
1803
+ if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage))
1804
+ return;
1805
+ throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`);
1806
+ }
1807
+ if (!isKeyLike(key)) {
1808
+ throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
1809
+ }
1810
+ if (key.type !== "secret") {
1811
+ throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
1812
+ }
1813
+ }, "symmetricTypeCheck");
1814
+ var asymmetricTypeCheck = /* @__PURE__ */ __name((alg, key, usage) => {
1815
+ if (isJWK(key)) {
1816
+ switch (usage) {
1817
+ case "decrypt":
1818
+ case "sign":
1819
+ if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
1820
+ return;
1821
+ throw new TypeError(`JSON Web Key for this operation must be a private JWK`);
1822
+ case "encrypt":
1823
+ case "verify":
1824
+ if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
1825
+ return;
1826
+ throw new TypeError(`JSON Web Key for this operation must be a public JWK`);
1827
+ }
1828
+ }
1829
+ if (!isKeyLike(key)) {
1830
+ throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
1831
+ }
1832
+ if (key.type === "secret") {
1833
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
1834
+ }
1835
+ if (key.type === "public") {
1836
+ switch (usage) {
1837
+ case "sign":
1838
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
1839
+ case "decrypt":
1840
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
1841
+ }
1842
+ }
1843
+ if (key.type === "private") {
1844
+ switch (usage) {
1845
+ case "verify":
1846
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
1847
+ case "encrypt":
1848
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
1849
+ }
1850
+ }
1851
+ }, "asymmetricTypeCheck");
1852
+ function checkKeyType(alg, key, usage) {
1853
+ switch (alg.substring(0, 2)) {
1854
+ case "A1":
1855
+ case "A2":
1856
+ case "di":
1857
+ case "HS":
1858
+ case "PB":
1859
+ symmetricTypeCheck(alg, key, usage);
1860
+ break;
1861
+ default:
1862
+ asymmetricTypeCheck(alg, key, usage);
1863
+ }
1864
+ }
1865
+ __name(checkKeyType, "checkKeyType");
1866
+
1867
+ // node_modules/jose/dist/webapi/jwe/flattened/decrypt.js
1868
+ async function flattenedDecrypt(jwe, key, options) {
1869
+ if (!isObject(jwe)) {
1870
+ throw new JWEInvalid("Flattened JWE must be an object");
1871
+ }
1872
+ if (jwe.protected === void 0 && jwe.header === void 0 && jwe.unprotected === void 0) {
1873
+ throw new JWEInvalid("JOSE Header missing");
1874
+ }
1875
+ if (jwe.iv !== void 0 && typeof jwe.iv !== "string") {
1876
+ throw new JWEInvalid("JWE Initialization Vector incorrect type");
1877
+ }
1878
+ if (typeof jwe.ciphertext !== "string") {
1879
+ throw new JWEInvalid("JWE Ciphertext missing or incorrect type");
1880
+ }
1881
+ if (jwe.tag !== void 0 && typeof jwe.tag !== "string") {
1882
+ throw new JWEInvalid("JWE Authentication Tag incorrect type");
1883
+ }
1884
+ if (jwe.protected !== void 0 && typeof jwe.protected !== "string") {
1885
+ throw new JWEInvalid("JWE Protected Header incorrect type");
1886
+ }
1887
+ if (jwe.encrypted_key !== void 0 && typeof jwe.encrypted_key !== "string") {
1888
+ throw new JWEInvalid("JWE Encrypted Key incorrect type");
1889
+ }
1890
+ if (jwe.aad !== void 0 && typeof jwe.aad !== "string") {
1891
+ throw new JWEInvalid("JWE AAD incorrect type");
1892
+ }
1893
+ if (jwe.header !== void 0 && !isObject(jwe.header)) {
1894
+ throw new JWEInvalid("JWE Shared Unprotected Header incorrect type");
1895
+ }
1896
+ if (jwe.unprotected !== void 0 && !isObject(jwe.unprotected)) {
1897
+ throw new JWEInvalid("JWE Per-Recipient Unprotected Header incorrect type");
1898
+ }
1899
+ let parsedProt;
1900
+ if (jwe.protected) {
1901
+ try {
1902
+ const protectedHeader2 = decode(jwe.protected);
1903
+ parsedProt = JSON.parse(decoder.decode(protectedHeader2));
1904
+ } catch {
1905
+ throw new JWEInvalid("JWE Protected Header is invalid");
1906
+ }
1907
+ }
1908
+ if (!isDisjoint(parsedProt, jwe.header, jwe.unprotected)) {
1909
+ throw new JWEInvalid("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");
1910
+ }
1911
+ const joseHeader = {
1912
+ ...parsedProt,
1913
+ ...jwe.header,
1914
+ ...jwe.unprotected
1915
+ };
1916
+ validateCrit(JWEInvalid, /* @__PURE__ */ new Map(), options?.crit, parsedProt, joseHeader);
1917
+ if (joseHeader.zip !== void 0) {
1918
+ throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
1919
+ }
1920
+ const { alg, enc } = joseHeader;
1921
+ if (typeof alg !== "string" || !alg) {
1922
+ throw new JWEInvalid("missing JWE Algorithm (alg) in JWE Header");
1923
+ }
1924
+ if (typeof enc !== "string" || !enc) {
1925
+ throw new JWEInvalid("missing JWE Encryption Algorithm (enc) in JWE Header");
1926
+ }
1927
+ const keyManagementAlgorithms = options && validateAlgorithms("keyManagementAlgorithms", options.keyManagementAlgorithms);
1928
+ const contentEncryptionAlgorithms = options && validateAlgorithms("contentEncryptionAlgorithms", options.contentEncryptionAlgorithms);
1929
+ if (keyManagementAlgorithms && !keyManagementAlgorithms.has(alg) || !keyManagementAlgorithms && alg.startsWith("PBES2")) {
1930
+ throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
1931
+ }
1932
+ if (contentEncryptionAlgorithms && !contentEncryptionAlgorithms.has(enc)) {
1933
+ throw new JOSEAlgNotAllowed('"enc" (Encryption Algorithm) Header Parameter value not allowed');
1934
+ }
1935
+ let encryptedKey;
1936
+ if (jwe.encrypted_key !== void 0) {
1937
+ try {
1938
+ encryptedKey = decode(jwe.encrypted_key);
1939
+ } catch {
1940
+ throw new JWEInvalid("Failed to base64url decode the encrypted_key");
1941
+ }
1942
+ }
1943
+ let resolvedKey = false;
1944
+ if (typeof key === "function") {
1945
+ key = await key(parsedProt, jwe);
1946
+ resolvedKey = true;
1947
+ }
1948
+ checkKeyType(alg === "dir" ? enc : alg, key, "decrypt");
1949
+ const k = await normalizeKey(key, alg);
1950
+ let cek;
1951
+ try {
1952
+ cek = await decryptKeyManagement(alg, k, encryptedKey, joseHeader, options);
1953
+ } catch (err) {
1954
+ if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {
1955
+ throw err;
1956
+ }
1957
+ cek = generateCek(enc);
1958
+ }
1959
+ let iv;
1960
+ let tag2;
1961
+ if (jwe.iv !== void 0) {
1962
+ try {
1963
+ iv = decode(jwe.iv);
1964
+ } catch {
1965
+ throw new JWEInvalid("Failed to base64url decode the iv");
1966
+ }
1967
+ }
1968
+ if (jwe.tag !== void 0) {
1969
+ try {
1970
+ tag2 = decode(jwe.tag);
1971
+ } catch {
1972
+ throw new JWEInvalid("Failed to base64url decode the tag");
1973
+ }
1974
+ }
1975
+ const protectedHeader = jwe.protected !== void 0 ? encode(jwe.protected) : new Uint8Array();
1976
+ let additionalData;
1977
+ if (jwe.aad !== void 0) {
1978
+ additionalData = concat(protectedHeader, encode("."), encode(jwe.aad));
1979
+ } else {
1980
+ additionalData = protectedHeader;
1981
+ }
1982
+ let ciphertext;
1983
+ try {
1984
+ ciphertext = decode(jwe.ciphertext);
1985
+ } catch {
1986
+ throw new JWEInvalid("Failed to base64url decode the ciphertext");
1987
+ }
1988
+ const plaintext = await decrypt(enc, cek, ciphertext, iv, tag2, additionalData);
1989
+ const result = { plaintext };
1990
+ if (jwe.protected !== void 0) {
1991
+ result.protectedHeader = parsedProt;
1992
+ }
1993
+ if (jwe.aad !== void 0) {
1994
+ try {
1995
+ result.additionalAuthenticatedData = decode(jwe.aad);
1996
+ } catch {
1997
+ throw new JWEInvalid("Failed to base64url decode the aad");
1998
+ }
1999
+ }
2000
+ if (jwe.unprotected !== void 0) {
2001
+ result.sharedUnprotectedHeader = jwe.unprotected;
2002
+ }
2003
+ if (jwe.header !== void 0) {
2004
+ result.unprotectedHeader = jwe.header;
2005
+ }
2006
+ if (resolvedKey) {
2007
+ return { ...result, key: k };
2008
+ }
2009
+ return result;
2010
+ }
2011
+ __name(flattenedDecrypt, "flattenedDecrypt");
2012
+
2013
+ // node_modules/jose/dist/webapi/jwe/compact/decrypt.js
2014
+ async function compactDecrypt(jwe, key, options) {
2015
+ if (jwe instanceof Uint8Array) {
2016
+ jwe = decoder.decode(jwe);
2017
+ }
2018
+ if (typeof jwe !== "string") {
2019
+ throw new JWEInvalid("Compact JWE must be a string or Uint8Array");
2020
+ }
2021
+ const { 0: protectedHeader, 1: encryptedKey, 2: iv, 3: ciphertext, 4: tag2, length } = jwe.split(".");
2022
+ if (length !== 5) {
2023
+ throw new JWEInvalid("Invalid Compact JWE");
2024
+ }
2025
+ const decrypted = await flattenedDecrypt({
2026
+ ciphertext,
2027
+ iv: iv || void 0,
2028
+ protected: protectedHeader,
2029
+ tag: tag2 || void 0,
2030
+ encrypted_key: encryptedKey || void 0
2031
+ }, key, options);
2032
+ const result = { plaintext: decrypted.plaintext, protectedHeader: decrypted.protectedHeader };
2033
+ if (typeof key === "function") {
2034
+ return { ...result, key: decrypted.key };
2035
+ }
2036
+ return result;
2037
+ }
2038
+ __name(compactDecrypt, "compactDecrypt");
2039
+
2040
+ // node_modules/jose/dist/webapi/jwe/general/decrypt.js
2041
+ init_esbuild_shims();
2042
+ async function generalDecrypt(jwe, key, options) {
2043
+ if (!isObject(jwe)) {
2044
+ throw new JWEInvalid("General JWE must be an object");
2045
+ }
2046
+ if (!Array.isArray(jwe.recipients) || !jwe.recipients.every(isObject)) {
2047
+ throw new JWEInvalid("JWE Recipients missing or incorrect type");
2048
+ }
2049
+ if (!jwe.recipients.length) {
2050
+ throw new JWEInvalid("JWE Recipients has no members");
2051
+ }
2052
+ for (const recipient of jwe.recipients) {
2053
+ try {
2054
+ return await flattenedDecrypt({
2055
+ aad: jwe.aad,
2056
+ ciphertext: jwe.ciphertext,
2057
+ encrypted_key: recipient.encrypted_key,
2058
+ header: recipient.header,
2059
+ iv: jwe.iv,
2060
+ protected: jwe.protected,
2061
+ tag: jwe.tag,
2062
+ unprotected: jwe.unprotected
2063
+ }, key, options);
2064
+ } catch {
2065
+ }
2066
+ }
2067
+ throw new JWEDecryptionFailed();
2068
+ }
2069
+ __name(generalDecrypt, "generalDecrypt");
2070
+
2071
+ // node_modules/jose/dist/webapi/jwe/general/encrypt.js
2072
+ init_esbuild_shims();
2073
+
2074
+ // node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
2075
+ init_esbuild_shims();
2076
+
2077
+ // node_modules/jose/dist/webapi/lib/private_symbols.js
2078
+ init_esbuild_shims();
2079
+ var unprotected = Symbol();
2080
+
2081
+ // node_modules/jose/dist/webapi/lib/encrypt_key_management.js
2082
+ init_esbuild_shims();
2083
+
2084
+ // node_modules/jose/dist/webapi/key/export.js
2085
+ init_esbuild_shims();
2086
+
2087
+ // node_modules/jose/dist/webapi/lib/key_to_jwk.js
2088
+ init_esbuild_shims();
2089
+ async function keyToJWK(key) {
2090
+ if (isKeyObject(key)) {
2091
+ if (key.type === "secret") {
2092
+ key = key.export();
2093
+ } else {
2094
+ return key.export({ format: "jwk" });
2095
+ }
2096
+ }
2097
+ if (key instanceof Uint8Array) {
2098
+ return {
2099
+ kty: "oct",
2100
+ k: encode2(key)
2101
+ };
2102
+ }
2103
+ if (!isCryptoKey(key)) {
2104
+ throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "Uint8Array"));
2105
+ }
2106
+ if (!key.extractable) {
2107
+ throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");
2108
+ }
2109
+ const { ext, key_ops, alg, use, ...jwk } = await crypto.subtle.exportKey("jwk", key);
2110
+ if (jwk.kty === "AKP") {
2111
+ ;
2112
+ jwk.alg = alg;
2113
+ }
2114
+ return jwk;
2115
+ }
2116
+ __name(keyToJWK, "keyToJWK");
2117
+
2118
+ // node_modules/jose/dist/webapi/key/export.js
2119
+ async function exportSPKI(key) {
2120
+ return toSPKI(key);
2121
+ }
2122
+ __name(exportSPKI, "exportSPKI");
2123
+ async function exportPKCS8(key) {
2124
+ return toPKCS8(key);
2125
+ }
2126
+ __name(exportPKCS8, "exportPKCS8");
2127
+ async function exportJWK(key) {
2128
+ return keyToJWK(key);
2129
+ }
2130
+ __name(exportJWK, "exportJWK");
2131
+
2132
+ // node_modules/jose/dist/webapi/lib/encrypt_key_management.js
2133
+ async function encryptKeyManagement(alg, enc, key, providedCek, providedParameters = {}) {
2134
+ let encryptedKey;
2135
+ let parameters;
2136
+ let cek;
2137
+ switch (alg) {
2138
+ case "dir": {
2139
+ cek = key;
2140
+ break;
2141
+ }
2142
+ case "ECDH-ES":
2143
+ case "ECDH-ES+A128KW":
2144
+ case "ECDH-ES+A192KW":
2145
+ case "ECDH-ES+A256KW": {
2146
+ assertCryptoKey(key);
2147
+ if (!allowed(key)) {
2148
+ throw new JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime");
2149
+ }
2150
+ const { apu, apv } = providedParameters;
2151
+ let ephemeralKey;
2152
+ if (providedParameters.epk) {
2153
+ ephemeralKey = await normalizeKey(providedParameters.epk, alg);
2154
+ } else {
2155
+ ephemeralKey = (await crypto.subtle.generateKey(key.algorithm, true, ["deriveBits"])).privateKey;
2156
+ }
2157
+ const { x, y, crv, kty } = await exportJWK(ephemeralKey);
2158
+ const sharedSecret = await deriveKey(key, ephemeralKey, alg === "ECDH-ES" ? enc : alg, alg === "ECDH-ES" ? cekLength(enc) : parseInt(alg.slice(-5, -2), 10), apu, apv);
2159
+ parameters = { epk: { x, crv, kty } };
2160
+ if (kty === "EC")
2161
+ parameters.epk.y = y;
2162
+ if (apu)
2163
+ parameters.apu = encode2(apu);
2164
+ if (apv)
2165
+ parameters.apv = encode2(apv);
2166
+ if (alg === "ECDH-ES") {
2167
+ cek = sharedSecret;
2168
+ break;
2169
+ }
2170
+ cek = providedCek || generateCek(enc);
2171
+ const kwAlg = alg.slice(-6);
2172
+ encryptedKey = await wrap(kwAlg, sharedSecret, cek);
2173
+ break;
2174
+ }
2175
+ case "RSA-OAEP":
2176
+ case "RSA-OAEP-256":
2177
+ case "RSA-OAEP-384":
2178
+ case "RSA-OAEP-512": {
2179
+ cek = providedCek || generateCek(enc);
2180
+ assertCryptoKey(key);
2181
+ encryptedKey = await encrypt(alg, key, cek);
2182
+ break;
2183
+ }
2184
+ case "PBES2-HS256+A128KW":
2185
+ case "PBES2-HS384+A192KW":
2186
+ case "PBES2-HS512+A256KW": {
2187
+ cek = providedCek || generateCek(enc);
2188
+ const { p2c, p2s } = providedParameters;
2189
+ ({ encryptedKey, ...parameters } = await wrap2(alg, key, cek, p2c, p2s));
2190
+ break;
2191
+ }
2192
+ case "A128KW":
2193
+ case "A192KW":
2194
+ case "A256KW": {
2195
+ cek = providedCek || generateCek(enc);
2196
+ encryptedKey = await wrap(alg, key, cek);
2197
+ break;
2198
+ }
2199
+ case "A128GCMKW":
2200
+ case "A192GCMKW":
2201
+ case "A256GCMKW": {
2202
+ cek = providedCek || generateCek(enc);
2203
+ const { iv } = providedParameters;
2204
+ ({ encryptedKey, ...parameters } = await wrap3(alg, key, cek, iv));
2205
+ break;
2206
+ }
2207
+ default: {
2208
+ throw new JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value');
2209
+ }
2210
+ }
2211
+ return { cek, encryptedKey, parameters };
2212
+ }
2213
+ __name(encryptKeyManagement, "encryptKeyManagement");
2214
+
2215
+ // node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
2216
+ var FlattenedEncrypt = class {
2217
+ static {
2218
+ __name(this, "FlattenedEncrypt");
2219
+ }
2220
+ #plaintext;
2221
+ #protectedHeader;
2222
+ #sharedUnprotectedHeader;
2223
+ #unprotectedHeader;
2224
+ #aad;
2225
+ #cek;
2226
+ #iv;
2227
+ #keyManagementParameters;
2228
+ constructor(plaintext) {
2229
+ if (!(plaintext instanceof Uint8Array)) {
2230
+ throw new TypeError("plaintext must be an instance of Uint8Array");
2231
+ }
2232
+ this.#plaintext = plaintext;
2233
+ }
2234
+ setKeyManagementParameters(parameters) {
2235
+ if (this.#keyManagementParameters) {
2236
+ throw new TypeError("setKeyManagementParameters can only be called once");
2237
+ }
2238
+ this.#keyManagementParameters = parameters;
2239
+ return this;
2240
+ }
2241
+ setProtectedHeader(protectedHeader) {
2242
+ if (this.#protectedHeader) {
2243
+ throw new TypeError("setProtectedHeader can only be called once");
2244
+ }
2245
+ this.#protectedHeader = protectedHeader;
2246
+ return this;
2247
+ }
2248
+ setSharedUnprotectedHeader(sharedUnprotectedHeader) {
2249
+ if (this.#sharedUnprotectedHeader) {
2250
+ throw new TypeError("setSharedUnprotectedHeader can only be called once");
2251
+ }
2252
+ this.#sharedUnprotectedHeader = sharedUnprotectedHeader;
2253
+ return this;
2254
+ }
2255
+ setUnprotectedHeader(unprotectedHeader) {
2256
+ if (this.#unprotectedHeader) {
2257
+ throw new TypeError("setUnprotectedHeader can only be called once");
2258
+ }
2259
+ this.#unprotectedHeader = unprotectedHeader;
2260
+ return this;
2261
+ }
2262
+ setAdditionalAuthenticatedData(aad) {
2263
+ this.#aad = aad;
2264
+ return this;
2265
+ }
2266
+ setContentEncryptionKey(cek) {
2267
+ if (this.#cek) {
2268
+ throw new TypeError("setContentEncryptionKey can only be called once");
2269
+ }
2270
+ this.#cek = cek;
2271
+ return this;
2272
+ }
2273
+ setInitializationVector(iv) {
2274
+ if (this.#iv) {
2275
+ throw new TypeError("setInitializationVector can only be called once");
2276
+ }
2277
+ this.#iv = iv;
2278
+ return this;
2279
+ }
2280
+ async encrypt(key, options) {
2281
+ if (!this.#protectedHeader && !this.#unprotectedHeader && !this.#sharedUnprotectedHeader) {
2282
+ throw new JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");
2283
+ }
2284
+ if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader, this.#sharedUnprotectedHeader)) {
2285
+ throw new JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");
2286
+ }
2287
+ const joseHeader = {
2288
+ ...this.#protectedHeader,
2289
+ ...this.#unprotectedHeader,
2290
+ ...this.#sharedUnprotectedHeader
2291
+ };
2292
+ validateCrit(JWEInvalid, /* @__PURE__ */ new Map(), options?.crit, this.#protectedHeader, joseHeader);
2293
+ if (joseHeader.zip !== void 0) {
2294
+ throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
2295
+ }
2296
+ const { alg, enc } = joseHeader;
2297
+ if (typeof alg !== "string" || !alg) {
2298
+ throw new JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');
2299
+ }
2300
+ if (typeof enc !== "string" || !enc) {
2301
+ throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');
2302
+ }
2303
+ let encryptedKey;
2304
+ if (this.#cek && (alg === "dir" || alg === "ECDH-ES")) {
2305
+ throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${alg}`);
2306
+ }
2307
+ checkKeyType(alg === "dir" ? enc : alg, key, "encrypt");
2308
+ let cek;
2309
+ {
2310
+ let parameters;
2311
+ const k = await normalizeKey(key, alg);
2312
+ ({ cek, encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, this.#cek, this.#keyManagementParameters));
2313
+ if (parameters) {
2314
+ if (options && unprotected in options) {
2315
+ if (!this.#unprotectedHeader) {
2316
+ this.setUnprotectedHeader(parameters);
2317
+ } else {
2318
+ this.#unprotectedHeader = { ...this.#unprotectedHeader, ...parameters };
2319
+ }
2320
+ } else if (!this.#protectedHeader) {
2321
+ this.setProtectedHeader(parameters);
2322
+ } else {
2323
+ this.#protectedHeader = { ...this.#protectedHeader, ...parameters };
2324
+ }
2325
+ }
2326
+ }
2327
+ let additionalData;
2328
+ let protectedHeaderS;
2329
+ let protectedHeaderB;
2330
+ let aadMember;
2331
+ if (this.#protectedHeader) {
2332
+ protectedHeaderS = encode2(JSON.stringify(this.#protectedHeader));
2333
+ protectedHeaderB = encode(protectedHeaderS);
2334
+ } else {
2335
+ protectedHeaderS = "";
2336
+ protectedHeaderB = new Uint8Array();
2337
+ }
2338
+ if (this.#aad) {
2339
+ aadMember = encode2(this.#aad);
2340
+ const aadMemberBytes = encode(aadMember);
2341
+ additionalData = concat(protectedHeaderB, encode("."), aadMemberBytes);
2342
+ } else {
2343
+ additionalData = protectedHeaderB;
2344
+ }
2345
+ const { ciphertext, tag: tag2, iv } = await encrypt2(enc, this.#plaintext, cek, this.#iv, additionalData);
2346
+ const jwe = {
2347
+ ciphertext: encode2(ciphertext)
2348
+ };
2349
+ if (iv) {
2350
+ jwe.iv = encode2(iv);
2351
+ }
2352
+ if (tag2) {
2353
+ jwe.tag = encode2(tag2);
2354
+ }
2355
+ if (encryptedKey) {
2356
+ jwe.encrypted_key = encode2(encryptedKey);
2357
+ }
2358
+ if (aadMember) {
2359
+ jwe.aad = aadMember;
2360
+ }
2361
+ if (this.#protectedHeader) {
2362
+ jwe.protected = protectedHeaderS;
2363
+ }
2364
+ if (this.#sharedUnprotectedHeader) {
2365
+ jwe.unprotected = this.#sharedUnprotectedHeader;
2366
+ }
2367
+ if (this.#unprotectedHeader) {
2368
+ jwe.header = this.#unprotectedHeader;
2369
+ }
2370
+ return jwe;
2371
+ }
2372
+ };
2373
+
2374
+ // node_modules/jose/dist/webapi/jwe/general/encrypt.js
2375
+ var IndividualRecipient = class {
2376
+ static {
2377
+ __name(this, "IndividualRecipient");
2378
+ }
2379
+ #parent;
2380
+ unprotectedHeader;
2381
+ keyManagementParameters;
2382
+ key;
2383
+ options;
2384
+ constructor(enc, key, options) {
2385
+ this.#parent = enc;
2386
+ this.key = key;
2387
+ this.options = options;
2388
+ }
2389
+ setUnprotectedHeader(unprotectedHeader) {
2390
+ if (this.unprotectedHeader) {
2391
+ throw new TypeError("setUnprotectedHeader can only be called once");
2392
+ }
2393
+ this.unprotectedHeader = unprotectedHeader;
2394
+ return this;
2395
+ }
2396
+ setKeyManagementParameters(parameters) {
2397
+ if (this.keyManagementParameters) {
2398
+ throw new TypeError("setKeyManagementParameters can only be called once");
2399
+ }
2400
+ this.keyManagementParameters = parameters;
2401
+ return this;
2402
+ }
2403
+ addRecipient(...args) {
2404
+ return this.#parent.addRecipient(...args);
2405
+ }
2406
+ encrypt(...args) {
2407
+ return this.#parent.encrypt(...args);
2408
+ }
2409
+ done() {
2410
+ return this.#parent;
2411
+ }
2412
+ };
2413
+ var GeneralEncrypt = class {
2414
+ static {
2415
+ __name(this, "GeneralEncrypt");
2416
+ }
2417
+ #plaintext;
2418
+ #recipients = [];
2419
+ #protectedHeader;
2420
+ #unprotectedHeader;
2421
+ #aad;
2422
+ constructor(plaintext) {
2423
+ this.#plaintext = plaintext;
2424
+ }
2425
+ addRecipient(key, options) {
2426
+ const recipient = new IndividualRecipient(this, key, { crit: options?.crit });
2427
+ this.#recipients.push(recipient);
2428
+ return recipient;
2429
+ }
2430
+ setProtectedHeader(protectedHeader) {
2431
+ if (this.#protectedHeader) {
2432
+ throw new TypeError("setProtectedHeader can only be called once");
2433
+ }
2434
+ this.#protectedHeader = protectedHeader;
2435
+ return this;
2436
+ }
2437
+ setSharedUnprotectedHeader(sharedUnprotectedHeader) {
2438
+ if (this.#unprotectedHeader) {
2439
+ throw new TypeError("setSharedUnprotectedHeader can only be called once");
2440
+ }
2441
+ this.#unprotectedHeader = sharedUnprotectedHeader;
2442
+ return this;
2443
+ }
2444
+ setAdditionalAuthenticatedData(aad) {
2445
+ this.#aad = aad;
2446
+ return this;
2447
+ }
2448
+ async encrypt() {
2449
+ if (!this.#recipients.length) {
2450
+ throw new JWEInvalid("at least one recipient must be added");
2451
+ }
2452
+ if (this.#recipients.length === 1) {
2453
+ const [recipient] = this.#recipients;
2454
+ const flattened = await new FlattenedEncrypt(this.#plaintext).setAdditionalAuthenticatedData(this.#aad).setProtectedHeader(this.#protectedHeader).setSharedUnprotectedHeader(this.#unprotectedHeader).setUnprotectedHeader(recipient.unprotectedHeader).encrypt(recipient.key, { ...recipient.options });
2455
+ const jwe2 = {
2456
+ ciphertext: flattened.ciphertext,
2457
+ iv: flattened.iv,
2458
+ recipients: [{}],
2459
+ tag: flattened.tag
2460
+ };
2461
+ if (flattened.aad)
2462
+ jwe2.aad = flattened.aad;
2463
+ if (flattened.protected)
2464
+ jwe2.protected = flattened.protected;
2465
+ if (flattened.unprotected)
2466
+ jwe2.unprotected = flattened.unprotected;
2467
+ if (flattened.encrypted_key)
2468
+ jwe2.recipients[0].encrypted_key = flattened.encrypted_key;
2469
+ if (flattened.header)
2470
+ jwe2.recipients[0].header = flattened.header;
2471
+ return jwe2;
2472
+ }
2473
+ let enc;
2474
+ for (let i = 0; i < this.#recipients.length; i++) {
2475
+ const recipient = this.#recipients[i];
2476
+ if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader, recipient.unprotectedHeader)) {
2477
+ throw new JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");
2478
+ }
2479
+ const joseHeader = {
2480
+ ...this.#protectedHeader,
2481
+ ...this.#unprotectedHeader,
2482
+ ...recipient.unprotectedHeader
2483
+ };
2484
+ const { alg } = joseHeader;
2485
+ if (typeof alg !== "string" || !alg) {
2486
+ throw new JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');
2487
+ }
2488
+ if (alg === "dir" || alg === "ECDH-ES") {
2489
+ throw new JWEInvalid('"dir" and "ECDH-ES" alg may only be used with a single recipient');
2490
+ }
2491
+ if (typeof joseHeader.enc !== "string" || !joseHeader.enc) {
2492
+ throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');
2493
+ }
2494
+ if (!enc) {
2495
+ enc = joseHeader.enc;
2496
+ } else if (enc !== joseHeader.enc) {
2497
+ throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients');
2498
+ }
2499
+ validateCrit(JWEInvalid, /* @__PURE__ */ new Map(), recipient.options.crit, this.#protectedHeader, joseHeader);
2500
+ if (joseHeader.zip !== void 0) {
2501
+ throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
2502
+ }
2503
+ }
2504
+ const cek = generateCek(enc);
2505
+ const jwe = {
2506
+ ciphertext: "",
2507
+ recipients: []
2508
+ };
2509
+ for (let i = 0; i < this.#recipients.length; i++) {
2510
+ const recipient = this.#recipients[i];
2511
+ const target = {};
2512
+ jwe.recipients.push(target);
2513
+ if (i === 0) {
2514
+ const flattened = await new FlattenedEncrypt(this.#plaintext).setAdditionalAuthenticatedData(this.#aad).setContentEncryptionKey(cek).setProtectedHeader(this.#protectedHeader).setSharedUnprotectedHeader(this.#unprotectedHeader).setUnprotectedHeader(recipient.unprotectedHeader).setKeyManagementParameters(recipient.keyManagementParameters).encrypt(recipient.key, {
2515
+ ...recipient.options,
2516
+ [unprotected]: true
2517
+ });
2518
+ jwe.ciphertext = flattened.ciphertext;
2519
+ jwe.iv = flattened.iv;
2520
+ jwe.tag = flattened.tag;
2521
+ if (flattened.aad)
2522
+ jwe.aad = flattened.aad;
2523
+ if (flattened.protected)
2524
+ jwe.protected = flattened.protected;
2525
+ if (flattened.unprotected)
2526
+ jwe.unprotected = flattened.unprotected;
2527
+ target.encrypted_key = flattened.encrypted_key;
2528
+ if (flattened.header)
2529
+ target.header = flattened.header;
2530
+ continue;
2531
+ }
2532
+ const alg = recipient.unprotectedHeader?.alg || this.#protectedHeader?.alg || this.#unprotectedHeader?.alg;
2533
+ checkKeyType(alg === "dir" ? enc : alg, recipient.key, "encrypt");
2534
+ const k = await normalizeKey(recipient.key, alg);
2535
+ const { encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, cek, recipient.keyManagementParameters);
2536
+ target.encrypted_key = encode2(encryptedKey);
2537
+ if (recipient.unprotectedHeader || parameters)
2538
+ target.header = { ...recipient.unprotectedHeader, ...parameters };
2539
+ }
2540
+ return jwe;
2541
+ }
2542
+ };
2543
+
2544
+ // node_modules/jose/dist/webapi/jws/compact/verify.js
2545
+ init_esbuild_shims();
2546
+
2547
+ // node_modules/jose/dist/webapi/jws/flattened/verify.js
2548
+ init_esbuild_shims();
2549
+
2550
+ // node_modules/jose/dist/webapi/lib/verify.js
2551
+ init_esbuild_shims();
2552
+
2553
+ // node_modules/jose/dist/webapi/lib/subtle_dsa.js
2554
+ init_esbuild_shims();
2555
+ function subtleAlgorithm2(alg, algorithm) {
2556
+ const hash = `SHA-${alg.slice(-3)}`;
2557
+ switch (alg) {
2558
+ case "HS256":
2559
+ case "HS384":
2560
+ case "HS512":
2561
+ return { hash, name: "HMAC" };
2562
+ case "PS256":
2563
+ case "PS384":
2564
+ case "PS512":
2565
+ return { hash, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
2566
+ case "RS256":
2567
+ case "RS384":
2568
+ case "RS512":
2569
+ return { hash, name: "RSASSA-PKCS1-v1_5" };
2570
+ case "ES256":
2571
+ case "ES384":
2572
+ case "ES512":
2573
+ return { hash, name: "ECDSA", namedCurve: algorithm.namedCurve };
2574
+ case "Ed25519":
2575
+ case "EdDSA":
2576
+ return { name: "Ed25519" };
2577
+ case "ML-DSA-44":
2578
+ case "ML-DSA-65":
2579
+ case "ML-DSA-87":
2580
+ return { name: alg };
2581
+ default:
2582
+ throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
2583
+ }
2584
+ }
2585
+ __name(subtleAlgorithm2, "subtleAlgorithm");
2586
+
2587
+ // node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
2588
+ init_esbuild_shims();
2589
+ async function getSigKey(alg, key, usage) {
2590
+ if (key instanceof Uint8Array) {
2591
+ if (!alg.startsWith("HS")) {
2592
+ throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
2593
+ }
2594
+ return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
2595
+ }
2596
+ checkSigCryptoKey(key, alg, usage);
2597
+ return key;
2598
+ }
2599
+ __name(getSigKey, "getSigKey");
2600
+
2601
+ // node_modules/jose/dist/webapi/lib/verify.js
2602
+ async function verify(alg, key, signature, data) {
2603
+ const cryptoKey = await getSigKey(alg, key, "verify");
2604
+ checkKeyLength(alg, cryptoKey);
2605
+ const algorithm = subtleAlgorithm2(alg, cryptoKey.algorithm);
2606
+ try {
2607
+ return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
2608
+ } catch {
2609
+ return false;
2610
+ }
2611
+ }
2612
+ __name(verify, "verify");
2613
+
2614
+ // node_modules/jose/dist/webapi/jws/flattened/verify.js
2615
+ async function flattenedVerify(jws, key, options) {
2616
+ if (!isObject(jws)) {
2617
+ throw new JWSInvalid("Flattened JWS must be an object");
2618
+ }
2619
+ if (jws.protected === void 0 && jws.header === void 0) {
2620
+ throw new JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');
2621
+ }
2622
+ if (jws.protected !== void 0 && typeof jws.protected !== "string") {
2623
+ throw new JWSInvalid("JWS Protected Header incorrect type");
2624
+ }
2625
+ if (jws.payload === void 0) {
2626
+ throw new JWSInvalid("JWS Payload missing");
2627
+ }
2628
+ if (typeof jws.signature !== "string") {
2629
+ throw new JWSInvalid("JWS Signature missing or incorrect type");
2630
+ }
2631
+ if (jws.header !== void 0 && !isObject(jws.header)) {
2632
+ throw new JWSInvalid("JWS Unprotected Header incorrect type");
2633
+ }
2634
+ let parsedProt = {};
2635
+ if (jws.protected) {
2636
+ try {
2637
+ const protectedHeader = decode(jws.protected);
2638
+ parsedProt = JSON.parse(decoder.decode(protectedHeader));
2639
+ } catch {
2640
+ throw new JWSInvalid("JWS Protected Header is invalid");
2641
+ }
2642
+ }
2643
+ if (!isDisjoint(parsedProt, jws.header)) {
2644
+ throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
2645
+ }
2646
+ const joseHeader = {
2647
+ ...parsedProt,
2648
+ ...jws.header
2649
+ };
2650
+ const extensions = validateCrit(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options?.crit, parsedProt, joseHeader);
2651
+ let b64 = true;
2652
+ if (extensions.has("b64")) {
2653
+ b64 = parsedProt.b64;
2654
+ if (typeof b64 !== "boolean") {
2655
+ throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
2656
+ }
2657
+ }
2658
+ const { alg } = joseHeader;
2659
+ if (typeof alg !== "string" || !alg) {
2660
+ throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
2661
+ }
2662
+ const algorithms = options && validateAlgorithms("algorithms", options.algorithms);
2663
+ if (algorithms && !algorithms.has(alg)) {
2664
+ throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
2665
+ }
2666
+ if (b64) {
2667
+ if (typeof jws.payload !== "string") {
2668
+ throw new JWSInvalid("JWS Payload must be a string");
2669
+ }
2670
+ } else if (typeof jws.payload !== "string" && !(jws.payload instanceof Uint8Array)) {
2671
+ throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
2672
+ }
2673
+ let resolvedKey = false;
2674
+ if (typeof key === "function") {
2675
+ key = await key(parsedProt, jws);
2676
+ resolvedKey = true;
2677
+ }
2678
+ checkKeyType(alg, key, "verify");
2679
+ const data = concat(jws.protected !== void 0 ? encode(jws.protected) : new Uint8Array(), encode("."), typeof jws.payload === "string" ? b64 ? encode(jws.payload) : encoder.encode(jws.payload) : jws.payload);
2680
+ let signature;
2681
+ try {
2682
+ signature = decode(jws.signature);
2683
+ } catch {
2684
+ throw new JWSInvalid("Failed to base64url decode the signature");
2685
+ }
2686
+ const k = await normalizeKey(key, alg);
2687
+ const verified = await verify(alg, k, signature, data);
2688
+ if (!verified) {
2689
+ throw new JWSSignatureVerificationFailed();
2690
+ }
2691
+ let payload;
2692
+ if (b64) {
2693
+ try {
2694
+ payload = decode(jws.payload);
2695
+ } catch {
2696
+ throw new JWSInvalid("Failed to base64url decode the payload");
2697
+ }
2698
+ } else if (typeof jws.payload === "string") {
2699
+ payload = encoder.encode(jws.payload);
2700
+ } else {
2701
+ payload = jws.payload;
2702
+ }
2703
+ const result = { payload };
2704
+ if (jws.protected !== void 0) {
2705
+ result.protectedHeader = parsedProt;
2706
+ }
2707
+ if (jws.header !== void 0) {
2708
+ result.unprotectedHeader = jws.header;
2709
+ }
2710
+ if (resolvedKey) {
2711
+ return { ...result, key: k };
2712
+ }
2713
+ return result;
2714
+ }
2715
+ __name(flattenedVerify, "flattenedVerify");
2716
+
2717
+ // node_modules/jose/dist/webapi/jws/compact/verify.js
2718
+ async function compactVerify(jws, key, options) {
2719
+ if (jws instanceof Uint8Array) {
2720
+ jws = decoder.decode(jws);
2721
+ }
2722
+ if (typeof jws !== "string") {
2723
+ throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
2724
+ }
2725
+ const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split(".");
2726
+ if (length !== 3) {
2727
+ throw new JWSInvalid("Invalid Compact JWS");
2728
+ }
2729
+ const verified = await flattenedVerify({ payload, protected: protectedHeader, signature }, key, options);
2730
+ const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };
2731
+ if (typeof key === "function") {
2732
+ return { ...result, key: verified.key };
2733
+ }
2734
+ return result;
2735
+ }
2736
+ __name(compactVerify, "compactVerify");
2737
+
2738
+ // node_modules/jose/dist/webapi/jws/general/verify.js
2739
+ init_esbuild_shims();
2740
+ async function generalVerify(jws, key, options) {
2741
+ if (!isObject(jws)) {
2742
+ throw new JWSInvalid("General JWS must be an object");
2743
+ }
2744
+ if (!Array.isArray(jws.signatures) || !jws.signatures.every(isObject)) {
2745
+ throw new JWSInvalid("JWS Signatures missing or incorrect type");
2746
+ }
2747
+ for (const signature of jws.signatures) {
2748
+ try {
2749
+ return await flattenedVerify({
2750
+ header: signature.header,
2751
+ payload: jws.payload,
2752
+ protected: signature.protected,
2753
+ signature: signature.signature
2754
+ }, key, options);
2755
+ } catch {
2756
+ }
2757
+ }
2758
+ throw new JWSSignatureVerificationFailed();
2759
+ }
2760
+ __name(generalVerify, "generalVerify");
2761
+
2762
+ // node_modules/jose/dist/webapi/jwt/verify.js
2763
+ init_esbuild_shims();
2764
+
2765
+ // node_modules/jose/dist/webapi/lib/jwt_claims_set.js
2766
+ init_esbuild_shims();
2767
+ var epoch = /* @__PURE__ */ __name((date) => Math.floor(date.getTime() / 1e3), "epoch");
2768
+ var minute = 60;
2769
+ var hour = minute * 60;
2770
+ var day = hour * 24;
2771
+ var week = day * 7;
2772
+ var year = day * 365.25;
2773
+ 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;
2774
+ function secs(str) {
2775
+ const matched = REGEX.exec(str);
2776
+ if (!matched || matched[4] && matched[1]) {
2777
+ throw new TypeError("Invalid time period format");
2778
+ }
2779
+ const value = parseFloat(matched[2]);
2780
+ const unit = matched[3].toLowerCase();
2781
+ let numericDate;
2782
+ switch (unit) {
2783
+ case "sec":
2784
+ case "secs":
2785
+ case "second":
2786
+ case "seconds":
2787
+ case "s":
2788
+ numericDate = Math.round(value);
2789
+ break;
2790
+ case "minute":
2791
+ case "minutes":
2792
+ case "min":
2793
+ case "mins":
2794
+ case "m":
2795
+ numericDate = Math.round(value * minute);
2796
+ break;
2797
+ case "hour":
2798
+ case "hours":
2799
+ case "hr":
2800
+ case "hrs":
2801
+ case "h":
2802
+ numericDate = Math.round(value * hour);
2803
+ break;
2804
+ case "day":
2805
+ case "days":
2806
+ case "d":
2807
+ numericDate = Math.round(value * day);
2808
+ break;
2809
+ case "week":
2810
+ case "weeks":
2811
+ case "w":
2812
+ numericDate = Math.round(value * week);
2813
+ break;
2814
+ default:
2815
+ numericDate = Math.round(value * year);
2816
+ break;
2817
+ }
2818
+ if (matched[1] === "-" || matched[4] === "ago") {
2819
+ return -numericDate;
2820
+ }
2821
+ return numericDate;
2822
+ }
2823
+ __name(secs, "secs");
2824
+ function validateInput(label, input) {
2825
+ if (!Number.isFinite(input)) {
2826
+ throw new TypeError(`Invalid ${label} input`);
2827
+ }
2828
+ return input;
2829
+ }
2830
+ __name(validateInput, "validateInput");
2831
+ var normalizeTyp = /* @__PURE__ */ __name((value) => {
2832
+ if (value.includes("/")) {
2833
+ return value.toLowerCase();
2834
+ }
2835
+ return `application/${value.toLowerCase()}`;
2836
+ }, "normalizeTyp");
2837
+ var checkAudiencePresence = /* @__PURE__ */ __name((audPayload, audOption) => {
2838
+ if (typeof audPayload === "string") {
2839
+ return audOption.includes(audPayload);
2840
+ }
2841
+ if (Array.isArray(audPayload)) {
2842
+ return audOption.some(Set.prototype.has.bind(new Set(audPayload)));
2843
+ }
2844
+ return false;
2845
+ }, "checkAudiencePresence");
2846
+ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
2847
+ let payload;
2848
+ try {
2849
+ payload = JSON.parse(decoder.decode(encodedPayload));
2850
+ } catch {
2851
+ }
2852
+ if (!isObject(payload)) {
2853
+ throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
2854
+ }
2855
+ const { typ } = options;
2856
+ if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
2857
+ throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', payload, "typ", "check_failed");
2858
+ }
2859
+ const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
2860
+ const presenceCheck = [...requiredClaims];
2861
+ if (maxTokenAge !== void 0)
2862
+ presenceCheck.push("iat");
2863
+ if (audience !== void 0)
2864
+ presenceCheck.push("aud");
2865
+ if (subject !== void 0)
2866
+ presenceCheck.push("sub");
2867
+ if (issuer !== void 0)
2868
+ presenceCheck.push("iss");
2869
+ for (const claim of new Set(presenceCheck.reverse())) {
2870
+ if (!(claim in payload)) {
2871
+ throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, payload, claim, "missing");
2872
+ }
2873
+ }
2874
+ if (issuer && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {
2875
+ throw new JWTClaimValidationFailed('unexpected "iss" claim value', payload, "iss", "check_failed");
2876
+ }
2877
+ if (subject && payload.sub !== subject) {
2878
+ throw new JWTClaimValidationFailed('unexpected "sub" claim value', payload, "sub", "check_failed");
2879
+ }
2880
+ if (audience && !checkAudiencePresence(payload.aud, typeof audience === "string" ? [audience] : audience)) {
2881
+ throw new JWTClaimValidationFailed('unexpected "aud" claim value', payload, "aud", "check_failed");
2882
+ }
2883
+ let tolerance;
2884
+ switch (typeof options.clockTolerance) {
2885
+ case "string":
2886
+ tolerance = secs(options.clockTolerance);
2887
+ break;
2888
+ case "number":
2889
+ tolerance = options.clockTolerance;
2890
+ break;
2891
+ case "undefined":
2892
+ tolerance = 0;
2893
+ break;
2894
+ default:
2895
+ throw new TypeError("Invalid clockTolerance option type");
2896
+ }
2897
+ const { currentDate } = options;
2898
+ const now = epoch(currentDate || /* @__PURE__ */ new Date());
2899
+ if ((payload.iat !== void 0 || maxTokenAge) && typeof payload.iat !== "number") {
2900
+ throw new JWTClaimValidationFailed('"iat" claim must be a number', payload, "iat", "invalid");
2901
+ }
2902
+ if (payload.nbf !== void 0) {
2903
+ if (typeof payload.nbf !== "number") {
2904
+ throw new JWTClaimValidationFailed('"nbf" claim must be a number', payload, "nbf", "invalid");
2905
+ }
2906
+ if (payload.nbf > now + tolerance) {
2907
+ throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', payload, "nbf", "check_failed");
2908
+ }
2909
+ }
2910
+ if (payload.exp !== void 0) {
2911
+ if (typeof payload.exp !== "number") {
2912
+ throw new JWTClaimValidationFailed('"exp" claim must be a number', payload, "exp", "invalid");
2913
+ }
2914
+ if (payload.exp <= now - tolerance) {
2915
+ throw new JWTExpired('"exp" claim timestamp check failed', payload, "exp", "check_failed");
2916
+ }
2917
+ }
2918
+ if (maxTokenAge) {
2919
+ const age = now - payload.iat;
2920
+ const max = typeof maxTokenAge === "number" ? maxTokenAge : secs(maxTokenAge);
2921
+ if (age - tolerance > max) {
2922
+ throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', payload, "iat", "check_failed");
2923
+ }
2924
+ if (age < 0 - tolerance) {
2925
+ throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', payload, "iat", "check_failed");
2926
+ }
2927
+ }
2928
+ return payload;
2929
+ }
2930
+ __name(validateClaimsSet, "validateClaimsSet");
2931
+ var JWTClaimsBuilder = class {
2932
+ static {
2933
+ __name(this, "JWTClaimsBuilder");
2934
+ }
2935
+ #payload;
2936
+ constructor(payload) {
2937
+ if (!isObject(payload)) {
2938
+ throw new TypeError("JWT Claims Set MUST be an object");
2939
+ }
2940
+ this.#payload = structuredClone(payload);
2941
+ }
2942
+ data() {
2943
+ return encoder.encode(JSON.stringify(this.#payload));
2944
+ }
2945
+ get iss() {
2946
+ return this.#payload.iss;
2947
+ }
2948
+ set iss(value) {
2949
+ this.#payload.iss = value;
2950
+ }
2951
+ get sub() {
2952
+ return this.#payload.sub;
2953
+ }
2954
+ set sub(value) {
2955
+ this.#payload.sub = value;
2956
+ }
2957
+ get aud() {
2958
+ return this.#payload.aud;
2959
+ }
2960
+ set aud(value) {
2961
+ this.#payload.aud = value;
2962
+ }
2963
+ set jti(value) {
2964
+ this.#payload.jti = value;
2965
+ }
2966
+ set nbf(value) {
2967
+ if (typeof value === "number") {
2968
+ this.#payload.nbf = validateInput("setNotBefore", value);
2969
+ } else if (value instanceof Date) {
2970
+ this.#payload.nbf = validateInput("setNotBefore", epoch(value));
2971
+ } else {
2972
+ this.#payload.nbf = epoch(/* @__PURE__ */ new Date()) + secs(value);
2973
+ }
2974
+ }
2975
+ set exp(value) {
2976
+ if (typeof value === "number") {
2977
+ this.#payload.exp = validateInput("setExpirationTime", value);
2978
+ } else if (value instanceof Date) {
2979
+ this.#payload.exp = validateInput("setExpirationTime", epoch(value));
2980
+ } else {
2981
+ this.#payload.exp = epoch(/* @__PURE__ */ new Date()) + secs(value);
2982
+ }
2983
+ }
2984
+ set iat(value) {
2985
+ if (value === void 0) {
2986
+ this.#payload.iat = epoch(/* @__PURE__ */ new Date());
2987
+ } else if (value instanceof Date) {
2988
+ this.#payload.iat = validateInput("setIssuedAt", epoch(value));
2989
+ } else if (typeof value === "string") {
2990
+ this.#payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value));
2991
+ } else {
2992
+ this.#payload.iat = validateInput("setIssuedAt", value);
2993
+ }
2994
+ }
2995
+ };
2996
+
2997
+ // node_modules/jose/dist/webapi/jwt/verify.js
2998
+ async function jwtVerify(jwt, key, options) {
2999
+ const verified = await compactVerify(jwt, key, options);
3000
+ if (verified.protectedHeader.crit?.includes("b64") && verified.protectedHeader.b64 === false) {
3001
+ throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
3002
+ }
3003
+ const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options);
3004
+ const result = { payload, protectedHeader: verified.protectedHeader };
3005
+ if (typeof key === "function") {
3006
+ return { ...result, key: verified.key };
3007
+ }
3008
+ return result;
3009
+ }
3010
+ __name(jwtVerify, "jwtVerify");
3011
+
3012
+ // node_modules/jose/dist/webapi/jwt/decrypt.js
3013
+ init_esbuild_shims();
3014
+ async function jwtDecrypt(jwt, key, options) {
3015
+ const decrypted = await compactDecrypt(jwt, key, options);
3016
+ const payload = validateClaimsSet(decrypted.protectedHeader, decrypted.plaintext, options);
3017
+ const { protectedHeader } = decrypted;
3018
+ if (protectedHeader.iss !== void 0 && protectedHeader.iss !== payload.iss) {
3019
+ throw new JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch', payload, "iss", "mismatch");
3020
+ }
3021
+ if (protectedHeader.sub !== void 0 && protectedHeader.sub !== payload.sub) {
3022
+ throw new JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch', payload, "sub", "mismatch");
3023
+ }
3024
+ if (protectedHeader.aud !== void 0 && JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)) {
3025
+ throw new JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch', payload, "aud", "mismatch");
3026
+ }
3027
+ const result = { payload, protectedHeader };
3028
+ if (typeof key === "function") {
3029
+ return { ...result, key: decrypted.key };
3030
+ }
3031
+ return result;
3032
+ }
3033
+ __name(jwtDecrypt, "jwtDecrypt");
3034
+
3035
+ // node_modules/jose/dist/webapi/jwe/compact/encrypt.js
3036
+ init_esbuild_shims();
3037
+ var CompactEncrypt = class {
3038
+ static {
3039
+ __name(this, "CompactEncrypt");
3040
+ }
3041
+ #flattened;
3042
+ constructor(plaintext) {
3043
+ this.#flattened = new FlattenedEncrypt(plaintext);
3044
+ }
3045
+ setContentEncryptionKey(cek) {
3046
+ this.#flattened.setContentEncryptionKey(cek);
3047
+ return this;
3048
+ }
3049
+ setInitializationVector(iv) {
3050
+ this.#flattened.setInitializationVector(iv);
3051
+ return this;
3052
+ }
3053
+ setProtectedHeader(protectedHeader) {
3054
+ this.#flattened.setProtectedHeader(protectedHeader);
3055
+ return this;
3056
+ }
3057
+ setKeyManagementParameters(parameters) {
3058
+ this.#flattened.setKeyManagementParameters(parameters);
3059
+ return this;
3060
+ }
3061
+ async encrypt(key, options) {
3062
+ const jwe = await this.#flattened.encrypt(key, options);
3063
+ return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join(".");
3064
+ }
3065
+ };
3066
+
3067
+ // node_modules/jose/dist/webapi/jws/compact/sign.js
3068
+ init_esbuild_shims();
3069
+
3070
+ // node_modules/jose/dist/webapi/jws/flattened/sign.js
3071
+ init_esbuild_shims();
3072
+
3073
+ // node_modules/jose/dist/webapi/lib/sign.js
3074
+ init_esbuild_shims();
3075
+ async function sign(alg, key, data) {
3076
+ const cryptoKey = await getSigKey(alg, key, "sign");
3077
+ checkKeyLength(alg, cryptoKey);
3078
+ const signature = await crypto.subtle.sign(subtleAlgorithm2(alg, cryptoKey.algorithm), cryptoKey, data);
3079
+ return new Uint8Array(signature);
3080
+ }
3081
+ __name(sign, "sign");
3082
+
3083
+ // node_modules/jose/dist/webapi/jws/flattened/sign.js
3084
+ var FlattenedSign = class {
3085
+ static {
3086
+ __name(this, "FlattenedSign");
3087
+ }
3088
+ #payload;
3089
+ #protectedHeader;
3090
+ #unprotectedHeader;
3091
+ constructor(payload) {
3092
+ if (!(payload instanceof Uint8Array)) {
3093
+ throw new TypeError("payload must be an instance of Uint8Array");
3094
+ }
3095
+ this.#payload = payload;
3096
+ }
3097
+ setProtectedHeader(protectedHeader) {
3098
+ if (this.#protectedHeader) {
3099
+ throw new TypeError("setProtectedHeader can only be called once");
3100
+ }
3101
+ this.#protectedHeader = protectedHeader;
3102
+ return this;
3103
+ }
3104
+ setUnprotectedHeader(unprotectedHeader) {
3105
+ if (this.#unprotectedHeader) {
3106
+ throw new TypeError("setUnprotectedHeader can only be called once");
3107
+ }
3108
+ this.#unprotectedHeader = unprotectedHeader;
3109
+ return this;
3110
+ }
3111
+ async sign(key, options) {
3112
+ if (!this.#protectedHeader && !this.#unprotectedHeader) {
3113
+ throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
3114
+ }
3115
+ if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader)) {
3116
+ throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
3117
+ }
3118
+ const joseHeader = {
3119
+ ...this.#protectedHeader,
3120
+ ...this.#unprotectedHeader
3121
+ };
3122
+ const extensions = validateCrit(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options?.crit, this.#protectedHeader, joseHeader);
3123
+ let b64 = true;
3124
+ if (extensions.has("b64")) {
3125
+ b64 = this.#protectedHeader.b64;
3126
+ if (typeof b64 !== "boolean") {
3127
+ throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
3128
+ }
3129
+ }
3130
+ const { alg } = joseHeader;
3131
+ if (typeof alg !== "string" || !alg) {
3132
+ throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
3133
+ }
3134
+ checkKeyType(alg, key, "sign");
3135
+ let payloadS;
3136
+ let payloadB;
3137
+ if (b64) {
3138
+ payloadS = encode2(this.#payload);
3139
+ payloadB = encode(payloadS);
3140
+ } else {
3141
+ payloadB = this.#payload;
3142
+ payloadS = "";
3143
+ }
3144
+ let protectedHeaderString;
3145
+ let protectedHeaderBytes;
3146
+ if (this.#protectedHeader) {
3147
+ protectedHeaderString = encode2(JSON.stringify(this.#protectedHeader));
3148
+ protectedHeaderBytes = encode(protectedHeaderString);
3149
+ } else {
3150
+ protectedHeaderString = "";
3151
+ protectedHeaderBytes = new Uint8Array();
3152
+ }
3153
+ const data = concat(protectedHeaderBytes, encode("."), payloadB);
3154
+ const k = await normalizeKey(key, alg);
3155
+ const signature = await sign(alg, k, data);
3156
+ const jws = {
3157
+ signature: encode2(signature),
3158
+ payload: payloadS
3159
+ };
3160
+ if (this.#unprotectedHeader) {
3161
+ jws.header = this.#unprotectedHeader;
3162
+ }
3163
+ if (this.#protectedHeader) {
3164
+ jws.protected = protectedHeaderString;
3165
+ }
3166
+ return jws;
3167
+ }
3168
+ };
3169
+
3170
+ // node_modules/jose/dist/webapi/jws/compact/sign.js
3171
+ var CompactSign = class {
3172
+ static {
3173
+ __name(this, "CompactSign");
3174
+ }
3175
+ #flattened;
3176
+ constructor(payload) {
3177
+ this.#flattened = new FlattenedSign(payload);
3178
+ }
3179
+ setProtectedHeader(protectedHeader) {
3180
+ this.#flattened.setProtectedHeader(protectedHeader);
3181
+ return this;
3182
+ }
3183
+ async sign(key, options) {
3184
+ const jws = await this.#flattened.sign(key, options);
3185
+ if (jws.payload === void 0) {
3186
+ throw new TypeError("use the flattened module for creating JWS with b64: false");
3187
+ }
3188
+ return `${jws.protected}.${jws.payload}.${jws.signature}`;
3189
+ }
3190
+ };
3191
+
3192
+ // node_modules/jose/dist/webapi/jws/general/sign.js
3193
+ init_esbuild_shims();
3194
+ var IndividualSignature = class {
3195
+ static {
3196
+ __name(this, "IndividualSignature");
3197
+ }
3198
+ #parent;
3199
+ protectedHeader;
3200
+ unprotectedHeader;
3201
+ options;
3202
+ key;
3203
+ constructor(sig, key, options) {
3204
+ this.#parent = sig;
3205
+ this.key = key;
3206
+ this.options = options;
3207
+ }
3208
+ setProtectedHeader(protectedHeader) {
3209
+ if (this.protectedHeader) {
3210
+ throw new TypeError("setProtectedHeader can only be called once");
3211
+ }
3212
+ this.protectedHeader = protectedHeader;
3213
+ return this;
3214
+ }
3215
+ setUnprotectedHeader(unprotectedHeader) {
3216
+ if (this.unprotectedHeader) {
3217
+ throw new TypeError("setUnprotectedHeader can only be called once");
3218
+ }
3219
+ this.unprotectedHeader = unprotectedHeader;
3220
+ return this;
3221
+ }
3222
+ addSignature(...args) {
3223
+ return this.#parent.addSignature(...args);
3224
+ }
3225
+ sign(...args) {
3226
+ return this.#parent.sign(...args);
3227
+ }
3228
+ done() {
3229
+ return this.#parent;
3230
+ }
3231
+ };
3232
+ var GeneralSign = class {
3233
+ static {
3234
+ __name(this, "GeneralSign");
3235
+ }
3236
+ #payload;
3237
+ #signatures = [];
3238
+ constructor(payload) {
3239
+ this.#payload = payload;
3240
+ }
3241
+ addSignature(key, options) {
3242
+ const signature = new IndividualSignature(this, key, options);
3243
+ this.#signatures.push(signature);
3244
+ return signature;
3245
+ }
3246
+ async sign() {
3247
+ if (!this.#signatures.length) {
3248
+ throw new JWSInvalid("at least one signature must be added");
3249
+ }
3250
+ const jws = {
3251
+ signatures: [],
3252
+ payload: ""
3253
+ };
3254
+ for (let i = 0; i < this.#signatures.length; i++) {
3255
+ const signature = this.#signatures[i];
3256
+ const flattened = new FlattenedSign(this.#payload);
3257
+ flattened.setProtectedHeader(signature.protectedHeader);
3258
+ flattened.setUnprotectedHeader(signature.unprotectedHeader);
3259
+ const { payload, ...rest } = await flattened.sign(signature.key, signature.options);
3260
+ if (i === 0) {
3261
+ jws.payload = payload;
3262
+ } else if (jws.payload !== payload) {
3263
+ throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
3264
+ }
3265
+ jws.signatures.push(rest);
3266
+ }
3267
+ return jws;
3268
+ }
3269
+ };
3270
+
3271
+ // node_modules/jose/dist/webapi/jwt/sign.js
3272
+ init_esbuild_shims();
3273
+ var SignJWT = class {
3274
+ static {
3275
+ __name(this, "SignJWT");
3276
+ }
3277
+ #protectedHeader;
3278
+ #jwt;
3279
+ constructor(payload = {}) {
3280
+ this.#jwt = new JWTClaimsBuilder(payload);
3281
+ }
3282
+ setIssuer(issuer) {
3283
+ this.#jwt.iss = issuer;
3284
+ return this;
3285
+ }
3286
+ setSubject(subject) {
3287
+ this.#jwt.sub = subject;
3288
+ return this;
3289
+ }
3290
+ setAudience(audience) {
3291
+ this.#jwt.aud = audience;
3292
+ return this;
3293
+ }
3294
+ setJti(jwtId) {
3295
+ this.#jwt.jti = jwtId;
3296
+ return this;
3297
+ }
3298
+ setNotBefore(input) {
3299
+ this.#jwt.nbf = input;
3300
+ return this;
3301
+ }
3302
+ setExpirationTime(input) {
3303
+ this.#jwt.exp = input;
3304
+ return this;
3305
+ }
3306
+ setIssuedAt(input) {
3307
+ this.#jwt.iat = input;
3308
+ return this;
3309
+ }
3310
+ setProtectedHeader(protectedHeader) {
3311
+ this.#protectedHeader = protectedHeader;
3312
+ return this;
3313
+ }
3314
+ async sign(key, options) {
3315
+ const sig = new CompactSign(this.#jwt.data());
3316
+ sig.setProtectedHeader(this.#protectedHeader);
3317
+ if (Array.isArray(this.#protectedHeader?.crit) && this.#protectedHeader.crit.includes("b64") && this.#protectedHeader.b64 === false) {
3318
+ throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
3319
+ }
3320
+ return sig.sign(key, options);
3321
+ }
3322
+ };
3323
+
3324
+ // node_modules/jose/dist/webapi/jwt/encrypt.js
3325
+ init_esbuild_shims();
3326
+ var EncryptJWT = class {
3327
+ static {
3328
+ __name(this, "EncryptJWT");
3329
+ }
3330
+ #cek;
3331
+ #iv;
3332
+ #keyManagementParameters;
3333
+ #protectedHeader;
3334
+ #replicateIssuerAsHeader;
3335
+ #replicateSubjectAsHeader;
3336
+ #replicateAudienceAsHeader;
3337
+ #jwt;
3338
+ constructor(payload = {}) {
3339
+ this.#jwt = new JWTClaimsBuilder(payload);
3340
+ }
3341
+ setIssuer(issuer) {
3342
+ this.#jwt.iss = issuer;
3343
+ return this;
3344
+ }
3345
+ setSubject(subject) {
3346
+ this.#jwt.sub = subject;
3347
+ return this;
3348
+ }
3349
+ setAudience(audience) {
3350
+ this.#jwt.aud = audience;
3351
+ return this;
3352
+ }
3353
+ setJti(jwtId) {
3354
+ this.#jwt.jti = jwtId;
3355
+ return this;
3356
+ }
3357
+ setNotBefore(input) {
3358
+ this.#jwt.nbf = input;
3359
+ return this;
3360
+ }
3361
+ setExpirationTime(input) {
3362
+ this.#jwt.exp = input;
3363
+ return this;
3364
+ }
3365
+ setIssuedAt(input) {
3366
+ this.#jwt.iat = input;
3367
+ return this;
3368
+ }
3369
+ setProtectedHeader(protectedHeader) {
3370
+ if (this.#protectedHeader) {
3371
+ throw new TypeError("setProtectedHeader can only be called once");
3372
+ }
3373
+ this.#protectedHeader = protectedHeader;
3374
+ return this;
3375
+ }
3376
+ setKeyManagementParameters(parameters) {
3377
+ if (this.#keyManagementParameters) {
3378
+ throw new TypeError("setKeyManagementParameters can only be called once");
3379
+ }
3380
+ this.#keyManagementParameters = parameters;
3381
+ return this;
3382
+ }
3383
+ setContentEncryptionKey(cek) {
3384
+ if (this.#cek) {
3385
+ throw new TypeError("setContentEncryptionKey can only be called once");
3386
+ }
3387
+ this.#cek = cek;
3388
+ return this;
3389
+ }
3390
+ setInitializationVector(iv) {
3391
+ if (this.#iv) {
3392
+ throw new TypeError("setInitializationVector can only be called once");
3393
+ }
3394
+ this.#iv = iv;
3395
+ return this;
3396
+ }
3397
+ replicateIssuerAsHeader() {
3398
+ this.#replicateIssuerAsHeader = true;
3399
+ return this;
3400
+ }
3401
+ replicateSubjectAsHeader() {
3402
+ this.#replicateSubjectAsHeader = true;
3403
+ return this;
3404
+ }
3405
+ replicateAudienceAsHeader() {
3406
+ this.#replicateAudienceAsHeader = true;
3407
+ return this;
3408
+ }
3409
+ async encrypt(key, options) {
3410
+ const enc = new CompactEncrypt(this.#jwt.data());
3411
+ if (this.#protectedHeader && (this.#replicateIssuerAsHeader || this.#replicateSubjectAsHeader || this.#replicateAudienceAsHeader)) {
3412
+ this.#protectedHeader = {
3413
+ ...this.#protectedHeader,
3414
+ iss: this.#replicateIssuerAsHeader ? this.#jwt.iss : void 0,
3415
+ sub: this.#replicateSubjectAsHeader ? this.#jwt.sub : void 0,
3416
+ aud: this.#replicateAudienceAsHeader ? this.#jwt.aud : void 0
3417
+ };
3418
+ }
3419
+ enc.setProtectedHeader(this.#protectedHeader);
3420
+ if (this.#iv) {
3421
+ enc.setInitializationVector(this.#iv);
3422
+ }
3423
+ if (this.#cek) {
3424
+ enc.setContentEncryptionKey(this.#cek);
3425
+ }
3426
+ if (this.#keyManagementParameters) {
3427
+ enc.setKeyManagementParameters(this.#keyManagementParameters);
3428
+ }
3429
+ return enc.encrypt(key, options);
3430
+ }
3431
+ };
3432
+
3433
+ // node_modules/jose/dist/webapi/jwk/thumbprint.js
3434
+ init_esbuild_shims();
3435
+ var check = /* @__PURE__ */ __name((value, description) => {
3436
+ if (typeof value !== "string" || !value) {
3437
+ throw new JWKInvalid(`${description} missing or invalid`);
3438
+ }
3439
+ }, "check");
3440
+ async function calculateJwkThumbprint(key, digestAlgorithm) {
3441
+ let jwk;
3442
+ if (isJWK(key)) {
3443
+ jwk = key;
3444
+ } else if (isKeyLike(key)) {
3445
+ jwk = await exportJWK(key);
3446
+ } else {
3447
+ throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
3448
+ }
3449
+ digestAlgorithm ??= "sha256";
3450
+ if (digestAlgorithm !== "sha256" && digestAlgorithm !== "sha384" && digestAlgorithm !== "sha512") {
3451
+ throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');
3452
+ }
3453
+ let components;
3454
+ switch (jwk.kty) {
3455
+ case "AKP":
3456
+ check(jwk.alg, '"alg" (Algorithm) Parameter');
3457
+ check(jwk.pub, '"pub" (Public key) Parameter');
3458
+ components = { alg: jwk.alg, kty: jwk.kty, pub: jwk.pub };
3459
+ break;
3460
+ case "EC":
3461
+ check(jwk.crv, '"crv" (Curve) Parameter');
3462
+ check(jwk.x, '"x" (X Coordinate) Parameter');
3463
+ check(jwk.y, '"y" (Y Coordinate) Parameter');
3464
+ components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };
3465
+ break;
3466
+ case "OKP":
3467
+ check(jwk.crv, '"crv" (Subtype of Key Pair) Parameter');
3468
+ check(jwk.x, '"x" (Public Key) Parameter');
3469
+ components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };
3470
+ break;
3471
+ case "RSA":
3472
+ check(jwk.e, '"e" (Exponent) Parameter');
3473
+ check(jwk.n, '"n" (Modulus) Parameter');
3474
+ components = { e: jwk.e, kty: jwk.kty, n: jwk.n };
3475
+ break;
3476
+ case "oct":
3477
+ check(jwk.k, '"k" (Key Value) Parameter');
3478
+ components = { k: jwk.k, kty: jwk.kty };
3479
+ break;
3480
+ default:
3481
+ throw new JOSENotSupported('"kty" (Key Type) Parameter missing or unsupported');
3482
+ }
3483
+ const data = encode(JSON.stringify(components));
3484
+ return encode2(await digest(digestAlgorithm, data));
3485
+ }
3486
+ __name(calculateJwkThumbprint, "calculateJwkThumbprint");
3487
+ async function calculateJwkThumbprintUri(key, digestAlgorithm) {
3488
+ digestAlgorithm ??= "sha256";
3489
+ const thumbprint = await calculateJwkThumbprint(key, digestAlgorithm);
3490
+ return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
3491
+ }
3492
+ __name(calculateJwkThumbprintUri, "calculateJwkThumbprintUri");
3493
+
3494
+ // node_modules/jose/dist/webapi/jwk/embedded.js
3495
+ init_esbuild_shims();
3496
+ async function EmbeddedJWK(protectedHeader, token) {
3497
+ const joseHeader = {
3498
+ ...protectedHeader,
3499
+ ...token?.header
3500
+ };
3501
+ if (!isObject(joseHeader.jwk)) {
3502
+ throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
3503
+ }
3504
+ const key = await importJWK({ ...joseHeader.jwk, ext: true }, joseHeader.alg);
3505
+ if (key instanceof Uint8Array || key.type !== "public") {
3506
+ throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');
3507
+ }
3508
+ return key;
3509
+ }
3510
+ __name(EmbeddedJWK, "EmbeddedJWK");
3511
+
3512
+ // node_modules/jose/dist/webapi/jwks/local.js
3513
+ init_esbuild_shims();
3514
+ function getKtyFromAlg(alg) {
3515
+ switch (typeof alg === "string" && alg.slice(0, 2)) {
3516
+ case "RS":
3517
+ case "PS":
3518
+ return "RSA";
3519
+ case "ES":
3520
+ return "EC";
3521
+ case "Ed":
3522
+ return "OKP";
3523
+ case "ML":
3524
+ return "AKP";
3525
+ default:
3526
+ throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
3527
+ }
3528
+ }
3529
+ __name(getKtyFromAlg, "getKtyFromAlg");
3530
+ function isJWKSLike(jwks) {
3531
+ return jwks && typeof jwks === "object" && Array.isArray(jwks.keys) && jwks.keys.every(isJWKLike);
3532
+ }
3533
+ __name(isJWKSLike, "isJWKSLike");
3534
+ function isJWKLike(key) {
3535
+ return isObject(key);
3536
+ }
3537
+ __name(isJWKLike, "isJWKLike");
3538
+ var LocalJWKSet = class {
3539
+ static {
3540
+ __name(this, "LocalJWKSet");
3541
+ }
3542
+ #jwks;
3543
+ #cached = /* @__PURE__ */ new WeakMap();
3544
+ constructor(jwks) {
3545
+ if (!isJWKSLike(jwks)) {
3546
+ throw new JWKSInvalid("JSON Web Key Set malformed");
3547
+ }
3548
+ this.#jwks = structuredClone(jwks);
3549
+ }
3550
+ jwks() {
3551
+ return this.#jwks;
3552
+ }
3553
+ async getKey(protectedHeader, token) {
3554
+ const { alg, kid } = { ...protectedHeader, ...token?.header };
3555
+ const kty = getKtyFromAlg(alg);
3556
+ const candidates = this.#jwks.keys.filter((jwk2) => {
3557
+ let candidate = kty === jwk2.kty;
3558
+ if (candidate && typeof kid === "string") {
3559
+ candidate = kid === jwk2.kid;
3560
+ }
3561
+ if (candidate && (typeof jwk2.alg === "string" || kty === "AKP")) {
3562
+ candidate = alg === jwk2.alg;
3563
+ }
3564
+ if (candidate && typeof jwk2.use === "string") {
3565
+ candidate = jwk2.use === "sig";
3566
+ }
3567
+ if (candidate && Array.isArray(jwk2.key_ops)) {
3568
+ candidate = jwk2.key_ops.includes("verify");
3569
+ }
3570
+ if (candidate) {
3571
+ switch (alg) {
3572
+ case "ES256":
3573
+ candidate = jwk2.crv === "P-256";
3574
+ break;
3575
+ case "ES384":
3576
+ candidate = jwk2.crv === "P-384";
3577
+ break;
3578
+ case "ES512":
3579
+ candidate = jwk2.crv === "P-521";
3580
+ break;
3581
+ case "Ed25519":
3582
+ case "EdDSA":
3583
+ candidate = jwk2.crv === "Ed25519";
3584
+ break;
3585
+ }
3586
+ }
3587
+ return candidate;
3588
+ });
3589
+ const { 0: jwk, length } = candidates;
3590
+ if (length === 0) {
3591
+ throw new JWKSNoMatchingKey();
3592
+ }
3593
+ if (length !== 1) {
3594
+ const error = new JWKSMultipleMatchingKeys();
3595
+ const _cached = this.#cached;
3596
+ error[Symbol.asyncIterator] = async function* () {
3597
+ for (const jwk2 of candidates) {
3598
+ try {
3599
+ yield await importWithAlgCache(_cached, jwk2, alg);
3600
+ } catch {
3601
+ }
3602
+ }
3603
+ };
3604
+ throw error;
3605
+ }
3606
+ return importWithAlgCache(this.#cached, jwk, alg);
3607
+ }
3608
+ };
3609
+ async function importWithAlgCache(cache2, jwk, alg) {
3610
+ const cached = cache2.get(jwk) || cache2.set(jwk, {}).get(jwk);
3611
+ if (cached[alg] === void 0) {
3612
+ const key = await importJWK({ ...jwk, ext: true }, alg);
3613
+ if (key instanceof Uint8Array || key.type !== "public") {
3614
+ throw new JWKSInvalid("JSON Web Key Set members must be public keys");
3615
+ }
3616
+ cached[alg] = key;
3617
+ }
3618
+ return cached[alg];
3619
+ }
3620
+ __name(importWithAlgCache, "importWithAlgCache");
3621
+ function createLocalJWKSet(jwks) {
3622
+ const set = new LocalJWKSet(jwks);
3623
+ const localJWKSet = /* @__PURE__ */ __name(async (protectedHeader, token) => set.getKey(protectedHeader, token), "localJWKSet");
3624
+ Object.defineProperties(localJWKSet, {
3625
+ jwks: {
3626
+ value: /* @__PURE__ */ __name(() => structuredClone(set.jwks()), "value"),
3627
+ enumerable: false,
3628
+ configurable: false,
3629
+ writable: false
3630
+ }
3631
+ });
3632
+ return localJWKSet;
3633
+ }
3634
+ __name(createLocalJWKSet, "createLocalJWKSet");
3635
+
3636
+ // node_modules/jose/dist/webapi/jwks/remote.js
3637
+ init_esbuild_shims();
3638
+ function isCloudflareWorkers() {
3639
+ return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
3640
+ }
3641
+ __name(isCloudflareWorkers, "isCloudflareWorkers");
3642
+ var USER_AGENT;
3643
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
3644
+ const NAME = "jose";
3645
+ const VERSION = "v6.1.3";
3646
+ USER_AGENT = `${NAME}/${VERSION}`;
3647
+ }
3648
+ var customFetch = Symbol();
3649
+ async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
3650
+ const response = await fetchImpl(url, {
3651
+ method: "GET",
3652
+ signal,
3653
+ redirect: "manual",
3654
+ headers
3655
+ }).catch((err) => {
3656
+ if (err.name === "TimeoutError") {
3657
+ throw new JWKSTimeout();
3658
+ }
3659
+ throw err;
3660
+ });
3661
+ if (response.status !== 200) {
3662
+ throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
3663
+ }
3664
+ try {
3665
+ return await response.json();
3666
+ } catch {
3667
+ throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
3668
+ }
3669
+ }
3670
+ __name(fetchJwks, "fetchJwks");
3671
+ var jwksCache = Symbol();
3672
+ function isFreshJwksCache(input, cacheMaxAge) {
3673
+ if (typeof input !== "object" || input === null) {
3674
+ return false;
3675
+ }
3676
+ if (!("uat" in input) || typeof input.uat !== "number" || Date.now() - input.uat >= cacheMaxAge) {
3677
+ return false;
3678
+ }
3679
+ if (!("jwks" in input) || !isObject(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isObject)) {
3680
+ return false;
3681
+ }
3682
+ return true;
3683
+ }
3684
+ __name(isFreshJwksCache, "isFreshJwksCache");
3685
+ var RemoteJWKSet = class {
3686
+ static {
3687
+ __name(this, "RemoteJWKSet");
3688
+ }
3689
+ #url;
3690
+ #timeoutDuration;
3691
+ #cooldownDuration;
3692
+ #cacheMaxAge;
3693
+ #jwksTimestamp;
3694
+ #pendingFetch;
3695
+ #headers;
3696
+ #customFetch;
3697
+ #local;
3698
+ #cache;
3699
+ constructor(url, options) {
3700
+ if (!(url instanceof URL)) {
3701
+ throw new TypeError("url must be an instance of URL");
3702
+ }
3703
+ this.#url = new URL(url.href);
3704
+ this.#timeoutDuration = typeof options?.timeoutDuration === "number" ? options?.timeoutDuration : 5e3;
3705
+ this.#cooldownDuration = typeof options?.cooldownDuration === "number" ? options?.cooldownDuration : 3e4;
3706
+ this.#cacheMaxAge = typeof options?.cacheMaxAge === "number" ? options?.cacheMaxAge : 6e5;
3707
+ this.#headers = new Headers(options?.headers);
3708
+ if (USER_AGENT && !this.#headers.has("User-Agent")) {
3709
+ this.#headers.set("User-Agent", USER_AGENT);
3710
+ }
3711
+ if (!this.#headers.has("accept")) {
3712
+ this.#headers.set("accept", "application/json");
3713
+ this.#headers.append("accept", "application/jwk-set+json");
3714
+ }
3715
+ this.#customFetch = options?.[customFetch];
3716
+ if (options?.[jwksCache] !== void 0) {
3717
+ this.#cache = options?.[jwksCache];
3718
+ if (isFreshJwksCache(options?.[jwksCache], this.#cacheMaxAge)) {
3719
+ this.#jwksTimestamp = this.#cache.uat;
3720
+ this.#local = createLocalJWKSet(this.#cache.jwks);
3721
+ }
3722
+ }
3723
+ }
3724
+ pendingFetch() {
3725
+ return !!this.#pendingFetch;
3726
+ }
3727
+ coolingDown() {
3728
+ return typeof this.#jwksTimestamp === "number" ? Date.now() < this.#jwksTimestamp + this.#cooldownDuration : false;
3729
+ }
3730
+ fresh() {
3731
+ return typeof this.#jwksTimestamp === "number" ? Date.now() < this.#jwksTimestamp + this.#cacheMaxAge : false;
3732
+ }
3733
+ jwks() {
3734
+ return this.#local?.jwks();
3735
+ }
3736
+ async getKey(protectedHeader, token) {
3737
+ if (!this.#local || !this.fresh()) {
3738
+ await this.reload();
3739
+ }
3740
+ try {
3741
+ return await this.#local(protectedHeader, token);
3742
+ } catch (err) {
3743
+ if (err instanceof JWKSNoMatchingKey) {
3744
+ if (this.coolingDown() === false) {
3745
+ await this.reload();
3746
+ return this.#local(protectedHeader, token);
3747
+ }
3748
+ }
3749
+ throw err;
3750
+ }
3751
+ }
3752
+ async reload() {
3753
+ if (this.#pendingFetch && isCloudflareWorkers()) {
3754
+ this.#pendingFetch = void 0;
3755
+ }
3756
+ this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch).then((json) => {
3757
+ this.#local = createLocalJWKSet(json);
3758
+ if (this.#cache) {
3759
+ this.#cache.uat = Date.now();
3760
+ this.#cache.jwks = json;
3761
+ }
3762
+ this.#jwksTimestamp = Date.now();
3763
+ this.#pendingFetch = void 0;
3764
+ }).catch((err) => {
3765
+ this.#pendingFetch = void 0;
3766
+ throw err;
3767
+ });
3768
+ await this.#pendingFetch;
3769
+ }
3770
+ };
3771
+ function createRemoteJWKSet(url, options) {
3772
+ const set = new RemoteJWKSet(url, options);
3773
+ const remoteJWKSet = /* @__PURE__ */ __name(async (protectedHeader, token) => set.getKey(protectedHeader, token), "remoteJWKSet");
3774
+ Object.defineProperties(remoteJWKSet, {
3775
+ coolingDown: {
3776
+ get: /* @__PURE__ */ __name(() => set.coolingDown(), "get"),
3777
+ enumerable: true,
3778
+ configurable: false
3779
+ },
3780
+ fresh: {
3781
+ get: /* @__PURE__ */ __name(() => set.fresh(), "get"),
3782
+ enumerable: true,
3783
+ configurable: false
3784
+ },
3785
+ reload: {
3786
+ value: /* @__PURE__ */ __name(() => set.reload(), "value"),
3787
+ enumerable: true,
3788
+ configurable: false,
3789
+ writable: false
3790
+ },
3791
+ reloading: {
3792
+ get: /* @__PURE__ */ __name(() => set.pendingFetch(), "get"),
3793
+ enumerable: true,
3794
+ configurable: false
3795
+ },
3796
+ jwks: {
3797
+ value: /* @__PURE__ */ __name(() => set.jwks(), "value"),
3798
+ enumerable: true,
3799
+ configurable: false,
3800
+ writable: false
3801
+ }
3802
+ });
3803
+ return remoteJWKSet;
3804
+ }
3805
+ __name(createRemoteJWKSet, "createRemoteJWKSet");
3806
+
3807
+ // node_modules/jose/dist/webapi/jwt/unsecured.js
3808
+ init_esbuild_shims();
3809
+ var UnsecuredJWT = class {
3810
+ static {
3811
+ __name(this, "UnsecuredJWT");
3812
+ }
3813
+ #jwt;
3814
+ constructor(payload = {}) {
3815
+ this.#jwt = new JWTClaimsBuilder(payload);
3816
+ }
3817
+ encode() {
3818
+ const header = encode2(JSON.stringify({ alg: "none" }));
3819
+ const payload = encode2(this.#jwt.data());
3820
+ return `${header}.${payload}.`;
3821
+ }
3822
+ setIssuer(issuer) {
3823
+ this.#jwt.iss = issuer;
3824
+ return this;
3825
+ }
3826
+ setSubject(subject) {
3827
+ this.#jwt.sub = subject;
3828
+ return this;
3829
+ }
3830
+ setAudience(audience) {
3831
+ this.#jwt.aud = audience;
3832
+ return this;
3833
+ }
3834
+ setJti(jwtId) {
3835
+ this.#jwt.jti = jwtId;
3836
+ return this;
3837
+ }
3838
+ setNotBefore(input) {
3839
+ this.#jwt.nbf = input;
3840
+ return this;
3841
+ }
3842
+ setExpirationTime(input) {
3843
+ this.#jwt.exp = input;
3844
+ return this;
3845
+ }
3846
+ setIssuedAt(input) {
3847
+ this.#jwt.iat = input;
3848
+ return this;
3849
+ }
3850
+ static decode(jwt, options) {
3851
+ if (typeof jwt !== "string") {
3852
+ throw new JWTInvalid("Unsecured JWT must be a string");
3853
+ }
3854
+ const { 0: encodedHeader, 1: encodedPayload, 2: signature, length } = jwt.split(".");
3855
+ if (length !== 3 || signature !== "") {
3856
+ throw new JWTInvalid("Invalid Unsecured JWT");
3857
+ }
3858
+ let header;
3859
+ try {
3860
+ header = JSON.parse(decoder.decode(decode(encodedHeader)));
3861
+ if (header.alg !== "none")
3862
+ throw new Error();
3863
+ } catch {
3864
+ throw new JWTInvalid("Invalid Unsecured JWT");
3865
+ }
3866
+ const payload = validateClaimsSet(header, decode(encodedPayload), options);
3867
+ return { payload, header };
3868
+ }
3869
+ };
3870
+
3871
+ // node_modules/jose/dist/webapi/util/decode_protected_header.js
3872
+ init_esbuild_shims();
3873
+ function decodeProtectedHeader(token) {
3874
+ let protectedB64u;
3875
+ if (typeof token === "string") {
3876
+ const parts = token.split(".");
3877
+ if (parts.length === 3 || parts.length === 5) {
3878
+ ;
3879
+ [protectedB64u] = parts;
3880
+ }
3881
+ } else if (typeof token === "object" && token) {
3882
+ if ("protected" in token) {
3883
+ protectedB64u = token.protected;
3884
+ } else {
3885
+ throw new TypeError("Token does not contain a Protected Header");
3886
+ }
3887
+ }
3888
+ try {
3889
+ if (typeof protectedB64u !== "string" || !protectedB64u) {
3890
+ throw new Error();
3891
+ }
3892
+ const result = JSON.parse(decoder.decode(decode(protectedB64u)));
3893
+ if (!isObject(result)) {
3894
+ throw new Error();
3895
+ }
3896
+ return result;
3897
+ } catch {
3898
+ throw new TypeError("Invalid Token or Protected Header formatting");
3899
+ }
3900
+ }
3901
+ __name(decodeProtectedHeader, "decodeProtectedHeader");
3902
+
3903
+ // node_modules/jose/dist/webapi/util/decode_jwt.js
3904
+ init_esbuild_shims();
3905
+ function decodeJwt(jwt) {
3906
+ if (typeof jwt !== "string")
3907
+ throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
3908
+ const { 1: payload, length } = jwt.split(".");
3909
+ if (length === 5)
3910
+ throw new JWTInvalid("Only JWTs using Compact JWS serialization can be decoded");
3911
+ if (length !== 3)
3912
+ throw new JWTInvalid("Invalid JWT");
3913
+ if (!payload)
3914
+ throw new JWTInvalid("JWTs must contain a payload");
3915
+ let decoded;
3916
+ try {
3917
+ decoded = decode(payload);
3918
+ } catch {
3919
+ throw new JWTInvalid("Failed to base64url decode the payload");
3920
+ }
3921
+ let result;
3922
+ try {
3923
+ result = JSON.parse(decoder.decode(decoded));
3924
+ } catch {
3925
+ throw new JWTInvalid("Failed to parse the decoded payload as JSON");
3926
+ }
3927
+ if (!isObject(result))
3928
+ throw new JWTInvalid("Invalid JWT Claims Set");
3929
+ return result;
3930
+ }
3931
+ __name(decodeJwt, "decodeJwt");
3932
+
3933
+ // node_modules/jose/dist/webapi/key/generate_key_pair.js
3934
+ init_esbuild_shims();
3935
+ function getModulusLengthOption(options) {
3936
+ const modulusLength = options?.modulusLength ?? 2048;
3937
+ if (typeof modulusLength !== "number" || modulusLength < 2048) {
3938
+ throw new JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");
3939
+ }
3940
+ return modulusLength;
3941
+ }
3942
+ __name(getModulusLengthOption, "getModulusLengthOption");
3943
+ async function generateKeyPair(alg, options) {
3944
+ let algorithm;
3945
+ let keyUsages;
3946
+ switch (alg) {
3947
+ case "PS256":
3948
+ case "PS384":
3949
+ case "PS512":
3950
+ algorithm = {
3951
+ name: "RSA-PSS",
3952
+ hash: `SHA-${alg.slice(-3)}`,
3953
+ publicExponent: Uint8Array.of(1, 0, 1),
3954
+ modulusLength: getModulusLengthOption(options)
3955
+ };
3956
+ keyUsages = ["sign", "verify"];
3957
+ break;
3958
+ case "RS256":
3959
+ case "RS384":
3960
+ case "RS512":
3961
+ algorithm = {
3962
+ name: "RSASSA-PKCS1-v1_5",
3963
+ hash: `SHA-${alg.slice(-3)}`,
3964
+ publicExponent: Uint8Array.of(1, 0, 1),
3965
+ modulusLength: getModulusLengthOption(options)
3966
+ };
3967
+ keyUsages = ["sign", "verify"];
3968
+ break;
3969
+ case "RSA-OAEP":
3970
+ case "RSA-OAEP-256":
3971
+ case "RSA-OAEP-384":
3972
+ case "RSA-OAEP-512":
3973
+ algorithm = {
3974
+ name: "RSA-OAEP",
3975
+ hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`,
3976
+ publicExponent: Uint8Array.of(1, 0, 1),
3977
+ modulusLength: getModulusLengthOption(options)
3978
+ };
3979
+ keyUsages = ["decrypt", "unwrapKey", "encrypt", "wrapKey"];
3980
+ break;
3981
+ case "ES256":
3982
+ algorithm = { name: "ECDSA", namedCurve: "P-256" };
3983
+ keyUsages = ["sign", "verify"];
3984
+ break;
3985
+ case "ES384":
3986
+ algorithm = { name: "ECDSA", namedCurve: "P-384" };
3987
+ keyUsages = ["sign", "verify"];
3988
+ break;
3989
+ case "ES512":
3990
+ algorithm = { name: "ECDSA", namedCurve: "P-521" };
3991
+ keyUsages = ["sign", "verify"];
3992
+ break;
3993
+ case "Ed25519":
3994
+ case "EdDSA": {
3995
+ keyUsages = ["sign", "verify"];
3996
+ algorithm = { name: "Ed25519" };
3997
+ break;
3998
+ }
3999
+ case "ML-DSA-44":
4000
+ case "ML-DSA-65":
4001
+ case "ML-DSA-87": {
4002
+ keyUsages = ["sign", "verify"];
4003
+ algorithm = { name: alg };
4004
+ break;
4005
+ }
4006
+ case "ECDH-ES":
4007
+ case "ECDH-ES+A128KW":
4008
+ case "ECDH-ES+A192KW":
4009
+ case "ECDH-ES+A256KW": {
4010
+ keyUsages = ["deriveBits"];
4011
+ const crv = options?.crv ?? "P-256";
4012
+ switch (crv) {
4013
+ case "P-256":
4014
+ case "P-384":
4015
+ case "P-521": {
4016
+ algorithm = { name: "ECDH", namedCurve: crv };
4017
+ break;
4018
+ }
4019
+ case "X25519":
4020
+ algorithm = { name: "X25519" };
4021
+ break;
4022
+ default:
4023
+ throw new JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519");
4024
+ }
4025
+ break;
4026
+ }
4027
+ default:
4028
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
4029
+ }
4030
+ return crypto.subtle.generateKey(algorithm, options?.extractable ?? false, keyUsages);
4031
+ }
4032
+ __name(generateKeyPair, "generateKeyPair");
4033
+
4034
+ // node_modules/jose/dist/webapi/key/generate_secret.js
4035
+ init_esbuild_shims();
4036
+ async function generateSecret(alg, options) {
4037
+ let length;
4038
+ let algorithm;
4039
+ let keyUsages;
4040
+ switch (alg) {
4041
+ case "HS256":
4042
+ case "HS384":
4043
+ case "HS512":
4044
+ length = parseInt(alg.slice(-3), 10);
4045
+ algorithm = { name: "HMAC", hash: `SHA-${length}`, length };
4046
+ keyUsages = ["sign", "verify"];
4047
+ break;
4048
+ case "A128CBC-HS256":
4049
+ case "A192CBC-HS384":
4050
+ case "A256CBC-HS512":
4051
+ length = parseInt(alg.slice(-3), 10);
4052
+ return crypto.getRandomValues(new Uint8Array(length >> 3));
4053
+ case "A128KW":
4054
+ case "A192KW":
4055
+ case "A256KW":
4056
+ length = parseInt(alg.slice(1, 4), 10);
4057
+ algorithm = { name: "AES-KW", length };
4058
+ keyUsages = ["wrapKey", "unwrapKey"];
4059
+ break;
4060
+ case "A128GCMKW":
4061
+ case "A192GCMKW":
4062
+ case "A256GCMKW":
4063
+ case "A128GCM":
4064
+ case "A192GCM":
4065
+ case "A256GCM":
4066
+ length = parseInt(alg.slice(1, 4), 10);
4067
+ algorithm = { name: "AES-GCM", length };
4068
+ keyUsages = ["encrypt", "decrypt"];
4069
+ break;
4070
+ default:
4071
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
4072
+ }
4073
+ return crypto.subtle.generateKey(algorithm, options?.extractable ?? false, keyUsages);
4074
+ }
4075
+ __name(generateSecret, "generateSecret");
4076
+
4077
+ // node_modules/jose/dist/webapi/index.js
4078
+ var cryptoRuntime = "WebCryptoAPI";
4079
+ export {
4080
+ CompactEncrypt,
4081
+ CompactSign,
4082
+ EmbeddedJWK,
4083
+ EncryptJWT,
4084
+ FlattenedEncrypt,
4085
+ FlattenedSign,
4086
+ GeneralEncrypt,
4087
+ GeneralSign,
4088
+ SignJWT,
4089
+ UnsecuredJWT,
4090
+ base64url_exports as base64url,
4091
+ calculateJwkThumbprint,
4092
+ calculateJwkThumbprintUri,
4093
+ compactDecrypt,
4094
+ compactVerify,
4095
+ createLocalJWKSet,
4096
+ createRemoteJWKSet,
4097
+ cryptoRuntime,
4098
+ customFetch,
4099
+ decodeJwt,
4100
+ decodeProtectedHeader,
4101
+ errors_exports as errors,
4102
+ exportJWK,
4103
+ exportPKCS8,
4104
+ exportSPKI,
4105
+ flattenedDecrypt,
4106
+ flattenedVerify,
4107
+ generalDecrypt,
4108
+ generalVerify,
4109
+ generateKeyPair,
4110
+ generateSecret,
4111
+ importJWK,
4112
+ importPKCS8,
4113
+ importSPKI,
4114
+ importX509,
4115
+ jwksCache,
4116
+ jwtDecrypt,
4117
+ jwtVerify
4118
+ };