@poe-platform/safe-bash 0.1.799 → 0.1.800

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 (847) hide show
  1. package/README.md +32 -17
  2. package/dist/image-ast/index.browser.js +1384 -23
  3. package/dist/image-ast/index.js +1384 -23
  4. package/dist/mp4-ast/types.d.ts +1 -0
  5. package/dist/office-package/zip.d.ts +2 -0
  6. package/dist/office-package/zip.js +1 -1
  7. package/dist/pdf-ast/index.js +1 -1
  8. package/dist/safe-bash/chunks/{chunk-IUTD5FH5.js → chunk-46UISJCK.js} +1 -6
  9. package/dist/safe-bash/chunks/chunk-4SEW2Q6H.js +26 -0
  10. package/dist/safe-bash/chunks/{chunk-AKC46AF6.js → chunk-7YSRXFEG.js} +7 -40
  11. package/dist/safe-bash/chunks/{chunk-KTGR4U57.js → chunk-BHJE5LPZ.js} +1 -2
  12. package/dist/safe-bash/chunks/{chunk-TRVGCN3U.js → chunk-HHW7MGS2.js} +2 -2
  13. package/dist/safe-bash/chunks/{chunk-ZNAFMYIA.js → chunk-I7L3G3NX.js} +1 -1
  14. package/dist/safe-bash/chunks/{chunk-KMH2DF3I.js → chunk-JJSTTIEZ.js} +6 -1
  15. package/dist/safe-bash/chunks/{chunk-6IBTC4YL.js → chunk-JTLSUJ7V.js} +57 -20
  16. package/dist/safe-bash/chunks/chunk-K2VCOJ2B.js +111 -0
  17. package/dist/safe-bash/chunks/chunk-K4YMYFRJ.js +9802 -0
  18. package/dist/safe-bash/chunks/{chunk-SPYL72GN.js → chunk-KW24TAIU.js} +446 -5519
  19. package/dist/safe-bash/chunks/{chunk-ENR3HB2B.js → chunk-NLAW7KDI.js} +0 -1
  20. package/dist/safe-bash/chunks/{chunk-B3DDEDH2.js → chunk-PPYM75Z3.js} +1 -1
  21. package/dist/safe-bash/chunks/{chunk-NX2SQVON.js → chunk-RKKRJ54E.js} +19 -7
  22. package/dist/safe-bash/chunks/{chunk-WUNK5NXJ.js → chunk-RMWLWH7Q.js} +870 -953
  23. package/dist/safe-bash/chunks/{chunk-JSVX4VIA.js → chunk-TFGRKY43.js} +2 -1
  24. package/dist/safe-bash/chunks/{chunk-T5KKDMYB.js → chunk-TYD7EVUJ.js} +6 -0
  25. package/dist/safe-bash/chunks/{csvkit-W2UEKH6P.js → csvkit-QGP3GAOB.js} +1 -1
  26. package/dist/safe-bash/chunks/{ffmpeg-42CGASMV.js → ffmpeg-JTVH26MK.js} +1 -1
  27. package/dist/safe-bash/chunks/{gh-26GYLH6D.js → gh-I7QX7N5C.js} +1 -1
  28. package/dist/safe-bash/chunks/{git-YREKMUVD.js → git-MA7NKYVP.js} +1 -1
  29. package/dist/safe-bash/chunks/{imagemagick-3YIX4XO2.js → imagemagick-Y4NPWX2Q.js} +1 -1
  30. package/dist/safe-bash/chunks/{implementation-E3YMKU3Z.js → implementation-BWDKOVQJ.js} +1 -1
  31. package/dist/safe-bash/chunks/mmdc-44PELHDG.js +118 -0
  32. package/dist/safe-bash/chunks/{pdfimages-UE2UISP2.js → pdfimages-635TRW4Q.js} +1 -1
  33. package/dist/safe-bash/chunks/{pdfinfo-RGARKLI5.js → pdfinfo-FSDAA2KY.js} +3 -11
  34. package/dist/safe-bash/chunks/{pdftk-JY3WVCCC.js → pdftk-GQ5UH3VG.js} +1 -1
  35. package/dist/safe-bash/chunks/{pdftoppm-GPD3BMPY.js → pdftoppm-YTXQCAYT.js} +1 -1
  36. package/dist/safe-bash/chunks/{pdftotext-K7GQ2QJZ.js → pdftotext-CVA2G7FY.js} +1 -1
  37. package/dist/safe-bash/chunks/{qpdf-F4U7WUSU.js → qpdf-HZMIFG4A.js} +1 -1
  38. package/dist/safe-bash/chunks/{sips-RWENS7X5.js → sips-E7UBDP33.js} +1 -1
  39. package/dist/safe-bash/chunks/{soffice-IT6W2C5F.js → soffice-ELASUWUK.js} +1 -1
  40. package/dist/safe-bash/chunks/{wkhtmltopdf-JYNDAHIZ.js → wkhtmltopdf-EPO6YCMG.js} +1 -1
  41. package/dist/safe-bash/command-chunks/chunk-2FGJYFWZ.js +44 -0
  42. package/dist/safe-bash/command-chunks/chunk-2H4JTFIL.js +53 -0
  43. package/dist/safe-bash/command-chunks/{chunk-LLCXZKZ6.js → chunk-2QHG43WJ.js} +2 -2
  44. package/dist/safe-bash/command-chunks/chunk-364TMWBT.js +946 -0
  45. package/dist/safe-bash/command-chunks/{chunk-EIVW3X3N.js → chunk-3DT2YOGW.js} +11 -6
  46. package/dist/safe-bash/command-chunks/chunk-3E2OIS2J.js +7037 -0
  47. package/dist/safe-bash/command-chunks/{chunk-AIRGA2SU.js → chunk-3HXDA5PT.js} +1 -1
  48. package/dist/safe-bash/command-chunks/chunk-3LSOYLNV.js +1091 -0
  49. package/dist/safe-bash/command-chunks/chunk-4B7Y7S6E.js +61 -0
  50. package/dist/safe-bash/command-chunks/{chunk-HRLIAMXC.js → chunk-4C6QI5BQ.js} +3 -2
  51. package/dist/safe-bash/command-chunks/chunk-4ZHMW6F5.js +104 -0
  52. package/dist/safe-bash/command-chunks/{chunk-4ZALPDBV.js → chunk-53P53XFM.js} +2 -2
  53. package/dist/safe-bash/command-chunks/chunk-5LSGEIZY.js +379 -0
  54. package/dist/safe-bash/command-chunks/{chunk-MKQVQMXO.js → chunk-5LU4UCBR.js} +1 -1
  55. package/dist/safe-bash/command-chunks/chunk-5T7CRJHW.js +560 -0
  56. package/dist/safe-bash/command-chunks/chunk-5TBUOBDE.js +346 -0
  57. package/dist/safe-bash/command-chunks/chunk-5XY4DTNG.js +34 -0
  58. package/dist/safe-bash/command-chunks/chunk-5ZMZ573Q.js +140 -0
  59. package/dist/safe-bash/command-chunks/{chunk-OPUJSTHS.js → chunk-67IQF5GC.js} +200 -66
  60. package/dist/safe-bash/command-chunks/chunk-67QKREJK.js +347 -0
  61. package/dist/safe-bash/command-chunks/chunk-6EPHJGGF.js +23 -0
  62. package/dist/safe-bash/command-chunks/chunk-6F4XCVON.js +266 -0
  63. package/dist/safe-bash/command-chunks/{chunk-ESMCX3YV.js → chunk-6HMX4CQS.js} +669 -130
  64. package/dist/safe-bash/command-chunks/chunk-7K6JYKPJ.js +422 -0
  65. package/dist/safe-bash/command-chunks/chunk-7N2LI2KO.js +206 -0
  66. package/dist/safe-bash/command-chunks/chunk-7RGB363W.js +362 -0
  67. package/dist/safe-bash/command-chunks/{pptx-GBPNWNEP-7EQEVXV5.js → chunk-AI5JAXQF.js} +34820 -18029
  68. package/dist/safe-bash/command-chunks/chunk-AMO3THU4.js +105 -0
  69. package/dist/safe-bash/command-chunks/chunk-BAGCY35S.js +231 -0
  70. package/dist/safe-bash/command-chunks/chunk-BAXU7B5Z.js +101 -0
  71. package/dist/safe-bash/command-chunks/{chunk-KMCZ6P4O.js → chunk-BKCNF5U3.js} +68 -7
  72. package/dist/safe-bash/command-chunks/chunk-BNOU5YQS.js +182 -0
  73. package/dist/safe-bash/command-chunks/chunk-C7I25AAL.js +25 -0
  74. package/dist/safe-bash/command-chunks/chunk-CKXV2CLD.js +65 -0
  75. package/dist/safe-bash/command-chunks/chunk-CQ5YGOGB.js +150 -0
  76. package/dist/safe-bash/command-chunks/{chunk-I3K5RYU4.js → chunk-D4OP2BR3.js} +72 -24
  77. package/dist/safe-bash/command-chunks/chunk-DB453IE6.js +122 -0
  78. package/dist/safe-bash/command-chunks/chunk-DOKKNRRM.js +87 -0
  79. package/dist/safe-bash/command-chunks/{chunk-2PX5B7T5.js → chunk-DQAVUDDX.js} +2 -2
  80. package/dist/safe-bash/command-chunks/chunk-DT7BCTWY.js +249 -0
  81. package/dist/safe-bash/command-chunks/chunk-E2LB7FRT.js +42 -0
  82. package/dist/safe-bash/command-chunks/chunk-EK6YNAXT.js +343 -0
  83. package/dist/safe-bash/command-chunks/chunk-EQ4HV54N.js +22 -0
  84. package/dist/safe-bash/command-chunks/chunk-ERYJLO6G.js +293 -0
  85. package/dist/safe-bash/command-chunks/{chunk-4ONEXMD3.js → chunk-EUSPTFAX.js} +1 -1
  86. package/dist/safe-bash/command-chunks/chunk-FKKB5X5V.js +97 -0
  87. package/dist/safe-bash/command-chunks/chunk-FXELCPFX.js +195 -0
  88. package/dist/safe-bash/command-chunks/{chunk-JCNNOMBV.js → chunk-GI4CJED2.js} +3 -2
  89. package/dist/safe-bash/command-chunks/{chunk-CU5RLO62.js → chunk-GLOZX57Y.js} +92 -18
  90. package/dist/safe-bash/command-chunks/chunk-GMIHJYDG.js +331 -0
  91. package/dist/safe-bash/command-chunks/chunk-H622NS6Z.js +11 -0
  92. package/dist/safe-bash/command-chunks/{chunk-UI32HWGS.js → chunk-HMOZ6XVJ.js} +1 -1
  93. package/dist/safe-bash/command-chunks/{chunk-AVSPNLWV.js → chunk-I237SNW5.js} +1 -1
  94. package/dist/safe-bash/command-chunks/{chunk-ZS3QPNUL.js → chunk-IR2BY7EL.js} +21 -6
  95. package/dist/safe-bash/command-chunks/chunk-IYPAQ7PH.js +42 -0
  96. package/dist/safe-bash/command-chunks/chunk-JN7WIP6S.js +94 -0
  97. package/dist/safe-bash/command-chunks/chunk-JNZ3CVAE.js +147 -0
  98. package/dist/safe-bash/command-chunks/{chunk-HLBX5IRS.js → chunk-JQ74HC37.js} +24 -32
  99. package/dist/safe-bash/command-chunks/chunk-KFVV7ZJO.js +216 -0
  100. package/dist/safe-bash/command-chunks/{chunk-G4PNVO6Z.js → chunk-KP7AO66M.js} +1 -1
  101. package/dist/safe-bash/command-chunks/chunk-KWESKQHR.js +25 -0
  102. package/dist/safe-bash/command-chunks/chunk-KYSPGS33.js +41 -0
  103. package/dist/safe-bash/command-chunks/{chunk-C7IHMJEW.js → chunk-KZC5UWFF.js} +2 -2
  104. package/dist/safe-bash/command-chunks/chunk-L6DVEBW3.js +553 -0
  105. package/dist/safe-bash/command-chunks/chunk-LC2MFKT4.js +2489 -0
  106. package/dist/safe-bash/command-chunks/chunk-LE5LZNHE.js +204 -0
  107. package/dist/safe-bash/command-chunks/chunk-MDH5T4OS.js +41 -0
  108. package/dist/safe-bash/command-chunks/chunk-MM6HU6CX.js +20 -0
  109. package/dist/safe-bash/command-chunks/{chunk-MYJAZ3U2.js → chunk-MPL2466A.js} +2 -2
  110. package/dist/safe-bash/command-chunks/{chunk-VZHRZMS7.js → chunk-NAY27PXB.js} +1 -1
  111. package/dist/safe-bash/command-chunks/chunk-NCD7PEWH.js +298 -0
  112. package/dist/safe-bash/command-chunks/chunk-NFGI5IGF.js +266 -0
  113. package/dist/safe-bash/command-chunks/{chunk-KVFCSLKK.js → chunk-NXEQ3ESQ.js} +6 -0
  114. package/dist/safe-bash/command-chunks/{chunk-3VGGYEDH.js → chunk-ORYGZYKW.js} +4 -3
  115. package/dist/safe-bash/command-chunks/{chunk-OLQG7ZCN.js → chunk-PEF7K3UQ.js} +136 -75
  116. package/dist/safe-bash/command-chunks/chunk-PII4YEZW.js +123 -0
  117. package/dist/safe-bash/command-chunks/{chunk-43GSSUAY.js → chunk-PJJUYO3R.js} +5 -5
  118. package/dist/safe-bash/command-chunks/{chunk-ZT4KSS2V.js → chunk-PTT3I223.js} +1 -1
  119. package/dist/safe-bash/command-chunks/chunk-Q3DII3Q7.js +174 -0
  120. package/dist/safe-bash/command-chunks/chunk-Q3EWDEUQ.js +185 -0
  121. package/dist/safe-bash/command-chunks/{chunk-2FUAW6GO.js → chunk-QI7LGHJJ.js} +58 -9
  122. package/dist/safe-bash/command-chunks/{chunk-6BETHLXZ.js → chunk-QJAFJP2G.js} +1 -1
  123. package/dist/safe-bash/command-chunks/chunk-QNIMV57G.js +63 -0
  124. package/dist/safe-bash/command-chunks/{chunk-VVI4Z73I.js → chunk-QP4R6GLA.js} +5 -1
  125. package/dist/safe-bash/command-chunks/{chunk-LPORMIZS.js → chunk-QWIDNAAK.js} +8 -8
  126. package/dist/safe-bash/command-chunks/chunk-RVLO4DYT.js +35 -0
  127. package/dist/safe-bash/command-chunks/{chunk-X2YQLGKS.js → chunk-SAMH7SQE.js} +4 -4
  128. package/dist/safe-bash/command-chunks/chunk-SEM36PG5.js +11 -0
  129. package/dist/safe-bash/command-chunks/chunk-STC3LEWJ.js +634 -0
  130. package/dist/safe-bash/command-chunks/chunk-SVULUDOP.js +331 -0
  131. package/dist/safe-bash/command-chunks/chunk-TEVJJPTC.js +1392 -0
  132. package/dist/safe-bash/command-chunks/{chunk-ZXKW7SJ2.js → chunk-TYCGMRLM.js} +2 -2
  133. package/dist/safe-bash/command-chunks/chunk-UG7SMZFF.js +178 -0
  134. package/dist/safe-bash/command-chunks/{chunk-YZ5SVZFD.js → chunk-UMDIOL3O.js} +3 -3
  135. package/dist/safe-bash/command-chunks/chunk-UXSR5BZH.js +136 -0
  136. package/dist/safe-bash/command-chunks/chunk-V6BEDRMQ.js +112 -0
  137. package/dist/safe-bash/command-chunks/chunk-V6MSPQLA.js +362 -0
  138. package/dist/safe-bash/command-chunks/{chunk-J4PEQWSF.js → chunk-VGG2DL5Q.js} +0 -1
  139. package/dist/safe-bash/command-chunks/{chunk-SG424QWS.js → chunk-VL67NWNS.js} +1 -1
  140. package/dist/safe-bash/command-chunks/chunk-WB5SVIG7.js +1034 -0
  141. package/dist/safe-bash/command-chunks/{src-UJOWAS2S.js → chunk-WD3ERGRY.js} +77 -277
  142. package/dist/safe-bash/command-chunks/{chunk-YFSDDFGV.js → chunk-WH627NJL.js} +446 -53
  143. package/dist/safe-bash/command-chunks/chunk-WNE7FPVR.js +236 -0
  144. package/dist/safe-bash/command-chunks/{chunk-UKS2XJZI.js → chunk-WPYIOKE3.js} +4 -4
  145. package/dist/safe-bash/command-chunks/chunk-XETLEHZP.js +1227 -0
  146. package/dist/safe-bash/command-chunks/chunk-XIIBTGC5.js +580 -0
  147. package/dist/safe-bash/command-chunks/chunk-XJXU3VVH.js +737 -0
  148. package/dist/safe-bash/command-chunks/chunk-Y5INTD6S.js +220 -0
  149. package/dist/safe-bash/command-chunks/{chunk-5ZSM4UFN.js → chunk-YGC6OS5O.js} +3 -56
  150. package/dist/safe-bash/command-chunks/chunk-YJDV76GL.js +262 -0
  151. package/dist/safe-bash/command-chunks/chunk-YOF7R4OY.js +80 -0
  152. package/dist/safe-bash/command-chunks/chunk-Z7RVSD5K.js +594 -0
  153. package/dist/safe-bash/command-chunks/chunk-ZHUWOUWB.js +618 -0
  154. package/dist/safe-bash/command-chunks/{model-store-L35QTZMJ.js → model-store-WPKMRPV4.js} +2 -2
  155. package/dist/safe-bash/command-chunks/pptx-7G52EJ6L-4JACH5FB.js +625 -0
  156. package/dist/safe-bash/command-chunks/python-worker-source-TYOFJMCW.js +4 -0
  157. package/dist/safe-bash/command-chunks/src-ICMQISAA.js +501 -0
  158. package/dist/safe-bash/commands/archive/create.d.ts +1 -17
  159. package/dist/safe-bash/commands/archive/create.js +1 -252
  160. package/dist/safe-bash/commands/archive/extract.d.ts +1 -11
  161. package/dist/safe-bash/commands/archive/extract.js +1 -640
  162. package/dist/safe-bash/commands/archive/format.d.ts +1 -32
  163. package/dist/safe-bash/commands/archive/format.js +1 -225
  164. package/dist/safe-bash/commands/archive/index.d.ts +5 -10
  165. package/dist/safe-bash/commands/archive/index.js +6 -931
  166. package/dist/safe-bash/commands/archive/listing.d.ts +1 -2
  167. package/dist/safe-bash/commands/archive/listing.js +1 -21
  168. package/dist/safe-bash/commands/archive/modes.d.ts +1 -5
  169. package/dist/safe-bash/commands/archive/modes.js +1 -182
  170. package/dist/safe-bash/commands/archive/options.d.ts +1 -53
  171. package/dist/safe-bash/commands/archive/options.js +1 -462
  172. package/dist/safe-bash/commands/archive/stream.d.ts +1 -22
  173. package/dist/safe-bash/commands/archive/stream.js +1 -188
  174. package/dist/safe-bash/commands/archive/transform.d.ts +1 -16
  175. package/dist/safe-bash/commands/archive/transform.js +1 -85
  176. package/dist/safe-bash/commands/archive/unzip/arguments.d.ts +1 -53
  177. package/dist/safe-bash/commands/archive/unzip/arguments.js +1 -322
  178. package/dist/safe-bash/commands/archive/unzip/safety.d.ts +1 -32
  179. package/dist/safe-bash/commands/archive/unzip/safety.js +1 -295
  180. package/dist/safe-bash/commands/archive/unzip.d.ts +1 -3
  181. package/dist/safe-bash/commands/archive/unzip.js +1 -398
  182. package/dist/safe-bash/commands/archive/zip/aes.d.ts +1 -17
  183. package/dist/safe-bash/commands/archive/zip/aes.js +1 -156
  184. package/dist/safe-bash/commands/archive/zip/comments.d.ts +1 -17
  185. package/dist/safe-bash/commands/archive/zip/comments.js +1 -83
  186. package/dist/safe-bash/commands/archive/zip/crc.d.ts +1 -1
  187. package/dist/safe-bash/commands/archive/zip/crc.js +1 -1
  188. package/dist/safe-bash/commands/archive/zip/crypto.d.ts +1 -19
  189. package/dist/safe-bash/commands/archive/zip/crypto.js +1 -118
  190. package/dist/safe-bash/commands/archive/zip/dates.d.ts +1 -4
  191. package/dist/safe-bash/commands/archive/zip/dates.js +1 -66
  192. package/dist/safe-bash/commands/archive/zip/environment.d.ts +1 -2
  193. package/dist/safe-bash/commands/archive/zip/environment.js +1 -62
  194. package/dist/safe-bash/commands/archive/zip/grow.d.ts +1 -3
  195. package/dist/safe-bash/commands/archive/zip/grow.js +1 -2
  196. package/dist/safe-bash/commands/archive/zip/help.d.ts +1 -4
  197. package/dist/safe-bash/commands/archive/zip/help.js +1 -182
  198. package/dist/safe-bash/commands/archive/zip/line-endings.d.ts +1 -2
  199. package/dist/safe-bash/commands/archive/zip/line-endings.js +1 -194
  200. package/dist/safe-bash/commands/archive/zip/log.d.ts +1 -22
  201. package/dist/safe-bash/commands/archive/zip/log.js +1 -159
  202. package/dist/safe-bash/commands/archive/zip/lzma.d.ts +1 -9
  203. package/dist/safe-bash/commands/archive/zip/lzma.js +1 -40
  204. package/dist/safe-bash/commands/archive/zip/move.d.ts +1 -11
  205. package/dist/safe-bash/commands/archive/zip/move.js +1 -59
  206. package/dist/safe-bash/commands/archive/zip/names.d.ts +1 -2
  207. package/dist/safe-bash/commands/archive/zip/names.js +1 -33
  208. package/dist/safe-bash/commands/archive/zip/options.d.ts +1 -13
  209. package/dist/safe-bash/commands/archive/zip/options.js +1 -124
  210. package/dist/safe-bash/commands/archive/zip/repair.d.ts +1 -10
  211. package/dist/safe-bash/commands/archive/zip/repair.js +1 -392
  212. package/dist/safe-bash/commands/archive/zip/safety.d.ts +1 -54
  213. package/dist/safe-bash/commands/archive/zip/safety.js +1 -360
  214. package/dist/safe-bash/commands/archive/zip/sfx.d.ts +1 -4
  215. package/dist/safe-bash/commands/archive/zip/sfx.js +1 -52
  216. package/dist/safe-bash/commands/archive/zip/test-command.d.ts +1 -5
  217. package/dist/safe-bash/commands/archive/zip/test-command.js +1 -101
  218. package/dist/safe-bash/commands/archive/zip/volumes.d.ts +1 -21
  219. package/dist/safe-bash/commands/archive/zip/volumes.js +1 -281
  220. package/dist/safe-bash/commands/archive/zip/zip64.d.ts +1 -30
  221. package/dist/safe-bash/commands/archive/zip/zip64.js +1 -227
  222. package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -68
  223. package/dist/safe-bash/commands/archive/zip-format.js +1 -1075
  224. package/dist/safe-bash/commands/archive/zip.d.ts +1 -3
  225. package/dist/safe-bash/commands/archive/zip.js +1 -1523
  226. package/dist/safe-bash/commands/awk/index.d.ts +2 -0
  227. package/dist/safe-bash/commands/awk/index.js +2 -0
  228. package/dist/safe-bash/commands/bytes/compression/index.js +2 -1
  229. package/dist/safe-bash/commands/curl/index.d.ts +2 -0
  230. package/dist/safe-bash/commands/curl/index.js +2 -0
  231. package/dist/safe-bash/commands/diff/index.d.ts +2 -0
  232. package/dist/safe-bash/commands/diff/index.js +2 -0
  233. package/dist/safe-bash/commands/diff-patch/diff-format.d.ts +1 -10
  234. package/dist/safe-bash/commands/diff-patch/diff-format.js +1 -237
  235. package/dist/safe-bash/commands/diff-patch/diff-options.d.ts +1 -38
  236. package/dist/safe-bash/commands/diff-patch/diff-options.js +1 -261
  237. package/dist/safe-bash/commands/diff-patch/diff-output.d.ts +1 -20
  238. package/dist/safe-bash/commands/diff-patch/diff-output.js +1 -290
  239. package/dist/safe-bash/commands/diff-patch/diff.d.ts +1 -2
  240. package/dist/safe-bash/commands/diff-patch/diff.js +1 -656
  241. package/dist/safe-bash/commands/diff-patch/index.d.ts +4 -5
  242. package/dist/safe-bash/commands/diff-patch/index.js +8 -333
  243. package/dist/safe-bash/commands/diff-patch/patch-envelope.d.ts +1 -2
  244. package/dist/safe-bash/commands/diff-patch/patch-envelope.js +1 -63
  245. package/dist/safe-bash/commands/diff-patch/patch-formats.d.ts +1 -7
  246. package/dist/safe-bash/commands/diff-patch/patch-formats.js +1 -264
  247. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.d.ts +1 -41
  248. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.js +1 -263
  249. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.d.ts +1 -3
  250. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.js +1 -100
  251. package/dist/safe-bash/commands/diff-patch/patch-path.d.ts +1 -3
  252. package/dist/safe-bash/commands/diff-patch/patch-path.js +1 -91
  253. package/dist/safe-bash/commands/diff-patch/patch-publication.d.ts +1 -13
  254. package/dist/safe-bash/commands/diff-patch/patch-publication.js +1 -107
  255. package/dist/safe-bash/commands/diff-patch/patch.d.ts +1 -2
  256. package/dist/safe-bash/commands/diff-patch/patch.js +1 -653
  257. package/dist/safe-bash/commands/diff-patch/shared.d.ts +1 -53
  258. package/dist/safe-bash/commands/diff-patch/shared.js +1 -267
  259. package/dist/safe-bash/commands/diff-patch/unified.d.ts +1 -52
  260. package/dist/safe-bash/commands/diff-patch/unified.js +1 -385
  261. package/dist/safe-bash/commands/directory-admission.d.ts +1 -3
  262. package/dist/safe-bash/commands/directory-admission.js +1 -26
  263. package/dist/safe-bash/commands/find/index.d.ts +2 -0
  264. package/dist/safe-bash/commands/find/index.js +2 -0
  265. package/dist/safe-bash/commands/find-format.d.ts +1 -20
  266. package/dist/safe-bash/commands/find-format.js +1 -161
  267. package/dist/safe-bash/commands/find.d.ts +2 -18
  268. package/dist/safe-bash/commands/find.js +2 -1236
  269. package/dist/safe-bash/commands/gzip/index.d.ts +2 -0
  270. package/dist/safe-bash/commands/gzip/index.js +2 -0
  271. package/dist/safe-bash/commands/line-endings/index.browser.js +1 -1
  272. package/dist/safe-bash/commands/line-endings/index.d.ts +1 -1
  273. package/dist/safe-bash/commands/line-endings/index.js +1 -262
  274. package/dist/safe-bash/commands/llm/index.browser.js +3 -1
  275. package/dist/safe-bash/commands/mdq/index.browser.js +2 -2
  276. package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -4
  277. package/dist/safe-bash/commands/metadata/chmod.js +2 -63
  278. package/dist/safe-bash/commands/network/aggregate.d.ts +1 -4
  279. package/dist/safe-bash/commands/network/aggregate.js +1 -23
  280. package/dist/safe-bash/commands/network/args.d.ts +1 -68
  281. package/dist/safe-bash/commands/network/args.js +1 -321
  282. package/dist/safe-bash/commands/network/authorizer.d.ts +1 -6
  283. package/dist/safe-bash/commands/network/authorizer.js +1 -33
  284. package/dist/safe-bash/commands/network/body.d.ts +1 -9
  285. package/dist/safe-bash/commands/network/body.js +1 -393
  286. package/dist/safe-bash/commands/network/curl.d.ts +3 -13
  287. package/dist/safe-bash/commands/network/curl.js +6 -693
  288. package/dist/safe-bash/commands/network/deadline.d.ts +1 -2
  289. package/dist/safe-bash/commands/network/deadline.js +1 -14
  290. package/dist/safe-bash/commands/network/decode.d.ts +1 -2
  291. package/dist/safe-bash/commands/network/decode.js +1 -79
  292. package/dist/safe-bash/commands/network/fetch-transport.d.ts +1 -7
  293. package/dist/safe-bash/commands/network/fetch-transport.js +1 -94
  294. package/dist/safe-bash/commands/network/form-content-type.d.ts +1 -5
  295. package/dist/safe-bash/commands/network/form-content-type.js +1 -63
  296. package/dist/safe-bash/commands/network/form-headers.d.ts +1 -2
  297. package/dist/safe-bash/commands/network/form-headers.js +1 -35
  298. package/dist/safe-bash/commands/network/glob.d.ts +1 -7
  299. package/dist/safe-bash/commands/network/glob.js +1 -134
  300. package/dist/safe-bash/commands/network/index.browser.js +2 -10
  301. package/dist/safe-bash/commands/network/input.d.ts +1 -5
  302. package/dist/safe-bash/commands/network/input.js +1 -276
  303. package/dist/safe-bash/commands/network/output.d.ts +1 -6
  304. package/dist/safe-bash/commands/network/output.js +1 -131
  305. package/dist/safe-bash/commands/network/private-address.d.ts +1 -1
  306. package/dist/safe-bash/commands/network/private-address.js +1 -44
  307. package/dist/safe-bash/commands/network/shared.d.ts +1 -14
  308. package/dist/safe-bash/commands/network/shared.js +1 -71
  309. package/dist/safe-bash/commands/network/types.d.ts +1 -37
  310. package/dist/safe-bash/commands/network/types.js +1 -31
  311. package/dist/safe-bash/commands/network/url.d.ts +1 -2
  312. package/dist/safe-bash/commands/network/url.js +1 -30
  313. package/dist/safe-bash/commands/network/wget.d.ts +3 -3
  314. package/dist/safe-bash/commands/network/wget.js +10 -331
  315. package/dist/safe-bash/commands/node/index.browser.js +4 -5
  316. package/dist/safe-bash/commands/node/index.d.ts +3 -3
  317. package/dist/safe-bash/commands/node/index.js +5 -0
  318. package/dist/safe-bash/commands/node/safejs.d.ts +3 -3
  319. package/dist/safe-bash/commands/node/safejs.js +6 -1
  320. package/dist/safe-bash/commands/node/types.d.ts +1 -1
  321. package/dist/safe-bash/commands/node/unconfigured.d.ts +3 -0
  322. package/dist/safe-bash/commands/node/unconfigured.js +10 -0
  323. package/dist/safe-bash/commands/op/index.browser.js +2 -2
  324. package/dist/safe-bash/commands/patch/index.d.ts +2 -0
  325. package/dist/safe-bash/commands/patch/index.js +2 -0
  326. package/dist/safe-bash/commands/pdfinfo/index.js +2 -1
  327. package/dist/safe-bash/commands/predicates.js +3 -4
  328. package/dist/safe-bash/commands/python/index.browser.js +5 -5
  329. package/dist/safe-bash/commands/python/llm-capability.d.ts +1 -0
  330. package/dist/safe-bash/commands/python/llm-capability.js +27 -7
  331. package/dist/safe-bash/commands/python/llm-module.js +11 -0
  332. package/dist/safe-bash/commands/python/manifest.d.ts +1 -0
  333. package/dist/safe-bash/commands/python/manifest.js +9 -5
  334. package/dist/safe-bash/commands/python/provisioning.js +1 -1
  335. package/dist/safe-bash/commands/regex-execution/matching.js +1 -2
  336. package/dist/safe-bash/commands/regex-execution/public.browser.js +5 -5
  337. package/dist/safe-bash/commands/search/index.d.ts +1 -1
  338. package/dist/safe-bash/commands/search/index.js +1 -347
  339. package/dist/safe-bash/commands/search/portable.d.ts +2 -2
  340. package/dist/safe-bash/commands/search/portable.js +3 -2
  341. package/dist/safe-bash/commands/sed/index.d.ts +2 -0
  342. package/dist/safe-bash/commands/sed/index.js +2 -0
  343. package/dist/safe-bash/commands/tar/index.d.ts +2 -0
  344. package/dist/safe-bash/commands/tar/index.js +2 -0
  345. package/dist/safe-bash/commands/text-programs/awk-inspection.d.ts +1 -19
  346. package/dist/safe-bash/commands/text-programs/awk-inspection.js +1 -50
  347. package/dist/safe-bash/commands/text-programs/awk-pipes.d.ts +2 -0
  348. package/dist/safe-bash/commands/text-programs/awk-pipes.js +2 -0
  349. package/dist/safe-bash/commands/text-programs/awk-pretty.d.ts +1 -3
  350. package/dist/safe-bash/commands/text-programs/awk-pretty.js +1 -197
  351. package/dist/safe-bash/commands/text-programs/awk-quote.d.ts +1 -2
  352. package/dist/safe-bash/commands/text-programs/awk-quote.js +1 -15
  353. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +1 -42
  354. package/dist/safe-bash/commands/text-programs/awk-reader.js +1 -449
  355. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +1 -13
  356. package/dist/safe-bash/commands/text-programs/awk-retention.js +1 -51
  357. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +1 -150
  358. package/dist/safe-bash/commands/text-programs/awk-runtime.js +1 -2627
  359. package/dist/safe-bash/commands/text-programs/awk-syntax.d.ts +1 -142
  360. package/dist/safe-bash/commands/text-programs/awk-syntax.js +1 -509
  361. package/dist/safe-bash/commands/text-programs/awk-values.d.ts +1 -32
  362. package/dist/safe-bash/commands/text-programs/awk-values.js +1 -386
  363. package/dist/safe-bash/commands/text-programs/awk.d.ts +1 -3
  364. package/dist/safe-bash/commands/text-programs/awk.js +1 -361
  365. package/dist/safe-bash/commands/text-programs/inplace.d.ts +1 -16
  366. package/dist/safe-bash/commands/text-programs/inplace.js +1 -155
  367. package/dist/safe-bash/commands/text-programs/sed.d.ts +1 -3
  368. package/dist/safe-bash/commands/text-programs/sed.js +1 -1647
  369. package/dist/safe-bash/commands/unzip/index.d.ts +2 -0
  370. package/dist/safe-bash/commands/unzip/index.js +2 -0
  371. package/dist/safe-bash/commands/wget/index.d.ts +2 -0
  372. package/dist/safe-bash/commands/wget/index.js +2 -0
  373. package/dist/safe-bash/commands/yq/index.browser.js +7 -2
  374. package/dist/safe-bash/commands/yq/index.d.ts +1 -6
  375. package/dist/safe-bash/commands/yq/index.js +1 -36
  376. package/dist/safe-bash/commands/zip/index.d.ts +2 -0
  377. package/dist/safe-bash/commands/zip/index.js +2 -0
  378. package/dist/safe-bash/core.browser.js +1 -1
  379. package/dist/safe-bash/core.d.ts +8 -1
  380. package/dist/safe-bash/core.js +7 -1
  381. package/dist/safe-bash/fs/s3/index.d.ts +2 -2
  382. package/dist/safe-bash/fs/s3/index.js +1 -1
  383. package/dist/safe-bash/full-core.browser.js +254 -223
  384. package/dist/safe-bash/jobs.browser.js +2 -2
  385. package/dist/safe-bash/lazy-mmdc.d.ts +6 -0
  386. package/dist/safe-bash/lazy-mmdc.js +23 -0
  387. package/dist/safe-bash/opt-in/commands/yq/mike.js +6 -13
  388. package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +1 -0
  389. package/dist/safe-bash/opt-in/commands/yq/native-work.js +17 -0
  390. package/dist/safe-bash/optional-host.browser.js +8 -4
  391. package/dist/safe-bash/optional-host.d.ts +1 -1
  392. package/dist/safe-bash/optional-host.js +1 -1
  393. package/dist/safe-bash/playwright/ability-execution.js +3 -2
  394. package/dist/safe-bash/playwright/adapter.js +1 -1
  395. package/dist/safe-bash/playwright/controller.js +9 -8
  396. package/dist/safe-bash/playwright/modal-capabilities.js +2 -1
  397. package/dist/safe-bash/playwright/native-json-snapshot.js +4 -3
  398. package/dist/safe-bash/playwright/native-snapshot.js +5 -4
  399. package/dist/safe-bash/playwright/open-options.js +3 -3
  400. package/dist/safe-bash/playwright/resource-limit.d.ts +2 -0
  401. package/dist/safe-bash/playwright/resource-limit.js +4 -0
  402. package/dist/safe-bash/playwright/session-configuration.js +8 -3
  403. package/dist/safe-bash/playwright/snapshot.js +8 -7
  404. package/dist/safe-bash/playwright/standard-capabilities.js +5 -4
  405. package/dist/safe-bash/plugins/index.browser.js +14 -16
  406. package/dist/safe-bash/registry-entry.browser.js +14 -16
  407. package/dist/safe-bash/shell/arrays/bindings.d.ts +3 -5
  408. package/dist/safe-bash/shell/arrays/bindings.js +6 -2
  409. package/dist/safe-bash/shell/input.js +16 -14
  410. package/dist/safe-bash/shell/runtime.d.ts +3 -0
  411. package/dist/safe-bash/shell/runtime.js +316 -64
  412. package/dist/safe-bash/shell/types.d.ts +2 -0
  413. package/dist/safe-bash/shell/value-state.js +17 -2
  414. package/dist/safe-bash/shell/worker-limits.js +1 -0
  415. package/dist/safe-bash/shell-entry.browser.js +13 -15
  416. package/dist/safe-bash/trap.browser.d.ts +3 -0
  417. package/dist/safe-bash/trap.browser.js +14 -0
  418. package/dist/safe-bash/worker/host.js +1 -1
  419. package/dist/safe-bash-command-apply-patch/apply.js +2 -2
  420. package/dist/safe-bash-command-apply-patch/index.js +3 -3
  421. package/dist/safe-bash-command-awk/LICENSE +21 -0
  422. package/dist/safe-bash-command-awk/awk-inspection.d.ts +19 -0
  423. package/dist/safe-bash-command-awk/awk-inspection.js +9 -0
  424. package/dist/safe-bash-command-awk/awk-pipes.d.ts +19 -0
  425. package/dist/safe-bash-command-awk/awk-pipes.js +8 -0
  426. package/dist/safe-bash-command-awk/awk-pretty.d.ts +3 -0
  427. package/dist/safe-bash-command-awk/awk-pretty.js +8 -0
  428. package/dist/safe-bash-command-awk/awk-quote.d.ts +2 -0
  429. package/dist/safe-bash-command-awk/awk-quote.js +7 -0
  430. package/dist/safe-bash-command-awk/awk-reader.d.ts +42 -0
  431. package/dist/safe-bash-command-awk/awk-reader.js +9 -0
  432. package/dist/safe-bash-command-awk/awk-retention.d.ts +13 -0
  433. package/dist/safe-bash-command-awk/awk-retention.js +7 -0
  434. package/dist/safe-bash-command-awk/awk-runtime.d.ts +151 -0
  435. package/dist/safe-bash-command-awk/awk-runtime.js +11 -0
  436. package/dist/safe-bash-command-awk/awk-syntax.d.ts +144 -0
  437. package/dist/safe-bash-command-awk/awk-syntax.js +14 -0
  438. package/dist/safe-bash-command-awk/awk-values.d.ts +32 -0
  439. package/dist/safe-bash-command-awk/awk-values.js +35 -0
  440. package/dist/safe-bash-command-awk/awk.d.ts +3 -0
  441. package/dist/safe-bash-command-awk/awk.js +16 -0
  442. package/dist/safe-bash-command-awk/index.d.ts +7 -0
  443. package/dist/safe-bash-command-awk/index.js +36 -0
  444. package/dist/safe-bash-command-bc/index.d.ts +4 -0
  445. package/dist/safe-bash-command-bc/index.js +15 -176
  446. package/dist/safe-bash-command-column/column.js +3 -3
  447. package/dist/safe-bash-command-column/index.js +3 -3
  448. package/dist/safe-bash-command-column/layout.js +2 -2
  449. package/dist/safe-bash-command-csplit/command.js +2 -2
  450. package/dist/safe-bash-command-csplit/index.js +2 -2
  451. package/dist/safe-bash-command-csvkit/contracts.d.ts +1 -0
  452. package/dist/safe-bash-command-csvkit/csvpy-interpreter.d.ts +2 -1
  453. package/dist/safe-bash-command-csvkit/default-csvpy.d.ts +11 -0
  454. package/dist/safe-bash-command-csvkit/errors.js +22 -0
  455. package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
  456. package/dist/safe-bash-command-csvkit/index.js +172 -4
  457. package/dist/safe-bash-command-csvkit/python-worker-browser.d.ts +3 -0
  458. package/dist/safe-bash-command-csvkit/python-worker-browser.js +16 -0
  459. package/dist/safe-bash-command-csvkit/python-worker-contract.d.ts +20 -0
  460. package/dist/safe-bash-command-csvkit/python-worker-node.d.ts +3 -0
  461. package/dist/safe-bash-command-csvkit/python-worker-node.js +9 -0
  462. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  463. package/dist/safe-bash-command-curl/LICENSE +21 -0
  464. package/dist/safe-bash-command-curl/curl.d.ts +13 -0
  465. package/dist/safe-bash-command-curl/curl.js +9 -0
  466. package/dist/safe-bash-command-curl/index.d.ts +6 -0
  467. package/dist/safe-bash-command-curl/index.js +26 -0
  468. package/dist/safe-bash-command-diff/LICENSE +21 -0
  469. package/dist/safe-bash-command-diff/diff-format.d.ts +10 -0
  470. package/dist/safe-bash-command-diff/diff-format.js +10 -0
  471. package/dist/safe-bash-command-diff/diff-options.d.ts +38 -0
  472. package/dist/safe-bash-command-diff/diff-options.js +7 -0
  473. package/dist/safe-bash-command-diff/diff-output.d.ts +20 -0
  474. package/dist/safe-bash-command-diff/diff-output.js +19 -0
  475. package/dist/safe-bash-command-diff/diff.d.ts +2 -0
  476. package/dist/safe-bash-command-diff/diff.js +10 -0
  477. package/dist/safe-bash-command-diff/index.d.ts +8 -0
  478. package/dist/safe-bash-command-diff/index.js +34 -0
  479. package/dist/safe-bash-command-diff/sync.d.ts +2 -0
  480. package/dist/safe-bash-command-diff/sync.js +9 -0
  481. package/dist/safe-bash-command-diff3/index.js +5 -5
  482. package/dist/safe-bash-command-docx/index.d.ts +4 -4
  483. package/dist/safe-bash-command-docx/index.js +12 -5
  484. package/dist/safe-bash-command-dos2unix/index.d.ts +1 -0
  485. package/dist/safe-bash-command-dos2unix/index.js +225 -1
  486. package/dist/safe-bash-command-dos2unix/sync.d.ts +1 -0
  487. package/dist/safe-bash-command-exiftool/index.js +2 -2
  488. package/dist/safe-bash-command-factor/command.js +2 -2
  489. package/dist/safe-bash-command-factor/index.js +2 -2
  490. package/dist/safe-bash-command-ffmpeg/index.js +86 -94
  491. package/dist/safe-bash-command-file/index.js +3 -3
  492. package/dist/safe-bash-command-find/LICENSE +21 -0
  493. package/dist/safe-bash-command-find/find-format.d.ts +20 -0
  494. package/dist/safe-bash-command-find/find-format.js +9 -0
  495. package/dist/safe-bash-command-find/find.d.ts +18 -0
  496. package/dist/safe-bash-command-find/find.js +10 -0
  497. package/dist/safe-bash-command-find/index.d.ts +13 -0
  498. package/dist/safe-bash-command-find/index.js +45 -0
  499. package/dist/safe-bash-command-fmt/index.js +7 -4
  500. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  501. package/dist/safe-bash-command-git/index.js +5 -7
  502. package/dist/safe-bash-command-git/wasm.generated.js +1 -1
  503. package/dist/safe-bash-command-gzip/LICENSE +21 -0
  504. package/dist/safe-bash-command-gzip/index.d.ts +11 -0
  505. package/dist/safe-bash-command-gzip/index.js +94 -0
  506. package/dist/safe-bash-command-html-to-markdown/index.js +5 -5
  507. package/dist/safe-bash-command-htmlq/index.js +12 -8
  508. package/dist/safe-bash-command-imagemagick/index.js +22 -30
  509. package/dist/safe-bash-command-jq/index.js +1 -1
  510. package/dist/safe-bash-command-jq/jq.js +1 -1
  511. package/dist/safe-bash-command-llm/command.js +1 -1
  512. package/dist/safe-bash-command-llm/index.d.ts +1 -0
  513. package/dist/safe-bash-command-llm/index.js +16 -14
  514. package/dist/safe-bash-command-llm/openai.js +3 -3
  515. package/dist/safe-bash-command-llm/providers/index.js +3 -3
  516. package/dist/safe-bash-command-llm/providers/openai.js +3 -3
  517. package/dist/safe-bash-command-llm/stored-schema.d.ts +10 -0
  518. package/dist/safe-bash-command-mmdc/index.js +13 -604
  519. package/dist/safe-bash-command-mmdc/settings.d.ts +2 -0
  520. package/dist/safe-bash-command-mmdc/settings.js +7 -0
  521. package/dist/safe-bash-command-pandoc/command.js +4 -3
  522. package/dist/safe-bash-command-pandoc/defaults.d.ts +1 -0
  523. package/dist/safe-bash-command-pandoc/index.js +4 -3
  524. package/dist/safe-bash-command-pandoc/lua-filters.js +1 -1
  525. package/dist/safe-bash-command-pandoc/types.d.ts +3 -1
  526. package/dist/safe-bash-command-patch/LICENSE +21 -0
  527. package/dist/safe-bash-command-patch/index.d.ts +8 -0
  528. package/dist/safe-bash-command-patch/index.js +38 -0
  529. package/dist/safe-bash-command-patch/patch-envelope.d.ts +2 -0
  530. package/dist/safe-bash-command-patch/patch-envelope.js +7 -0
  531. package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -0
  532. package/dist/safe-bash-command-patch/patch-formats.js +9 -0
  533. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +41 -0
  534. package/dist/safe-bash-command-patch/patch-gnu-paths.js +26 -0
  535. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +3 -0
  536. package/dist/safe-bash-command-patch/patch-gnu-reject.js +7 -0
  537. package/dist/safe-bash-command-patch/patch-path.d.ts +3 -0
  538. package/dist/safe-bash-command-patch/patch-path.js +11 -0
  539. package/dist/safe-bash-command-patch/patch-publication.d.ts +13 -0
  540. package/dist/safe-bash-command-patch/patch-publication.js +7 -0
  541. package/dist/safe-bash-command-patch/patch.d.ts +2 -0
  542. package/dist/safe-bash-command-patch/patch.js +14 -0
  543. package/dist/safe-bash-command-patch/sync.d.ts +2 -0
  544. package/dist/safe-bash-command-patch/sync.js +7 -0
  545. package/dist/safe-bash-command-patch/unified.d.ts +52 -0
  546. package/dist/safe-bash-command-patch/unified.js +16 -0
  547. package/dist/safe-bash-command-pdfimages/index.js +37 -16
  548. package/dist/safe-bash-command-pdfinfo/index.d.ts +0 -23
  549. package/dist/safe-bash-command-pdfinfo/index.js +20 -772
  550. package/dist/safe-bash-command-pdftk/index.js +37 -9
  551. package/dist/safe-bash-command-pdftoppm/index.js +50 -20
  552. package/dist/safe-bash-command-pdftotext/index.js +10 -2
  553. package/dist/safe-bash-command-pptx/index.d.ts +4 -4
  554. package/dist/safe-bash-command-pptx/index.js +11 -5
  555. package/dist/safe-bash-command-pr/command.js +2 -2
  556. package/dist/safe-bash-command-pr/index.js +4 -4
  557. package/dist/safe-bash-command-qpdf/index.js +26 -13
  558. package/dist/safe-bash-command-rg/index.d.ts +1 -0
  559. package/dist/safe-bash-command-rg/index.js +222 -1
  560. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  561. package/dist/safe-bash-command-rg/sync.d.ts +1 -0
  562. package/dist/safe-bash-command-sed/LICENSE +21 -0
  563. package/dist/safe-bash-command-sed/index.d.ts +7 -0
  564. package/dist/safe-bash-command-sed/index.js +28 -0
  565. package/dist/safe-bash-command-sed/inplace.d.ts +16 -0
  566. package/dist/safe-bash-command-sed/inplace.js +9 -0
  567. package/dist/safe-bash-command-sed/sed.d.ts +3 -0
  568. package/dist/safe-bash-command-sed/sed.js +8 -0
  569. package/dist/safe-bash-command-sips/index.js +111 -35
  570. package/dist/safe-bash-command-soffice/index.js +4 -4
  571. package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -2
  572. package/dist/safe-bash-command-sqlite3/index.js +152 -452
  573. package/dist/safe-bash-command-ssconvert/commands.js +1 -1
  574. package/dist/safe-bash-command-ssconvert/formats/ods.js +2 -2
  575. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +3 -3
  576. package/dist/safe-bash-command-ssconvert/index.js +5 -5
  577. package/dist/safe-bash-command-tar/LICENSE +21 -0
  578. package/dist/safe-bash-command-tar/create.d.ts +17 -0
  579. package/dist/safe-bash-command-tar/create.js +14 -0
  580. package/dist/safe-bash-command-tar/extract.d.ts +11 -0
  581. package/dist/safe-bash-command-tar/extract.js +14 -0
  582. package/dist/safe-bash-command-tar/format.d.ts +32 -0
  583. package/dist/safe-bash-command-tar/format.js +19 -0
  584. package/dist/safe-bash-command-tar/index.d.ts +8 -0
  585. package/dist/safe-bash-command-tar/index.js +550 -0
  586. package/dist/safe-bash-command-tar/listing.d.ts +2 -0
  587. package/dist/safe-bash-command-tar/listing.js +7 -0
  588. package/dist/safe-bash-command-tar/modes.d.ts +5 -0
  589. package/dist/safe-bash-command-tar/modes.js +16 -0
  590. package/dist/safe-bash-command-tar/options.d.ts +53 -0
  591. package/dist/safe-bash-command-tar/options.js +10 -0
  592. package/dist/safe-bash-command-tar/stream.d.ts +22 -0
  593. package/dist/safe-bash-command-tar/stream.js +15 -0
  594. package/dist/safe-bash-command-tar/transform.d.ts +16 -0
  595. package/dist/safe-bash-command-tar/transform.js +9 -0
  596. package/dist/safe-bash-command-unzip/LICENSE +21 -0
  597. package/dist/safe-bash-command-unzip/index.d.ts +7 -0
  598. package/dist/safe-bash-command-unzip/index.js +39 -0
  599. package/dist/safe-bash-command-unzip/sync.d.ts +3 -0
  600. package/dist/safe-bash-command-unzip/sync.js +9 -0
  601. package/dist/safe-bash-command-unzip/unzip/safety.d.ts +32 -0
  602. package/dist/safe-bash-command-unzip/unzip/safety.js +7 -0
  603. package/dist/safe-bash-command-unzip/unzip.d.ts +3 -0
  604. package/dist/safe-bash-command-unzip/unzip.js +8 -0
  605. package/dist/safe-bash-command-wget/LICENSE +21 -0
  606. package/dist/safe-bash-command-wget/index.d.ts +6 -0
  607. package/dist/safe-bash-command-wget/index.js +26 -0
  608. package/dist/safe-bash-command-wget/wget.d.ts +3 -0
  609. package/dist/safe-bash-command-wget/wget.js +7 -0
  610. package/dist/safe-bash-command-xan/argv.d.ts +4 -1
  611. package/dist/safe-bash-command-xan/argv.js +1 -1
  612. package/dist/safe-bash-command-xan/commands.js +4 -3
  613. package/dist/safe-bash-command-xan/index.js +15 -14
  614. package/dist/safe-bash-command-xan/io.js +2 -2
  615. package/dist/safe-bash-command-xmllint/index.js +189 -49
  616. package/dist/safe-bash-command-xz/index.js +3 -2
  617. package/dist/safe-bash-command-xz/options.d.ts +9 -1
  618. package/dist/safe-bash-command-xz/options.js +3 -1
  619. package/dist/safe-bash-command-yq/index.d.ts +4 -11
  620. package/dist/safe-bash-command-yq/index.js +3367 -670
  621. package/dist/safe-bash-command-yq/mike.js +6 -13
  622. package/dist/safe-bash-command-yq/native-work.d.ts +1 -0
  623. package/dist/safe-bash-command-yq/native-work.js +17 -0
  624. package/dist/safe-bash-command-yq/query.d.ts +11 -0
  625. package/dist/safe-bash-command-yq/query.js +735 -0
  626. package/dist/safe-bash-command-zip/LICENSE +21 -0
  627. package/dist/safe-bash-command-zip/index.d.ts +7 -0
  628. package/dist/safe-bash-command-zip/index.js +38 -0
  629. package/dist/safe-bash-command-zip/sync.d.ts +3 -0
  630. package/dist/safe-bash-command-zip/sync.js +9 -0
  631. package/dist/safe-bash-command-zip/zip.d.ts +3 -0
  632. package/dist/safe-bash-command-zip/zip.js +7 -0
  633. package/dist/safe-bash-compression-engine/files.js +4 -4
  634. package/dist/safe-bash-compression-engine/index.js +2 -2
  635. package/dist/safe-bash-compression-engine/operand.js +6 -6
  636. package/dist/safe-bash-compression-engine/stream.js +2 -2
  637. package/dist/safe-bash-compression-engine/zstd-decode.js +1 -1
  638. package/dist/safe-bash-contracts/command.js +1 -1
  639. package/dist/safe-bash-contracts/diagnostics.js +4 -4
  640. package/dist/safe-bash-contracts/escaping.js +11 -11
  641. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  642. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  643. package/dist/safe-bash-contracts/index.js +34 -34
  644. package/dist/safe-bash-contracts/io.js +2 -2
  645. package/dist/safe-bash-contracts/output.js +3 -3
  646. package/dist/safe-bash-diff-engine/LICENSE +21 -0
  647. package/dist/safe-bash-diff-engine/index.d.ts +1 -0
  648. package/dist/safe-bash-diff-engine/index.js +24 -0
  649. package/dist/safe-bash-diff-engine/shared.d.ts +53 -0
  650. package/dist/safe-bash-diff-engine/shared.js +19 -0
  651. package/dist/safe-bash-io-engine/commands/directory-admission.d.ts +3 -0
  652. package/dist/safe-bash-io-engine/commands/directory-admission.js +34 -0
  653. package/dist/safe-bash-io-engine/commands/mode-change.d.ts +4 -0
  654. package/dist/safe-bash-io-engine/commands/mode-change.js +60 -0
  655. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +20 -31
  656. package/dist/safe-bash-io-engine/shell/pattern.js +7 -12
  657. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  658. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  659. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  660. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  661. package/dist/safe-bash-markdown-engine/index.js +7 -7
  662. package/dist/safe-bash-mcp/index.browser.d.ts +6 -0
  663. package/dist/safe-bash-mcp/index.browser.js +1 -0
  664. package/dist/safe-bash-mcp/index.d.ts +12 -0
  665. package/dist/safe-bash-mcp/index.js +1558 -36
  666. package/dist/safe-bash-network-engine/LICENSE +21 -0
  667. package/dist/safe-bash-network-engine/aggregate.d.ts +4 -0
  668. package/dist/safe-bash-network-engine/aggregate.js +37 -0
  669. package/dist/safe-bash-network-engine/args.d.ts +68 -0
  670. package/dist/safe-bash-network-engine/args.js +19 -0
  671. package/dist/safe-bash-network-engine/authorizer.d.ts +6 -0
  672. package/dist/safe-bash-network-engine/authorizer.js +8 -0
  673. package/dist/safe-bash-network-engine/body.d.ts +9 -0
  674. package/dist/safe-bash-network-engine/body.js +374 -0
  675. package/dist/safe-bash-network-engine/deadline.d.ts +2 -0
  676. package/dist/safe-bash-network-engine/deadline.js +7 -0
  677. package/dist/safe-bash-network-engine/decode.d.ts +2 -0
  678. package/dist/safe-bash-network-engine/decode.js +81 -0
  679. package/dist/safe-bash-network-engine/fetch-transport.d.ts +7 -0
  680. package/dist/safe-bash-network-engine/fetch-transport.js +9 -0
  681. package/dist/safe-bash-network-engine/form-content-type.d.ts +5 -0
  682. package/dist/safe-bash-network-engine/form-content-type.js +8 -0
  683. package/dist/safe-bash-network-engine/form-headers.d.ts +2 -0
  684. package/dist/safe-bash-network-engine/form-headers.js +10 -0
  685. package/dist/safe-bash-network-engine/glob.d.ts +7 -0
  686. package/dist/safe-bash-network-engine/glob.js +124 -0
  687. package/dist/safe-bash-network-engine/index.d.ts +3 -0
  688. package/dist/safe-bash-network-engine/index.js +26 -0
  689. package/dist/safe-bash-network-engine/input.d.ts +5 -0
  690. package/dist/safe-bash-network-engine/input.js +255 -0
  691. package/dist/safe-bash-network-engine/output.d.ts +6 -0
  692. package/dist/safe-bash-network-engine/output.js +132 -0
  693. package/dist/safe-bash-network-engine/platform-portable.d.ts +5 -0
  694. package/dist/safe-bash-network-engine/platform-portable.js +19 -0
  695. package/dist/safe-bash-network-engine/private-address.d.ts +1 -0
  696. package/dist/safe-bash-network-engine/private-address.js +7 -0
  697. package/dist/safe-bash-network-engine/shared.d.ts +14 -0
  698. package/dist/safe-bash-network-engine/shared.js +23 -0
  699. package/dist/safe-bash-network-engine/types.d.ts +37 -0
  700. package/dist/safe-bash-network-engine/types.js +11 -0
  701. package/dist/safe-bash-network-engine/url.d.ts +2 -0
  702. package/dist/safe-bash-network-engine/url.js +8 -0
  703. package/dist/safe-bash-query-engine/capture.d.ts +1 -0
  704. package/dist/safe-bash-query-engine/capture.js +9 -7
  705. package/dist/safe-bash-query-engine/dates.d.ts +5 -1
  706. package/dist/safe-bash-query-engine/dates.js +10 -2
  707. package/dist/safe-bash-query-engine/delpaths.js +5 -5
  708. package/dist/safe-bash-query-engine/formats.js +3 -3
  709. package/dist/safe-bash-query-engine/index.js +15 -15
  710. package/dist/safe-bash-query-engine/indices.js +5 -5
  711. package/dist/safe-bash-query-engine/input.d.ts +1 -2
  712. package/dist/safe-bash-query-engine/input.js +2 -4
  713. package/dist/safe-bash-query-engine/interpreter.d.ts +5 -0
  714. package/dist/safe-bash-query-engine/interpreter.js +13 -13
  715. package/dist/safe-bash-query-engine/limits.js +1 -1
  716. package/dist/safe-bash-query-engine/parser.d.ts +8 -1
  717. package/dist/safe-bash-query-engine/parser.js +2 -2
  718. package/dist/safe-bash-query-engine/query-core.js +15 -15
  719. package/dist/safe-bash-query-engine/recurse.js +2 -2
  720. package/dist/safe-bash-query-engine/regex.d.ts +4 -2
  721. package/dist/safe-bash-query-engine/regex.js +10 -5
  722. package/dist/safe-bash-query-engine/split.js +2 -2
  723. package/dist/safe-bash-query-engine/splits.d.ts +1 -1
  724. package/dist/safe-bash-query-engine/splits.js +7 -6
  725. package/dist/safe-bash-query-engine/values.js +4 -4
  726. package/dist/safe-bash-regex-engine/ere/matcher.js +4 -4
  727. package/dist/safe-bash-regex-engine/index.js +2 -2
  728. package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -0
  729. package/dist/safe-bash-regex-engine/text/regex.js +2 -2
  730. package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +12 -2
  731. package/dist/safe-bash-search-engine/ergonomic-regex.js +2 -2
  732. package/dist/safe-bash-search-engine/glob.js +2 -2
  733. package/dist/safe-bash-search-engine/grep.js +2 -2
  734. package/dist/safe-bash-search-engine/matcher.d.ts +6 -2
  735. package/dist/safe-bash-search-engine/matcher.js +30 -8
  736. package/dist/safe-bash-search-engine/options.js +1 -1
  737. package/dist/safe-bash-search-engine/output.d.ts +3 -2
  738. package/dist/safe-bash-search-engine/output.js +111 -30
  739. package/dist/safe-bash-search-engine/shared.d.ts +2 -0
  740. package/dist/safe-bash-search-engine/shared.js +2 -2
  741. package/dist/safe-bash-search-engine/walk.js +11 -10
  742. package/dist/safe-bash-xml-engine/document.d.ts +1 -1
  743. package/dist/safe-bash-xml-engine/document.js +3 -3
  744. package/dist/safe-bash-xml-engine/evaluate.d.ts +1 -0
  745. package/dist/safe-bash-xml-engine/evaluate.js +4 -1
  746. package/dist/safe-bash-xml-engine/index.js +8 -6
  747. package/dist/safe-bash-xml-engine/io.js +1 -1
  748. package/dist/safe-bash-xml-engine/limits.d.ts +2 -0
  749. package/dist/safe-bash-xml-engine/limits.js +1 -1
  750. package/dist/safe-bash-xml-engine/predicate.d.ts +57 -0
  751. package/dist/safe-bash-xml-engine/query.d.ts +3 -15
  752. package/dist/safe-bash-xml-engine/query.js +3 -2
  753. package/dist/safe-bash-zip-engine/LICENSE +21 -0
  754. package/dist/safe-bash-zip-engine/index.d.ts +1 -0
  755. package/dist/safe-bash-zip-engine/index.js +32 -0
  756. package/dist/safe-bash-zip-engine/unzip/arguments.d.ts +53 -0
  757. package/dist/safe-bash-zip-engine/unzip/arguments.js +270 -0
  758. package/dist/safe-bash-zip-engine/zip/aes.d.ts +17 -0
  759. package/dist/safe-bash-zip-engine/zip/aes.js +15 -0
  760. package/dist/safe-bash-zip-engine/zip/comments.d.ts +17 -0
  761. package/dist/safe-bash-zip-engine/zip/comments.js +77 -0
  762. package/dist/safe-bash-zip-engine/zip/crc.d.ts +1 -0
  763. package/dist/safe-bash-zip-engine/zip/crc.js +7 -0
  764. package/dist/safe-bash-zip-engine/zip/crypto.d.ts +19 -0
  765. package/dist/safe-bash-zip-engine/zip/crypto.js +16 -0
  766. package/dist/safe-bash-zip-engine/zip/dates.d.ts +4 -0
  767. package/dist/safe-bash-zip-engine/zip/dates.js +68 -0
  768. package/dist/safe-bash-zip-engine/zip/environment.d.ts +2 -0
  769. package/dist/safe-bash-zip-engine/zip/environment.js +60 -0
  770. package/dist/safe-bash-zip-engine/zip/grow.d.ts +3 -0
  771. package/dist/safe-bash-zip-engine/zip/grow.js +7 -0
  772. package/dist/safe-bash-zip-engine/zip/help.d.ts +4 -0
  773. package/dist/safe-bash-zip-engine/zip/help.js +194 -0
  774. package/dist/safe-bash-zip-engine/zip/line-endings.d.ts +2 -0
  775. package/dist/safe-bash-zip-engine/zip/line-endings.js +165 -0
  776. package/dist/safe-bash-zip-engine/zip/log.d.ts +22 -0
  777. package/dist/safe-bash-zip-engine/zip/log.js +153 -0
  778. package/dist/safe-bash-zip-engine/zip/lzma.d.ts +9 -0
  779. package/dist/safe-bash-zip-engine/zip/lzma.js +7 -0
  780. package/dist/safe-bash-zip-engine/zip/move.d.ts +11 -0
  781. package/dist/safe-bash-zip-engine/zip/move.js +57 -0
  782. package/dist/safe-bash-zip-engine/zip/names.d.ts +2 -0
  783. package/dist/safe-bash-zip-engine/zip/names.js +37 -0
  784. package/dist/safe-bash-zip-engine/zip/options.d.ts +13 -0
  785. package/dist/safe-bash-zip-engine/zip/options.js +23 -0
  786. package/dist/safe-bash-zip-engine/zip/repair.d.ts +10 -0
  787. package/dist/safe-bash-zip-engine/zip/repair.js +348 -0
  788. package/dist/safe-bash-zip-engine/zip/safety.d.ts +54 -0
  789. package/dist/safe-bash-zip-engine/zip/safety.js +19 -0
  790. package/dist/safe-bash-zip-engine/zip/sfx.d.ts +4 -0
  791. package/dist/safe-bash-zip-engine/zip/sfx.js +58 -0
  792. package/dist/safe-bash-zip-engine/zip/test-command.d.ts +5 -0
  793. package/dist/safe-bash-zip-engine/zip/test-command.js +98 -0
  794. package/dist/safe-bash-zip-engine/zip/volumes.d.ts +21 -0
  795. package/dist/safe-bash-zip-engine/zip/volumes.js +255 -0
  796. package/dist/safe-bash-zip-engine/zip/zip64.d.ts +30 -0
  797. package/dist/safe-bash-zip-engine/zip/zip64.js +25 -0
  798. package/dist/safe-bash-zip-engine/zip-format.d.ts +68 -0
  799. package/dist/safe-bash-zip-engine/zip-format.js +27 -0
  800. package/dist/safe-playwright-cloudflare/browser-codegen.generated.d.ts +7 -7
  801. package/dist/safe-playwright-cloudflare/browser-codegen.generated.js +866 -8069
  802. package/dist/safe-playwright-cloudflare/browser-run-code-budget.d.ts +0 -1
  803. package/dist/safe-playwright-cloudflare/browser-run-code-budget.js +0 -2
  804. package/dist/safe-playwright-cloudflare/browser-trace-archive.d.ts +5 -1
  805. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +2 -1
  806. package/dist/safe-playwright-cloudflare/browser-trace-budget.js +2 -2
  807. package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +2 -0
  808. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +3 -11
  809. package/dist/safe-playwright-cloudflare/shell-playwright.d.ts +2 -0
  810. package/dist/safe-playwright-cloudflare/shell-playwright.js +1 -1
  811. package/dist/spreadsheet-engine/io/publication.d.ts +1 -0
  812. package/package.json +163 -14
  813. package/dist/safe-bash/chunks/chunk-AZAJJVFX.js +0 -23017
  814. package/dist/safe-bash/chunks/chunk-O4ZUCRGN.js +0 -13
  815. package/dist/safe-bash/chunks/chunk-S264DZO2.js +0 -243
  816. package/dist/safe-bash/chunks/chunk-WVG5SHHQ.js +0 -12
  817. package/dist/safe-bash/chunks/chunk-ZW6K2J7P.js +0 -2652
  818. package/dist/safe-bash/command-chunks/chunk-5MPOQ6V3.js +0 -181
  819. package/dist/safe-bash/command-chunks/chunk-BIXLZ3OG.js +0 -14342
  820. package/dist/safe-bash/command-chunks/chunk-DUYJE2HY.js +0 -14
  821. package/dist/safe-bash/command-chunks/chunk-NETECMOF.js +0 -40
  822. package/dist/safe-bash/command-chunks/chunk-XS3PGJU2.js +0 -343
  823. package/dist/safe-bash/command-chunks/chunk-XTZALMLR.js +0 -488
  824. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.d.ts +0 -2
  825. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.js +0 -3
  826. package/dist/safe-bash/commands/archive/zip/aes-primitives.d.ts +0 -2
  827. package/dist/safe-bash/commands/archive/zip/aes-primitives.js +0 -3
  828. package/dist/safe-bash/commands/xml/document.d.ts +0 -2
  829. package/dist/safe-bash/commands/xml/document.js +0 -2
  830. package/dist/safe-bash/commands/xml/evaluate.d.ts +0 -2
  831. package/dist/safe-bash/commands/xml/evaluate.js +0 -2
  832. package/dist/safe-bash/commands/xml/json.d.ts +0 -2
  833. package/dist/safe-bash/commands/xml/json.js +0 -2
  834. package/dist/safe-bash/commands/xml/limits.d.ts +0 -2
  835. package/dist/safe-bash/commands/xml/limits.js +0 -2
  836. package/dist/safe-bash/commands/xml/query.d.ts +0 -2
  837. package/dist/safe-bash/commands/xml/query.js +0 -2
  838. package/dist/safe-bash/chunks/{chunk-NHOXKQNE.js → chunk-QVSRRNZT.js} +3 -3
  839. package/dist/safe-bash/command-chunks/{chunk-FIUFIDAO.js → chunk-2JRBIDAD.js} +3 -3
  840. package/dist/safe-bash/command-chunks/{chunk-B5BKA5WH.js → chunk-B5TAOCKD.js} +3 -3
  841. package/dist/safe-bash/command-chunks/{chunk-TYVCKQDH.js → chunk-J5SN3PZ3.js} +3 -3
  842. package/dist/safe-bash/command-chunks/{chunk-2ENZ6JGA.js → chunk-KEV7C3KH.js} +3 -3
  843. package/dist/safe-bash/command-chunks/{chunk-S62HELHU.js → chunk-PL6O4K6W.js} +3 -3
  844. package/dist/safe-bash/command-chunks/{chunk-2WRTLCGK.js → chunk-QZF3SINC.js} +4 -4
  845. package/dist/safe-bash/command-chunks/{chunk-X7TM3AKW.js → chunk-U6G67N23.js} +3 -3
  846. package/dist/safe-bash/command-chunks/{chunk-DDLQ5YDB.js → chunk-YHFXOX6U.js} +9 -9
  847. package/dist/safe-bash/command-chunks/{chunk-DQMOM72Z.js → chunk-ZRRBXU3M.js} +4 -4
