toolcraft 0.0.749 → 0.0.750

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 (374) hide show
  1. package/composition.json +23 -3
  2. package/dist/composition.json +23 -3
  3. package/dist/human-in-loop/approvals-commands.d.ts +1 -1
  4. package/dist/index.d.ts +1 -262
  5. package/dist/index.js +1 -573
  6. package/dist/runtime-platform.d.ts +2 -0
  7. package/dist/runtime-platform.js +2 -0
  8. package/dist/runtime-platform.workerd.d.ts +3 -0
  9. package/dist/runtime-platform.workerd.js +10 -0
  10. package/dist/runtime.d.ts +262 -0
  11. package/dist/runtime.js +576 -0
  12. package/node_modules/@noble/hashes/LICENSE +21 -0
  13. package/node_modules/@noble/hashes/README.md +478 -0
  14. package/node_modules/@noble/hashes/_blake.d.ts +20 -0
  15. package/node_modules/@noble/hashes/_blake.js +59 -0
  16. package/node_modules/@noble/hashes/_md.d.ts +95 -0
  17. package/node_modules/@noble/hashes/_md.js +209 -0
  18. package/node_modules/@noble/hashes/_u64.d.ts +36 -0
  19. package/node_modules/@noble/hashes/_u64.js +77 -0
  20. package/node_modules/@noble/hashes/argon2.d.ts +148 -0
  21. package/node_modules/@noble/hashes/argon2.js +577 -0
  22. package/node_modules/@noble/hashes/blake1.d.ts +162 -0
  23. package/node_modules/@noble/hashes/blake1.js +630 -0
  24. package/node_modules/@noble/hashes/blake2.d.ts +203 -0
  25. package/node_modules/@noble/hashes/blake2.js +573 -0
  26. package/node_modules/@noble/hashes/blake3.d.ts +68 -0
  27. package/node_modules/@noble/hashes/blake3.js +310 -0
  28. package/node_modules/@noble/hashes/eskdf.d.ts +91 -0
  29. package/node_modules/@noble/hashes/eskdf.js +225 -0
  30. package/node_modules/@noble/hashes/hkdf.d.ts +70 -0
  31. package/node_modules/@noble/hashes/hkdf.js +152 -0
  32. package/node_modules/@noble/hashes/hmac.d.ts +50 -0
  33. package/node_modules/@noble/hashes/hmac.js +93 -0
  34. package/node_modules/@noble/hashes/index.d.ts +1 -0
  35. package/node_modules/@noble/hashes/index.js +34 -0
  36. package/node_modules/@noble/hashes/legacy.d.ts +107 -0
  37. package/node_modules/@noble/hashes/legacy.js +348 -0
  38. package/node_modules/@noble/hashes/package.json +91 -0
  39. package/node_modules/@noble/hashes/pbkdf2.d.ts +66 -0
  40. package/node_modules/@noble/hashes/pbkdf2.js +176 -0
  41. package/node_modules/@noble/hashes/scrypt.d.ts +98 -0
  42. package/node_modules/@noble/hashes/scrypt.js +304 -0
  43. package/node_modules/@noble/hashes/sha2.d.ts +176 -0
  44. package/node_modules/@noble/hashes/sha2.js +446 -0
  45. package/node_modules/@noble/hashes/sha3-addons.d.ts +533 -0
  46. package/node_modules/@noble/hashes/sha3-addons.js +973 -0
  47. package/node_modules/@noble/hashes/sha3.d.ts +208 -0
  48. package/node_modules/@noble/hashes/sha3.js +475 -0
  49. package/node_modules/@noble/hashes/src/_blake.ts +67 -0
  50. package/node_modules/@noble/hashes/src/_md.ts +227 -0
  51. package/node_modules/@noble/hashes/src/_u64.ts +111 -0
  52. package/node_modules/@noble/hashes/src/argon2.ts +693 -0
  53. package/node_modules/@noble/hashes/src/blake1.ts +677 -0
  54. package/node_modules/@noble/hashes/src/blake2.ts +648 -0
  55. package/node_modules/@noble/hashes/src/blake3.ts +344 -0
  56. package/node_modules/@noble/hashes/src/eskdf.ts +265 -0
  57. package/node_modules/@noble/hashes/src/hkdf.ts +161 -0
  58. package/node_modules/@noble/hashes/src/hmac.ts +130 -0
  59. package/node_modules/@noble/hashes/src/index.ts +33 -0
  60. package/node_modules/@noble/hashes/src/legacy.ts +361 -0
  61. package/node_modules/@noble/hashes/src/pbkdf2.ts +219 -0
  62. package/node_modules/@noble/hashes/src/scrypt.ts +375 -0
  63. package/node_modules/@noble/hashes/src/sha2.ts +486 -0
  64. package/node_modules/@noble/hashes/src/sha3-addons.ts +1157 -0
  65. package/node_modules/@noble/hashes/src/sha3.ts +525 -0
  66. package/node_modules/@noble/hashes/src/utils.ts +978 -0
  67. package/node_modules/@noble/hashes/src/webcrypto.ts +283 -0
  68. package/node_modules/@noble/hashes/utils.d.ts +560 -0
  69. package/node_modules/@noble/hashes/utils.js +687 -0
  70. package/node_modules/@noble/hashes/webcrypto.d.ts +121 -0
  71. package/node_modules/@noble/hashes/webcrypto.js +228 -0
  72. package/node_modules/@poe-code/agent-mcp-config/dist/apply.js +23 -9
  73. package/node_modules/@poe-code/config-mutations/README.md +2 -0
  74. package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +4 -5
  75. package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +3 -4
  76. package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +3 -3
  77. package/node_modules/@poe-code/config-mutations/dist/template/render.js +1 -1
  78. package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +2 -2
  79. package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +3 -6
  80. package/node_modules/@poe-code/config-mutations/dist/types.d.ts +4 -2
  81. package/node_modules/@poe-code/process-runner/README.md +2 -1
  82. package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.d.ts +1 -0
  83. package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.js +1 -0
  84. package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.d.ts +2 -0
  85. package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.js +1 -0
  86. package/node_modules/@poe-code/process-runner/dist/types.d.ts +1 -1
  87. package/node_modules/@poe-code/process-runner/dist/workspace-transfer.d.ts +6 -5
  88. package/node_modules/@poe-code/process-runner/dist/workspace-transfer.js +67 -29
  89. package/node_modules/@poe-code/process-runner/package.json +13 -0
  90. package/node_modules/@poe-code/safe-fs/LICENSE +21 -0
  91. package/node_modules/@poe-code/safe-fs/PROVENANCE.json +428 -0
  92. package/node_modules/@poe-code/safe-fs/README.md +411 -0
  93. package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.d.ts +3 -0
  94. package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.js +171 -0
  95. package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.d.ts +93 -0
  96. package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.js +453 -0
  97. package/node_modules/@poe-code/safe-fs/dist/bridge/index.d.ts +7 -0
  98. package/node_modules/@poe-code/safe-fs/dist/bridge/index.js +19 -0
  99. package/node_modules/@poe-code/safe-fs/dist/bridge/stats.d.ts +4 -0
  100. package/node_modules/@poe-code/safe-fs/dist/bridge/stats.js +37 -0
  101. package/node_modules/@poe-code/safe-fs/dist/bridge/types.d.ts +81 -0
  102. package/node_modules/@poe-code/safe-fs/dist/bridge/types.js +1 -0
  103. package/node_modules/@poe-code/safe-fs/dist/bridge/values.d.ts +6 -0
  104. package/node_modules/@poe-code/safe-fs/dist/bridge/values.js +65 -0
  105. package/node_modules/@poe-code/safe-fs/dist/config/memory.d.ts +3 -0
  106. package/node_modules/@poe-code/safe-fs/dist/config/memory.js +7 -0
  107. package/node_modules/@poe-code/safe-fs/dist/config/real.d.ts +5 -0
  108. package/node_modules/@poe-code/safe-fs/dist/config/real.js +16 -0
  109. package/node_modules/@poe-code/safe-fs/dist/config/registry.d.ts +2 -0
  110. package/node_modules/@poe-code/safe-fs/dist/config/registry.js +15 -0
  111. package/node_modules/@poe-code/safe-fs/dist/config.d.ts +15 -0
  112. package/node_modules/@poe-code/safe-fs/dist/config.js +46 -0
  113. package/node_modules/@poe-code/safe-fs/dist/config.node.d.ts +2 -0
  114. package/node_modules/@poe-code/safe-fs/dist/config.node.js +11 -0
  115. package/node_modules/@poe-code/safe-fs/dist/config.portable.d.ts +3 -0
  116. package/node_modules/@poe-code/safe-fs/dist/config.portable.js +9 -0
  117. package/node_modules/@poe-code/safe-fs/dist/contracts/abort.d.ts +5 -0
  118. package/node_modules/@poe-code/safe-fs/dist/contracts/abort.js +34 -0
  119. package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.d.ts +1 -0
  120. package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.js +9 -0
  121. package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.d.ts +38 -0
  122. package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.js +1 -0
  123. package/node_modules/@poe-code/safe-fs/dist/contracts/errors.d.ts +53 -0
  124. package/node_modules/@poe-code/safe-fs/dist/contracts/errors.js +99 -0
  125. package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.d.ts +379 -0
  126. package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.js +1 -0
  127. package/node_modules/@poe-code/safe-fs/dist/contracts/index.d.ts +6 -0
  128. package/node_modules/@poe-code/safe-fs/dist/contracts/index.js +6 -0
  129. package/node_modules/@poe-code/safe-fs/dist/contracts/io.d.ts +12 -0
  130. package/node_modules/@poe-code/safe-fs/dist/contracts/io.js +321 -0
  131. package/node_modules/@poe-code/safe-fs/dist/contracts/object.d.ts +134 -0
  132. package/node_modules/@poe-code/safe-fs/dist/contracts/object.js +97 -0
  133. package/node_modules/@poe-code/safe-fs/dist/contracts/path.d.ts +3 -0
  134. package/node_modules/@poe-code/safe-fs/dist/contracts/path.js +2 -0
  135. package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.d.ts +21 -0
  136. package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.js +78 -0
  137. package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.d.ts +15 -0
  138. package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.js +162 -0
  139. package/node_modules/@poe-code/safe-fs/dist/core.d.ts +19 -0
  140. package/node_modules/@poe-code/safe-fs/dist/core.js +17 -0
  141. package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.d.ts +10 -0
  142. package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.js +216 -0
  143. package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.d.ts +7 -0
  144. package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.js +19 -0
  145. package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.d.ts +21 -0
  146. package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.js +279 -0
  147. package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.d.ts +59 -0
  148. package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.js +875 -0
  149. package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.d.ts +7 -0
  150. package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.js +250 -0
  151. package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.d.ts +6 -0
  152. package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.js +136 -0
  153. package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.d.ts +3 -0
  154. package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.js +14 -0
  155. package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.d.ts +11 -0
  156. package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.js +13 -0
  157. package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.d.ts +186 -0
  158. package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.js +3771 -0
  159. package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.d.ts +26 -0
  160. package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.js +96 -0
  161. package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.d.ts +13 -0
  162. package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.js +26 -0
  163. package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.d.ts +15 -0
  164. package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.js +144 -0
  165. package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.d.ts +19 -0
  166. package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.js +118 -0
  167. package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.d.ts +6 -0
  168. package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.js +29 -0
  169. package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.d.ts +74 -0
  170. package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.js +1291 -0
  171. package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.d.ts +27 -0
  172. package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.js +287 -0
  173. package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.d.ts +45 -0
  174. package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.js +531 -0
  175. package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.d.ts +87 -0
  176. package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.js +1185 -0
  177. package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.d.ts +42 -0
  178. package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.js +558 -0
  179. package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.d.ts +4 -0
  180. package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.js +63 -0
  181. package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.d.ts +12 -0
  182. package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.js +520 -0
  183. package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.d.ts +37 -0
  184. package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.js +208 -0
  185. package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.d.ts +1 -0
  186. package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.js +8 -0
  187. package/node_modules/@poe-code/safe-fs/dist/fs/real/index.d.ts +105 -0
  188. package/node_modules/@poe-code/safe-fs/dist/fs/real/index.js +1259 -0
  189. package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.d.ts +7 -0
  190. package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.js +38 -0
  191. package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.d.ts +130 -0
  192. package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.js +1137 -0
  193. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.d.ts +1 -0
  194. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.js +9 -0
  195. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.d.ts +2 -0
  196. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.js +1 -0
  197. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.d.ts +15 -0
  198. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.js +74 -0
  199. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.d.ts +4 -0
  200. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.js +111 -0
  201. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.d.ts +17 -0
  202. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.js +89 -0
  203. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.d.ts +20 -0
  204. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.js +76 -0
  205. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.d.ts +3 -0
  206. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.js +478 -0
  207. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.d.ts +30 -0
  208. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.js +1 -0
  209. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.d.ts +14 -0
  210. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.js +192 -0
  211. package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.d.ts +8 -0
  212. package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.js +4 -0
  213. package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.d.ts +2 -0
  214. package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.js +11 -0
  215. package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.d.ts +8 -0
  216. package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.js +167 -0
  217. package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.d.ts +48 -0
  218. package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.js +249 -0
  219. package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.d.ts +13 -0
  220. package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.js +400 -0
  221. package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.d.ts +10 -0
  222. package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.js +73 -0
  223. package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.d.ts +103 -0
  224. package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.js +28 -0
  225. package/node_modules/@poe-code/safe-fs/dist/fs/scoped.d.ts +19 -0
  226. package/node_modules/@poe-code/safe-fs/dist/fs/scoped.js +663 -0
  227. package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.d.ts +8 -0
  228. package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.js +115 -0
  229. package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.d.ts +5 -0
  230. package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.js +63 -0
  231. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.d.ts +2 -0
  232. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.js +1 -0
  233. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.d.ts +18 -0
  234. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.js +109 -0
  235. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.d.ts +141 -0
  236. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.js +1377 -0
  237. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.d.ts +15 -0
  238. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.js +59 -0
  239. package/node_modules/@poe-code/safe-fs/dist/index.d.ts +25 -0
  240. package/node_modules/@poe-code/safe-fs/dist/index.js +21 -0
  241. package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/linux-x64-glibc.node +0 -0
  242. package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.d.ts +5 -0
  243. package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.mjs +120 -0
  244. package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/manifest.json +46 -0
  245. package/node_modules/@poe-code/safe-fs/dist/node/filesystem.d.ts +19 -0
  246. package/node_modules/@poe-code/safe-fs/dist/node/filesystem.js +30 -0
  247. package/node_modules/@poe-code/safe-fs/dist/node/host.d.ts +3 -0
  248. package/node_modules/@poe-code/safe-fs/dist/node/host.js +78 -0
  249. package/node_modules/@poe-code/safe-fs/dist/node/index.d.ts +3 -0
  250. package/node_modules/@poe-code/safe-fs/dist/node/index.js +2 -0
  251. package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.d.ts +1 -0
  252. package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.js +5 -0
  253. package/node_modules/@poe-code/safe-fs/dist/node/native-seek.d.ts +3 -0
  254. package/node_modules/@poe-code/safe-fs/dist/node/native-seek.js +54 -0
  255. package/node_modules/@poe-code/safe-fs/dist/node/stats.d.ts +1 -0
  256. package/node_modules/@poe-code/safe-fs/dist/node/stats.js +1 -0
  257. package/node_modules/@poe-code/safe-fs/dist/node/values.d.ts +1 -0
  258. package/node_modules/@poe-code/safe-fs/dist/node/values.js +1 -0
  259. package/node_modules/@poe-code/safe-fs/dist/node-host.d.ts +1 -0
  260. package/node_modules/@poe-code/safe-fs/dist/node-host.js +1 -0
  261. package/node_modules/@poe-code/safe-fs/dist/node-unavailable.d.ts +1 -0
  262. package/node_modules/@poe-code/safe-fs/dist/node-unavailable.js +1 -0
  263. package/node_modules/@poe-code/safe-fs/dist/package.json +29 -0
  264. package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.d.ts +1 -0
  265. package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.js +1 -0
  266. package/node_modules/@poe-code/safe-fs/dist/platform/browser.d.ts +26 -0
  267. package/node_modules/@poe-code/safe-fs/dist/platform/browser.js +58 -0
  268. package/node_modules/@poe-code/safe-fs/dist/platform/node-path.d.ts +1 -0
  269. package/node_modules/@poe-code/safe-fs/dist/platform/node-path.js +1 -0
  270. package/node_modules/@poe-code/safe-fs/dist/platform/node.d.ts +26 -0
  271. package/node_modules/@poe-code/safe-fs/dist/platform/node.js +64 -0
  272. package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.d.ts +9 -0
  273. package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.js +17 -0
  274. package/node_modules/@poe-code/safe-fs/dist/python/emscripten.d.ts +15 -0
  275. package/node_modules/@poe-code/safe-fs/dist/python/emscripten.js +357 -0
  276. package/node_modules/@poe-code/safe-fs/dist/python/filesystem.d.ts +51 -0
  277. package/node_modules/@poe-code/safe-fs/dist/python/filesystem.js +243 -0
  278. package/node_modules/@poe-code/safe-fs/dist/python/flags.d.ts +3 -0
  279. package/node_modules/@poe-code/safe-fs/dist/python/flags.js +14 -0
  280. package/node_modules/@poe-code/safe-fs/dist/python/index.d.ts +9 -0
  281. package/node_modules/@poe-code/safe-fs/dist/python/index.js +5 -0
  282. package/node_modules/@poe-code/safe-fs/dist/python/native.d.ts +18 -0
  283. package/node_modules/@poe-code/safe-fs/dist/python/native.js +446 -0
  284. package/node_modules/@poe-code/safe-fs/dist/python/request.d.ts +2 -0
  285. package/node_modules/@poe-code/safe-fs/dist/python/request.js +61 -0
  286. package/node_modules/@poe-code/safe-fs/dist/python/stat.d.ts +8 -0
  287. package/node_modules/@poe-code/safe-fs/dist/python/stat.js +34 -0
  288. package/node_modules/@poe-code/safe-fs/dist/runtime-core.d.ts +27 -0
  289. package/node_modules/@poe-code/safe-fs/dist/runtime-core.js +57 -0
  290. package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.d.ts +16 -0
  291. package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.js +496 -0
  292. package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.d.ts +23 -0
  293. package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.js +39 -0
  294. package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.d.ts +31 -0
  295. package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.js +143 -0
  296. package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.d.ts +19 -0
  297. package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.js +209 -0
  298. package/node_modules/@poe-code/safe-fs/dist/xml.d.ts +1 -0
  299. package/node_modules/@poe-code/safe-fs/dist/xml.js +1 -0
  300. package/node_modules/@poe-code/safe-fs/package.json +189 -0
  301. package/node_modules/@poe-code/task-list/README.md +2 -0
  302. package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.d.ts +1 -1
  303. package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.js +11 -4
  304. package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +2 -2
  305. package/node_modules/@poe-code/task-list/dist/backends/utils.js +5 -7
  306. package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +1 -1
  307. package/node_modules/@poe-code/task-list/dist/default-host.d.ts +2 -0
  308. package/node_modules/@poe-code/task-list/dist/default-host.js +2 -0
  309. package/node_modules/@poe-code/task-list/dist/default-host.workerd.d.ts +4 -0
  310. package/node_modules/@poe-code/task-list/dist/default-host.workerd.js +6 -0
  311. package/node_modules/@poe-code/task-list/dist/filesystem.d.ts +3 -0
  312. package/node_modules/@poe-code/task-list/dist/filesystem.js +32 -0
  313. package/node_modules/@poe-code/task-list/dist/move.js +3 -3
  314. package/node_modules/@poe-code/task-list/dist/open.js +2 -5
  315. package/node_modules/@poe-code/task-list/dist/paths.d.ts +12 -0
  316. package/node_modules/@poe-code/task-list/dist/paths.js +7 -0
  317. package/node_modules/@poe-code/task-list/dist/types.d.ts +6 -5
  318. package/node_modules/@poe-code/task-list/package.json +9 -0
  319. package/node_modules/@poe-code/terminal-text/LICENSE +21 -0
  320. package/node_modules/@poe-code/terminal-text/README.md +12 -0
  321. package/node_modules/@poe-code/terminal-text/dist/index.d.ts +2 -0
  322. package/node_modules/@poe-code/terminal-text/dist/index.js +20 -0
  323. package/node_modules/@poe-code/terminal-text/package.json +22 -0
  324. package/node_modules/@poe-code/xml-ast/LICENSE +21 -0
  325. package/node_modules/@poe-code/xml-ast/README.md +28 -0
  326. package/node_modules/@poe-code/xml-ast/dist/index.d.ts +47 -0
  327. package/node_modules/@poe-code/xml-ast/dist/index.js +635 -0
  328. package/node_modules/@poe-code/xml-ast/package.json +25 -0
  329. package/node_modules/auth-store/README.md +35 -0
  330. package/node_modules/auth-store/dist/index.browser.d.ts +4 -0
  331. package/node_modules/auth-store/dist/index.browser.js +2 -0
  332. package/node_modules/auth-store/dist/provider-store.d.ts +1 -1
  333. package/node_modules/auth-store/dist/safe-fs-secret-store.d.ts +21 -0
  334. package/node_modules/auth-store/dist/safe-fs-secret-store.js +119 -0
  335. package/node_modules/auth-store/dist/secret-store.d.ts +12 -0
  336. package/node_modules/auth-store/dist/secret-store.js +1 -0
  337. package/node_modules/auth-store/dist/transaction-lock.d.ts +2 -4
  338. package/node_modules/auth-store/dist/types.d.ts +2 -9
  339. package/node_modules/auth-store/package.json +16 -2
  340. package/node_modules/tiny-http-mcp-server/dist/composition.json +16 -1
  341. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/README.md +25 -0
  342. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-state.js +4 -4
  343. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +6 -40
  344. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.d.ts +10 -0
  345. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.js +20 -0
  346. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/pkce.js +4 -3
  347. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.d.ts +14 -0
  348. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.js +53 -0
  349. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.d.ts +16 -2
  350. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.js +29 -9
  351. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.d.ts +12 -0
  352. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.js +23 -0
  353. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-endpoint.js +6 -19
  354. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-fetch.js +1 -1
  355. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.d.ts +6 -2
  356. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.js +5 -1
  357. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.d.ts +5 -2
  358. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.js +4 -1
  359. package/node_modules/tiny-http-mcp-server/package.json +4 -4
  360. package/node_modules/tiny-mcp-client/README.md +2 -0
  361. package/node_modules/tiny-mcp-client/dist/index.browser.d.ts +25 -23
  362. package/node_modules/tiny-mcp-client/dist/index.browser.js +116 -1
  363. package/node_modules/tiny-mcp-client/dist/index.d.ts +25 -23
  364. package/node_modules/tiny-mcp-client/dist/index.js +1034 -561
  365. package/node_modules/tiny-mcp-client/package.json +15 -0
  366. package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
  367. package/node_modules/toolcraft-design/dist/components/table.js +6 -0
  368. package/node_modules/toolcraft-design/dist/escape-terminal-text.d.ts +1 -2
  369. package/node_modules/toolcraft-design/dist/escape-terminal-text.js +1 -20
  370. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +2 -1
  371. package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +2 -1
  372. package/node_modules/toolcraft-schema/dist/json-schema/utils.js +3 -0
  373. package/node_modules/toolcraft-schema/package.json +1 -1
  374. package/package.json +32 -7
