toolcraft 0.0.749 → 0.0.751

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,693 @@
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.ts';
12
+ import {
13
+ anumber,
14
+ checkOpts,
15
+ clean,
16
+ kdfInputToBytes,
17
+ nextTick,
18
+ swap32IfBE,
19
+ swap8IfBE,
20
+ u32,
21
+ u8,
22
+ type KDFInput,
23
+ type TArg,
24
+ type TRet,
25
+ } from './utils.ts';
26
+
27
+ // RFC 9106 §3.1 type `y`: 0 = Argon2d, 1 = Argon2i, 2 = Argon2id. The numeric values are the
28
+ // spec-bound part here; the object keys are internal labels.
29
+ const AT = { Argon2d: 0, Argon2i: 1, Argon2id: 2 } as const;
30
+ type Types = (typeof AT)[keyof typeof AT];
31
+
32
+ // RFC 9106 sync points constant `SL = 4`, fixed by the design rather than exposed as a tuning knob.
33
+ const ARGON2_SYNC_POINTS = 4;
34
+ // Preserve Argon2's `LE32(len(X)) || X` encoding for omitted
35
+ // optional fields by emitting empty bytes.
36
+ const abytesOrZero = (buf?: TArg<KDFInput>, errorTitle = ''): TRet<Uint8Array> => {
37
+ if (buf === undefined) return Uint8Array.of();
38
+ return kdfInputToBytes(buf, errorTitle);
39
+ };
40
+
41
+ // Temporary block buffer.
42
+ // 1024-byte block: 256 u32 = 128 interleaved low/high halves = RFC's
43
+ // 8x8 matrix of 16-byte registers.
44
+ const A2_BUF = new Uint32Array(256);
45
+
46
+ // Quarter-round over 64-bit word indices into `A2_BUF`; each index maps to adjacent low/high u32s.
47
+ // Each BlaMka step `X = X + Y + 2 * trunc(X) * trunc(Y)` (trunc = low 32 bits) starts
48
+ // with an exact low product from `Math.imul`. The rounded double product is within 1024 of the
49
+ // exact u64 product; subtracting that exact low half and rounding to the nearest multiple of
50
+ // 2^32 therefore recovers the exact high half. RFC 9106 Figure 19 GB then rotates by 32, 24,
51
+ // 16, and 63 bits after each XOR.
52
+ function G(a: number, b: number, c: number, d: number) {
53
+ let Al = A2_BUF[2*a], Ah = A2_BUF[2*a + 1]; // prettier-ignore
54
+ let Bl = A2_BUF[2*b], Bh = A2_BUF[2*b + 1]; // prettier-ignore
55
+ let Cl = A2_BUF[2*c], Ch = A2_BUF[2*c + 1]; // prettier-ignore
56
+ let Dl = A2_BUF[2*d], Dh = A2_BUF[2*d + 1]; // prettier-ignore
57
+ let ml = 0, mh = 0, rl = 0, xh = 0, xl = 0; // prettier-ignore
58
+
59
+ // A = blamka(A, B); D = rotr64(D ^ A, 32)
60
+ ml = Math.imul(Al, Bl);
61
+ mh = (((Al >>> 0) * (Bl >>> 0) - (ml >>> 0)) / 0x100000000 + 0.5) | 0; // prettier-ignore
62
+ rl = (Al >>> 0) + (Bl >>> 0) + ((ml << 1) >>> 0);
63
+ Ah = (Ah + Bh + ((mh << 1) | (ml >>> 31)) + ((rl / 0x100000000) | 0)) | 0;
64
+ Al = rl | 0; // prettier-ignore
65
+ xh = Dh ^ Ah;
66
+ xl = Dl ^ Al; // prettier-ignore
67
+ Dh = xl;
68
+ Dl = xh; // prettier-ignore
69
+
70
+ // C = blamka(C, D); B = rotr64(B ^ C, 24)
71
+ ml = Math.imul(Cl, Dl);
72
+ mh = (((Cl >>> 0) * (Dl >>> 0) - (ml >>> 0)) / 0x100000000 + 0.5) | 0; // prettier-ignore
73
+ rl = (Cl >>> 0) + (Dl >>> 0) + ((ml << 1) >>> 0);
74
+ Ch = (Ch + Dh + ((mh << 1) | (ml >>> 31)) + ((rl / 0x100000000) | 0)) | 0;
75
+ Cl = rl | 0; // prettier-ignore
76
+ xh = Bh ^ Ch;
77
+ xl = Bl ^ Cl; // prettier-ignore
78
+ Bh = (xh >>> 24) | (xl << 8);
79
+ Bl = (xh << 8) | (xl >>> 24); // prettier-ignore
80
+
81
+ // A = blamka(A, B); D = rotr64(D ^ A, 16)
82
+ ml = Math.imul(Al, Bl);
83
+ mh = (((Al >>> 0) * (Bl >>> 0) - (ml >>> 0)) / 0x100000000 + 0.5) | 0; // prettier-ignore
84
+ rl = (Al >>> 0) + (Bl >>> 0) + ((ml << 1) >>> 0);
85
+ Ah = (Ah + Bh + ((mh << 1) | (ml >>> 31)) + ((rl / 0x100000000) | 0)) | 0;
86
+ Al = rl | 0; // prettier-ignore
87
+ xh = Dh ^ Ah;
88
+ xl = Dl ^ Al; // prettier-ignore
89
+ Dh = (xh >>> 16) | (xl << 16);
90
+ Dl = (xh << 16) | (xl >>> 16); // prettier-ignore
91
+
92
+ // C = blamka(C, D); B = rotr64(B ^ C, 63)
93
+ ml = Math.imul(Cl, Dl);
94
+ mh = (((Cl >>> 0) * (Dl >>> 0) - (ml >>> 0)) / 0x100000000 + 0.5) | 0; // prettier-ignore
95
+ rl = (Cl >>> 0) + (Dl >>> 0) + ((ml << 1) >>> 0);
96
+ Ch = (Ch + Dh + ((mh << 1) | (ml >>> 31)) + ((rl / 0x100000000) | 0)) | 0;
97
+ Cl = rl | 0; // prettier-ignore
98
+ xh = Bh ^ Ch;
99
+ xl = Bl ^ Cl; // prettier-ignore
100
+ Bh = (xh << 1) | (xl >>> 31);
101
+ Bl = (xh >>> 31) | (xl << 1); // prettier-ignore
102
+
103
+ ((A2_BUF[2 * a] = Al), (A2_BUF[2 * a + 1] = Ah));
104
+ ((A2_BUF[2 * b] = Bl), (A2_BUF[2 * b + 1] = Bh));
105
+ ((A2_BUF[2 * c] = Cl), (A2_BUF[2 * c + 1] = Ch));
106
+ ((A2_BUF[2 * d] = Dl), (A2_BUF[2 * d + 1] = Dh));
107
+ }
108
+
109
+ // Argon2 permutation over 16 register indices into `A2_BUF`, not the register values themselves.
110
+ // RFC 9106 Figure 17: these arguments are the 16 `v0..v15` 64-bit word
111
+ // indices inside eight 16-byte inputs, not copied word values.
112
+ // prettier-ignore
113
+ function P(
114
+ v00: number, v01: number, v02: number, v03: number, v04: number, v05: number, v06: number, v07: number,
115
+ v08: number, v09: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number,
116
+ ) {
117
+ // RFC 9106 Figure 18: first apply GB across rows, then across columns of the 8x8 register matrix.
118
+ G(v00, v04, v08, v12);
119
+ G(v01, v05, v09, v13);
120
+ G(v02, v06, v10, v14);
121
+ G(v03, v07, v11, v15);
122
+ G(v00, v05, v10, v15);
123
+ G(v01, v06, v11, v12);
124
+ G(v02, v07, v08, v13);
125
+ G(v03, v04, v09, v14);
126
+ }
127
+
128
+ function block(x: TArg<Uint32Array>, xPos: number, yPos: number, outPos: number, needXor: boolean) {
129
+ // Stage R = X xor Y in the destination before permuting it. This avoids rereading both source
130
+ // blocks when folding R into the permuted scratch block below.
131
+ if (needXor) {
132
+ for (let i = 0; i < 256; i++) {
133
+ const r = x[xPos + i] ^ x[yPos + i];
134
+ A2_BUF[i] = r;
135
+ x[outPos + i] ^= r;
136
+ }
137
+ } else {
138
+ for (let i = 0; i < 256; i++) {
139
+ const r = x[xPos + i] ^ x[yPos + i];
140
+ A2_BUF[i] = r;
141
+ x[outPos + i] = r;
142
+ }
143
+ }
144
+ // rows (8 consecutive 16-register groups)
145
+ for (let i = 0; i < 128; i += 16) {
146
+ // prettier-ignore
147
+ P(
148
+ i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7,
149
+ i + 8, i + 9, i + 10, i + 11, i + 12, i + 13, i + 14, i + 15
150
+ );
151
+ }
152
+ // columns (8 strided 16-register groups)
153
+ for (let i = 0; i < 16; i += 2) {
154
+ // prettier-ignore
155
+ P(
156
+ i, i + 1, i + 16, i + 17, i + 32, i + 33, i + 48, i + 49,
157
+ i + 64, i + 65, i + 80, i + 81, i + 96, i + 97, i + 112, i + 113
158
+ );
159
+ }
160
+
161
+ // RFC 9106 step 6: passes after the first XOR the old destination block into the new G(X, Y).
162
+ for (let i = 0; i < 256; i++) x[outPos + i] ^= A2_BUF[i];
163
+ clean(A2_BUF);
164
+ }
165
+
166
+ // Variable-Length Hash Function H'
167
+ // Returns bytes, not words; 1024-byte block callers explicitly reinterpret with `u32(...)`.
168
+ function Hp(A: TArg<Uint32Array>, dkLen: number): TRet<Uint8Array> {
169
+ const A8 = u8(A);
170
+ const T = new Uint32Array(1);
171
+ const T8 = u8(T);
172
+ // Argon2 H' prefixes dkLen as LE32; native Uint32Array writes would serialize as BE on s390x.
173
+ T[0] = swap8IfBE(dkLen);
174
+ // Fast path
175
+ if (dkLen <= 64) return blake2b.create({ dkLen }).update(T8).update(A8).digest();
176
+ const out = new Uint8Array(dkLen);
177
+ let V = blake2b.create({}).update(T8).update(A8).digest();
178
+ let pos = 0;
179
+ // RFC 9106 Figure 8: each intermediate `V_i` contributes only `W_i`, its first 32 bytes; only
180
+ // `V_{r+1}` is emitted in full at the remaining length.
181
+ out.set(V.subarray(0, 32));
182
+ pos += 32;
183
+ // Rest blocks
184
+ for (; dkLen - pos > 64; pos += 32) {
185
+ const Vh = blake2b.create({}).update(V);
186
+ Vh.digestInto(V);
187
+ Vh.destroy();
188
+ out.set(V.subarray(0, 32), pos);
189
+ }
190
+ // Last block
191
+ out.set(blake2b(V, { dkLen: dkLen - pos }), pos);
192
+ clean(V, T);
193
+ // H' is byte-oriented; returning `u32(out)` would silently drop dkLen % 4 tail bytes.
194
+ return out as TRet<Uint8Array>;
195
+ }
196
+
197
+ // Used only inside argon2Blocks!
198
+ function indexAlpha(
199
+ r: number,
200
+ s: number,
201
+ laneLen: number,
202
+ segmentLen: number,
203
+ index: number,
204
+ randL: number,
205
+ sameLane: boolean = false
206
+ ) {
207
+ // RFC 9106 §3.4.2 Figures 12-13: map `J1` / `J2` into the current lane's reference area `W`.
208
+ let area: number;
209
+ if (r === 0) {
210
+ if (s === 0) area = index - 1;
211
+ else if (sameLane) area = s * segmentLen + index - 1;
212
+ else area = s * segmentLen + (index == 0 ? -1 : 0);
213
+ } else if (sameLane) area = laneLen - segmentLen + index - 1;
214
+ else area = laneLen - segmentLen + (index == 0 ? -1 : 0);
215
+ const startPos = r !== 0 && s !== ARGON2_SYNC_POINTS - 1 ? (s + 1) * segmentLen : 0;
216
+ // Use the same exact-high recovery as G. `areaHigh` is floor(|W| * J1^2/2^32 / 2^32).
217
+ const randLow = Math.imul(randL, randL);
218
+ const randHigh = (((randL >>> 0) * (randL >>> 0) - (randLow >>> 0)) / 0x100000000 + 0.5) | 0;
219
+ const areaLow = Math.imul(area, randHigh);
220
+ const areaHigh = (((area >>> 0) * (randHigh >>> 0) - (areaLow >>> 0)) / 0x100000000 + 0.5) | 0;
221
+ const rel = area - 1 - areaHigh;
222
+ return (startPos + rel) % laneLen;
223
+ }
224
+
225
+ /** Argon2 cost, output, and optional secret/personalization inputs. */
226
+ export type ArgonOpts = {
227
+ /** Time cost measured in iterations. Defaults to `3`. */
228
+ t?: number;
229
+ /** Memory cost in kibibytes. Defaults to `1024 ** 2` (1 GiB). */
230
+ m?: number;
231
+ /** Parallelization parameter. Defaults to `1`. */
232
+ p?: number;
233
+ /** Argon2 version number. Defaults to `0x13`. */
234
+ version?: number;
235
+ /** Optional secret key mixed into initialization. */
236
+ key?: KDFInput;
237
+ /** Optional personalization string or bytes. */
238
+ personalization?: KDFInput;
239
+ /** Desired output length in bytes. RFC 9106 §3.1 requires `T` in the 4..(2^32 - 1) range. */
240
+ dkLen?: number;
241
+ /** Max scheduler block time in milliseconds for the async variants. */
242
+ asyncTick?: number;
243
+ /** Maximum temporary memory budget in bytes. Defaults to 1 GiB. */
244
+ maxmem?: number;
245
+ /**
246
+ * Optional progress callback invoked during long-running derivations.
247
+ * @param progress - completion fraction in the `0..1` range
248
+ */
249
+ onProgress?: (progress: number) => void;
250
+ };
251
+
252
+ // Exclusive `2^32` sentinel used by `isU32(...)`, not the inclusive maximum u32 value.
253
+ const maxUint32 = Math.pow(2, 32);
254
+ const ARGON2_DEFAULT_MEMORY = 1024 ** 2; // KiB: 1 GiB
255
+ const ARGON2_DEFAULT_MAXMEM = ARGON2_DEFAULT_MEMORY * 1024;
256
+ // Validate safe JS integers in `[0, 2^32 - 1]`.
257
+ function isU32(num: number) {
258
+ return Number.isSafeInteger(num) && num >= 0 && num < maxUint32;
259
+ }
260
+
261
+ function argon2Opts(opts: TArg<ArgonOpts> = {}) {
262
+ opts = checkOpts({}, opts);
263
+ const merged: any = {
264
+ t: 3,
265
+ m: ARGON2_DEFAULT_MEMORY,
266
+ p: 1,
267
+ version: 0x13,
268
+ dkLen: 32,
269
+ maxmem: ARGON2_DEFAULT_MAXMEM,
270
+ asyncTick: 10,
271
+ };
272
+ // Unknown keys are copied through unchanged here and later ignored unless
273
+ // destructuring consumes them.
274
+ for (let [k, v] of Object.entries(opts)) if (v !== undefined) merged[k] = v;
275
+
276
+ const { dkLen, p, m, t, version, onProgress, asyncTick } = merged;
277
+ // RFC 9106 §3.1: tag length `T` MUST be an integer number of bytes from 4 to 2^32-1.
278
+ if (!isU32(dkLen) || dkLen < 4) throw new Error('"dkLen" must be 4..');
279
+ if (!isU32(p) || p < 1 || p >= Math.pow(2, 24)) throw new Error('"p" must be 1..2^24');
280
+ if (!isU32(m)) throw new Error('"m" must be 0..2^32');
281
+ if (!isU32(t) || t < 1) throw new Error('"t" (iterations) must be 1..2^32');
282
+ if (onProgress !== undefined && typeof onProgress !== 'function')
283
+ throw new Error('"onProgress" must be a function');
284
+ anumber(asyncTick, 'asyncTick');
285
+ /*
286
+ Memory size m MUST be an integer number of kibibytes from 8*p
287
+ to 2^(32)-1. The actual number of blocks is m', which is m
288
+ rounded down to the nearest multiple of 4*p.
289
+ */
290
+ if (!isU32(m) || m < 8 * p) throw new Error('"m" (memory) must be at least 8*p bytes');
291
+ // Accept legacy `0x10` for compatibility even though RFC 9106 profiles standardize `0x13`.
292
+ if (version !== 0x10 && version !== 0x13)
293
+ throw new Error('"version" must be 0x10 or 0x13, got ' + version);
294
+ return merged;
295
+ }
296
+
297
+ function argon2InitialHash(
298
+ password: TArg<KDFInput>,
299
+ salt: TArg<KDFInput>,
300
+ type: Types,
301
+ opts: TArg<ArgonOpts>
302
+ ) {
303
+ const ownedInputs: Uint8Array[] = [];
304
+ const BUF = new Uint32Array(1);
305
+ const BUF8 = u8(BUF);
306
+ let h: ReturnType<typeof blake2b.create> | undefined;
307
+ let H0: Uint32Array | undefined;
308
+ let succeeded = false;
309
+ const rememberOwned = (input: unknown, bytes: TArg<TRet<Uint8Array>>): TRet<Uint8Array> => {
310
+ if (typeof input === 'string') ownedInputs.push(bytes);
311
+ return bytes as TRet<Uint8Array>;
312
+ };
313
+ try {
314
+ const passwordBytes = rememberOwned(password, kdfInputToBytes(password, 'password'));
315
+ const saltBytes = rememberOwned(salt, kdfInputToBytes(salt, 'salt'));
316
+ if (!isU32(passwordBytes.length)) throw new Error('"password" must be less of length 1..4Gb');
317
+ // RFC 9106 §3.1 only requires S <= 2^32-1 bytes and says 16 bytes is RECOMMENDED for password
318
+ // hashing; this library intentionally takes the stricter common >=8-byte salt path.
319
+ if (!isU32(saltBytes.length) || saltBytes.length < 8)
320
+ throw new Error('"salt" must be of length 8..4Gb');
321
+ if (!Object.values(AT).includes(type)) throw new Error('"type" was invalid');
322
+ let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } =
323
+ argon2Opts(opts);
324
+ // Validation
325
+ const keyInput = key;
326
+ key = rememberOwned(keyInput, abytesOrZero(keyInput, 'key'));
327
+ const personalizationInput = personalization;
328
+ personalization = rememberOwned(
329
+ personalizationInput,
330
+ abytesOrZero(personalizationInput, 'personalization')
331
+ );
332
+ // H_0 = H^(64)(LE32(p) || LE32(T) || LE32(m) || LE32(t) ||
333
+ // LE32(v) || LE32(y) || LE32(length(P)) || P ||
334
+ // LE32(length(S)) || S || LE32(length(K)) || K ||
335
+ // LE32(length(X)) || X)
336
+ h = blake2b.create();
337
+ for (let item of [p, dkLen, m, t, version, type]) {
338
+ // RFC 9106 H0 encodes these scalars as LE32, so normalize the host word before
339
+ // exposing bytes.
340
+ BUF[0] = swap8IfBE(item);
341
+ h.update(BUF8);
342
+ }
343
+ for (let i of [passwordBytes, saltBytes, key, personalization]) {
344
+ BUF[0] = swap8IfBE(i.length); // BUF is u32 array, this is valid once normalized to LE bytes
345
+ h.update(BUF8).update(i);
346
+ }
347
+ // Reserve two extra LE32 words after the 64-byte `H_0` so Figures 3-4 can append
348
+ // `LE32(0 or 1) || LE32(i)` in place for the lane-starting blocks.
349
+ H0 = new Uint32Array(18);
350
+ h.digestInto(u8(H0));
351
+ succeeded = true;
352
+ return { H0, p, dkLen, m, t, version, maxmem, onProgress, asyncTick };
353
+ } finally {
354
+ // digestInto() does not destroy BLAKE2 state. It and all string-derived inputs contain secrets.
355
+ if (h) h.destroy();
356
+ clean(BUF, ...ownedInputs);
357
+ if (!succeeded && H0) clean(H0);
358
+ }
359
+ }
360
+
361
+ function argon2Init(
362
+ password: TArg<KDFInput>,
363
+ salt: TArg<KDFInput>,
364
+ type: Types,
365
+ opts: TArg<ArgonOpts>
366
+ ) {
367
+ const { H0, p, dkLen, m, t, version, maxmem, onProgress, asyncTick } = argon2InitialHash(
368
+ password,
369
+ salt,
370
+ type,
371
+ opts
372
+ );
373
+ // 256 u32 = 1024 (BLOCK_SIZE), fills A2_BUF on processing
374
+ try {
375
+ // Params
376
+ const lanes = p;
377
+ // m' = 4 * p * floor (m / 4p)
378
+ const mP = 4 * p * Math.floor(m / (ARGON2_SYNC_POINTS * p));
379
+ //q = m' / p columns
380
+ const laneLen = Math.floor(mP / p);
381
+ const segmentLen = Math.floor(laneLen / ARGON2_SYNC_POINTS);
382
+ // `maxmem` is documented in bytes; compare against the actual 1024-byte block allocation.
383
+ const memUsed = mP * 1024;
384
+ if (!isU32(maxmem)) throw new Error('"maxmem" expected <2**32, got ' + maxmem);
385
+ if (memUsed > maxmem)
386
+ throw new Error('"maxmem" limit was hit: memUsed(mP*1024)=' + memUsed + ', maxmem=' + maxmem);
387
+ const B = new Uint32Array(memUsed / 4);
388
+ // Fill first blocks
389
+ for (let l = 0; l < p; l++) {
390
+ const i = 256 * laneLen * l;
391
+ // B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i))
392
+ H0[17] = swap8IfBE(l);
393
+ H0[16] = swap8IfBE(0);
394
+ B.set(swap32IfBE(u32(Hp(H0, 1024))), i);
395
+ // B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i))
396
+ H0[16] = swap8IfBE(1);
397
+ B.set(swap32IfBE(u32(Hp(H0, 1024))), i + 256);
398
+ }
399
+ let perBlock = () => {};
400
+ if (onProgress) {
401
+ // The first segment of the first pass skips two preinitialized blocks per lane.
402
+ const totalBlock = t * ARGON2_SYNC_POINTS * p * segmentLen - 2 * p;
403
+ // Invoke callback if progress changes from 10.01 to 10.02
404
+ // Allows to draw smooth progress bar on up to 8K screen
405
+ const callbackPer = Math.max(Math.floor(totalBlock / 10000), 1);
406
+ let blockCnt = 0;
407
+ perBlock = () => {
408
+ blockCnt++;
409
+ if (onProgress && (!(blockCnt % callbackPer) || blockCnt === totalBlock))
410
+ onProgress(blockCnt / totalBlock);
411
+ };
412
+ }
413
+ return { type, mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick };
414
+ } finally {
415
+ clean(H0);
416
+ }
417
+ }
418
+
419
+ function argon2Output(
420
+ B: TArg<Uint32Array>,
421
+ p: number,
422
+ laneLen: number,
423
+ dkLen: number
424
+ ): TRet<Uint8Array> {
425
+ const B_final = new Uint32Array(256);
426
+ for (let l = 0; l < p; l++)
427
+ for (let j = 0; j < 256; j++) B_final[j] ^= B[256 * (laneLen * l + laneLen - 1) + j];
428
+ // RFC 9106 steps 7-8 feed the byte string `C` into `H'^T(C)`, so normalize the xor'ed words
429
+ // back to spec byte order before `Hp(...)` reinterprets them as bytes.
430
+ const res = Hp(swap32IfBE(B_final), dkLen);
431
+ // Wipe both the xor scratch and the full working matrix once final digest bytes exist.
432
+ // JS cleanup is still only best-effort, but this local buffer is no longer needed here.
433
+ clean(B, B_final);
434
+ return res;
435
+ }
436
+
437
+ /**
438
+ * Fills every Argon2 block for all passes / slices / lanes, yielding once per
439
+ * processed block so callers control pacing: the sync driver just drains the
440
+ * generator, while the async driver awaits `nextTick()` between time slices.
441
+ */
442
+ function* argon2Blocks(
443
+ ctx: ReturnType<typeof argon2Init>,
444
+ address: TArg<Uint32Array>
445
+ ): Generator<void, void> {
446
+ const { type, mP, p, t, version, B, laneLen, lanes, segmentLen, perBlock } = ctx;
447
+ // [address, input, zero_block] format so we can pass single U32 to block function
448
+ address[256 + 6] = mP;
449
+ address[256 + 8] = t;
450
+ address[256 + 10] = type;
451
+ for (let r = 0; r < t; r++) {
452
+ // RFC 9106 step 6 applies the XOR-on-later-passes rule only for version `0x13`; legacy
453
+ // `0x10` keeps the older overwrite behavior used by the v16 test vectors.
454
+ const needXor = r !== 0 && version === 0x13;
455
+ address[256 + 0] = r;
456
+ for (let s = 0; s < ARGON2_SYNC_POINTS; s++) {
457
+ address[256 + 4] = s;
458
+ // RFC 9106 §3.4.1.3: Argon2id uses Argon2i's data-independent `J1` / `J2` generation only
459
+ // in pass 0, slices 0 and 1; Argon2i uses it in every segment.
460
+ const dataIndependent = type == AT.Argon2i || (type == AT.Argon2id && r === 0 && s < 2);
461
+ for (let l = 0; l < p; l++) {
462
+ address[256 + 2] = l;
463
+ address[256 + 12] = 0;
464
+ let startPos = 0;
465
+ if (r === 0 && s === 0) {
466
+ startPos = 2;
467
+ if (dataIndependent) {
468
+ address[256 + 12]++;
469
+ block(address, 256, 2 * 256, 0, false);
470
+ block(address, 0, 2 * 256, 0, false);
471
+ }
472
+ }
473
+ // current block position
474
+ let offset = l * laneLen + s * segmentLen + startPos;
475
+ for (let index = startPos; index < segmentLen; index++, offset++) {
476
+ perBlock();
477
+ // Previous block position: wraps to the lane's last block only at lane start,
478
+ // which can happen here only for the first block of slice 0 on passes > 0.
479
+ const prev = offset % laneLen ? offset - 1 : offset + laneLen - 1;
480
+ let randL, randH;
481
+ if (dataIndependent) {
482
+ let i128 = index % 128;
483
+ // RFC 9106 §3.4.1.2: each 1024-byte address block yields 128 `(J1, J2)` pairs, so
484
+ // regenerate it whenever the segment index crosses a multiple of 128.
485
+ if (i128 === 0) {
486
+ address[256 + 12]++;
487
+ block(address, 256, 2 * 256, 0, false);
488
+ block(address, 0, 2 * 256, 0, false);
489
+ }
490
+ randL = address[2 * i128];
491
+ randH = address[2 * i128 + 1];
492
+ } else {
493
+ const T = 256 * prev;
494
+ randL = B[T];
495
+ randH = B[T + 1];
496
+ }
497
+ // Address-block path selects `J1` / `J2`, then maps them to the reference
498
+ // lane/block per RFC 9106 §3.4.
499
+ const refLane = r === 0 && s === 0 ? l : randH % lanes;
500
+ const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l);
501
+ const refBlock = laneLen * refLane + refPos;
502
+ // B[i][j] = G(B[i][j-1], B[l][z])
503
+ block(B, 256 * prev, 256 * refBlock, offset * 256, needXor);
504
+ yield;
505
+ }
506
+ }
507
+ }
508
+ }
509
+ clean(address);
510
+ }
511
+
512
+ function argon2(
513
+ type: Types,
514
+ password: TArg<KDFInput>,
515
+ salt: TArg<KDFInput>,
516
+ opts: TArg<ArgonOpts>
517
+ ): TRet<Uint8Array> {
518
+ const ctx = argon2Init(password, salt, type, opts);
519
+ const blocks = argon2Blocks(ctx, new Uint32Array(3 * 256));
520
+ while (!blocks.next().done) {}
521
+ return argon2Output(ctx.B, ctx.p, ctx.laneLen, ctx.dkLen);
522
+ }
523
+
524
+ /**
525
+ * Argon2d GPU-resistant version.
526
+ * @param password - password or input key material
527
+ * @param salt - unique salt value
528
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
529
+ * @returns Derived key bytes.
530
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
531
+ * @example
532
+ * Derive a key with Argon2d.
533
+ * ```ts
534
+ * argon2d('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
535
+ * ```
536
+ * @example
537
+ * Derive a key with optional secret and scheduler controls.
538
+ * ```ts
539
+ * const progressLog: number[] = [];
540
+ * argon2d('password', 'salt1234', {
541
+ * t: 1,
542
+ * m: 8,
543
+ * p: 1,
544
+ * dkLen: 32,
545
+ * version: 0x13,
546
+ * key: 'secret',
547
+ * personalization: 'application',
548
+ * maxmem: 1024 * 1024,
549
+ * asyncTick: 1,
550
+ * onProgress(progress) {
551
+ * progressLog.push(progress);
552
+ * },
553
+ * });
554
+ * ```
555
+ */
556
+ export const argon2d = (
557
+ password: TArg<KDFInput>,
558
+ salt: TArg<KDFInput>,
559
+ opts: TArg<ArgonOpts> = {}
560
+ ): TRet<Uint8Array> => argon2(AT.Argon2d, password, salt, opts);
561
+ /**
562
+ * Argon2i side-channel-resistant version.
563
+ * @param password - password or input key material
564
+ * @param salt - unique salt value
565
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
566
+ * @returns Derived key bytes.
567
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
568
+ * @example
569
+ * Derive a key with Argon2i.
570
+ * ```ts
571
+ * argon2i('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
572
+ * ```
573
+ */
574
+ export const argon2i = (
575
+ password: TArg<KDFInput>,
576
+ salt: TArg<KDFInput>,
577
+ opts: TArg<ArgonOpts> = {}
578
+ ): TRet<Uint8Array> => argon2(AT.Argon2i, password, salt, opts);
579
+ /**
580
+ * Argon2id, combining i+d, the most popular version from RFC 9106.
581
+ * @param password - password or input key material
582
+ * @param salt - unique salt value
583
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
584
+ * @returns Derived key bytes.
585
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
586
+ * @example
587
+ * Derive a key with Argon2id.
588
+ * ```ts
589
+ * argon2id('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
590
+ * ```
591
+ */
592
+ export const argon2id = (
593
+ password: TArg<KDFInput>,
594
+ salt: TArg<KDFInput>,
595
+ opts: TArg<ArgonOpts> = {}
596
+ ): TRet<Uint8Array> => argon2(AT.Argon2id, password, salt, opts);
597
+
598
+ async function argon2Async(
599
+ type: Types,
600
+ password: TArg<KDFInput>,
601
+ salt: TArg<KDFInput>,
602
+ opts: TArg<ArgonOpts>
603
+ ): Promise<TRet<Uint8Array>> {
604
+ const ctx = argon2Init(password, salt, type, opts);
605
+ // Keep the generator-local address block reachable so an aborted scheduler yield can wipe it.
606
+ const address = new Uint32Array(3 * 256);
607
+ const blocks = argon2Blocks(ctx, address);
608
+ const abort = () => clean(address, ctx.B);
609
+ let ts = Date.now();
610
+ while (!blocks.next().done) {
611
+ // Date.now() is not monotonic. If the clock goes backwards,
612
+ // still yield control.
613
+ const diff = Date.now() - ts;
614
+ if (diff >= 0 && diff < ctx.asyncTick) continue;
615
+ await nextTick(abort);
616
+ // Scheduler delay is outside the synchronous work budget.
617
+ ts = Date.now();
618
+ }
619
+ return argon2Output(ctx.B, ctx.p, ctx.laneLen, ctx.dkLen);
620
+ }
621
+
622
+ /**
623
+ * Argon2d async GPU-resistant version.
624
+ * @param password - password or input key material
625
+ * @param salt - unique salt value
626
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
627
+ * @returns Promise resolving to derived key bytes.
628
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
629
+ * @example
630
+ * Derive a key with Argon2d asynchronously.
631
+ * ```ts
632
+ * await argon2dAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
633
+ * ```
634
+ * @example
635
+ * Derive a key asynchronously with optional secret and scheduler controls.
636
+ * ```ts
637
+ * await argon2dAsync('password', 'salt1234', {
638
+ * t: 1,
639
+ * m: 8,
640
+ * p: 1,
641
+ * dkLen: 32,
642
+ * version: 0x13,
643
+ * key: 'secret',
644
+ * personalization: 'application',
645
+ * maxmem: 1024 * 1024,
646
+ * asyncTick: 1,
647
+ * onProgress(progress) {
648
+ * if (progress > 1) throw new Error('invalid progress');
649
+ * },
650
+ * });
651
+ * ```
652
+ */
653
+ export const argon2dAsync = (
654
+ password: TArg<KDFInput>,
655
+ salt: TArg<KDFInput>,
656
+ opts: TArg<ArgonOpts> = {}
657
+ ): Promise<TRet<Uint8Array>> => argon2Async(AT.Argon2d, password, salt, opts);
658
+ /**
659
+ * Argon2i async side-channel-resistant version.
660
+ * @param password - password or input key material
661
+ * @param salt - unique salt value
662
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
663
+ * @returns Promise resolving to derived key bytes.
664
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
665
+ * @example
666
+ * Derive a key with Argon2i asynchronously.
667
+ * ```ts
668
+ * await argon2iAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
669
+ * ```
670
+ */
671
+ export const argon2iAsync = (
672
+ password: TArg<KDFInput>,
673
+ salt: TArg<KDFInput>,
674
+ opts: TArg<ArgonOpts> = {}
675
+ ): Promise<TRet<Uint8Array>> => argon2Async(AT.Argon2i, password, salt, opts);
676
+ /**
677
+ * Argon2id async, combining i+d, the most popular version from RFC 9106.
678
+ * @param password - password or input key material
679
+ * @param salt - unique salt value
680
+ * @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
681
+ * @returns Promise resolving to derived key bytes.
682
+ * @throws If the Argon2 input or cost parameters are invalid. {@link Error}
683
+ * @example
684
+ * Derive a key with Argon2id asynchronously.
685
+ * ```ts
686
+ * await argon2idAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
687
+ * ```
688
+ */
689
+ export const argon2idAsync = (
690
+ password: TArg<KDFInput>,
691
+ salt: TArg<KDFInput>,
692
+ opts: TArg<ArgonOpts> = {}
693
+ ): Promise<TRet<Uint8Array>> => argon2Async(AT.Argon2id, password, salt, opts);