@@ -1,1076 +1,2 @@
1
- import { byteLength, concatBytes } from "../../byte-encoding.js";
2
- import { zipGrowRecords } from "./zip/grow.js";
3
- import { zip64Directory, zip64Fields, zipDiskOffset, zipDiskRecord, stripZip64, zip64Extra, zip64Member, zipEnd, zipDescriptor } from "./zip/zip64.js";
4
- import { crcTable } from "./zip/crc.js";
5
- import { encryptZipPayload, decryptZipPayload } from "./zip/crypto.js";
6
- import { aesParameters, aesExtra, encryptAesPayload, decryptAesPayload } from "./zip/aes.js";
7
- import { collectBytes, readBytes } from "../../contracts/index.js";
8
- import { yieldTurn } from "../../contracts/yield.js";
9
- import { codec, CodecReader } from "../bytes/compression/codec.js";
10
- import { boundedCodec } from "../bytes/compression/bounded-codec.js";
11
- import { fail, text } from "./internal.js";
12
- import { zipLzma } from "./zip/lzma.js";
13
- const encoder = new TextEncoder();
14
- const cp437 = "ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";
15
- export function crc32(bytes, previous = 0) {
16
- let value = previous ^ 0xffffffff;
17
- for (const byte of bytes)
18
- value = (value >>> 8) ^ crcTable[(value ^ byte) & 255];
19
- return (value ^ 0xffffffff) >>> 0;
20
- }
21
- function number(value, maximum, label) {
22
- if (!Number.isSafeInteger(value) || value < 0 || value > maximum)
23
- fail(`ZIP ${label} limit exceeded or invalid value`);
24
- }
25
- function admit(limits, signal) {
26
- signal.throwIfAborted();
27
- for (const key of ["maxArchiveBytes", "maxEntryBytes", "maxTotalBytes", "maxMembers", "maxPathBytes", "maxDepth", "maxPaxBytes", "maxTextBytes", "maxPatternSteps", "chunkSize"]) {
28
- if (limits[key] !== Infinity || key === "chunkSize")
29
- number(limits[key], Number.MAX_SAFE_INTEGER, key);
30
- }
31
- if (limits.chunkSize < 512 || limits.chunkSize > 1024 * 1024)
32
- fail("ZIP chunk size must be between 512 and 1048576");
33
- return Math.min(limits.chunkSize, 64 * 1024);
34
- }
35
- function pathBytes(name, limits) {
36
- if (name.length > Math.min(limits.maxPathBytes, 65535))
37
- fail("ZIP path byte limit exceeded");
38
- number(byteLength(name), Math.min(limits.maxPathBytes, limits.maxArchiveBytes, 65535), "path byte");
39
- const bytes = encoder.encode(name);
40
- if (!name || text(bytes) !== name || name.includes("\0"))
41
- fail("ZIP invalid or unsafe path");
42
- number(bytes.length, Math.min(limits.maxPathBytes, 65535), "path byte");
43
- const parts = name.split("/");
44
- if (parts.at(-1) === "")
45
- parts.pop();
46
- if (parts.some(part => !part || part === "." || part === ".."))
47
- fail("ZIP unsafe traversal or absolute path");
48
- number(parts.length, limits.maxDepth, "path depth");
49
- return bytes;
50
- }
51
- function equal(first, second) {
52
- return first.length === second.length && first.every((byte, index) => byte === second[index]);
53
- }
54
- function legacyName(bytes) {
55
- let name = "";
56
- for (const byte of bytes)
57
- name += byte < 128 ? String.fromCharCode(byte) : cp437[byte - 128];
58
- return name;
59
- }
60
- function extras(bytes, rawName, comment, central, limits) {
61
- number(bytes.length, Math.min(limits.maxPaxBytes, 65535), "extra field");
62
- const result = {};
63
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
64
- const seen = new Set();
65
- let offset = 0;
66
- while (offset < bytes.length) {
67
- if (offset + 4 > bytes.length)
68
- fail("ZIP truncated extra field");
69
- const identifier = view.getUint16(offset, true);
70
- const length = view.getUint16(offset + 2, true);
71
- offset += 4;
72
- if (offset + length > bytes.length)
73
- fail("ZIP truncated extra field payload");
74
- if (seen.has(identifier))
75
- fail("ZIP duplicate extra field");
76
- seen.add(identifier);
77
- if (identifier === 1) {
78
- if (!length || length > 28 || length % 4)
79
- fail("ZIP64 invalid extra field length");
80
- result.zip64 = bytes.subarray(offset, offset + length);
81
- }
82
- if (identifier === 0x9901) {
83
- if (length !== 7 || bytes[offset + 2] !== 65 || bytes[offset + 3] !== 69)
84
- fail("ZIP invalid AES extra field");
85
- const aes = { version: view.getUint16(offset, true), strength: (bytes[offset + 4] + 1) * 64, method: view.getUint16(offset + 5, true) };
86
- aesParameters(aes);
87
- if (aes.method !== 0 && aes.method !== 8 && aes.method !== 12)
88
- fail("ZIP unsupported AES compression method");
89
- result.aes = aes;
90
- }
91
- if (identifier === 0x0017 || identifier === 0x0018 || identifier === 0x0019)
92
- fail("ZIP encryption is unsupported");
93
- if (identifier === 0x7075 || identifier === 0x6375) {
94
- if (length < 5 || bytes[offset] !== 1)
95
- fail("ZIP unsupported or truncated Unicode extra field");
96
- const original = identifier === 0x7075 ? rawName : comment;
97
- if (view.getUint32(offset + 1, true) !== crc32(original))
98
- fail("ZIP Unicode extra field CRC mismatch");
99
- const decoded = text(bytes.subarray(offset + 5, offset + length));
100
- if (identifier === 0x7075) {
101
- pathBytes(decoded, limits);
102
- result.name = decoded;
103
- }
104
- else
105
- number(length - 5, limits.maxTextBytes, "Unicode comment");
106
- }
107
- if (identifier === 0x5455) {
108
- if (!length)
109
- fail("ZIP truncated timestamp extra field");
110
- const flags = bytes[offset];
111
- if (flags & ~7)
112
- fail("ZIP unsupported timestamp flags");
113
- const count = (flags & 1) + (central ? 0 : ((flags >>> 1) & 1) + ((flags >>> 2) & 1));
114
- if (length !== 1 + count * 4)
115
- fail("ZIP truncated or inconsistent timestamp extra field");
116
- if (flags & 1)
117
- result.modified = view.getInt32(offset + 1, true) * 1000;
118
- }
119
- offset += length;
120
- }
121
- return result;
122
- }
123
- function nameFrom(rawName, flags, metadata, limits) {
124
- number(rawName.length, Math.min(limits.maxPathBytes, 65535), "raw path byte");
125
- const raw = flags & 0x800 ? text(rawName) : legacyName(rawName);
126
- pathBytes(raw, limits);
127
- if (flags & 0x800 && metadata.name !== undefined && metadata.name !== raw)
128
- fail("ZIP conflicting UTF-8 and Unicode extra names");
129
- return metadata.name ?? raw;
130
- }
131
- function format(method, flags, version) {
132
- number(flags, 65535, "general purpose flags");
133
- if (flags & (64 | 0x2000))
134
- fail("ZIP encryption is unsupported");
135
- if (method === 99) {
136
- if (!(flags & 1) || flags & ~0x80f || version !== 51)
137
- fail("ZIP invalid AES flags or extraction version");
138
- return;
139
- }
140
- if (method === 14 ? flags & ~0x80b : flags & ~0x80f || method !== 8 && flags & 6)
141
- fail("ZIP unsupported general purpose flags");
142
- if (method === 14) {
143
- if (version !== 63)
144
- fail("ZIP unsupported LZMA extraction version");
145
- return;
146
- }
147
- if (method !== 0 && method !== 8 && method !== 12)
148
- fail("ZIP unsupported compression method");
149
- // Info-ZIP uses version 10 for encrypted STORE, including descriptors.
150
- if (version < (method === 12 ? 46 : method === 8 || flags & 8 && !(flags & 1) ? 20 : 10) || version > 20 && version !== 45 && version !== 46)
151
- fail("ZIP unsupported extraction version (including ZIP64)");
152
- }
153
- function dosModified(date, time) {
154
- if (!date && !time)
155
- return new Date(1980, 0, 1);
156
- const year = 1980 + (date >>> 9);
157
- const month = ((date >>> 5) & 15) - 1;
158
- const day = date & 31;
159
- const hours = time >>> 11;
160
- const minutes = (time >>> 5) & 63;
161
- const seconds = (time & 31) * 2;
162
- const result = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
163
- if (result.getUTCFullYear() !== year || result.getUTCMonth() !== month || result.getUTCDate() !== day || hours > 23 || minutes > 59 || seconds > 59)
164
- fail("ZIP invalid DOS timestamp");
165
- return new Date(year, month, day, hours, minutes, seconds);
166
- }
167
- function attributeMode(versionMadeBy, externalAttributes, directory) {
168
- const host = versionMadeBy >>> 8;
169
- const unixMode = host === 3 || host === 19 ? externalAttributes >>> 16 : 0;
170
- if (unixMode)
171
- return unixMode;
172
- const mode = directory ? 0o040755 : 0o100644;
173
- return externalAttributes & 1 ? mode & ~0o222 : mode;
174
- }
175
- function entryBounds(entry, limits) {
176
- pathBytes(entry.name, limits);
177
- number(entry.size, Math.min(limits.maxEntryBytes, limits.maxTotalBytes), "entry byte");
178
- number(entry.data.length, limits.maxArchiveBytes, "compressed byte");
179
- number(entry.crc32, 0xffffffff, "CRC32");
180
- number(entry.mode, 0xffff, "mode");
181
- format(entry.method, entry.flags ?? 0x800, entry.method === 14 ? 63 : entry.method === 99 ? 51 : entry.method === 12 ? 46 : entry.method === 8 || (entry.flags ?? 0) & 9 ? 20 : 10);
182
- if (entry.method === 99 && !entry.aes || entry.method !== 99 && entry.aes)
183
- fail("ZIP inconsistent AES metadata");
184
- if (entry.aes) {
185
- aesParameters(entry.aes);
186
- if (entry.aes.method !== 0 && entry.aes.method !== 8 && entry.aes.method !== 12)
187
- fail("ZIP unsupported AES compression method");
188
- if (entry.aes.version === 2 && entry.crc32 !== 0)
189
- fail("ZIP AE-2 CRC must be zero");
190
- }
191
- if (entry.directory !== entry.name.endsWith("/") || entry.directory && (entry.symlink || entry.size !== 0))
192
- fail("ZIP inconsistent directory metadata");
193
- const type = entry.mode & 0o170000;
194
- const pipePayload = !entry.directory && !entry.symlink && type === 0o010000;
195
- if (type !== 0 && !pipePayload && type !== (entry.directory ? 0o040000 : entry.symlink ? 0o120000 : 0o100000))
196
- fail("ZIP unsupported or conflicting file type");
197
- if (!Number.isFinite(entry.modified.getTime()))
198
- fail("ZIP invalid modification time");
199
- }
200
- async function copyBytes(source, destination, start, chunkSize, signal) {
201
- for (let offset = 0; offset < source.length; offset += chunkSize) {
202
- signal.throwIfAborted();
203
- destination.set(source.subarray(offset, offset + chunkSize), start + offset);
204
- if (offset + chunkSize < source.length)
205
- await yieldTurn(signal);
206
- }
207
- }
208
- export async function readZipArchive(bytes, limits, signal, profile = {}) {
209
- const chunkSize = admit(limits, signal);
210
- number(bytes.length, limits.maxArchiveBytes, "archive byte");
211
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
212
- let end = -1;
213
- let displacement = 0;
214
- const lower = Math.max(0, bytes.length - 22 - 65535);
215
- await yieldTurn(signal);
216
- for (let offset = bytes.length - 22; offset >= lower; offset--) {
217
- if ((bytes.length - offset) % 4096 === 0)
218
- signal.throwIfAborted();
219
- if (view.getUint32(offset, true) === 0x06054b50 && offset + 22 + view.getUint16(offset + 20, true) === bytes.length) {
220
- const size = view.getUint32(offset + 12, true);
221
- const start = view.getUint32(offset + 16, true);
222
- const zip64 = size === 0xffffffff || start === 0xffffffff || offset >= 20 && view.getUint32(offset - 20, true) === 0x07064b50;
223
- let candidateDisplacement = 0;
224
- if (!zip64 && !profile.disks && start + size !== offset) {
225
- if (!profile.prefix || start + size > offset || offset - size < 0 || size && view.getUint32(offset - size, true) !== 0x02014b50)
226
- continue;
227
- candidateDisplacement = offset - size - start;
228
- }
229
- if (zip64 && profile.prefix && !profile.disks && offset >= 76 && view.getUint32(offset - 20, true) === 0x07064b50) {
230
- const declared = view.getBigUint64(offset - 12, true);
231
- if (declared > BigInt(Number.MAX_SAFE_INTEGER))
232
- fail("ZIP64 unsafe numeric field");
233
- if (Number(declared) + 12 > offset - 20 || view.getUint32(Number(declared), true) !== 0x06064b50) {
234
- let found = -1;
235
- const low = Math.max(0, offset - 76 - limits.maxPaxBytes);
236
- for (let wide = offset - 76; wide >= low; wide--) {
237
- if (offset - 76 - wide > limits.maxPatternSteps)
238
- fail("ZIP SFX scan work limit exceeded");
239
- if ((offset - wide) % 4096 === 0)
240
- await yieldTurn(signal);
241
- if (view.getUint32(wide, true) !== 0x06064b50 || view.getBigUint64(wide + 4, true) !== BigInt(offset - 32 - wide))
242
- continue;
243
- if (found !== -1)
244
- fail("ZIP64 ambiguous SFX end records");
245
- found = wide;
246
- }
247
- if (found < Number(declared))
248
- continue;
249
- candidateDisplacement = found - Number(declared);
250
- }
251
- }
252
- if (end !== -1)
253
- fail("ZIP ambiguous end records");
254
- end = offset;
255
- displacement = candidateDisplacement;
256
- }
257
- }
258
- if (end === -1)
259
- fail("ZIP truncated or missing end of central directory");
260
- const { members, centralStart, centralEnd, diskMembers, disk: finalDisk, zip64Disk, zip64DiskMembers } = zip64Directory(view, end, limits, profile.disks, displacement);
261
- number(bytes.length - end - 22, limits.maxTextBytes, "archive comment");
262
- const entries = [];
263
- const spans = [];
264
- const growSpans = new Map();
265
- let offset = centralStart;
266
- let total = 0;
267
- let finalMembers = 0;
268
- let wideDiskMembers = 0;
269
- for (let index = 0; index < members; index++) {
270
- if (index > 0 && (index & 63) === 0)
271
- await yieldTurn(signal);
272
- else
273
- signal.throwIfAborted();
274
- if (!profile.disks || offset >= profile.disks.starts[finalDisk])
275
- finalMembers++;
276
- if (zip64Disk >= 0 && (!profile.disks || offset >= profile.disks.starts[zip64Disk] && offset < profile.disks.starts[zip64Disk] + profile.disks.lengths[zip64Disk]))
277
- wideDiskMembers++;
278
- if (offset + 46 > centralEnd || view.getUint32(offset, true) !== 0x02014b50)
279
- fail("ZIP truncated or invalid central header");
280
- const versionMadeBy = view.getUint16(offset + 4, true);
281
- const version = view.getUint16(offset + 6, true);
282
- const flags = view.getUint16(offset + 8, true);
283
- const method = view.getUint16(offset + 10, true);
284
- format(method, flags, version);
285
- const dosTime = view.getUint16(offset + 12, true);
286
- const dosDate = view.getUint16(offset + 14, true);
287
- const checksum = view.getUint32(offset + 16, true);
288
- let compressedSize = view.getUint32(offset + 20, true);
289
- let size = view.getUint32(offset + 24, true);
290
- const nameLength = view.getUint16(offset + 28, true);
291
- const extraLength = view.getUint16(offset + 30, true);
292
- const commentLength = view.getUint16(offset + 32, true);
293
- const internalAttributes = view.getUint16(offset + 36, true);
294
- if (internalAttributes & ~1)
295
- fail("ZIP unsupported internal attributes");
296
- const externalAttributes = view.getUint32(offset + 38, true);
297
- let local = view.getUint32(offset + 42, true);
298
- const disk = view.getUint16(offset + 34, true);
299
- const next = offset + 46 + nameLength + extraLength + commentLength;
300
- if (next > centralEnd)
301
- fail("ZIP truncated central metadata");
302
- zipDiskRecord(profile.disks, offset, next);
303
- number(commentLength, limits.maxTextBytes, "entry comment");
304
- const rawName = bytes.subarray(offset + 46, offset + 46 + nameLength);
305
- const centralExtra = bytes.subarray(offset + 46 + nameLength, next - commentLength);
306
- const comment = bytes.subarray(next - commentLength, next);
307
- if (flags & 0x800)
308
- text(comment);
309
- const centralMetadata = extras(centralExtra, rawName, comment, true, limits);
310
- if (Boolean(centralMetadata.aes) !== (method === 99))
311
- fail("ZIP inconsistent AES method and extra field");
312
- const aes = centralMetadata.aes;
313
- if (aes && aes.method !== 8 && flags & 6)
314
- fail("ZIP unsupported AES compression flags");
315
- if (aes?.version === 2 && checksum !== 0)
316
- fail("ZIP AE-2 CRC must be zero");
317
- if (version < 45 && (size === 0xffffffff || compressedSize === 0xffffffff || local === 0xffffffff || disk === 65535))
318
- fail("ZIP64 unsupported member extraction version");
319
- const resolved = zip64Fields(centralMetadata.zip64, [size, compressedSize, local, disk === 65535 ? 0xffffffff : disk]);
320
- [size, compressedSize, local] = resolved;
321
- local = zipDiskOffset(profile.disks, resolved[3], local);
322
- local += displacement;
323
- number(size, limits.maxEntryBytes, "entry byte");
324
- number(compressedSize, limits.maxArchiveBytes, "compressed entry byte");
325
- if (flags & 1 && compressedSize < (aes ? aesParameters(aes).saltBytes + 12 : 12))
326
- fail("ZIP truncated encryption header");
327
- if (aes?.method === 0 && compressedSize !== size + aesParameters(aes).saltBytes + 12)
328
- fail("ZIP AES stored size mismatch");
329
- if (method === 0 && compressedSize !== size + (flags & 1 ? 12 : 0))
330
- fail("ZIP stored size mismatch");
331
- total += size;
332
- number(total, limits.maxTotalBytes, "total byte");
333
- const name = nameFrom(rawName, flags, centralMetadata, limits);
334
- if (local + 30 > centralStart || view.getUint32(local, true) !== 0x04034b50)
335
- fail("ZIP invalid local header span");
336
- if (view.getUint16(local + 4, true) !== version || view.getUint16(local + 6, true) !== flags || view.getUint16(local + 8, true) !== method || view.getUint16(local + 10, true) !== dosTime || view.getUint16(local + 12, true) !== dosDate)
337
- fail("ZIP central/local metadata mismatch");
338
- const localNameLength = view.getUint16(local + 26, true);
339
- const localExtraLength = view.getUint16(local + 28, true);
340
- const payloadStart = local + 30 + localNameLength + localExtraLength;
341
- zipDiskRecord(profile.disks, local, payloadStart);
342
- let payloadEnd = payloadStart + compressedSize;
343
- if (payloadEnd > centralStart)
344
- fail("ZIP truncated or overlapping local payload");
345
- const localName = bytes.subarray(local + 30, local + 30 + localNameLength);
346
- if (!equal(rawName, localName))
347
- fail("ZIP central/local filename mismatch");
348
- const localExtra = bytes.subarray(local + 30 + localNameLength, payloadStart);
349
- const localMetadata = extras(localExtra, localName, comment, false, limits);
350
- if (aes ? !localMetadata.aes || aes.version !== localMetadata.aes.version || aes.strength !== localMetadata.aes.strength || aes.method !== localMetadata.aes.method : localMetadata.aes !== undefined)
351
- fail("ZIP central/local AES metadata mismatch");
352
- const localEffective = nameFrom(localName, flags, localMetadata, limits);
353
- if (localMetadata.name !== undefined && localEffective !== name)
354
- fail("ZIP central/local Unicode name mismatch");
355
- if (centralMetadata.modified !== undefined && localMetadata.modified !== undefined && centralMetadata.modified !== localMetadata.modified)
356
- fail("ZIP central/local timestamp mismatch");
357
- const rawLocalSize = view.getUint32(local + 22, true);
358
- const rawLocalCompressed = view.getUint32(local + 18, true);
359
- if (version < 45 && (rawLocalSize === 0xffffffff || rawLocalCompressed === 0xffffffff))
360
- fail("ZIP64 unsupported member extraction version");
361
- const [localSize, localCompressed] = zip64Fields(localMetadata.zip64, [rawLocalSize, rawLocalCompressed]);
362
- for (const [actual, expected] of [[view.getUint32(local + 14, true), checksum], [localCompressed, compressedSize], [localSize, size]]) {
363
- if (actual !== expected && (!(flags & 8) || actual !== 0))
364
- fail("ZIP central/local size or CRC mismatch");
365
- }
366
- if (flags & 8) {
367
- const matches = [];
368
- for (const signed of [false, true]) {
369
- const descriptor = payloadEnd + (signed ? 4 : 0);
370
- const wide = rawLocalSize === 0xffffffff || rawLocalCompressed === 0xffffffff;
371
- const length = wide ? 20 : 12;
372
- if (descriptor + length > centralStart || signed && view.getUint32(payloadEnd, true) !== 0x08074b50 || view.getUint32(descriptor, true) !== checksum)
373
- continue;
374
- const compressed = wide ? view.getBigUint64(descriptor + 4, true) : BigInt(view.getUint32(descriptor + 4, true));
375
- const expanded = wide ? view.getBigUint64(descriptor + 12, true) : BigInt(view.getUint32(descriptor + 8, true));
376
- if (compressed === BigInt(compressedSize) && expanded === BigInt(size))
377
- matches.push(descriptor + length);
378
- }
379
- if (matches.length !== 1)
380
- fail("ZIP truncated, ambiguous or mismatched data descriptor");
381
- zipDiskRecord(profile.disks, payloadEnd, matches[0]);
382
- payloadEnd = matches[0];
383
- }
384
- const directory = name.endsWith("/");
385
- if (Boolean(externalAttributes & 16) && !directory)
386
- fail("ZIP conflicting directory attributes");
387
- const mode = attributeMode(versionMadeBy, externalAttributes, directory);
388
- const symlink = (mode & 0o170000) === 0o120000;
389
- const modified = dosModified(dosDate, dosTime);
390
- const timestamp = centralMetadata.modified ?? localMetadata.modified;
391
- if (timestamp !== undefined)
392
- modified.setTime(timestamp);
393
- const entry = { name, data: bytes.subarray(payloadStart, payloadStart + compressedSize), size, method, crc32: checksum, modified, mode, directory, symlink, rawName, localName, comment, localExtra, centralExtra, flags, versionMadeBy, internalAttributes, externalAttributes, dosTime, dosDate };
394
- if (aes)
395
- entry.aes = aes;
396
- entryBounds(entry, limits);
397
- if (profile.grow) {
398
- if (centralMetadata.zip64 || localMetadata.zip64)
399
- entry.zip64 = true;
400
- growSpans.set(entry, { start: local, end: payloadEnd });
401
- }
402
- entries.push(entry);
403
- spans.push({ start: local, end: payloadEnd });
404
- offset = next;
405
- }
406
- if (offset !== centralEnd)
407
- fail("ZIP central directory size or member count mismatch");
408
- if (diskMembers !== 65535 && diskMembers !== finalMembers)
409
- fail("ZIP inconsistent per-disk member count");
410
- if (zip64DiskMembers >= 0 && zip64DiskMembers !== wideDiskMembers)
411
- fail("ZIP64 inconsistent per-disk member count");
412
- spans.sort((first, second) => first.start - second.start);
413
- if (profile.disks && view.getUint32(0, true) !== 0x08074b50)
414
- fail("ZIP missing split signature");
415
- let covered = profile.disks ? 4 : profile.prefix ? spans[0]?.start ?? centralStart : 0;
416
- for (const span of spans) {
417
- if (span.start !== covered)
418
- fail("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
419
- covered = span.end;
420
- }
421
- if (covered !== centralStart)
422
- fail("ZIP unreferenced local data is unsupported");
423
- for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {
424
- const entry = entries[entryIndex];
425
- const span = growSpans.get(entry);
426
- if (span) {
427
- const record = new Uint8Array(span.end - span.start);
428
- await copyBytes(bytes.subarray(span.start, span.end), record, 0, chunkSize, signal);
429
- zipGrowRecords.set(entry, record);
430
- }
431
- const data = new Uint8Array(entry.data.length);
432
- await copyBytes(entry.data, data, 0, chunkSize, signal);
433
- entry.data = data;
434
- entry.rawName = new Uint8Array(entry.rawName);
435
- entry.localName = new Uint8Array(entry.localName);
436
- entry.comment = new Uint8Array(entry.comment);
437
- entry.localExtra = new Uint8Array(entry.localExtra);
438
- entry.centralExtra = new Uint8Array(entry.centralExtra);
439
- if (entryIndex > 0 && (entryIndex & 63) === 0)
440
- await yieldTurn(signal);
441
- else
442
- signal.throwIfAborted();
443
- }
444
- return { entries, comment: new Uint8Array(bytes.subarray(end + 22)), ...(profile.prefix ? { prefix: new Uint8Array(bytes.subarray(0, spans[0]?.start ?? centralStart)) } : {}) };
445
- }
446
- export async function* decodeZipEntry(entry, limits, signal, password) {
447
- if (!entry.aes) {
448
- yield* decodeZipContent(entry, limits, signal, password);
449
- return;
450
- }
451
- admit(limits, signal);
452
- entryBounds(entry, limits);
453
- if (password === undefined)
454
- fail("ZIP password required");
455
- // Budget ciphertext's authentication copy, compressed plaintext and verified
456
- // decompressed output together. The archive input is separately bounded.
457
- const available = limits.maxBufferedFileBytes - entry.data.length * 2;
458
- if (available < entry.size * 2)
459
- fail("ZIP AES authenticated staging limit exceeded");
460
- const plaintext = await decryptAesPayload(entry.data, password, entry.aes, available, signal);
461
- let verified;
462
- try {
463
- verified = await collectBytes(decodeZipContent(entry, limits, signal, password, plaintext), { ...(Number.isFinite(Math.floor((available - plaintext.length) / 2)) ? { maxBytes: Math.floor((available - plaintext.length) / 2) } : {}), signal });
464
- yield* wireChunks(verified, Math.min(limits.chunkSize, 65536), signal);
465
- }
466
- finally {
467
- plaintext.fill(0);
468
- verified?.fill(0);
469
- }
470
- }
471
- async function* decodeZipContent(entry, limits, signal, password, authenticated) {
472
- const chunkSize = admit(limits, signal);
473
- entryBounds(entry, limits);
474
- if (entry.flags & 1 && password === undefined)
475
- fail("ZIP password required");
476
- const input = (async function* () { yield authenticated ?? entry.data; })();
477
- const decrypted = authenticated === undefined && entry.flags & 1 ? decryptZipPayload(input, password, entry.flags & 8 ? (entry.dosTime ?? 0) >>> 8 : entry.crc32 >>> 24, signal) : input;
478
- const reader = new CodecReader(decrypted, signal);
479
- let length = 0;
480
- let checksum = 0;
481
- const method = entry.aes?.method ?? entry.method;
482
- const source = method === 14 ? zipLzma(reader, signal, { decode: true, level: 1, eos: Boolean(entry.flags & 2), size: entry.size }) : method === 12 ? boundedCodec(reader, { format: "bzip2", decompress: true, level: 9, singleMember: true }, signal) : method === 8 ? codec(reader, { mode: "inflate-raw", chunkSize }, signal) : (async function* () {
483
- for (;;) {
484
- const chunk = await reader.chunk();
485
- if (chunk === undefined)
486
- break;
487
- yield new Uint8Array(chunk);
488
- await yieldTurn(signal);
489
- }
490
- })();
491
- try {
492
- for await (const chunk of source) {
493
- signal.throwIfAborted();
494
- length += chunk.length;
495
- number(length, Math.min(limits.maxEntryBytes, limits.maxTotalBytes, method === 14 ? entry.size : Number.MAX_SAFE_INTEGER), "decoded byte");
496
- checksum = crc32(chunk, checksum);
497
- yield chunk;
498
- }
499
- if (method !== 0 && await reader.chunk() !== undefined)
500
- fail("ZIP trailing compressed data");
501
- if (length !== entry.size)
502
- fail("ZIP uncompressed size mismatch");
503
- if (entry.aes?.version !== 2 && checksum !== entry.crc32)
504
- fail("ZIP CRC32 mismatch");
505
- }
506
- finally {
507
- await reader.close();
508
- }
509
- }
510
- export async function makeZipEntry(name, bytes, attributes, limits, signal, level = 6, forceCompression = false, method = "deflate") {
511
- const chunkSize = admit(limits, signal);
512
- const entry = { name, data: bytes, size: bytes.length, method: 0, crc32: 0, ...attributes, modified: new Date(attributes.modified.getTime()) };
513
- entryBounds(entry, limits);
514
- let textual = false;
515
- let binary = false;
516
- for (let offset = 0; offset < bytes.length; offset += chunkSize) {
517
- if (level !== 0 && !entry.directory && !entry.symlink) {
518
- for (let index = offset; index < Math.min(bytes.length, offset + chunkSize); index++) {
519
- const byte = bytes[index];
520
- if (byte <= 6 || byte >= 14 && byte <= 25 || byte >= 28 && byte <= 31)
521
- binary = true;
522
- else if (byte === 9 || byte === 10 || byte === 13 || byte >= 32)
523
- textual = true;
524
- }
525
- }
526
- entry.crc32 = crc32(bytes.subarray(offset, offset + chunkSize), entry.crc32);
527
- if (offset + chunkSize < bytes.length)
528
- await yieldTurn(signal);
529
- else
530
- signal.throwIfAborted();
531
- }
532
- if (level !== 0 && !entry.directory && !entry.symlink)
533
- entry.internalAttributes = !binary && textual ? 1 : 0;
534
- const reader = new CodecReader((async function* () { yield bytes; })(), signal);
535
- try {
536
- if (level !== 0 && (bytes.length || forceCompression) && !entry.directory && !entry.symlink) {
537
- const chunks = [];
538
- let length = 0;
539
- const source = method === "lzma" ? zipLzma(reader, signal, { decode: false, level, eos: true, size: bytes.length }) : method === "bzip2" ? boundedCodec(reader, { format: "bzip2", decompress: false, level }, signal) : codec(reader, { mode: "deflate-raw", chunkSize, level }, signal);
540
- for await (const chunk of source) {
541
- length += chunk.length;
542
- if (length > limits.maxArchiveBytes)
543
- fail("ZIP compressed byte limit exceeded");
544
- if (!forceCompression && length >= bytes.length)
545
- break;
546
- chunks.push(new Uint8Array(chunk));
547
- }
548
- if (forceCompression || length < bytes.length) {
549
- entry.data = new Uint8Array(length);
550
- let offset = 0;
551
- for (const chunk of chunks) {
552
- entry.data.set(chunk, offset);
553
- offset += chunk.length;
554
- if (offset < length)
555
- await yieldTurn(signal);
556
- else
557
- signal.throwIfAborted();
558
- }
559
- entry.method = method === "lzma" ? 14 : method === "bzip2" ? 12 : 8;
560
- if (entry.method === 14)
561
- entry.flags = 0x802;
562
- return entry;
563
- }
564
- }
565
- entry.data = new Uint8Array(bytes.length);
566
- await copyBytes(bytes, entry.data, 0, chunkSize, signal);
567
- return entry;
568
- }
569
- finally {
570
- await reader.close();
571
- }
572
- }
573
- function timestampExtra(modified) {
574
- const seconds = Math.floor(modified.getTime() / 1000);
575
- if (seconds < -0x80000000 || seconds > 0x7fffffff)
576
- return new Uint8Array();
577
- const bytes = new Uint8Array(9);
578
- const view = new DataView(bytes.buffer);
579
- view.setUint16(0, 0x5455, true);
580
- view.setUint16(2, 5, true);
581
- bytes[4] = 1;
582
- view.setInt32(5, seconds, true);
583
- return bytes;
584
- }
585
- export function updateZipExtras(entry, previous, mode, limits) {
586
- const fresh = mode === "strip" ? new Uint8Array() : timestampExtra(entry.modified);
587
- const retained = [];
588
- for (const [original, central] of [[previous?.localExtra, false], [previous?.centralExtra, true]]) {
589
- const fields = [];
590
- let length = fresh.length;
591
- if (mode === "all" && original) {
592
- extras(original, previous.rawName ?? pathBytes(previous.name, limits), previous.comment ?? new Uint8Array(), central, limits);
593
- const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
594
- for (let offset = 0; offset < original.length;) {
595
- const identifier = view.getUint16(offset, true);
596
- const next = offset + 4 + view.getUint16(offset + 2, true);
597
- // Sizes, timestamps and Unicode names/comments are rebuilt for the new entry.
598
- if (identifier !== 1 && identifier !== 0x9901 && identifier !== 0x5455 && identifier !== 0x7075 && identifier !== 0x6375) {
599
- fields.push(original.subarray(offset, next));
600
- length += next - offset;
601
- }
602
- offset = next;
603
- }
604
- }
605
- number(length, Math.min(limits.maxPaxBytes, 65535), "extra field");
606
- const bytes = new Uint8Array(length);
607
- let offset = 0;
608
- for (const field of fields) {
609
- bytes.set(field, offset);
610
- offset += field.length;
611
- }
612
- bytes.set(fresh, offset);
613
- retained.push(bytes);
614
- }
615
- return { ...entry, localExtra: retained[0], centralExtra: retained[1] };
616
- }
617
- export function setZipEntryComment(entry, comment, limits) {
618
- number(comment.length, Math.min(limits.maxTextBytes, 65535), "entry comment");
619
- let flags = entry.flags ?? 0x800;
620
- if (flags & 0x800) {
621
- try {
622
- new TextDecoder("utf-8", { fatal: true }).decode(comment);
623
- }
624
- catch {
625
- flags &= ~0x800;
626
- }
627
- }
628
- const rawName = entry.rawName ?? pathBytes(entry.name, limits);
629
- const needUnicodePath = !(flags & 0x800) && legacyName(rawName) !== entry.name;
630
- const metadata = [];
631
- for (const [original, central] of [[entry.localExtra ?? timestampExtra(entry.modified), false], [entry.centralExtra ?? timestampExtra(entry.modified), true]]) {
632
- extras(original, rawName, entry.comment ?? new Uint8Array(), central, limits);
633
- const fields = [];
634
- const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
635
- for (let offset = 0; offset < original.length;) {
636
- const identifier = view.getUint16(offset, true);
637
- const next = offset + 4 + view.getUint16(offset + 2, true);
638
- // A changed comment invalidates the old Unicode-comment CRC. Rebuild the
639
- // Unicode path when it is required after clearing the UTF-8 flag.
640
- if (identifier !== 0x6375 && !(needUnicodePath && identifier === 0x7075))
641
- fields.push(original.subarray(offset, next));
642
- offset = next;
643
- }
644
- if (needUnicodePath) {
645
- const name = pathBytes(entry.name, limits);
646
- const field = new Uint8Array(9 + name.length);
647
- const header = new DataView(field.buffer);
648
- header.setUint16(0, 0x7075, true);
649
- header.setUint16(2, 5 + name.length, true);
650
- field[4] = 1;
651
- header.setUint32(5, crc32(rawName), true);
652
- field.set(name, 9);
653
- fields.push(field);
654
- }
655
- const rebuilt = concatBytes(fields);
656
- number(rebuilt.length, Math.min(limits.maxPaxBytes, 65535), "extra field");
657
- metadata.push(rebuilt);
658
- }
659
- return { ...entry, comment: new Uint8Array(comment), flags, localExtra: metadata[0], centralExtra: metadata[1] };
660
- }
661
- export async function* streamZipArchive(archive, limits, signal, descriptors = false, forceZip64 = false, allowZip64 = true) {
662
- const chunkSize = admit(limits, signal);
663
- if (archive.entries.some(entry => entry.encryption?.aes && !entry.directory)) {
664
- number(archive.entries.length, limits.maxMembers, "member");
665
- if (archive.entries.length > limits.maxPatternSteps)
666
- fail("ZIP archive work limit exceeded");
667
- const entries = [];
668
- let total = 0;
669
- let stagedBytes = 0;
670
- let retained = archive.entries.reduce((sum, entry) => sum + entry.data.length, 0);
671
- number(retained, limits.maxArchiveBytes, "compressed byte");
672
- for (const original of archive.entries) {
673
- await yieldTurn(signal);
674
- total += original.source ? 0 : original.size;
675
- number(total, limits.maxTotalBytes, "total byte");
676
- if (!original.encryption?.aes || original.directory) {
677
- entries.push(original);
678
- continue;
679
- }
680
- entryBounds(original, limits);
681
- const aes = { ...original.encryption.aes };
682
- aesParameters(aes);
683
- // Conservative allowance for overlapping owned input, codec result,
684
- // encryption input/output and wire assembly. Codec workspace is separate.
685
- const maximum = Math.floor((limits.maxBufferedFileBytes - 28) / 6);
686
- if (maximum < 0)
687
- fail("ZIP AES authenticated staging limit exceeded");
688
- let entry = original;
689
- if (original.source) {
690
- const plaintext = await collectBytes(original.source, { ...(Number.isFinite(Math.min(maximum, limits.maxEntryBytes, limits.maxTotalBytes - total)) ? { maxBytes: Math.min(maximum, limits.maxEntryBytes, limits.maxTotalBytes - total) } : {}), signal });
691
- total += plaintext.length;
692
- try {
693
- if (original.expectedSize !== undefined && plaintext.length !== original.expectedSize)
694
- fail("ZIP live input size mismatch");
695
- const made = await makeZipEntry(original.name, plaintext, { modified: original.modified, mode: original.mode, directory: original.directory, symlink: original.symlink }, limits, signal, original.method === 0 ? 0 : original.level ?? 6, original.method !== 0, original.method === 14 ? "lzma" : original.method === 12 ? "bzip2" : "deflate");
696
- entry = { ...original, ...made };
697
- delete entry.source;
698
- delete entry.expectedSize;
699
- }
700
- finally {
701
- plaintext.fill(0);
702
- }
703
- }
704
- if (entry.data.length > maximum || entry.size > maximum)
705
- fail("ZIP AES authenticated staging limit exceeded");
706
- const overhead = aesParameters(aes).saltBytes + 12;
707
- retained += entry.data.length + overhead - original.data.length;
708
- number(retained, limits.maxArchiveBytes, "encrypted byte");
709
- const data = await encryptAesPayload((async function* () { yield entry.data; })(), { ...original.encryption, aes }, maximum, signal);
710
- stagedBytes += data.length;
711
- if (original.source) {
712
- original.size = entry.size;
713
- original.compressedSize = data.length;
714
- original.crc32 = entry.crc32;
715
- if (entry.internalAttributes !== undefined)
716
- original.internalAttributes = entry.internalAttributes;
717
- }
718
- const extra = aesExtra(aes, entry.method);
719
- const append = (bytes) => {
720
- const joined = new Uint8Array(bytes.length + extra.length);
721
- joined.set(bytes);
722
- joined.set(extra, bytes.length);
723
- return joined;
724
- };
725
- const encrypted = { ...entry, data, aes: { ...aes, method: entry.method }, method: 99, crc32: aes.version === 2 ? 0 : entry.crc32,
726
- flags: (((entry.flags ?? 0x800) | 1) & ~6) | (descriptors || original.descriptors ? 8 : 0),
727
- localExtra: append(entry.localExtra ?? timestampExtra(entry.modified)), centralExtra: append(entry.centralExtra ?? timestampExtra(entry.modified)) };
728
- delete encrypted.encryption;
729
- entries.push(encrypted);
730
- }
731
- yield* streamZipArchive({ ...archive, entries, ...(archive.onRetention ? { onRetention: (counters) => archive.onRetention({ ...counters, payloadBytes: counters.payloadBytes + stagedBytes }) } : {}) }, limits, signal, descriptors, forceZip64, allowZip64);
732
- return;
733
- }
734
- if (archive.entries.some(entry => entry.encryption && !entry.source && !entry.directory)) {
735
- const entries = [];
736
- for (const original of archive.entries) {
737
- if (!original.encryption || original.source || original.directory) {
738
- entries.push(original);
739
- continue;
740
- }
741
- entryBounds(original, limits);
742
- number(original.data.length + 12, limits.maxArchiveBytes, "encrypted byte");
743
- const rounded = new Date(Math.ceil(Math.floor(original.modified.getTime() / 1000) / 2) * 2000);
744
- const time = original.dosTime ?? ((rounded.getHours() << 11) | (rounded.getMinutes() << 5) | (rounded.getSeconds() >>> 1));
745
- const descriptor = descriptors || original.descriptors === true;
746
- const data = await collectBytes(encryptZipPayload((async function* () { yield original.data; })(), original.encryption, descriptor ? time >>> 8 : original.crc32 >>> 24, signal), { ...(Number.isFinite(limits.maxArchiveBytes) ? { maxBytes: limits.maxArchiveBytes } : {}), signal });
747
- const entry = { ...original, data, dosTime: time, flags: (original.flags ?? 0x800) | 1 | (descriptor ? 8 : 0) };
748
- delete entry.encryption;
749
- entries.push(entry);
750
- }
751
- yield* streamZipArchive({ ...archive, entries }, limits, signal, descriptors, forceZip64, allowZip64);
752
- return;
753
- }
754
- number(archive.entries.length, limits.maxMembers, "member");
755
- number(archive.comment.length, Math.min(limits.maxTextBytes, 65535), "archive comment");
756
- const wideProfile = (entry) => {
757
- const required = Math.max(entry.size, entry.data.length, entry.expectedSize ?? 0) >= 0xffffffff;
758
- const unknown = entry.source !== undefined && entry.zip64 !== false && allowZip64 &&
759
- (entry.expectedSize === undefined && limits.maxEntryBytes >= 0xffffffff || entry.method !== 0 && limits.maxArchiveBytes >= 0xffffffff);
760
- return forceZip64 || entry.zip64 === true || required || unknown;
761
- };
762
- let wideArchive = archive.entries.length >= 65535 || forceZip64 || archive.entries.some(wideProfile);
763
- if (wideArchive && !allowZip64)
764
- fail("ZIP64 required but disabled");
765
- let length = 22 + archive.comment.length + (wideArchive ? 76 : 0);
766
- number(length, limits.maxArchiveBytes, "archive byte");
767
- let localLength = 0;
768
- let total = 0;
769
- let metadataBytes = 0;
770
- let work = 0;
771
- const encoded = [];
772
- await yieldTurn(signal);
773
- for (const entry of archive.entries) {
774
- if (++work > limits.maxPatternSteps)
775
- fail("ZIP archive work limit exceeded");
776
- if ((work & 63) === 0)
777
- await yieldTurn(signal);
778
- else
779
- signal.throwIfAborted();
780
- entryBounds(entry, limits);
781
- if (!entry.source && entry.method === 0 && entry.data.length !== entry.size + (entry.flags & 1 ? 12 : 0))
782
- fail("ZIP stored size mismatch");
783
- if (entry.source && (entry.data.length || entry.directory || entry.symlink))
784
- fail("ZIP invalid live source profile");
785
- if (entry.expectedSize !== undefined)
786
- number(entry.expectedSize, Math.min(limits.maxEntryBytes, limits.maxTotalBytes), "expected input byte");
787
- if (entry.source)
788
- number(entry.level ?? 6, 9, "compression level");
789
- total += entry.source ? 0 : entry.size;
790
- number(total, limits.maxTotalBytes, "total byte");
791
- const rawName = entry.rawName ?? pathBytes(entry.name, limits);
792
- // Retained ciphertext binds its verifier to the original descriptor flag.
793
- const descriptor = entry.flags & 1 || zipGrowRecords.has(entry) ? Boolean(entry.flags & 8) : (entry.source !== undefined || descriptors || entry.descriptors === true) && !entry.directory;
794
- const flags = ((entry.flags ?? (entry.method === 14 ? 0x802 : 0x800)) & ~8) | (descriptor ? 8 : 0) | (entry.encryption && !entry.directory ? 1 : 0) | (entry.source && entry.method === 14 ? 2 : 0);
795
- const comment = entry.comment ?? new Uint8Array();
796
- number(comment.length, Math.min(limits.maxTextBytes, 65535), "entry comment");
797
- if (flags & 0x800)
798
- text(comment);
799
- const originalLocalExtra = entry.localExtra ?? timestampExtra(entry.modified);
800
- const originalLocalMetadata = extras(originalLocalExtra, rawName, comment, false, limits);
801
- const wide = wideProfile(entry);
802
- if (wide && (!allowZip64 || !forceZip64 && entry.zip64 === false))
803
- fail("ZIP64 required but disabled");
804
- const member = zip64Member(entry.size, entry.data.length, localLength, forceZip64 || entry.zip64 === true, allowZip64 && (forceZip64 || entry.zip64 !== false), wide && descriptor);
805
- const originalCentralExtra = entry.centralExtra ?? timestampExtra(entry.modified);
806
- const originalCentralMetadata = extras(originalCentralExtra, rawName, comment, true, limits);
807
- const record = forceZip64 ? undefined : zipGrowRecords.get(entry);
808
- const localValues = descriptor && wide
809
- ? (entry.method === 12 || entry.method === 14) && !entry.source ? [entry.size, entry.data.length] : [0, 0]
810
- : [entry.size, entry.data.length].filter(value => forceZip64 || entry.zip64 === true || value >= 0xffffffff);
811
- const localExtraSize = record ? originalLocalExtra.length : originalLocalExtra.length - (originalLocalMetadata.zip64 ? originalLocalMetadata.zip64.length + 4 : 0) + (localValues.length ? 4 + localValues.length * 8 : 0);
812
- const centralExtraSize = originalCentralExtra.length - (originalCentralMetadata.zip64 ? originalCentralMetadata.zip64.length + 4 : 0) + (member.values.length ? 4 + member.values.length * 8 : 0);
813
- number(localExtraSize, Math.min(limits.maxPaxBytes, 65535), "extra field");
814
- number(centralExtraSize, Math.min(limits.maxPaxBytes, 65535), "extra field");
815
- const retainedSize = record
816
- ? record.length + 46 + rawName.length + centralExtraSize + comment.length
817
- : 76 + 2 * rawName.length + localExtraSize + centralExtraSize + comment.length + entry.data.length + (descriptor ? wide ? 24 : 16 : 0);
818
- number(length + retainedSize, limits.maxArchiveBytes, "archive byte");
819
- const localExtra = record ? originalLocalExtra : localValues.length ? zip64Extra(localValues, stripZip64(originalLocalExtra)) : stripZip64(originalLocalExtra);
820
- const centralExtra = member.values.length ? zip64Extra(member.values, stripZip64(originalCentralExtra)) : stripZip64(originalCentralExtra);
821
- const localMetadata = extras(localExtra, rawName, comment, false, limits);
822
- const centralMetadata = extras(centralExtra, rawName, comment, true, limits);
823
- if (entry.aes ? !localMetadata.aes || !centralMetadata.aes || [localMetadata.aes, centralMetadata.aes].some(aes => aes.version !== entry.aes.version || aes.strength !== entry.aes.strength || aes.method !== entry.aes.method) : localMetadata.aes || centralMetadata.aes)
824
- fail("ZIP retained AES metadata mismatch");
825
- if (nameFrom(rawName, flags, centralMetadata, limits) !== entry.name || localMetadata.name !== undefined && nameFrom(rawName, flags, localMetadata, limits) !== entry.name || entry.localName && !equal(rawName, entry.localName))
826
- fail("ZIP retained filename metadata mismatch");
827
- if (localMetadata.modified !== undefined && centralMetadata.modified !== undefined && localMetadata.modified !== centralMetadata.modified)
828
- fail("ZIP retained timestamp metadata mismatch");
829
- const rounded = new Date(Math.ceil(Math.floor(entry.modified.getTime() / 1000) / 2) * 2000);
830
- const year = Math.max(1980, Math.min(2107, rounded.getFullYear()));
831
- const date = entry.dosDate ?? (((year - 1980) << 9) | ((rounded.getMonth() + 1) << 5) | rounded.getDate());
832
- const time = entry.dosTime ?? ((rounded.getHours() << 11) | (rounded.getMinutes() << 5) | (rounded.getSeconds() >>> 1));
833
- number(date, 65535, "DOS date");
834
- number(time, 65535, "DOS time");
835
- const dosTimestamp = dosModified(date, time);
836
- const extendedTimestamp = centralMetadata.modified ?? localMetadata.modified;
837
- // DOS stores local calendar fields, so it cannot distinguish the two
838
- // occurrences of a repeated DST hour. UT still binds the absolute instant.
839
- const timestampMatches = extendedTimestamp === undefined
840
- ? ["getFullYear", "getMonth", "getDate", "getHours", "getMinutes", "getSeconds"]
841
- .every(field => dosTimestamp[field]() === rounded[field]())
842
- : Math.floor(extendedTimestamp / 1000) === Math.floor(entry.modified.getTime() / 1000);
843
- if (!timestampMatches)
844
- fail("ZIP retained or unrepresentable timestamp metadata mismatch");
845
- for (const [value, maximum, label] of [[entry.versionMadeBy ?? 0x31e, 65535, "creator version"], [entry.internalAttributes ?? 0, 65535, "internal attributes"], [entry.externalAttributes ?? 0, 0xffffffff, "external attributes"]])
846
- number(value, maximum, label);
847
- if ((entry.internalAttributes ?? 0) & ~1)
848
- fail("ZIP unsupported internal attributes");
849
- if (entry.externalAttributes !== undefined) {
850
- const mode = attributeMode(entry.versionMadeBy ?? 0x31e, entry.externalAttributes, entry.directory);
851
- if (mode !== entry.mode || Boolean(entry.externalAttributes & 16) && !entry.directory)
852
- fail("ZIP retained file attributes mismatch");
853
- }
854
- metadataBytes += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment.length;
855
- number(metadataBytes, limits.maxArchiveBytes, "metadata byte");
856
- const localSize = record?.length ?? 30 + rawName.length + localExtra.length + entry.data.length + (descriptor ? wide ? 24 : 16 : 0);
857
- length += localSize + 46 + rawName.length + centralExtra.length + comment.length;
858
- number(length, limits.maxArchiveBytes, "archive byte");
859
- const metadata = { ...entry, data: new Uint8Array() };
860
- delete metadata.source;
861
- delete metadata.encryption;
862
- const item = { entry: metadata, rawName, wide, flags, localExtra, centralExtra, comment, date, time, offset: localLength, compressedSize: entry.data.length };
863
- encoded.push(item);
864
- archive.onRetention?.({ metadataBytes, payloadBytes: 0 });
865
- localLength += localSize;
866
- }
867
- const plannedCentralSize = length - (22 + archive.comment.length + (wideArchive ? 76 : 0)) - localLength;
868
- if (!wideArchive && (localLength >= 0xffffffff || plannedCentralSize >= 0xffffffff)) {
869
- if (!allowZip64)
870
- fail("ZIP64 required but disabled");
871
- number(length + 76, limits.maxArchiveBytes, "archive byte");
872
- length += 76;
873
- wideArchive = true;
874
- }
875
- const refreshCentral = (item, size, compressed, offset) => {
876
- const member = zip64Member(size, compressed, offset, forceZip64 || item.entry.zip64 === true, allowZip64 && (forceZip64 || item.entry.zip64 !== false), item.wide && Boolean(item.flags & 8));
877
- const retained = stripZip64(item.centralExtra);
878
- const extraSize = retained.length + (member.values.length ? 4 + member.values.length * 8 : 0);
879
- number(extraSize, Math.min(limits.maxPaxBytes, 65535), "extra field");
880
- const delta = extraSize - item.centralExtra.length;
881
- const overhead = !wideArchive && member.wide ? 76 : 0;
882
- number(length + delta + overhead, limits.maxArchiveBytes, "archive byte");
883
- length += delta + overhead;
884
- metadataBytes += delta;
885
- wideArchive ||= member.wide;
886
- item.centralExtra = member.values.length ? zip64Extra(member.values, retained) : retained;
887
- };
888
- localLength = 0;
889
- for (const [index, item] of encoded.entries()) {
890
- const entry = archive.entries[index];
891
- const { rawName, wide, flags, localExtra, date, time } = item;
892
- const descriptor = Boolean(flags & 8);
893
- item.offset = localLength;
894
- refreshCentral(item, entry.size, entry.data.length, localLength);
895
- if (index > 0 && (index & 63) === 0)
896
- await yieldTurn(signal);
897
- else
898
- signal.throwIfAborted();
899
- const record = forceZip64 ? undefined : zipGrowRecords.get(entry);
900
- if (record) {
901
- yield* wireChunks(record, chunkSize, signal);
902
- localLength += record.length;
903
- continue;
904
- }
905
- const offset = 0;
906
- const bytes = new Uint8Array(30 + rawName.length + localExtra.length);
907
- const view = new DataView(bytes.buffer);
908
- const version = entry.method === 14 ? 63 : entry.method === 99 ? 51 : entry.method === 12 ? 46 : wide || item.offset >= 0xffffffff ? 45 : entry.method === 8 || flags & 9 ? 20 : 10;
909
- view.setUint32(offset, 0x04034b50, true);
910
- view.setUint16(offset + 4, version, true);
911
- view.setUint16(offset + 6, flags, true);
912
- view.setUint16(offset + 8, entry.method, true);
913
- view.setUint16(offset + 10, time, true);
914
- view.setUint16(offset + 12, date, true);
915
- // Buffered BZIP2/LZMA have known compressed spans. Retain them with a
916
- // descriptor so streaming native readers can locate the member boundary.
917
- const knownCompressedSpan = (entry.method === 12 || entry.method === 14) && !entry.source;
918
- view.setUint32(offset + 14, flags & 8 && !knownCompressedSpan ? 0 : entry.crc32, true);
919
- view.setUint32(offset + 18, wide && (descriptor || forceZip64 || entry.zip64 === true || entry.data.length >= 0xffffffff) ? 0xffffffff : flags & 8 && !knownCompressedSpan ? 0 : entry.data.length, true);
920
- view.setUint32(offset + 22, wide && (descriptor || forceZip64 || entry.zip64 === true || entry.size >= 0xffffffff) ? 0xffffffff : flags & 8 && !knownCompressedSpan ? 0 : entry.size, true);
921
- view.setUint16(offset + 26, rawName.length, true);
922
- view.setUint16(offset + 28, localExtra.length, true);
923
- bytes.set(rawName, offset + 30);
924
- bytes.set(localExtra, offset + 30 + rawName.length);
925
- yield* wireChunks(bytes, chunkSize, signal);
926
- if (entry.source) {
927
- let size = 0;
928
- let checksum = 0;
929
- let textual = false;
930
- let binary = false;
931
- let previousSlab = 0;
932
- const measured = (async function* () {
933
- for await (const chunk of readBytes(entry.source, signal)) {
934
- if (chunk.length === 0) {
935
- if (++work > limits.maxPatternSteps)
936
- fail("ZIP archive work limit exceeded");
937
- await yieldTurn(signal);
938
- continue;
939
- }
940
- number(size + chunk.length, Math.min(limits.maxEntryBytes, limits.maxTotalBytes - total, entry.expectedSize ?? Number.MAX_SAFE_INTEGER), "input byte");
941
- if (!wide)
942
- number(size + chunk.length, 0xfffffffe, "classic input byte");
943
- // STORE output has the same size as its input. Admit it before
944
- // copying any producer bytes into an owned slab.
945
- if (entry.method === 0) {
946
- const overhead = !wideArchive && localLength + bytes.length + item.compressedSize + chunk.length + (descriptor ? wide ? 24 : 16 : 0) >= 0xffffffff ? 76 : 0;
947
- number(length + chunk.length + overhead, limits.maxArchiveBytes, "archive byte");
948
- }
949
- for (let offset = 0; offset < chunk.length; offset += chunkSize) {
950
- if (++work > limits.maxPatternSteps)
951
- fail("ZIP archive work limit exceeded");
952
- const view = chunk.subarray(offset, Math.min(chunk.length, offset + chunkSize));
953
- size += view.length;
954
- checksum = crc32(view, checksum);
955
- if (entry.method !== 0)
956
- for (const byte of view) {
957
- if (byte <= 6 || byte >= 14 && byte <= 25 || byte >= 28 && byte <= 31)
958
- binary = true;
959
- else if (byte === 9 || byte === 10 || byte === 13 || byte >= 32)
960
- textual = true;
961
- }
962
- // A consumer can still reference the consumed slab while next()
963
- // admits its replacement. Account for both before allocating.
964
- archive.onRetention?.({ metadataBytes, payloadBytes: previousSlab + view.length });
965
- previousSlab = view.length;
966
- yield new Uint8Array(view);
967
- await yieldTurn(signal);
968
- }
969
- }
970
- if (entry.expectedSize !== undefined && size !== entry.expectedSize)
971
- fail("ZIP source changed while reading");
972
- })();
973
- const reader = new CodecReader(measured, signal);
974
- const payload = entry.method === 14 ? zipLzma(reader, signal, { decode: false, level: entry.level ?? 6, eos: true, size: entry.expectedSize ?? 0 }) : entry.method === 12 ? boundedCodec(reader, { format: "bzip2", decompress: false, level: entry.level ?? 6 }, signal)
975
- : entry.method === 8 ? codec(reader, { mode: "deflate-raw", level: entry.level ?? 6, chunkSize }, signal) : measured;
976
- item.compressedSize = 0;
977
- try {
978
- const wire = entry.encryption ? encryptZipPayload(payload, entry.encryption, time >>> 8, signal) : payload;
979
- for await (const chunk of wire) {
980
- if (++work > limits.maxPatternSteps)
981
- fail("ZIP archive work limit exceeded");
982
- if (!wideArchive && localLength + bytes.length + item.compressedSize + chunk.length + (descriptor ? wide ? 24 : 16 : 0) >= 0xffffffff) {
983
- if (!allowZip64)
984
- fail("ZIP64 required but disabled");
985
- number(length + chunk.length + 76, limits.maxArchiveBytes, "archive byte");
986
- length += 76;
987
- wideArchive = true;
988
- }
989
- number(length + chunk.length, limits.maxArchiveBytes, "archive byte");
990
- if (!wide)
991
- number(item.compressedSize + chunk.length, 0xfffffffe, "classic compressed byte");
992
- length += chunk.length;
993
- item.compressedSize += chunk.length;
994
- yield chunk;
995
- signal.throwIfAborted();
996
- }
997
- }
998
- finally {
999
- await reader.close();
1000
- }
1001
- total += size;
1002
- item.entry.size = size;
1003
- item.entry.crc32 = checksum;
1004
- if (entry.method !== 0)
1005
- item.entry.internalAttributes = !binary && textual ? 1 : 0;
1006
- refreshCentral(item, size, item.compressedSize, item.offset);
1007
- archive.onRetention?.({ metadataBytes, payloadBytes: 0 });
1008
- entry.size = size;
1009
- entry.crc32 = checksum;
1010
- entry.compressedSize = item.compressedSize;
1011
- if (item.entry.internalAttributes !== undefined)
1012
- entry.internalAttributes = item.entry.internalAttributes;
1013
- }
1014
- else
1015
- yield* wireChunks(entry.data, chunkSize, signal);
1016
- localLength += bytes.length + item.compressedSize + (descriptor ? wide ? 24 : 16 : 0);
1017
- if (flags & 8) {
1018
- const bytes = zipDescriptor(item.entry.crc32, item.compressedSize, item.entry.size, wide);
1019
- yield* wireChunks(bytes, chunkSize, signal);
1020
- }
1021
- }
1022
- let centralSize = 0;
1023
- for (const [index, item] of encoded.entries()) {
1024
- if (index > 0 && (index & 63) === 0)
1025
- await yieldTurn(signal);
1026
- else
1027
- signal.throwIfAborted();
1028
- const { entry, rawName, wide, flags, centralExtra, comment, date, time, offset } = item;
1029
- const member = zip64Member(entry.size, item.compressedSize, offset, forceZip64 || entry.zip64 === true, allowZip64 && (forceZip64 || entry.zip64 !== false), wide && Boolean(flags & 8));
1030
- const record = forceZip64 ? undefined : zipGrowRecords.get(archive.entries[index]);
1031
- const version = record ? new DataView(record.buffer, record.byteOffset, record.byteLength).getUint16(4, true)
1032
- : entry.method === 14 ? 63 : entry.method === 99 ? 51 : entry.method === 12 ? 46 : wide || member.wide ? 45 : entry.method === 8 || flags & 9 ? 20 : 10;
1033
- const central = 0;
1034
- const bytes = new Uint8Array(46 + rawName.length + centralExtra.length + comment.length);
1035
- const view = new DataView(bytes.buffer);
1036
- view.setUint32(central, 0x02014b50, true);
1037
- view.setUint16(central + 4, entry.versionMadeBy ?? 0x31e, true);
1038
- view.setUint16(central + 6, version, true);
1039
- view.setUint16(central + 8, flags, true);
1040
- view.setUint16(central + 10, entry.method, true);
1041
- view.setUint16(central + 12, time, true);
1042
- view.setUint16(central + 14, date, true);
1043
- view.setUint32(central + 16, entry.crc32, true);
1044
- view.setUint32(central + 20, member.compressed, true);
1045
- view.setUint32(central + 24, member.size, true);
1046
- view.setUint16(central + 28, rawName.length, true);
1047
- view.setUint16(central + 30, centralExtra.length, true);
1048
- view.setUint16(central + 32, comment.length, true);
1049
- view.setUint16(central + 36, entry.internalAttributes ?? 0, true);
1050
- const mode = entry.mode & 0o170000 ? entry.mode : entry.mode | (entry.directory ? 0o040000 : entry.symlink ? 0o120000 : 0o100000);
1051
- view.setUint32(central + 38, entry.externalAttributes ?? (mode * 65536 + (entry.directory ? 16 : 0)), true);
1052
- view.setUint32(central + 42, member.offset, true);
1053
- bytes.set(rawName, central + 46);
1054
- bytes.set(centralExtra, central + 46 + rawName.length);
1055
- bytes.set(comment, central + 46 + rawName.length + centralExtra.length);
1056
- centralSize += bytes.length;
1057
- yield* wireChunks(bytes, chunkSize, signal);
1058
- }
1059
- number(localLength + centralSize + 22 + archive.comment.length + (wideArchive || centralSize >= 0xffffffff || localLength >= 0xffffffff ? 76 : 0), limits.maxArchiveBytes, "archive byte");
1060
- const bytes = zipEnd(encoded.length, centralSize, localLength, archive.comment, wideArchive, allowZip64);
1061
- yield* wireChunks(bytes, chunkSize, signal);
1062
- }
1063
- async function* wireChunks(bytes, chunkSize, signal) {
1064
- for (let offset = 0; offset < bytes.length; offset += chunkSize) {
1065
- if (offset > 0)
1066
- await yieldTurn(signal);
1067
- else
1068
- signal.throwIfAborted();
1069
- yield new Uint8Array(bytes.subarray(offset, Math.min(bytes.length, offset + chunkSize)));
1070
- signal.throwIfAborted();
1071
- }
1072
- }
1073
- export async function writeZipArchive(archive, limits, signal, descriptors = false, forceZip64 = false, allowZip64 = true) {
1074
- return collectBytes(streamZipArchive(archive, limits, signal, descriptors, forceZip64, allowZip64), { ...(Number.isFinite(limits.maxArchiveBytes) ? { maxBytes: limits.maxArchiveBytes } : {}), signal });
1075
- }
1
+ export * from "../../../safe-bash-zip-engine/zip-format.js";
1076
2
  //# sourceMappingURL=zip-format.js.map