@@ -0,0 +1,577 @@
1
+ /**
2
+ * Argon2 KDF from RFC 9106. Can be used to create a key from password and salt.
3
+ * We suggest to use Scrypt. JS Argon is 2-10x slower than native code because of 64-bitness:
4
+ * * argon uses uint64, but JS doesn't have fast uint64array
5
+ * * uint64 multiplication is 1/3 of time
6
+ * * `P` function would be very nice with u64, because most of value will be in registers,
7
+ * hovewer with u32 it will require 32 registers, which is too much.
8
+ * * JS arrays do slow bound checks, so reading from `A2_BUF` slows it down
9
+ * @module
10
+ */
11
+ import { blake2b } from "./blake2.js";
12
+ import { anumber, checkOpts, clean, kdfInputToBytes, nextTick, swap32IfBE, swap8IfBE, u32, u8, } from "./utils.js";
13
+ // RFC 9106 §3.1 type `y`: 0 = Argon2d, 1 = Argon2i, 2 = Argon2id. The numeric values are the
14
+ // spec-bound part here; the object keys are internal labels.
15
+ const AT = { Argon2d: 0, Argon2i: 1, Argon2id: 2 };
16
+ // RFC 9106 sync points constant `SL = 4`, fixed by the design rather than exposed as a tuning knob.
17
+ const ARGON2_SYNC_POINTS = 4;
18
+ // Preserve Argon2's `LE32(len(X)) || X` encoding for omitted
19
+ // optional fields by emitting empty bytes.
20
+ const abytesOrZero = (buf, errorTitle = '') => {
21
+ if (buf === undefined)
22
+ return Uint8Array.of();
23
+ return kdfInputToBytes(buf, errorTitle);
24
+ };
25
+ // Temporary block buffer.
26
+ // 1024-byte block: 256 u32 = 128 interleaved low/high halves = RFC's
27
+ // 8x8 matrix of 16-byte registers.
28
+ const A2_BUF = new Uint32Array(256);
29
+ // Quarter-round over 64-bit word indices into `A2_BUF`; each index maps to adjacent low/high u32s.
30
+ // Each BlaMka step `X = X + Y + 2 * trunc(X) * trunc(Y)` (trunc = low 32 bits) starts
31
+ // with an exact low product from `Math.imul`. The rounded double product is within 1024 of the
32
+ // exact u64 product; subtracting that exact low half and rounding to the nearest multiple of
33
+ // 2^32 therefore recovers the exact high half. RFC 9106 Figure 19 GB then rotates by 32, 24,
34
+ // 16, and 63 bits after each XOR.
35
+ function G(a, b, c, d) {
36
+ let Al = A2_BUF[2 * a], Ah = A2_BUF[2 * a + 1]; // prettier-ignore
37
+ let Bl = A2_BUF[2 * b], Bh = A2_BUF[2 * b + 1]; // prettier-ignore
38
+ let Cl = A2_BUF[2 * c], Ch = A2_BUF[2 * c + 1]; // prettier-ignore
39
+ let Dl = A2_BUF[2 * d], Dh = A2_BUF[2 * d + 1]; // prettier-ignore
40
+ let ml = 0, mh = 0, rl = 0, xh = 0, xl = 0; // prettier-ignore
41
+ // A = blamka(A, B); D = rotr64(D ^ A, 32)
42
+ ml = Math.imul(Al, Bl);
43
+ mh = (((Al >>> 0) * (Bl >>> 0) - (ml >>> 0)) / 0x100000000 + 0.5) | 0; // prettier-ignore
44
+ rl = (Al >>> 0) + (Bl >>> 0) + ((ml << 1) >>> 0);
45
+ Ah = (Ah + Bh + ((mh << 1) | (ml >>> 31)) + ((rl / 0x100000000) | 0)) | 0;
46
+ Al = rl | 0; // prettier-ignore
47
+ xh = Dh ^ Ah;
48
+ xl = Dl ^ Al; // prettier-ignore
49
+ Dh = xl;
50
+ Dl = xh; // prettier-ignore
51
+ // C = blamka(C, D); B = rotr64(B ^ C, 24)
52
+ ml = Math.imul(Cl, Dl);
53
+ mh = (((Cl >>> 0) * (Dl >>> 0) - (ml >>> 0)) / 0x100000000 + 0.5) | 0; // prettier-ignore
54
+ rl = (Cl >>> 0) + (Dl >>> 0) + ((ml << 1) >>> 0);
55
+ Ch = (Ch + Dh + ((mh << 1) | (ml >>> 31)) + ((rl / 0x100000000) | 0)) | 0;
56
+ Cl = rl | 0; // prettier-ignore
57
+ xh = Bh ^ Ch;
58
+ xl = Bl ^ Cl; // prettier-ignore
59
+ Bh = (xh >>> 24) | (xl << 8);
60
+ Bl = (xh << 8) | (xl >>> 24); // prettier-ignore
61
+ // A = blamka(A, B); D = rotr64(D ^ A, 16)
62
+ ml = Math.imul(Al, Bl);
63
+ mh = (((Al >>> 0) * (Bl >>> 0) - (ml >>> 0)) / 0x100000000 + 0.5) | 0; // prettier-ignore
64
+ rl = (Al >>> 0) + (Bl >>> 0) + ((ml << 1) >>> 0);
65
+ Ah = (Ah + Bh + ((mh << 1) | (ml >>> 31)) + ((rl / 0x100000000) | 0)) | 0;
66
+ Al = rl | 0; // prettier-ignore
67
+ xh = Dh ^ Ah;
68
+ xl = Dl ^ Al; // prettier-ignore
69
+ Dh = (xh >>> 16) | (xl << 16);
70
+ Dl = (xh << 16) | (xl >>> 16); // prettier-ignore
71
+ // C = blamka(C, D); B = rotr64(B ^ C, 63)
72
+ ml = Math.imul(Cl, Dl);
73
+ mh = (((Cl >>> 0) * (Dl >>> 0) - (ml >>> 0)) / 0x100000000 + 0.5) | 0; // prettier-ignore
74
+ rl = (Cl >>> 0) + (Dl >>> 0) + ((ml << 1) >>> 0);
75
+ Ch = (Ch + Dh + ((mh << 1) | (ml >>> 31)) + ((rl / 0x100000000) | 0)) | 0;
76
+ Cl = rl | 0; // prettier-ignore
77
+ xh = Bh ^ Ch;
78
+ xl = Bl ^ Cl; // prettier-ignore
79
+ Bh = (xh << 1) | (xl >>> 31);
80
+ Bl = (xh >>> 31) | (xl << 1); // prettier-ignore
81
+ ((A2_BUF[2 * a] = Al), (A2_BUF[2 * a + 1] = Ah));
82
+ ((A2_BUF[2 * b] = Bl), (A2_BUF[2 * b + 1] = Bh));
83
+ ((A2_BUF[2 * c] = Cl), (A2_BUF[2 * c + 1] = Ch));
84
+ ((A2_BUF[2 * d] = Dl), (A2_BUF[2 * d + 1] = Dh));
85
+ }
86
+ // Argon2 permutation over 16 register indices into `A2_BUF`, not the register values themselves.
87
+ // RFC 9106 Figure 17: these arguments are the 16 `v0..v15` 64-bit word
88
+ // indices inside eight 16-byte inputs, not copied word values.
89
+ // prettier-ignore
90
+ function P(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13, v14, v15) {
91
+ // RFC 9106 Figure 18: first apply GB across rows, then across columns of the 8x8 register matrix.
92
+ G(v00, v04, v08, v12);
93
+ G(v01, v05, v09, v13);
94
+ G(v02, v06, v10, v14);
95
+ G(v03, v07, v11, v15);
96
+ G(v00, v05, v10, v15);
97
+ G(v01, v06, v11, v12);
98
+ G(v02, v07, v08, v13);
99
+ G(v03, v04, v09, v14);
100
+ }
101
+ function block(x, xPos, yPos, outPos, needXor) {
102
+ // Stage R = X xor Y in the destination before permuting it. This avoids rereading both source
103
+ // blocks when folding R into the permuted scratch block below.
104
+ if (needXor) {
105
+ for (let i = 0; i < 256; i++) {
106
+ const r = x[xPos + i] ^ x[yPos + i];
107
+ A2_BUF[i] = r;
108
+ x[outPos + i] ^= r;
109
+ }
110
+ }
111
+ else {
112
+ for (let i = 0; i < 256; i++) {
113
+ const r = x[xPos + i] ^ x[yPos + i];
114
+ A2_BUF[i] = r;
115
+ x[outPos + i] = r;
116
+ }
117
+ }
118
+ // rows (8 consecutive 16-register groups)
119
+ for (let i = 0; i < 128; i += 16) {
120
+ // prettier-ignore
121
+ P(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8, i + 9, i + 10, i + 11, i + 12, i + 13, i + 14, i + 15);
122
+ }
123
+ // columns (8 strided 16-register groups)
124
+ for (let i = 0; i < 16; i += 2) {
125
+ // prettier-ignore
126
+ P(i, i + 1, i + 16, i + 17, i + 32, i + 33, i + 48, i + 49, i + 64, i + 65, i + 80, i + 81, i + 96, i + 97, i + 112, i + 113);
127
+ }
128
+ // RFC 9106 step 6: passes after the first XOR the old destination block into the new G(X, Y).
129
+ for (let i = 0; i < 256; i++)
130
+ x[outPos + i] ^= A2_BUF[i];
131
+ clean(A2_BUF);
132
+ }
133
+ // Variable-Length Hash Function H'
134
+ // Returns bytes, not words; 1024-byte block callers explicitly reinterpret with `u32(...)`.
135
+ function Hp(A, dkLen) {
136
+ const A8 = u8(A);
137
+ const T = new Uint32Array(1);
138
+ const T8 = u8(T);
139
+ // Argon2 H' prefixes dkLen as LE32; native Uint32Array writes would serialize as BE on s390x.
140
+ T[0] = swap8IfBE(dkLen);
141
+ // Fast path
142
+ if (dkLen <= 64)
143
+ return blake2b.create({ dkLen }).update(T8).update(A8).digest();
144
+ const out = new Uint8Array(dkLen);
145
+ let V = blake2b.create({}).update(T8).update(A8).digest();
146
+ let pos = 0;
147
+ // RFC 9106 Figure 8: each intermediate `V_i` contributes only `W_i`, its first 32 bytes; only
148
+ // `V_{r+1}` is emitted in full at the remaining length.
149
+ out.set(V.subarray(0, 32));
150
+ pos += 32;
151
+ // Rest blocks
152
+ for (; dkLen - pos > 64; pos += 32) {
153
+ const Vh = blake2b.create({}).update(V);
154
+ Vh.digestInto(V);
155
+ Vh.destroy();
156
+ out.set(V.subarray(0, 32), pos);
157
+ }
158
+ // Last block
159
+ out.set(blake2b(V, { dkLen: dkLen - pos }), pos);
160
+ clean(V, T);
161
+ // H' is byte-oriented; returning `u32(out)` would silently drop dkLen % 4 tail bytes.
162
+ return out;
163
+ }
164
+ // Used only inside argon2Blocks!
165
+ function indexAlpha(r, s, laneLen, segmentLen, index, randL, sameLane = false) {
166
+ // RFC 9106 §3.4.2 Figures 12-13: map `J1` / `J2` into the current lane's reference area `W`.
167
+ let area;
168
+ if (r === 0) {
169
+ if (s === 0)
170
+ area = index - 1;
171
+ else if (sameLane)
172
+ area = s * segmentLen + index - 1;
173
+ else
174
+ area = s * segmentLen + (index == 0 ? -1 : 0);
175
+ }
176
+ else if (sameLane)
177
+ area = laneLen - segmentLen + index - 1;
178
+ else
179
+ area = laneLen - segmentLen + (index == 0 ? -1 : 0);
180
+ const startPos = r !== 0 && s !== ARGON2_SYNC_POINTS - 1 ? (s + 1) * segmentLen : 0;
181
+ // Use the same exact-high recovery as G. `areaHigh` is floor(|W| * J1^2/2^32 / 2^32).
182
+ const randLow = Math.imul(randL, randL);
183
+ const randHigh = (((randL >>> 0) * (randL >>> 0) - (randLow >>> 0)) / 0x100000000 + 0.5) | 0;
184
+ const areaLow = Math.imul(area, randHigh);
185
+ const areaHigh = (((area >>> 0) * (randHigh >>> 0) - (areaLow >>> 0)) / 0x100000000 + 0.5) | 0;
186
+ const rel = area - 1 - areaHigh;
187
+ return (startPos + rel) % laneLen;
188
+ }
189
+ // Exclusive `2^32` sentinel used by `isU32(...)`, not the inclusive maximum u32 value.
190
+ const maxUint32 = Math.pow(2, 32);
191
+ const ARGON2_DEFAULT_MEMORY = 1024 ** 2; // KiB: 1 GiB
192
+ const ARGON2_DEFAULT_MAXMEM = ARGON2_DEFAULT_MEMORY * 1024;
193
+ // Validate safe JS integers in `[0, 2^32 - 1]`.
194
+ function isU32(num) {
195
+ return Number.isSafeInteger(num) && num >= 0 && num < maxUint32;
196
+ }
197
+ function argon2Opts(opts = {}) {
198
+ opts = checkOpts({}, opts);
199
+ const merged = {
200
+ t: 3,
201
+ m: ARGON2_DEFAULT_MEMORY,
202
+ p: 1,
203
+ version: 0x13,
204
+ dkLen: 32,
205
+ maxmem: ARGON2_DEFAULT_MAXMEM,
206
+ asyncTick: 10,
207
+ };
208
+ // Unknown keys are copied through unchanged here and later ignored unless
209
+ // destructuring consumes them.
210
+ for (let [k, v] of Object.entries(opts))
211
+ if (v !== undefined)
212
+ merged[k] = v;
213
+ const { dkLen, p, m, t, version, onProgress, asyncTick } = merged;
214
+ // RFC 9106 §3.1: tag length `T` MUST be an integer number of bytes from 4 to 2^32-1.
215
+ if (!isU32(dkLen) || dkLen < 4)
216
+ throw new Error('"dkLen" must be 4..');
217
+ if (!isU32(p) || p < 1 || p >= Math.pow(2, 24))
218
+ throw new Error('"p" must be 1..2^24');
219
+ if (!isU32(m))
220
+ throw new Error('"m" must be 0..2^32');
221
+ if (!isU32(t) || t < 1)
222
+ throw new Error('"t" (iterations) must be 1..2^32');
223
+ if (onProgress !== undefined && typeof onProgress !== 'function')
224
+ throw new Error('"onProgress" must be a function');
225
+ anumber(asyncTick, 'asyncTick');
226
+ /*
227
+ Memory size m MUST be an integer number of kibibytes from 8*p
228
+ to 2^(32)-1. The actual number of blocks is m', which is m
229
+ rounded down to the nearest multiple of 4*p.
230
+ */
231
+ if (!isU32(m) || m < 8 * p)
232
+ throw new Error('"m" (memory) must be at least 8*p bytes');
233
+ // Accept legacy `0x10` for compatibility even though RFC 9106 profiles standardize `0x13`.
234
+ if (version !== 0x10 && version !== 0x13)
235
+ throw new Error('"version" must be 0x10 or 0x13, got ' + version);
236
+ return merged;
237
+ }
238
+ function argon2InitialHash(password, salt, type, opts) {
239
+ const ownedInputs = [];
240
+ const BUF = new Uint32Array(1);
241
+ const BUF8 = u8(BUF);
242
+ let h;
243
+ let H0;
244
+ let succeeded = false;
245
+ const rememberOwned = (input, bytes) => {
246
+ if (typeof input === 'string')
247
+ ownedInputs.push(bytes);
248
+ return bytes;
249
+ };
250
+ try {
251
+ const passwordBytes = rememberOwned(password, kdfInputToBytes(password, 'password'));
252
+ const saltBytes = rememberOwned(salt, kdfInputToBytes(salt, 'salt'));
253
+ if (!isU32(passwordBytes.length))
254
+ throw new Error('"password" must be less of length 1..4Gb');
255
+ // RFC 9106 §3.1 only requires S <= 2^32-1 bytes and says 16 bytes is RECOMMENDED for password
256
+ // hashing; this library intentionally takes the stricter common >=8-byte salt path.
257
+ if (!isU32(saltBytes.length) || saltBytes.length < 8)
258
+ throw new Error('"salt" must be of length 8..4Gb');
259
+ if (!Object.values(AT).includes(type))
260
+ throw new Error('"type" was invalid');
261
+ let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } = argon2Opts(opts);
262
+ // Validation
263
+ const keyInput = key;
264
+ key = rememberOwned(keyInput, abytesOrZero(keyInput, 'key'));
265
+ const personalizationInput = personalization;
266
+ personalization = rememberOwned(personalizationInput, abytesOrZero(personalizationInput, 'personalization'));
267
+ // H_0 = H^(64)(LE32(p) || LE32(T) || LE32(m) || LE32(t) ||
268
+ // LE32(v) || LE32(y) || LE32(length(P)) || P ||
269
+ // LE32(length(S)) || S || LE32(length(K)) || K ||
270
+ // LE32(length(X)) || X)
271
+ h = blake2b.create();
272
+ for (let item of [p, dkLen, m, t, version, type]) {
273
+ // RFC 9106 H0 encodes these scalars as LE32, so normalize the host word before
274
+ // exposing bytes.
275
+ BUF[0] = swap8IfBE(item);
276
+ h.update(BUF8);
277
+ }
278
+ for (let i of [passwordBytes, saltBytes, key, personalization]) {
279
+ BUF[0] = swap8IfBE(i.length); // BUF is u32 array, this is valid once normalized to LE bytes
280
+ h.update(BUF8).update(i);
281
+ }
282
+ // Reserve two extra LE32 words after the 64-byte `H_0` so Figures 3-4 can append
283
+ // `LE32(0 or 1) || LE32(i)` in place for the lane-starting blocks.
284
+ H0 = new Uint32Array(18);
285
+ h.digestInto(u8(H0));
286
+ succeeded = true;
287
+ return { H0, p, dkLen, m, t, version, maxmem, onProgress, asyncTick };
288
+ }
289
+ finally {
290
+ // digestInto() does not destroy BLAKE2 state. It and all string-derived inputs contain secrets.
291
+ if (h)
292
+ h.destroy();
293
+ clean(BUF, ...ownedInputs);
294
+ if (!succeeded && H0)
295
+ clean(H0);
296
+ }
297
+ }
298
+ function argon2Init(password, salt, type, opts) {
299
+ const { H0, p, dkLen, m, t, version, maxmem, onProgress, asyncTick } = argon2InitialHash(password, salt, type, opts);
300
+ // 256 u32 = 1024 (BLOCK_SIZE), fills A2_BUF on processing
301
+ try {
302
+ // Params
303
+ const lanes = p;
304
+ // m' = 4 * p * floor (m / 4p)
305
+ const mP = 4 * p * Math.floor(m / (ARGON2_SYNC_POINTS * p));
306
+ //q = m' / p columns
307
+ const laneLen = Math.floor(mP / p);
308
+ const segmentLen = Math.floor(laneLen / ARGON2_SYNC_POINTS);
309
+ // `maxmem` is documented in bytes; compare against the actual 1024-byte block allocation.
310
+ const memUsed = mP * 1024;
311
+ if (!isU32(maxmem))
312
+ throw new Error('"maxmem" expected <2**32, got ' + maxmem);
313
+ if (memUsed > maxmem)
314
+ throw new Error('"maxmem" limit was hit: memUsed(mP*1024)=' + memUsed + ', maxmem=' + maxmem);
315
+ const B = new Uint32Array(memUsed / 4);
316
+ // Fill first blocks
317
+ for (let l = 0; l < p; l++) {
318
+ const i = 256 * laneLen * l;
319
+ // B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i))
320
+ H0[17] = swap8IfBE(l);
321
+ H0[16] = swap8IfBE(0);
322
+ B.set(swap32IfBE(u32(Hp(H0, 1024))), i);
323
+ // B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i))
324
+ H0[16] = swap8IfBE(1);
325
+ B.set(swap32IfBE(u32(Hp(H0, 1024))), i + 256);
326
+ }
327
+ let perBlock = () => { };
328
+ if (onProgress) {
329
+ // The first segment of the first pass skips two preinitialized blocks per lane.
330
+ const totalBlock = t * ARGON2_SYNC_POINTS * p * segmentLen - 2 * p;
331
+ // Invoke callback if progress changes from 10.01 to 10.02
332
+ // Allows to draw smooth progress bar on up to 8K screen
333
+ const callbackPer = Math.max(Math.floor(totalBlock / 10000), 1);
334
+ let blockCnt = 0;
335
+ perBlock = () => {
336
+ blockCnt++;
337
+ if (onProgress && (!(blockCnt % callbackPer) || blockCnt === totalBlock))
338
+ onProgress(blockCnt / totalBlock);
339
+ };
340
+ }
341
+ return { type, mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick };
342
+ }
343
+ finally {
344
+ clean(H0);
345
+ }
346
+ }
347
+ function argon2Output(B, p, laneLen, dkLen) {
348
+ const B_final = new Uint32Array(256);
349
+ for (let l = 0; l < p; l++)
350
+ for (let j = 0; j < 256; j++)
351
+ B_final[j] ^= B[256 * (laneLen * l + laneLen - 1) + j];
352
+ // RFC 9106 steps 7-8 feed the byte string `C` into `H'^T(C)`, so normalize the xor'ed words
353
+ // back to spec byte order before `Hp(...)` reinterprets them as bytes.
354
+ const res = Hp(swap32IfBE(B_final), dkLen);
355
+ // Wipe both the xor scratch and the full working matrix once final digest bytes exist.
356
+ // JS cleanup is still only best-effort, but this local buffer is no longer needed here.
357
+ clean(B, B_final);
358
+ return res;
359
+ }
360
+ /**
361
+ * Fills every Argon2 block for all passes / slices / lanes, yielding once per
362
+ * processed block so callers control pacing: the sync driver just drains the
363
+ * generator, while the async driver awaits `nextTick()` between time slices.
364
+ */
365
+ function* argon2Blocks(ctx, address) {
366
+ const { type, mP, p, t, version, B, laneLen, lanes, segmentLen, perBlock } = ctx;
367
+ // [address, input, zero_block] format so we can pass single U32 to block function
368
+ address[256 + 6] = mP;
369
+ address[256 + 8] = t;
370
+ address[256 + 10] = type;
371
+ for (let r = 0; r < t; r++) {
372
+ // RFC 9106 step 6 applies the XOR-on-later-passes rule only for version `0x13`; legacy
373
+ // `0x10` keeps the older overwrite behavior used by the v16 test vectors.
374
+ const needXor = r !== 0 && version === 0x13;
375
+ address[256 + 0] = r;
376
+ for (let s = 0; s < ARGON2_SYNC_POINTS; s++) {
377
+ address[256 + 4] = s;
378
+ // RFC 9106 §3.4.1.3: Argon2id uses Argon2i's data-independent `J1` / `J2` generation only
379
+ // in pass 0, slices 0 and 1; Argon2i uses it in every segment.
380
+ const dataIndependent = type == AT.Argon2i || (type == AT.Argon2id && r === 0 && s < 2);
381
+ for (let l = 0; l < p; l++) {
382
+ address[256 + 2] = l;
383
+ address[256 + 12] = 0;
384
+ let startPos = 0;
385
+ if (r === 0 && s === 0) {
386
+ startPos = 2;
387
+ if (dataIndependent) {
388
+ address[256 + 12]++;
389
+ block(address, 256, 2 * 256, 0, false);
390
+ block(address, 0, 2 * 256, 0, false);
391
+ }
392
+ }
393
+ // current block position
394
+ let offset = l * laneLen + s * segmentLen + startPos;
395
+ for (let index = startPos; index < segmentLen; index++, offset++) {
396
+ perBlock();
397
+ // Previous block position: wraps to the lane's last block only at lane start,
398
+ // which can happen here only for the first block of slice 0 on passes > 0.
399
+ const prev = offset % laneLen ? offset - 1 : offset + laneLen - 1;
400
+ let randL, randH;
401
+ if (dataIndependent) {
402
+ let i128 = index % 128;
403
+ // RFC 9106 §3.4.1.2: each 1024-byte address block yields 128 `(J1, J2)` pairs, so
404
+ // regenerate it whenever the segment index crosses a multiple of 128.
405
+ if (i128 === 0) {
406
+ address[256 + 12]++;
407
+ block(address, 256, 2 * 256, 0, false);
408
+ block(address, 0, 2 * 256, 0, false);
409
+ }
410
+ randL = address[2 * i128];
411
+ randH = address[2 * i128 + 1];
412
+ }
413
+ else {
414
+ const T = 256 * prev;
415
+ randL = B[T];
416
+ randH = B[T + 1];
417
+ }
418
+ // Address-block path selects `J1` / `J2`, then maps them to the reference
419
+ // lane/block per RFC 9106 §3.4.
420
+ const refLane = r === 0 && s === 0 ? l : randH % lanes;
421
+ const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l);
422
+ const refBlock = laneLen * refLane + refPos;
423
+ // B[i][j] = G(B[i][j-1], B[l][z])
424
+ block(B, 256 * prev, 256 * refBlock, offset * 256, needXor);
425
+ yield;
426
+ }
427
+ }
428
+ }
429
+ }
430
+ clean(address);
431
+ }
432
+ function argon2(type, password, salt, opts) {
433
+ const ctx = argon2Init(password, salt, type, opts);
434
+ const blocks = argon2Blocks(ctx, new Uint32Array(3 * 256));
435
+ while (!blocks.next().done) { }
436
+ return argon2Output(ctx.B, ctx.p, ctx.laneLen, ctx.dkLen);
437
+ }
438
+ /**
439
+ * Argon2d GPU-resistant version.
440
+ * @param password - password or input key material
441
+ * @param salt - unique salt value
442
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
443
+ * @returns Derived key bytes.
444
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
445
+ * @example
446
+ * Derive a key with Argon2d.
447
+ * ```ts
448
+ * argon2d('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
449
+ * ```
450
+ * @example
451
+ * Derive a key with optional secret and scheduler controls.
452
+ * ```ts
453
+ * const progressLog: number[] = [];
454
+ * argon2d('password', 'salt1234', {
455
+ * t: 1,
456
+ * m: 8,
457
+ * p: 1,
458
+ * dkLen: 32,
459
+ * version: 0x13,
460
+ * key: 'secret',
461
+ * personalization: 'application',
462
+ * maxmem: 1024 * 1024,
463
+ * asyncTick: 1,
464
+ * onProgress(progress) {
465
+ * progressLog.push(progress);
466
+ * },
467
+ * });
468
+ * ```
469
+ */
470
+ export const argon2d = (password, salt, opts = {}) => argon2(AT.Argon2d, password, salt, opts);
471
+ /**
472
+ * Argon2i side-channel-resistant version.
473
+ * @param password - password or input key material
474
+ * @param salt - unique salt value
475
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
476
+ * @returns Derived key bytes.
477
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
478
+ * @example
479
+ * Derive a key with Argon2i.
480
+ * ```ts
481
+ * argon2i('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
482
+ * ```
483
+ */
484
+ export const argon2i = (password, salt, opts = {}) => argon2(AT.Argon2i, password, salt, opts);
485
+ /**
486
+ * Argon2id, combining i+d, the most popular version from RFC 9106.
487
+ * @param password - password or input key material
488
+ * @param salt - unique salt value
489
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
490
+ * @returns Derived key bytes.
491
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
492
+ * @example
493
+ * Derive a key with Argon2id.
494
+ * ```ts
495
+ * argon2id('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
496
+ * ```
497
+ */
498
+ export const argon2id = (password, salt, opts = {}) => argon2(AT.Argon2id, password, salt, opts);
499
+ async function argon2Async(type, password, salt, opts) {
500
+ const ctx = argon2Init(password, salt, type, opts);
501
+ // Keep the generator-local address block reachable so an aborted scheduler yield can wipe it.
502
+ const address = new Uint32Array(3 * 256);
503
+ const blocks = argon2Blocks(ctx, address);
504
+ const abort = () => clean(address, ctx.B);
505
+ let ts = Date.now();
506
+ while (!blocks.next().done) {
507
+ // Date.now() is not monotonic. If the clock goes backwards,
508
+ // still yield control.
509
+ const diff = Date.now() - ts;
510
+ if (diff >= 0 && diff < ctx.asyncTick)
511
+ continue;
512
+ await nextTick(abort);
513
+ // Scheduler delay is outside the synchronous work budget.
514
+ ts = Date.now();
515
+ }
516
+ return argon2Output(ctx.B, ctx.p, ctx.laneLen, ctx.dkLen);
517
+ }
518
+ /**
519
+ * Argon2d async GPU-resistant version.
520
+ * @param password - password or input key material
521
+ * @param salt - unique salt value
522
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
523
+ * @returns Promise resolving to derived key bytes.
524
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
525
+ * @example
526
+ * Derive a key with Argon2d asynchronously.
527
+ * ```ts
528
+ * await argon2dAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
529
+ * ```
530
+ * @example
531
+ * Derive a key asynchronously with optional secret and scheduler controls.
532
+ * ```ts
533
+ * await argon2dAsync('password', 'salt1234', {
534
+ * t: 1,
535
+ * m: 8,
536
+ * p: 1,
537
+ * dkLen: 32,
538
+ * version: 0x13,
539
+ * key: 'secret',
540
+ * personalization: 'application',
541
+ * maxmem: 1024 * 1024,
542
+ * asyncTick: 1,
543
+ * onProgress(progress) {
544
+ * if (progress > 1) throw new Error('invalid progress');
545
+ * },
546
+ * });
547
+ * ```
548
+ */
549
+ export const argon2dAsync = (password, salt, opts = {}) => argon2Async(AT.Argon2d, password, salt, opts);
550
+ /**
551
+ * Argon2i async side-channel-resistant version.
552
+ * @param password - password or input key material
553
+ * @param salt - unique salt value
554
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
555
+ * @returns Promise resolving to derived key bytes.
556
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
557
+ * @example
558
+ * Derive a key with Argon2i asynchronously.
559
+ * ```ts
560
+ * await argon2iAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
561
+ * ```
562
+ */
563
+ export const argon2iAsync = (password, salt, opts = {}) => argon2Async(AT.Argon2i, password, salt, opts);
564
+ /**
565
+ * Argon2id async, combining i+d, the most popular version from RFC 9106.
566
+ * @param password - password or input key material
567
+ * @param salt - unique salt value
568
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
569
+ * @returns Promise resolving to derived key bytes.
570
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
571
+ * @example
572
+ * Derive a key with Argon2id asynchronously.
573
+ * ```ts
574
+ * await argon2idAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
575
+ * ```
576
+ */
577
+ export const argon2idAsync = (password, salt, opts = {}) => argon2Async(AT.Argon2id, password, salt, opts);