wao 0.41.3 → 0.41.5

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 (719) hide show
  1. package/.babelrc-cjs +5 -0
  2. package/.babelrc-esm +5 -0
  3. package/.gitmodules +4 -0
  4. package/.prettierrc +6 -0
  5. package/README.md +90 -0
  6. package/app/.eslintrc.json +3 -0
  7. package/app/.mocharc.cjs +6 -0
  8. package/app/arweave.mjs +87 -0
  9. package/app/components/Footer.js +76 -0
  10. package/app/components/Global.js +1128 -0
  11. package/app/components/Header.js +306 -0
  12. package/app/components/Left.js +28 -0
  13. package/app/components/Logo.js +34 -0
  14. package/app/components/Middle.js +37 -0
  15. package/app/components/Sidebar.js +93 -0
  16. package/app/components/Tags.js +42 -0
  17. package/app/components/editor/Editor.js +322 -0
  18. package/app/components/editor/FilePath.js +42 -0
  19. package/app/components/editor/MonacoEditor.js +44 -0
  20. package/app/components/left/LeftMessages.js +85 -0
  21. package/app/components/left/LeftModules.js +86 -0
  22. package/app/components/left/LeftNetworks.js +438 -0
  23. package/app/components/left/LeftProcesses.js +98 -0
  24. package/app/components/left/LeftProjects.js +397 -0
  25. package/app/components/left/LeftTests.js +189 -0
  26. package/app/components/middle/MiddleBlocks.js +79 -0
  27. package/app/components/middle/MiddleEntity.js +16 -0
  28. package/app/components/middle/MiddleEntityAccount.js +264 -0
  29. package/app/components/middle/MiddleEntityAssignment.js +104 -0
  30. package/app/components/middle/MiddleEntityBlock.js +148 -0
  31. package/app/components/middle/MiddleEntityMessage.js +430 -0
  32. package/app/components/middle/MiddleEntityModule.js +183 -0
  33. package/app/components/middle/MiddleEntityProcess.js +323 -0
  34. package/app/components/middle/MiddleEntityTx.js +211 -0
  35. package/app/components/middle/MiddleMessages.js +87 -0
  36. package/app/components/middle/MiddleModules.js +89 -0
  37. package/app/components/middle/MiddleNetworks.js +516 -0
  38. package/app/components/middle/MiddleProcesses.js +87 -0
  39. package/app/components/middle/MiddleTests.js +134 -0
  40. package/app/components/modals/CreateFileModal.js +115 -0
  41. package/app/components/modals/CreateFolderModal.js +83 -0
  42. package/app/components/modals/CreateProjectModal.js +63 -0
  43. package/app/components/modals/FSModal.js +141 -0
  44. package/app/components/modals/ImportModal.js +105 -0
  45. package/app/components/modals/LaunchNetworkModal.js +95 -0
  46. package/app/components/modals/Modal.js +38 -0
  47. package/app/components/modals/ProxyModal.js +122 -0
  48. package/app/components/modals/RenameFileModal.js +95 -0
  49. package/app/components/styles/EditorScrollbarStyle.js +29 -0
  50. package/app/components/styles/EntityScrollbarStyle.js +29 -0
  51. package/app/components/styles/GlobalStyle.js +102 -0
  52. package/app/components/styles/XtermStyle.js +37 -0
  53. package/app/components/terminal/Terminal.js +132 -0
  54. package/app/components/terminal/Xterm.js +160 -0
  55. package/app/components/ui/avatar.jsx +49 -0
  56. package/app/components/ui/checkbox.jsx +17 -0
  57. package/app/components/ui/close-button.jsx +20 -0
  58. package/app/components/ui/color-mode.jsx +61 -0
  59. package/app/components/ui/dialog.jsx +54 -0
  60. package/app/components/ui/drawer.jsx +44 -0
  61. package/app/components/ui/field.jsx +22 -0
  62. package/app/components/ui/input-group.jsx +39 -0
  63. package/app/components/ui/popover.jsx +49 -0
  64. package/app/components/ui/provider.jsx +12 -0
  65. package/app/components/ui/radio.jsx +17 -0
  66. package/app/components/ui/slider.jsx +107 -0
  67. package/app/components/ui/toaster.jsx +69 -0
  68. package/app/components/ui/tooltip.jsx +35 -0
  69. package/app/index.js +10 -0
  70. package/app/jsconfig.json +7 -0
  71. package/app/lib/GithubCSS.js +1218 -0
  72. package/app/lib/addon-fit.js +72 -0
  73. package/app/lib/data.js +31 -0
  74. package/app/lib/github-markdown.css +1169 -0
  75. package/app/lib/global.js +1 -0
  76. package/app/lib/guide.js +82 -0
  77. package/app/lib/hub.js +109 -0
  78. package/app/lib/scripts.js +47 -0
  79. package/app/lib/store.js +34 -0
  80. package/app/lib/use.js +64 -0
  81. package/app/lib/utils.js +387 -0
  82. package/app/lib/webrtc.js +217 -0
  83. package/app/next.config.js +25 -0
  84. package/app/package.json +62 -0
  85. package/app/pages/404.js +9 -0
  86. package/app/pages/_app.js +10 -0
  87. package/app/pages/_document.js +14 -0
  88. package/app/pages/index.js +121 -0
  89. package/app/playwright.config.mjs +41 -0
  90. package/app/proxy.mjs +21 -0
  91. package/app/public/assets/cover.png +0 -0
  92. package/app/public/blueprints/apm.lua +91 -0
  93. package/app/public/blueprints/arena.lua +345 -0
  94. package/app/public/blueprints/arns.lua +318 -0
  95. package/app/public/blueprints/chat.lua +210 -0
  96. package/app/public/blueprints/chatroom.lua +56 -0
  97. package/app/public/blueprints/patch-legacy-reply.lua +13 -0
  98. package/app/public/blueprints/staking.lua +93 -0
  99. package/app/public/blueprints/token.lua +298 -0
  100. package/app/public/blueprints/voting.lua +45 -0
  101. package/app/public/favicon.ico +0 -0
  102. package/app/public/logo.png +0 -0
  103. package/cli-esm.js +55 -0
  104. package/cli.js +54 -0
  105. package/devnet/app/api.js +129 -0
  106. package/devnet/app/components/layout.js +89 -0
  107. package/devnet/app/components/pagination.js +144 -0
  108. package/devnet/app/components/search.js +159 -0
  109. package/devnet/app/components/table.js +124 -0
  110. package/devnet/app/components/tags.js +89 -0
  111. package/devnet/app/index.html +14 -0
  112. package/devnet/app/main.js +215 -0
  113. package/devnet/app/router.js +59 -0
  114. package/devnet/app/state.js +19 -0
  115. package/devnet/app/style.css +1606 -0
  116. package/devnet/app/utils.js +77 -0
  117. package/devnet/app/views/blocks.js +75 -0
  118. package/devnet/app/views/dashboard.js +127 -0
  119. package/devnet/app/views/entity.js +1473 -0
  120. package/devnet/app/views/messages.js +90 -0
  121. package/devnet/app/views/modules.js +165 -0
  122. package/devnet/app/views/processes.js +90 -0
  123. package/devnet/app/views/schedulers.js +90 -0
  124. package/devnet/app/views/transactions.js +88 -0
  125. package/devnet/migrations/0001_initial.sql +51 -0
  126. package/devnet/package.json +26 -0
  127. package/devnet/playwright.config.js +7 -0
  128. package/devnet/src/cu-worker.js +166 -0
  129. package/devnet/src/index.js +309 -0
  130. package/devnet/vite.config.js +17 -0
  131. package/devnet/vitest.config.js +10 -0
  132. package/devnet/wrangler-cu.toml +32 -0
  133. package/devnet/wrangler.toml +38 -0
  134. package/dhfs-tutorial-app/package.json +15 -0
  135. package/dist/esm/workspace/dashboard/public/favicon.png +0 -0
  136. package/dist/esm/workspace/src/counter.lua +14 -0
  137. package/dist/package.json +82 -0
  138. package/hb.sh +18 -0
  139. package/hbsig/.babelrc-cjs +5 -0
  140. package/hbsig/.babelrc-esm +5 -0
  141. package/hbsig/README.md +1 -0
  142. package/hbsig/dist/cjs/bin_to_str.js +44 -0
  143. package/hbsig/dist/cjs/collect-body-keys.js +470 -0
  144. package/hbsig/dist/cjs/commit.js +330 -0
  145. package/hbsig/dist/cjs/encode-array-item.js +110 -0
  146. package/hbsig/dist/cjs/encode-utils.js +242 -0
  147. package/hbsig/dist/cjs/encode.js +1365 -0
  148. package/hbsig/dist/cjs/erl_json.js +326 -0
  149. package/hbsig/dist/cjs/erl_str.js +1042 -0
  150. package/hbsig/dist/cjs/flat.js +279 -0
  151. package/hbsig/dist/cjs/http-message-signatures/httpbis.js +489 -0
  152. package/hbsig/dist/cjs/http-message-signatures/index.js +25 -0
  153. package/hbsig/dist/cjs/http-message-signatures/structured-header.js +129 -0
  154. package/hbsig/dist/cjs/httpsig.js +861 -0
  155. package/hbsig/dist/cjs/id.js +470 -0
  156. package/hbsig/dist/cjs/index.js +174 -0
  157. package/hbsig/dist/cjs/nocrypto.js +51 -0
  158. package/hbsig/dist/cjs/parser.js +201 -0
  159. package/hbsig/dist/cjs/send-utils.js +1231 -0
  160. package/hbsig/dist/cjs/send.js +211 -0
  161. package/hbsig/dist/cjs/signer-utils.js +494 -0
  162. package/hbsig/dist/cjs/signer.js +436 -0
  163. package/hbsig/dist/cjs/structured.js +515 -0
  164. package/hbsig/dist/cjs/test.js +12 -0
  165. package/hbsig/dist/cjs/utils.js +44 -0
  166. package/hbsig/dist/esm/bin_to_str.js +46 -0
  167. package/hbsig/dist/esm/collect-body-keys.js +436 -0
  168. package/hbsig/dist/esm/commit.js +219 -0
  169. package/hbsig/dist/esm/encode-array-item.js +112 -0
  170. package/hbsig/dist/esm/encode-utils.js +191 -0
  171. package/hbsig/dist/esm/encode.js +1256 -0
  172. package/hbsig/dist/esm/erl_json.js +292 -0
  173. package/hbsig/dist/esm/erl_str.js +1144 -0
  174. package/hbsig/dist/esm/flat.js +250 -0
  175. package/hbsig/dist/esm/http-message-signatures/httpbis.js +438 -0
  176. package/hbsig/dist/esm/http-message-signatures/index.js +4 -0
  177. package/hbsig/dist/esm/http-message-signatures/structured-header.js +105 -0
  178. package/hbsig/dist/esm/httpsig.js +866 -0
  179. package/hbsig/dist/esm/id.js +459 -0
  180. package/hbsig/dist/esm/index.js +13 -0
  181. package/hbsig/dist/esm/nocrypto.js +4 -0
  182. package/hbsig/dist/esm/package.json +3 -0
  183. package/hbsig/dist/esm/parser.js +171 -0
  184. package/hbsig/dist/esm/send-utils.js +1132 -0
  185. package/hbsig/dist/esm/send.js +142 -0
  186. package/hbsig/dist/esm/signer-utils.js +375 -0
  187. package/hbsig/dist/esm/signer.js +312 -0
  188. package/hbsig/dist/esm/structured.js +496 -0
  189. package/hbsig/dist/esm/test.js +2 -0
  190. package/hbsig/dist/esm/utils.js +29 -0
  191. package/hbsig/dist/package.json +39 -0
  192. package/hbsig/make.js +36 -0
  193. package/hbsig/package.json +39 -0
  194. package/hbsig/src/bin_to_str.js +46 -0
  195. package/hbsig/src/collect-body-keys.js +436 -0
  196. package/hbsig/src/commit.js +219 -0
  197. package/hbsig/src/encode-array-item.js +112 -0
  198. package/hbsig/src/encode-utils.js +191 -0
  199. package/hbsig/src/encode.js +1256 -0
  200. package/hbsig/src/erl_json.js +292 -0
  201. package/hbsig/src/erl_str.js +1144 -0
  202. package/hbsig/src/flat.js +250 -0
  203. package/hbsig/src/http-message-signatures/httpbis.js +438 -0
  204. package/hbsig/src/http-message-signatures/index.js +4 -0
  205. package/hbsig/src/http-message-signatures/structured-header.js +105 -0
  206. package/hbsig/src/httpsig.js +866 -0
  207. package/hbsig/src/id.js +459 -0
  208. package/hbsig/src/index.js +13 -0
  209. package/hbsig/src/nocrypto.js +4 -0
  210. package/hbsig/src/parser.js +171 -0
  211. package/hbsig/src/send-utils.js +1132 -0
  212. package/hbsig/src/send.js +142 -0
  213. package/hbsig/src/signer-utils.js +375 -0
  214. package/hbsig/src/signer.js +312 -0
  215. package/hbsig/src/structured.js +496 -0
  216. package/hbsig/src/test.js +2 -0
  217. package/hbsig/src/utils.js +29 -0
  218. package/lp/index.html +25 -0
  219. package/lp/package.json +19 -0
  220. package/lp/public/cover.png +0 -0
  221. package/lp/public/favicon.ico +0 -0
  222. package/lp/public/favicon.png +0 -0
  223. package/lp/public/images/book.jpg +0 -0
  224. package/lp/public/images/dashboard.png +0 -0
  225. package/lp/public/images/devnet.png +0 -0
  226. package/lp/public/images/hero-bg.png +0 -0
  227. package/lp/public/images/hyperadd.png +0 -0
  228. package/lp/public/images/message-flow.png +0 -0
  229. package/lp/public/images/mobile.png +0 -0
  230. package/lp/public/images/og-cover.png +0 -0
  231. package/lp/public/images/scan.png +0 -0
  232. package/lp/public/images/wao-hub.png +0 -0
  233. package/lp/public/images/wao-web.png +0 -0
  234. package/lp/public/logo.png +0 -0
  235. package/lp/src/App.jsx +29 -0
  236. package/lp/src/components/CodeBlock.jsx +37 -0
  237. package/lp/src/components/CodeBlock.module.css +89 -0
  238. package/lp/src/components/Footer.jsx +22 -0
  239. package/lp/src/components/Footer.module.css +60 -0
  240. package/lp/src/components/Nav.jsx +80 -0
  241. package/lp/src/components/Nav.module.css +177 -0
  242. package/lp/src/components/SectionWrapper.jsx +15 -0
  243. package/lp/src/hooks/useReveal.js +25 -0
  244. package/lp/src/hooks/useScrolled.js +14 -0
  245. package/lp/src/main.jsx +10 -0
  246. package/lp/src/sections/Book.jsx +60 -0
  247. package/lp/src/sections/Book.module.css +204 -0
  248. package/lp/src/sections/Browser.jsx +46 -0
  249. package/lp/src/sections/Browser.module.css +67 -0
  250. package/lp/src/sections/Devnet.jsx +55 -0
  251. package/lp/src/sections/Devnet.module.css +136 -0
  252. package/lp/src/sections/GetStarted.jsx +51 -0
  253. package/lp/src/sections/GetStarted.module.css +128 -0
  254. package/lp/src/sections/Hero.jsx +67 -0
  255. package/lp/src/sections/Hero.module.css +202 -0
  256. package/lp/src/sections/HyperADD.jsx +46 -0
  257. package/lp/src/sections/HyperADD.module.css +113 -0
  258. package/lp/src/sections/SDK.jsx +90 -0
  259. package/lp/src/sections/SDK.module.css +122 -0
  260. package/lp/src/sections/Testing.jsx +47 -0
  261. package/lp/src/sections/Testing.module.css +124 -0
  262. package/lp/src/sections/Vision.jsx +93 -0
  263. package/lp/src/sections/Vision.module.css +147 -0
  264. package/lp/src/styles/globals.css +285 -0
  265. package/lp/src/utils/scrollTo.js +4 -0
  266. package/lp/vite.config.js +7 -0
  267. package/make.js +39 -0
  268. package/package.json +17 -12
  269. package/patches/@permaweb+ao-loader+0.0.44.patch +64 -0
  270. package/plan.md +435 -0
  271. package/rebar.lock +1 -0
  272. package/src/accounts-web.js +128 -0
  273. package/src/accounts.js +124 -0
  274. package/src/adaptor-base.js +622 -0
  275. package/src/adaptor-cf.js +11 -0
  276. package/src/adaptor-web.js +11 -0
  277. package/src/adaptor.js +10 -0
  278. package/src/ao-loader.js +30660 -0
  279. package/src/ao.js +1173 -0
  280. package/src/aoconnect-base.js +1098 -0
  281. package/src/aoconnect-cf.js +9 -0
  282. package/src/aoconnect-web.js +8 -0
  283. package/src/aoconnect.js +8 -0
  284. package/src/aos_wamr.js +1 -0
  285. package/src/ar-remote.js +87 -0
  286. package/src/ar.js +276 -0
  287. package/src/armem-base.js +529 -0
  288. package/src/armem-cf.js +67 -0
  289. package/src/armem-web.js +19 -0
  290. package/src/armem.js +26 -0
  291. package/src/bao.js +141 -0
  292. package/src/bar.js +366 -0
  293. package/src/build.js +7 -0
  294. package/src/bundler.js +119 -0
  295. package/src/car.js +10 -0
  296. package/src/cf-env.js +29 -0
  297. package/src/cf.js +11 -0
  298. package/src/cli.js +561 -0
  299. package/src/compress.js +112 -0
  300. package/src/create.js +415 -0
  301. package/src/devs.js +86 -0
  302. package/src/dirname.js +1 -0
  303. package/src/dodb.js +26 -0
  304. package/src/erl_json.js +289 -0
  305. package/src/erl_str.js +1139 -0
  306. package/src/gql.js +229 -0
  307. package/src/hb.js +967 -0
  308. package/src/helpers.js +203 -0
  309. package/src/http.js +619 -0
  310. package/src/hub/bundler.js +123 -0
  311. package/src/hub/cu.js +74 -0
  312. package/src/hub/fs.js +157 -0
  313. package/src/hub/index.js +85 -0
  314. package/src/hub/utils.js +64 -0
  315. package/src/hub/ws-proxy.js +67 -0
  316. package/src/hyper-aos.js +1 -0
  317. package/src/hyperbeam-server.js +21 -0
  318. package/src/hyperbeam.js +585 -0
  319. package/src/index.js +5 -0
  320. package/src/keygen.js +47 -0
  321. package/src/lfdb.js +67 -0
  322. package/src/lua/aos.wasm +0 -0
  323. package/src/lua/aos2_0_1.js +1 -0
  324. package/src/lua/aos2_0_1.wasm +0 -0
  325. package/src/lua/aos2_0_3.js +1 -0
  326. package/src/lua/aos2_0_3.wasm +0 -0
  327. package/src/lua/aos2_0_4_32.js +1 -0
  328. package/src/lua/aos2_0_4_32.wasm +0 -0
  329. package/src/lua/aos2_0_6.wasm +0 -0
  330. package/src/lua/apm.lua +61 -0
  331. package/src/lua/llama.wasm +0 -0
  332. package/src/lua/process.wasm +0 -0
  333. package/src/lua/sqlite.js +1 -0
  334. package/src/lua/sqlite.wasm +0 -0
  335. package/src/lua/weavedb_mock.lua +44 -0
  336. package/src/lua/weavedrive.lua +53 -0
  337. package/src/run.js +25 -0
  338. package/src/server.js +173 -0
  339. package/src/storage-multi.js +183 -0
  340. package/src/tao.js +12 -0
  341. package/src/tar.js +10 -0
  342. package/src/test.js +42 -0
  343. package/src/tgql-d1.js +407 -0
  344. package/src/tgql.js +310 -0
  345. package/src/toerl.js +162 -0
  346. package/src/utils.js +777 -0
  347. package/src/wao.js +29 -0
  348. package/src/waosm/README.md +81 -0
  349. package/src/waosm/waosm.d.ts +40 -0
  350. package/src/waosm/waosm.js +240 -0
  351. package/src/waosm/waosm_bg.wasm +0 -0
  352. package/src/waosm/waosm_bg.wasm.d.ts +8 -0
  353. package/src/waosm-node/README.md +81 -0
  354. package/src/waosm-node/waosm.d.ts +8 -0
  355. package/src/waosm-node/waosm.js +4 -0
  356. package/src/waosm-node/waosm_bg.js +147 -0
  357. package/src/waosm-node/waosm_bg.wasm +0 -0
  358. package/src/waosm-node/waosm_bg.wasm.d.ts +8 -0
  359. package/src/waosm-node/waosm_bg.wasm.js +14 -0
  360. package/src/waosm-node.js +9 -0
  361. package/src/war.js +10 -0
  362. package/src/weavedrive.js +376 -0
  363. package/src/web.js +11 -0
  364. package/src/workspace/.mcp.json +8 -0
  365. package/src/workspace/CLAUDE.md +258 -0
  366. package/src/workspace/README.md +85 -0
  367. package/src/workspace/dashboard/index.html +163 -0
  368. package/src/workspace/dashboard/package.json +18 -0
  369. package/src/workspace/dashboard/public/favicon.ico +0 -0
  370. package/src/workspace/dashboard/public/favicon.png +0 -0
  371. package/src/workspace/dashboard/server.js +224 -0
  372. package/src/workspace/dashboard/src/App.jsx +2350 -0
  373. package/{cjs/workspace/frontend → src/workspace/dashboard}/vite.config.js +6 -0
  374. package/src/workspace/package.json +18 -0
  375. package/src/workspace/src/counter.lua +14 -0
  376. package/tsconfig.json +18 -0
  377. package/types/index.d.ts +329 -0
  378. package/waollama/.eslintrc.json +3 -0
  379. package/waollama/README.md +19 -0
  380. package/waollama/arweave.mjs +87 -0
  381. package/waollama/components/ui/avatar.jsx +49 -0
  382. package/waollama/components/ui/checkbox.jsx +17 -0
  383. package/waollama/components/ui/close-button.jsx +20 -0
  384. package/waollama/components/ui/color-mode.jsx +61 -0
  385. package/waollama/components/ui/dialog.jsx +54 -0
  386. package/waollama/components/ui/drawer.jsx +44 -0
  387. package/waollama/components/ui/field.jsx +22 -0
  388. package/waollama/components/ui/input-group.jsx +39 -0
  389. package/waollama/components/ui/popover.jsx +49 -0
  390. package/waollama/components/ui/provider.jsx +12 -0
  391. package/waollama/components/ui/radio.jsx +17 -0
  392. package/waollama/components/ui/slider.jsx +107 -0
  393. package/waollama/components/ui/tooltip.jsx +35 -0
  394. package/waollama/index.js +10 -0
  395. package/waollama/jsconfig.json +7 -0
  396. package/waollama/lib/ao-loader.js +30654 -0
  397. package/waollama/lib/client.js +1 -0
  398. package/waollama/lib/wasm.js +1 -0
  399. package/waollama/next.config.js +25 -0
  400. package/waollama/package.json +43 -0
  401. package/waollama/pages/404.js +9 -0
  402. package/waollama/pages/_app.js +9 -0
  403. package/waollama/pages/_document.js +14 -0
  404. package/waollama/pages/index.js +212 -0
  405. package/waollama/playwright.config.js +31 -0
  406. package/waollama/proxy.mjs +21 -0
  407. package/waollama/public/favicon.ico +0 -0
  408. package/waollama/public/human.png +0 -0
  409. package/waollama/public/llama.png +0 -0
  410. package/waosm/Cargo.toml +11 -0
  411. package/waosm/README.md +81 -0
  412. package/waosm/compress.js +112 -0
  413. package/waosm/make.js +33 -0
  414. package/waosm/package.json +10 -0
  415. package/waosm/src/lib.rs +180 -0
  416. package/waosm/test.js +16 -0
  417. package/cjs/workspace/.claude/agents/builder.md +0 -99
  418. package/cjs/workspace/.claude/agents/device-builder.md +0 -86
  419. package/cjs/workspace/.claude/agents/tester.md +0 -90
  420. package/cjs/workspace/.claude/mcp/dashboard/server.js +0 -128
  421. package/cjs/workspace/.claude/rules/deploy.md +0 -45
  422. package/cjs/workspace/.claude/rules/frontend.md +0 -69
  423. package/cjs/workspace/.claude/rules/hyperbeam.md +0 -104
  424. package/cjs/workspace/.claude/rules/lua.md +0 -108
  425. package/cjs/workspace/.claude/rules/testing.md +0 -257
  426. package/cjs/workspace/.claude/settings.json +0 -109
  427. package/cjs/workspace/.claude/skills/build/SKILL.md +0 -214
  428. package/cjs/workspace/.claude/skills/build-aos/SKILL.md +0 -129
  429. package/cjs/workspace/.claude/skills/build-device/SKILL.md +0 -192
  430. package/cjs/workspace/.claude/skills/build-frontend/SKILL.md +0 -134
  431. package/cjs/workspace/.claude/skills/build-module/SKILL.md +0 -281
  432. package/cjs/workspace/.claude/skills/create-aos/SKILL.md +0 -63
  433. package/cjs/workspace/.claude/skills/create-device/SKILL.md +0 -87
  434. package/cjs/workspace/.claude/skills/create-module/SKILL.md +0 -162
  435. package/cjs/workspace/.claude/skills/debug/SKILL.md +0 -57
  436. package/cjs/workspace/.claude/skills/deploy/SKILL.md +0 -85
  437. package/cjs/workspace/.claude/skills/dev/SKILL.md +0 -32
  438. package/cjs/workspace/.claude/skills/plan/SKILL.md +0 -176
  439. package/cjs/workspace/.claude/skills/readme/SKILL.md +0 -186
  440. package/cjs/workspace/.claude/skills/report/SKILL.md +0 -49
  441. package/cjs/workspace/.claude/skills/team/SKILL.md +0 -101
  442. package/cjs/workspace/.claude/skills/test/SKILL.md +0 -56
  443. package/cjs/workspace/.claude/skills/test-device/SKILL.md +0 -114
  444. package/cjs/workspace/.claude/skills/test-e2e/SKILL.md +0 -103
  445. package/cjs/workspace/.claude/skills/test-hb/SKILL.md +0 -76
  446. package/cjs/workspace/.claude/skills/validate/SKILL.md +0 -96
  447. package/cjs/workspace/.claude/skills/validate/scripts/check-lua.sh +0 -41
  448. package/cjs/workspace/docs/aos-lua.md +0 -428
  449. package/cjs/workspace/docs/debug.md +0 -230
  450. package/cjs/workspace/docs/hyperbeam-dev.md +0 -606
  451. package/cjs/workspace/docs/hyperbeam-devices.md +0 -618
  452. package/cjs/workspace/docs/wao-sdk.md +0 -807
  453. package/cjs/workspace/frontend/e2e/.gitkeep +0 -0
  454. package/cjs/workspace/frontend/index.html +0 -12
  455. package/cjs/workspace/frontend/package.json +0 -24
  456. package/cjs/workspace/frontend/playwright.config.js +0 -10
  457. package/cjs/workspace/frontend/src/App.jsx +0 -24
  458. package/cjs/workspace/frontend/test/.gitkeep +0 -0
  459. package/cjs/workspace/frontend/vitest.config.js +0 -10
  460. package/cjs/workspace/scripts/deploy.js +0 -140
  461. package/cjs/workspace/scripts/keygen.js +0 -52
  462. package/cjs/workspace/test/aos.test.js +0 -98
  463. package/cjs/workspace/test/hyperbeam.test.js +0 -80
  464. package/esm/compiler/native +0 -0
  465. package/esm/workspace/.claude/agents/builder.md +0 -99
  466. package/esm/workspace/.claude/agents/device-builder.md +0 -86
  467. package/esm/workspace/.claude/agents/tester.md +0 -90
  468. package/esm/workspace/.claude/mcp/dashboard/server.js +0 -128
  469. package/esm/workspace/.claude/rules/deploy.md +0 -45
  470. package/esm/workspace/.claude/rules/frontend.md +0 -69
  471. package/esm/workspace/.claude/rules/hyperbeam.md +0 -104
  472. package/esm/workspace/.claude/rules/lua.md +0 -108
  473. package/esm/workspace/.claude/rules/testing.md +0 -257
  474. package/esm/workspace/.claude/settings.json +0 -109
  475. package/esm/workspace/.claude/skills/build/SKILL.md +0 -214
  476. package/esm/workspace/.claude/skills/build-aos/SKILL.md +0 -129
  477. package/esm/workspace/.claude/skills/build-device/SKILL.md +0 -192
  478. package/esm/workspace/.claude/skills/build-frontend/SKILL.md +0 -134
  479. package/esm/workspace/.claude/skills/build-module/SKILL.md +0 -281
  480. package/esm/workspace/.claude/skills/create-aos/SKILL.md +0 -63
  481. package/esm/workspace/.claude/skills/create-device/SKILL.md +0 -87
  482. package/esm/workspace/.claude/skills/create-module/SKILL.md +0 -162
  483. package/esm/workspace/.claude/skills/debug/SKILL.md +0 -57
  484. package/esm/workspace/.claude/skills/deploy/SKILL.md +0 -85
  485. package/esm/workspace/.claude/skills/dev/SKILL.md +0 -32
  486. package/esm/workspace/.claude/skills/plan/SKILL.md +0 -176
  487. package/esm/workspace/.claude/skills/readme/SKILL.md +0 -186
  488. package/esm/workspace/.claude/skills/report/SKILL.md +0 -49
  489. package/esm/workspace/.claude/skills/team/SKILL.md +0 -101
  490. package/esm/workspace/.claude/skills/test/SKILL.md +0 -56
  491. package/esm/workspace/.claude/skills/test-device/SKILL.md +0 -114
  492. package/esm/workspace/.claude/skills/test-e2e/SKILL.md +0 -103
  493. package/esm/workspace/.claude/skills/test-hb/SKILL.md +0 -76
  494. package/esm/workspace/.claude/skills/validate/SKILL.md +0 -96
  495. package/esm/workspace/.claude/skills/validate/scripts/check-lua.sh +0 -41
  496. package/esm/workspace/docs/aos-lua.md +0 -428
  497. package/esm/workspace/docs/debug.md +0 -230
  498. package/esm/workspace/docs/hyperbeam-dev.md +0 -606
  499. package/esm/workspace/docs/hyperbeam-devices.md +0 -618
  500. package/esm/workspace/docs/wao-sdk.md +0 -807
  501. package/esm/workspace/frontend/e2e/.gitkeep +0 -0
  502. package/esm/workspace/frontend/index.html +0 -12
  503. package/esm/workspace/frontend/package.json +0 -24
  504. package/esm/workspace/frontend/playwright.config.js +0 -10
  505. package/esm/workspace/frontend/src/App.jsx +0 -24
  506. package/esm/workspace/frontend/src/main.jsx +0 -9
  507. package/esm/workspace/frontend/test/.gitkeep +0 -0
  508. package/esm/workspace/frontend/vite.config.js +0 -6
  509. package/esm/workspace/frontend/vitest.config.js +0 -10
  510. package/esm/workspace/scripts/deploy.js +0 -140
  511. package/esm/workspace/scripts/keygen.js +0 -52
  512. package/esm/workspace/test/aos.test.js +0 -98
  513. package/esm/workspace/test/hyperbeam.test.js +0 -80
  514. /package/{cjs/workspace/dashboard/public → devnet/app}/favicon.ico +0 -0
  515. /package/{cjs/workspace → dhfs-tutorial-app}/src/counter.lua +0 -0
  516. /package/{cjs → dist/cjs}/accounts-web.js +0 -0
  517. /package/{cjs → dist/cjs}/accounts.js +0 -0
  518. /package/{cjs → dist/cjs}/adaptor-base.js +0 -0
  519. /package/{cjs → dist/cjs}/adaptor-cf.js +0 -0
  520. /package/{cjs → dist/cjs}/adaptor-web.js +0 -0
  521. /package/{cjs → dist/cjs}/adaptor.js +0 -0
  522. /package/{cjs → dist/cjs}/ao-loader.js +0 -0
  523. /package/{cjs → dist/cjs}/ao.js +0 -0
  524. /package/{cjs → dist/cjs}/aoconnect-base.js +0 -0
  525. /package/{cjs → dist/cjs}/aoconnect-cf.js +0 -0
  526. /package/{cjs → dist/cjs}/aoconnect-web.js +0 -0
  527. /package/{cjs → dist/cjs}/aoconnect.js +0 -0
  528. /package/{cjs → dist/cjs}/aos_wamr.js +0 -0
  529. /package/{cjs → dist/cjs}/ar-remote.js +0 -0
  530. /package/{cjs → dist/cjs}/ar.js +0 -0
  531. /package/{cjs → dist/cjs}/armem-base.js +0 -0
  532. /package/{cjs → dist/cjs}/armem-cf.js +0 -0
  533. /package/{cjs → dist/cjs}/armem-web.js +0 -0
  534. /package/{cjs → dist/cjs}/armem.js +0 -0
  535. /package/{cjs → dist/cjs}/bao.js +0 -0
  536. /package/{cjs → dist/cjs}/bar.js +0 -0
  537. /package/{cjs → dist/cjs}/build.js +0 -0
  538. /package/{cjs → dist/cjs}/bundler.js +0 -0
  539. /package/{cjs → dist/cjs}/car.js +0 -0
  540. /package/{cjs → dist/cjs}/cf-env.js +0 -0
  541. /package/{cjs → dist/cjs}/cf.js +0 -0
  542. /package/{cjs → dist/cjs}/cli.js +0 -0
  543. /package/{cjs → dist/cjs}/compress.js +0 -0
  544. /package/{cjs → dist/cjs}/create.js +0 -0
  545. /package/{cjs → dist/cjs}/devs.js +0 -0
  546. /package/{cjs → dist/cjs}/dirname.js +0 -0
  547. /package/{cjs → dist/cjs}/dodb.js +0 -0
  548. /package/{cjs → dist/cjs}/erl_json.js +0 -0
  549. /package/{cjs → dist/cjs}/erl_str.js +0 -0
  550. /package/{cjs → dist/cjs}/gql.js +0 -0
  551. /package/{cjs → dist/cjs}/hb.js +0 -0
  552. /package/{cjs → dist/cjs}/helpers.js +0 -0
  553. /package/{cjs → dist/cjs}/http.js +0 -0
  554. /package/{cjs → dist/cjs}/hub/bundler.js +0 -0
  555. /package/{cjs → dist/cjs}/hub/cu.js +0 -0
  556. /package/{cjs → dist/cjs}/hub/fs.js +0 -0
  557. /package/{cjs → dist/cjs}/hub/index.js +0 -0
  558. /package/{cjs → dist/cjs}/hub/utils.js +0 -0
  559. /package/{cjs → dist/cjs}/hub/ws-proxy.js +0 -0
  560. /package/{cjs → dist/cjs}/hyper-aos.js +0 -0
  561. /package/{cjs → dist/cjs}/hyperbeam-server.js +0 -0
  562. /package/{cjs → dist/cjs}/hyperbeam.js +0 -0
  563. /package/{cjs → dist/cjs}/index.js +0 -0
  564. /package/{cjs → dist/cjs}/keygen.js +0 -0
  565. /package/{cjs → dist/cjs}/lfdb.js +0 -0
  566. /package/{cjs → dist/cjs}/lua/aos.wasm +0 -0
  567. /package/{cjs → dist/cjs}/lua/aos2_0_1.js +0 -0
  568. /package/{cjs → dist/cjs}/lua/aos2_0_1.wasm +0 -0
  569. /package/{cjs → dist/cjs}/lua/aos2_0_3.js +0 -0
  570. /package/{cjs → dist/cjs}/lua/aos2_0_3.wasm +0 -0
  571. /package/{cjs → dist/cjs}/lua/aos2_0_4_32.js +0 -0
  572. /package/{cjs → dist/cjs}/lua/aos2_0_4_32.wasm +0 -0
  573. /package/{cjs → dist/cjs}/lua/aos2_0_6.wasm +0 -0
  574. /package/{cjs → dist/cjs}/lua/apm.lua +0 -0
  575. /package/{cjs → dist/cjs}/lua/llama.wasm +0 -0
  576. /package/{cjs → dist/cjs}/lua/process.wasm +0 -0
  577. /package/{cjs → dist/cjs}/lua/sqlite.js +0 -0
  578. /package/{cjs → dist/cjs}/lua/sqlite.wasm +0 -0
  579. /package/{cjs → dist/cjs}/lua/weavedb_mock.lua +0 -0
  580. /package/{cjs → dist/cjs}/lua/weavedrive.lua +0 -0
  581. /package/{cjs → dist/cjs}/run.js +0 -0
  582. /package/{cjs → dist/cjs}/server.js +0 -0
  583. /package/{cjs → dist/cjs}/storage-multi.js +0 -0
  584. /package/{cjs → dist/cjs}/tao.js +0 -0
  585. /package/{cjs → dist/cjs}/tar.js +0 -0
  586. /package/{cjs → dist/cjs}/test.js +0 -0
  587. /package/{cjs → dist/cjs}/tgql-d1.js +0 -0
  588. /package/{cjs → dist/cjs}/tgql.js +0 -0
  589. /package/{cjs → dist/cjs}/toerl.js +0 -0
  590. /package/{cjs → dist/cjs}/utils.js +0 -0
  591. /package/{cjs → dist/cjs}/wao.js +0 -0
  592. /package/{cjs → dist/cjs}/waosm/waosm.js +0 -0
  593. /package/{cjs → dist/cjs}/waosm-node/waosm.js +0 -0
  594. /package/{cjs → dist/cjs}/waosm-node/waosm_bg.js +0 -0
  595. /package/{cjs → dist/cjs}/waosm-node/waosm_bg.wasm +0 -0
  596. /package/{cjs → dist/cjs}/waosm-node/waosm_bg.wasm.js +0 -0
  597. /package/{cjs → dist/cjs}/waosm-node.js +0 -0
  598. /package/{cjs → dist/cjs}/war.js +0 -0
  599. /package/{cjs → dist/cjs}/weavedrive.js +0 -0
  600. /package/{cjs → dist/cjs}/web.js +0 -0
  601. /package/{cjs → dist/cjs}/workspace/.mcp.json +0 -0
  602. /package/{cjs → dist/cjs}/workspace/CLAUDE.md +0 -0
  603. /package/{cjs → dist/cjs}/workspace/README.md +0 -0
  604. /package/{cjs → dist/cjs}/workspace/dashboard/index.html +0 -0
  605. /package/{cjs → dist/cjs}/workspace/dashboard/package.json +0 -0
  606. /package/{esm → dist/cjs}/workspace/dashboard/public/favicon.ico +0 -0
  607. /package/{cjs → dist/cjs}/workspace/dashboard/public/favicon.png +0 -0
  608. /package/{cjs → dist/cjs}/workspace/dashboard/server.js +0 -0
  609. /package/{cjs → dist/cjs}/workspace/dashboard/src/App.jsx +0 -0
  610. /package/{cjs → dist/cjs}/workspace/dashboard/src/main.jsx +0 -0
  611. /package/{cjs → dist/cjs}/workspace/dashboard/vite.config.js +0 -0
  612. /package/{cjs → dist/cjs}/workspace/package.json +0 -0
  613. /package/{esm → dist/cjs}/workspace/src/counter.lua +0 -0
  614. /package/{esm → dist/esm}/accounts-web.js +0 -0
  615. /package/{esm → dist/esm}/accounts.js +0 -0
  616. /package/{esm → dist/esm}/adaptor-base.js +0 -0
  617. /package/{esm → dist/esm}/adaptor-cf.js +0 -0
  618. /package/{esm → dist/esm}/adaptor-web.js +0 -0
  619. /package/{esm → dist/esm}/adaptor.js +0 -0
  620. /package/{esm → dist/esm}/ao-loader.js +0 -0
  621. /package/{esm → dist/esm}/ao.js +0 -0
  622. /package/{esm → dist/esm}/aoconnect-base.js +0 -0
  623. /package/{esm → dist/esm}/aoconnect-cf.js +0 -0
  624. /package/{esm → dist/esm}/aoconnect-web.js +0 -0
  625. /package/{esm → dist/esm}/aoconnect.js +0 -0
  626. /package/{esm → dist/esm}/aos_wamr.js +0 -0
  627. /package/{esm → dist/esm}/ar-remote.js +0 -0
  628. /package/{esm → dist/esm}/ar.js +0 -0
  629. /package/{esm → dist/esm}/armem-base.js +0 -0
  630. /package/{esm → dist/esm}/armem-cf.js +0 -0
  631. /package/{esm → dist/esm}/armem-web.js +0 -0
  632. /package/{esm → dist/esm}/armem.js +0 -0
  633. /package/{esm → dist/esm}/bao.js +0 -0
  634. /package/{esm → dist/esm}/bar.js +0 -0
  635. /package/{esm → dist/esm}/build.js +0 -0
  636. /package/{esm → dist/esm}/bundler.js +0 -0
  637. /package/{esm → dist/esm}/car.js +0 -0
  638. /package/{esm → dist/esm}/cf-env.js +0 -0
  639. /package/{esm → dist/esm}/cf.js +0 -0
  640. /package/{esm → dist/esm}/cli.js +0 -0
  641. /package/{esm → dist/esm}/compress.js +0 -0
  642. /package/{esm → dist/esm}/create.js +0 -0
  643. /package/{esm → dist/esm}/devs.js +0 -0
  644. /package/{esm → dist/esm}/dirname.js +0 -0
  645. /package/{esm → dist/esm}/dodb.js +0 -0
  646. /package/{esm → dist/esm}/erl_json.js +0 -0
  647. /package/{esm → dist/esm}/erl_str.js +0 -0
  648. /package/{esm → dist/esm}/gql.js +0 -0
  649. /package/{esm → dist/esm}/hb.js +0 -0
  650. /package/{esm → dist/esm}/helpers.js +0 -0
  651. /package/{esm → dist/esm}/http.js +0 -0
  652. /package/{esm → dist/esm}/hub/bundler.js +0 -0
  653. /package/{esm → dist/esm}/hub/cu.js +0 -0
  654. /package/{esm → dist/esm}/hub/fs.js +0 -0
  655. /package/{esm → dist/esm}/hub/index.js +0 -0
  656. /package/{esm → dist/esm}/hub/utils.js +0 -0
  657. /package/{esm → dist/esm}/hub/ws-proxy.js +0 -0
  658. /package/{esm → dist/esm}/hyper-aos.js +0 -0
  659. /package/{esm → dist/esm}/hyperbeam-server.js +0 -0
  660. /package/{esm → dist/esm}/hyperbeam.js +0 -0
  661. /package/{esm → dist/esm}/index.js +0 -0
  662. /package/{esm → dist/esm}/keygen.js +0 -0
  663. /package/{esm → dist/esm}/lfdb.js +0 -0
  664. /package/{esm → dist/esm}/lua/aos.wasm +0 -0
  665. /package/{esm → dist/esm}/lua/aos2_0_1.js +0 -0
  666. /package/{esm → dist/esm}/lua/aos2_0_1.wasm +0 -0
  667. /package/{esm → dist/esm}/lua/aos2_0_3.js +0 -0
  668. /package/{esm → dist/esm}/lua/aos2_0_3.wasm +0 -0
  669. /package/{esm → dist/esm}/lua/aos2_0_4_32.js +0 -0
  670. /package/{esm → dist/esm}/lua/aos2_0_4_32.wasm +0 -0
  671. /package/{esm → dist/esm}/lua/aos2_0_6.wasm +0 -0
  672. /package/{esm → dist/esm}/lua/apm.lua +0 -0
  673. /package/{esm → dist/esm}/lua/llama.wasm +0 -0
  674. /package/{esm → dist/esm}/lua/process.wasm +0 -0
  675. /package/{esm → dist/esm}/lua/sqlite.js +0 -0
  676. /package/{esm → dist/esm}/lua/sqlite.wasm +0 -0
  677. /package/{esm → dist/esm}/lua/weavedb_mock.lua +0 -0
  678. /package/{esm → dist/esm}/lua/weavedrive.lua +0 -0
  679. /package/{esm → dist/esm}/package.json +0 -0
  680. /package/{esm → dist/esm}/run.js +0 -0
  681. /package/{esm → dist/esm}/server.js +0 -0
  682. /package/{esm → dist/esm}/storage-multi.js +0 -0
  683. /package/{esm → dist/esm}/tao.js +0 -0
  684. /package/{esm → dist/esm}/tar.js +0 -0
  685. /package/{esm → dist/esm}/test.js +0 -0
  686. /package/{esm → dist/esm}/tgql-d1.js +0 -0
  687. /package/{esm → dist/esm}/tgql.js +0 -0
  688. /package/{esm → dist/esm}/toerl.js +0 -0
  689. /package/{esm → dist/esm}/utils.js +0 -0
  690. /package/{esm → dist/esm}/wao.js +0 -0
  691. /package/{esm → dist/esm}/waosm/README.md +0 -0
  692. /package/{esm → dist/esm}/waosm/waosm.d.ts +0 -0
  693. /package/{esm → dist/esm}/waosm/waosm.js +0 -0
  694. /package/{esm → dist/esm}/waosm/waosm_bg.wasm +0 -0
  695. /package/{esm → dist/esm}/waosm/waosm_bg.wasm.d.ts +0 -0
  696. /package/{esm → dist/esm}/waosm-node/README.md +0 -0
  697. /package/{esm → dist/esm}/waosm-node/waosm.d.ts +0 -0
  698. /package/{esm → dist/esm}/waosm-node/waosm.js +0 -0
  699. /package/{esm → dist/esm}/waosm-node/waosm_bg.js +0 -0
  700. /package/{esm → dist/esm}/waosm-node/waosm_bg.wasm +0 -0
  701. /package/{esm → dist/esm}/waosm-node/waosm_bg.wasm.d.ts +0 -0
  702. /package/{esm → dist/esm}/waosm-node/waosm_bg.wasm.js +0 -0
  703. /package/{esm → dist/esm}/waosm-node.js +0 -0
  704. /package/{esm → dist/esm}/war.js +0 -0
  705. /package/{esm → dist/esm}/weavedrive.js +0 -0
  706. /package/{esm → dist/esm}/web.js +0 -0
  707. /package/{esm → dist/esm}/workspace/.mcp.json +0 -0
  708. /package/{esm → dist/esm}/workspace/CLAUDE.md +0 -0
  709. /package/{esm → dist/esm}/workspace/README.md +0 -0
  710. /package/{esm → dist/esm}/workspace/dashboard/index.html +0 -0
  711. /package/{esm → dist/esm}/workspace/dashboard/package.json +0 -0
  712. /package/{esm/workspace/dashboard/public/favicon.png → dist/esm/workspace/dashboard/public/favicon.ico} +0 -0
  713. /package/{esm → dist/esm}/workspace/dashboard/server.js +0 -0
  714. /package/{esm → dist/esm}/workspace/dashboard/src/App.jsx +0 -0
  715. /package/{cjs/workspace/frontend → dist/esm/workspace/dashboard}/src/main.jsx +0 -0
  716. /package/{esm → dist/esm}/workspace/dashboard/vite.config.js +0 -0
  717. /package/{esm → dist/esm}/workspace/package.json +0 -0
  718. /package/{postinstall.cjs → dist/postinstall.cjs} +0 -0
  719. /package/{esm → src}/workspace/dashboard/src/main.jsx +0 -0
@@ -0,0 +1,1231 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.verifyContentDigest = exports.toBuffer = exports.result = exports.hasValidSignature = exports.getSignatureNames = exports.from = exports.extractKeys = void 0;
7
+ var _ramda = require("ramda");
8
+ var _utils = require("./utils.js");
9
+ var _signerUtils = require("./signer-utils.js");
10
+ var _httpsig = require("./httpsig.js");
11
+ var _structured = require("./structured.js");
12
+ var _base64url = _interopRequireDefault(require("base64url"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
15
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
16
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
17
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
18
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
19
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
20
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
21
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
22
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
25
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
26
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
28
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
29
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
30
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
31
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
32
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
33
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
34
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
35
+ /**
36
+ * Get multipart boundary from content-type header
37
+ */
38
+ var getBoundary = function getBoundary(http) {
39
+ var ctype = http.headers["content-type"];
40
+ if (ctype && /^multipart\/form-data;/.test((0, _ramda.trim)(ctype))) {
41
+ var _iterator = _createForOfIteratorHelper((0, _ramda.trim)(ctype).split(";").slice(1)),
42
+ _step;
43
+ try {
44
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
45
+ var v = _step.value;
46
+ var sp2 = v.split("=");
47
+ if ((0, _ramda.trim)(sp2[0]) === "boundary") return (0, _ramda.trim)(sp2[1]).replace(/"/g, "");
48
+ }
49
+ } catch (err) {
50
+ _iterator.e(err);
51
+ } finally {
52
+ _iterator.f();
53
+ }
54
+ }
55
+ return null;
56
+ };
57
+
58
+ /**
59
+ * Extract specified components from HTTP message
60
+ * @param {Object} http - HTTP message object with headers and optional body
61
+ * @param {Array} components - Array of component names to extract
62
+ * @returns {Object} Extracted components with their values
63
+ */
64
+ var extract = function extract(http, components) {
65
+ var extracted = {};
66
+ var needsBody = components.some(function (c) {
67
+ return c.replace(/"/g, "").toLowerCase() === "content-digest";
68
+ });
69
+
70
+ // First extract ao-types if it's signed
71
+ var hasAoTypes = components.some(function (c) {
72
+ return c.replace(/"/g, "").toLowerCase() === "ao-types";
73
+ });
74
+ if (hasAoTypes) {
75
+ var aoTypes = http.headers["ao-types"] || http.headers["Ao-Types"];
76
+ if (aoTypes) {
77
+ extracted["ao-types"] = aoTypes;
78
+ }
79
+ }
80
+
81
+ // Extract ao-ids if it's signed
82
+ var hasAoIds = components.some(function (c) {
83
+ return c.replace(/"/g, "").toLowerCase() === "ao-ids";
84
+ });
85
+ if (hasAoIds) {
86
+ var aoIds = http.headers["ao-ids"] || http.headers["Ao-Ids"];
87
+ if (aoIds) {
88
+ extracted["ao-ids"] = aoIds;
89
+ }
90
+ }
91
+ var _iterator2 = _createForOfIteratorHelper(components),
92
+ _step2;
93
+ try {
94
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
95
+ var component = _step2.value;
96
+ var cleanComponent = component.replace(/"/g, "");
97
+ if (cleanComponent.startsWith("@")) {
98
+ // Handle derived components
99
+ switch (cleanComponent) {
100
+ case "@method":
101
+ extracted[cleanComponent] = http.method || "GET";
102
+ break;
103
+ case "@target-uri":
104
+ extracted[cleanComponent] = http.url || "";
105
+ break;
106
+ case "@authority":
107
+ extracted[cleanComponent] = http.headers.host || "";
108
+ break;
109
+ case "@scheme":
110
+ if (http.url) {
111
+ var url = new URL(http.url);
112
+ extracted[cleanComponent] = url.protocol.replace(":", "");
113
+ }
114
+ break;
115
+ case "@request-target":
116
+ if (http.url) {
117
+ var _url = new URL(http.url);
118
+ extracted[cleanComponent] = _url.pathname + _url.search;
119
+ }
120
+ break;
121
+ case "@path":
122
+ if (http.url) {
123
+ var _url2 = new URL(http.url);
124
+ extracted[cleanComponent] = _url2.pathname;
125
+ }
126
+ break;
127
+ case "@query":
128
+ if (http.url) {
129
+ var _url3 = new URL(http.url);
130
+ extracted[cleanComponent] = _url3.search;
131
+ }
132
+ break;
133
+ case "@status":
134
+ extracted[cleanComponent] = String(http.status || http["@status"] || "");
135
+ break;
136
+ case "@query-param":
137
+ // This would need additional parsing logic for specific query parameters
138
+ break;
139
+ }
140
+ } else {
141
+ // Handle regular headers - try both exact case and lowercase
142
+ var headerValue = http.headers[cleanComponent] || http.headers[cleanComponent.toLowerCase()];
143
+ if (headerValue !== null && headerValue !== undefined) {
144
+ extracted[cleanComponent] = headerValue;
145
+ }
146
+ }
147
+ }
148
+
149
+ // If content-digest is signed, we need to include the body
150
+ } catch (err) {
151
+ _iterator2.e(err);
152
+ } finally {
153
+ _iterator2.f();
154
+ }
155
+ if (needsBody && http.body !== undefined) {
156
+ extracted["body"] = http.body;
157
+ }
158
+
159
+ // Add flag if body is needed but missing
160
+ if (needsBody && http.body === undefined) {
161
+ extracted["__bodyRequired__"] = true;
162
+ }
163
+ return extracted;
164
+ };
165
+
166
+ /**
167
+ * Convert body to Buffer from various sources
168
+ * @param {string|Buffer|ArrayBuffer} body - The body to convert
169
+ * @returns {Buffer} The body as a Buffer
170
+ */
171
+ var toBuffer = exports.toBuffer = function toBuffer(body) {
172
+ if (!body) {
173
+ return Buffer.alloc(0);
174
+ }
175
+
176
+ // If it's already a Buffer, return it
177
+ if (Buffer.isBuffer(body)) {
178
+ return body;
179
+ }
180
+
181
+ // If it's a string, convert to Buffer
182
+ if (typeof body === "string") {
183
+ return Buffer.from(body, "utf-8");
184
+ }
185
+
186
+ // If it's an ArrayBuffer or TypedArray
187
+ if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {
188
+ return Buffer.from(body);
189
+ }
190
+ throw new Error("Unsupported body type");
191
+ };
192
+
193
+ /**
194
+ * Parse ao-ids dictionary
195
+ * @param {string} aoIds - The ao-ids header value
196
+ * @returns {Object} Parsed ID mappings
197
+ */
198
+ var parseAoIds = function parseAoIds(aoIds) {
199
+ var result = {};
200
+
201
+ // Match pattern: ID="value"
202
+ var regex = /([A-Za-z0-9_-]{43})="([^"]*)"/g;
203
+ var match;
204
+ while ((match = regex.exec(aoIds)) !== null) {
205
+ var _match = match,
206
+ _match2 = _slicedToArray(_match, 3),
207
+ id = _match2[1],
208
+ value = _match2[2];
209
+ result[id] = value;
210
+ }
211
+ return result;
212
+ };
213
+
214
+ /**
215
+ * Convert message to JSON with proper type conversions
216
+ * Following the logic from dev_codec_structured, dev_codec_httpsig_conv, and dev_codec_flat
217
+ * @param {Object} msg - The message to convert
218
+ * @returns {Object} JSON representation
219
+ */
220
+ var _toJSON = function toJSON(msg) {
221
+ if (!msg || _typeof(msg) !== "object") {
222
+ return msg;
223
+ }
224
+ var result = _objectSpread({}, msg);
225
+
226
+ // Handle ao-ids parsing
227
+ if (result["ao-ids"]) {
228
+ var parsedIds = parseAoIds(result["ao-ids"]);
229
+ // Remove the ao-ids header and merge the parsed IDs
230
+ delete result["ao-ids"];
231
+ result = _objectSpread(_objectSpread({}, result), parsedIds);
232
+ }
233
+
234
+ // First, handle the multipart body if present
235
+ var contentType = result["content-type"];
236
+ var body = result.body;
237
+ if (body && contentType && contentType.includes("multipart/form-data")) {
238
+ var boundary = getBoundary({
239
+ headers: {
240
+ "content-type": contentType
241
+ }
242
+ });
243
+ if (boundary) {
244
+ // Parse multipart body
245
+ var parts = parseMultipartBody(body, boundary);
246
+
247
+ // Remove the raw body since we've parsed it
248
+ delete result.body;
249
+
250
+ // Merge parsed parts into result
251
+ for (var _i = 0, _Object$entries = Object.entries(parts); _i < _Object$entries.length; _i++) {
252
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
253
+ partName = _Object$entries$_i[0],
254
+ partData = _Object$entries$_i[1];
255
+ // Parse ao-types from part data if present
256
+ var partTypes = {};
257
+ if (partData["ao-types"]) {
258
+ // Updated regex to handle spaces and trim the key
259
+ var matches = _toConsumableArray(partData["ao-types"].matchAll(/([^=,]+)="([^"]+)"/g));
260
+ var _iterator3 = _createForOfIteratorHelper(matches),
261
+ _step3;
262
+ try {
263
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
264
+ var _step3$value = _slicedToArray(_step3.value, 3),
265
+ _ = _step3$value[0],
266
+ key = _step3$value[1],
267
+ type = _step3$value[2];
268
+ partTypes[key.trim()] = type;
269
+ }
270
+ } catch (err) {
271
+ _iterator3.e(err);
272
+ } finally {
273
+ _iterator3.f();
274
+ }
275
+ }
276
+
277
+ // Apply type conversions to part data
278
+ var convertedPartData = {};
279
+ for (var _i2 = 0, _Object$entries2 = Object.entries(partData); _i2 < _Object$entries2.length; _i2++) {
280
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
281
+ _key = _Object$entries2$_i[0],
282
+ value = _Object$entries2$_i[1];
283
+ if (_key === "ao-types" || _key === "content-disposition") continue;
284
+ var _type = partTypes[_key];
285
+ if (_type && typeof value === "string") {
286
+ convertedPartData[_key] = convertByType(value, _type);
287
+ } else {
288
+ convertedPartData[_key] = value;
289
+ }
290
+ }
291
+
292
+ // Store the result
293
+ if (Object.keys(convertedPartData).length > 0) {
294
+ // Check if the part name suggests it's an array element (ends with /number)
295
+ var isArrayElement = /\/\d+$/.test(partName);
296
+
297
+ // For top-level parts (no slash in name) with objects, keep the structure
298
+ var isTopLevel = !partName.includes("/");
299
+
300
+ // Check if this is a nested path that will be unflattened
301
+ var isNestedPath = partName.includes("/") && !isArrayElement;
302
+ if (isArrayElement || isNestedPath) {
303
+ // Array elements and nested paths keep their structure
304
+ result[partName] = convertedPartData;
305
+ } else if (isTopLevel || Object.keys(convertedPartData).length > 1) {
306
+ // Top-level objects or multi-field objects keep their structure
307
+ result[partName] = convertedPartData;
308
+ } else {
309
+ // Only lift single values for simple cases
310
+ result[partName] = convertedPartData[Object.keys(convertedPartData)[0]];
311
+ }
312
+ }
313
+
314
+ // Store type information for nested fields
315
+ if (Object.keys(partTypes).length > 0) {
316
+ for (var _i3 = 0, _Object$entries3 = Object.entries(partTypes); _i3 < _Object$entries3.length; _i3++) {
317
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
318
+ fieldKey = _Object$entries3$_i[0],
319
+ fieldType = _Object$entries3$_i[1];
320
+ if (fieldKey !== "ao-types" && fieldKey !== "content-disposition") {
321
+ // Add to global typeMap with the full path
322
+ var fullPath = partName + "/" + fieldKey;
323
+ // Store in the ao-types for later use
324
+ if (!result["__typeMap"]) result["__typeMap"] = {};
325
+ result["__typeMap"][fullPath] = fieldType;
326
+ }
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+
333
+ // Parse global ao-types to get type information
334
+ var typeMap = {};
335
+ if (result["ao-types"]) {
336
+ // Updated regex to handle spaces and trim the key
337
+ var _matches = _toConsumableArray(result["ao-types"].matchAll(/([^=,]+)="([^"]+)"/g));
338
+ var _iterator4 = _createForOfIteratorHelper(_matches),
339
+ _step4;
340
+ try {
341
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
342
+ var _step4$value = _slicedToArray(_step4.value, 3),
343
+ _2 = _step4$value[0],
344
+ _key2 = _step4$value[1],
345
+ _type2 = _step4$value[2];
346
+ typeMap[_key2.trim()] = _type2;
347
+ }
348
+ } catch (err) {
349
+ _iterator4.e(err);
350
+ } finally {
351
+ _iterator4.f();
352
+ }
353
+ }
354
+
355
+ // Merge in types from multipart parsing
356
+ if (result["__typeMap"]) {
357
+ Object.assign(typeMap, result["__typeMap"]);
358
+ delete result["__typeMap"];
359
+ }
360
+
361
+ // Also collect types from multipart parts for nested fields
362
+ for (var _i4 = 0, _Object$entries4 = Object.entries(result); _i4 < _Object$entries4.length; _i4++) {
363
+ var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
364
+ _key3 = _Object$entries4$_i[0],
365
+ _value = _Object$entries4$_i[1];
366
+ if (_key3.includes("/") && _typeof(_value) === "object" && _value !== null && _value.__partTypes) {
367
+ // This is a multipart part with type information
368
+ for (var _i5 = 0, _Object$entries5 = Object.entries(_value.__partTypes); _i5 < _Object$entries5.length; _i5++) {
369
+ var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2),
370
+ _fieldKey = _Object$entries5$_i[0],
371
+ _fieldType = _Object$entries5$_i[1];
372
+ // Create the full path for the type
373
+ var _fullPath = "".concat(_key3, "/").concat(_fieldKey);
374
+ typeMap[_fullPath] = _fieldType;
375
+ }
376
+ // Remove the __partTypes after processing
377
+ delete _value.__partTypes;
378
+ }
379
+ }
380
+
381
+ // Add empty values for fields that are in ao-types but not in result
382
+ for (var _i6 = 0, _Object$entries6 = Object.entries(typeMap); _i6 < _Object$entries6.length; _i6++) {
383
+ var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i6], 2),
384
+ _key4 = _Object$entries6$_i[0],
385
+ _type3 = _Object$entries6$_i[1];
386
+ if (!(_key4 in result) && _type3.startsWith("empty-")) {
387
+ result[_key4] = convertByType("", _type3);
388
+ }
389
+ }
390
+
391
+ // Apply type conversions and build final result
392
+ var finalResult = {};
393
+ for (var _i7 = 0, _Object$entries7 = Object.entries(result); _i7 < _Object$entries7.length; _i7++) {
394
+ var _Object$entries7$_i = _slicedToArray(_Object$entries7[_i7], 2),
395
+ _key5 = _Object$entries7$_i[0],
396
+ _value2 = _Object$entries7$_i[1];
397
+ // Skip internal keys and headers we don't want in the final result
398
+ if (_key5.startsWith("__")) continue;
399
+
400
+ // Skip @ fields EXCEPT @path which we want to include
401
+ if (_key5.startsWith("@") && _key5 !== "@path") continue;
402
+ if (_key5 === "ao-types") continue;
403
+ if (_key5 === "content-type") continue;
404
+ if (_key5 === "content-digest") continue;
405
+ if (_key5 === "signature") continue;
406
+ if (_key5 === "signature-input") continue;
407
+ if (_key5 === "body-keys") continue;
408
+
409
+ // Get the type for this key
410
+ var _type4 = typeMap[_key5];
411
+
412
+ // Special handling for objects that should be lists
413
+ if (_type4 === "list" && _typeof(_value2) === "object" && _value2 !== null && !Array.isArray(_value2)) {
414
+ // This is an object that should be converted to a list
415
+ var converted = maybeConvertToArray(_value2);
416
+ finalResult[_key5] = converted;
417
+ } else if (_type4 && typeof _value2 === "string") {
418
+ // Convert based on type
419
+ finalResult[_key5] = convertByType(_value2, _type4);
420
+ } else if (_type4 && _value2 === undefined) {
421
+ // Handle empty types
422
+ finalResult[_key5] = convertByType("", _type4);
423
+ } else if (_typeof(_value2) === "object" && _value2 !== null && !Array.isArray(_value2)) {
424
+ // For objects without a specific type, keep them as objects
425
+ // Only recurse for processing nested values
426
+ var processedObj = {};
427
+ for (var _i8 = 0, _Object$entries8 = Object.entries(_value2); _i8 < _Object$entries8.length; _i8++) {
428
+ var _Object$entries8$_i = _slicedToArray(_Object$entries8[_i8], 2),
429
+ k = _Object$entries8$_i[0],
430
+ v = _Object$entries8$_i[1];
431
+ if (Array.isArray(v)) {
432
+ // Keep arrays as arrays
433
+ processedObj[k] = v;
434
+ } else if (_typeof(v) === "object" && v !== null) {
435
+ processedObj[k] = _toJSON(v);
436
+ } else {
437
+ processedObj[k] = v;
438
+ }
439
+ }
440
+ finalResult[_key5] = processedObj;
441
+ } else {
442
+ // Keep as-is (including arrays)
443
+ finalResult[_key5] = _value2;
444
+ }
445
+ }
446
+
447
+ // Handle flattened paths - pass typeMap for context
448
+ return unflattenPaths(finalResult, typeMap);
449
+ };
450
+
451
+ /**
452
+ * Convert objects with numeric keys to arrays
453
+ */
454
+ var maybeConvertToArray = function maybeConvertToArray(obj) {
455
+ if (Array.isArray(obj)) return obj;
456
+ var keys = Object.keys(obj);
457
+ var numericKeys = keys.filter(function (k) {
458
+ return /^\d+$/.test(k);
459
+ });
460
+
461
+ // If all keys are numeric and sequential starting from 1
462
+ if (numericKeys.length > 0 && numericKeys.length === keys.length) {
463
+ var sortedNumericKeys = numericKeys.map(Number).sort(function (a, b) {
464
+ return a - b;
465
+ });
466
+ var maxIndex = Math.max.apply(Math, _toConsumableArray(sortedNumericKeys));
467
+ var arr = [];
468
+
469
+ // Fill array based on numeric keys (1-based to 0-based)
470
+ for (var i = 1; i <= maxIndex; i++) {
471
+ if (obj[String(i)] !== undefined) {
472
+ arr[i - 1] = obj[String(i)];
473
+ }
474
+ }
475
+ return arr;
476
+ }
477
+ return obj;
478
+ };
479
+
480
+ /**
481
+ * Convert value based on its type
482
+ */
483
+ var convertByType = function convertByType(value, type) {
484
+ switch (type) {
485
+ case "integer":
486
+ // Handle structured field integer format
487
+ if (typeof value === "string" && value.match(/^"?\(ao-type-integer\)\s+(\d+)"?$/)) {
488
+ var match = value.match(/(\d+)/);
489
+ return parseInt(match[1], 10);
490
+ }
491
+ return parseInt(value, 10);
492
+ case "float":
493
+ case "decimal":
494
+ return parseFloat(value);
495
+ case "boolean":
496
+ return value === "true" || value === "?1";
497
+ case "atom":
498
+ // Remove quotes from atom values
499
+ var atomValue = value;
500
+
501
+ // Remove any surrounding quotes (single or double)
502
+ if (atomValue.startsWith('"') && atomValue.endsWith('"') || atomValue.startsWith("'") && atomValue.endsWith("'")) {
503
+ atomValue = atomValue.slice(1, -1);
504
+ }
505
+
506
+ // Also handle escaped quotes
507
+ atomValue = atomValue.replace(/\\"/g, '"').replace(/\\'/g, "'");
508
+
509
+ // Handle special atom values
510
+ if (atomValue === "true") return true;
511
+ if (atomValue === "false") return false;
512
+ if (atomValue === "null") return null;
513
+
514
+ // For other atoms, return as Symbol
515
+ return Symbol["for"](atomValue);
516
+ case "list":
517
+ // Handle case where list is a comma-separated string
518
+ if (typeof value === "string" && !value.startsWith("(")) {
519
+ var items = [];
520
+ var current = "";
521
+ var inQuotes = false;
522
+ var depth = 0;
523
+ for (var i = 0; i < value.length; i++) {
524
+ var _char = value[i];
525
+ var prevChar = value[i - 1];
526
+ if (_char === '"' && prevChar !== "\\") {
527
+ inQuotes = !inQuotes;
528
+ }
529
+ if (!inQuotes) {
530
+ if (_char === "(") {
531
+ depth++;
532
+ } else if (_char === ")") {
533
+ depth--;
534
+ } else if (_char === "," && depth === 0) {
535
+ if (current.trim()) {
536
+ // Parse the item to handle type annotations
537
+ items.push(parseStructuredItem(current.trim()));
538
+ }
539
+ current = "";
540
+ continue;
541
+ }
542
+ }
543
+ current += _char;
544
+ }
545
+ if (current.trim()) {
546
+ items.push(parseStructuredItem(current.trim()));
547
+ }
548
+ return items;
549
+ }
550
+ return parseStructuredList(value);
551
+ case "map":
552
+ case "dictionary":
553
+ return parseStructuredDict(value);
554
+ case "empty-binary":
555
+ return "";
556
+ case "empty-list":
557
+ return [];
558
+ case "empty-message":
559
+ return {};
560
+ default:
561
+ return value;
562
+ }
563
+ };
564
+
565
+ /**
566
+ * Parse structured field list
567
+ */
568
+ var parseStructuredList = function parseStructuredList(value) {
569
+ if (!value || value === "()") return [];
570
+
571
+ // Remove outer quotes if present
572
+ var content = value.trim();
573
+ if (content.startsWith('"') && content.endsWith('"')) {
574
+ content = content.slice(1, -1);
575
+ }
576
+ var items = [];
577
+ var current = "";
578
+ var inQuotes = false;
579
+ var depth = 0;
580
+ for (var i = 0; i < content.length; i++) {
581
+ var _char2 = content[i];
582
+ var prevChar = content[i - 1];
583
+ if (_char2 === '"' && prevChar !== "\\") {
584
+ inQuotes = !inQuotes;
585
+ current += _char2;
586
+ } else if (!inQuotes) {
587
+ if (_char2 === "(") {
588
+ depth++;
589
+ current += _char2;
590
+ } else if (_char2 === ")") {
591
+ depth--;
592
+ current += _char2;
593
+ } else if (_char2 === "," && depth === 0) {
594
+ if (current.trim()) {
595
+ items.push(parseStructuredItem(current.trim()));
596
+ }
597
+ current = "";
598
+ } else {
599
+ current += _char2;
600
+ }
601
+ } else {
602
+ current += _char2;
603
+ }
604
+ }
605
+ if (current.trim()) {
606
+ items.push(parseStructuredItem(current.trim()));
607
+ }
608
+ return items;
609
+ };
610
+
611
+ /**
612
+ * Parse structured field item
613
+ */
614
+ var parseStructuredItem = function parseStructuredItem(item) {
615
+ // Quoted string - handle first to properly process inner content
616
+ if (item.startsWith('"') && item.endsWith('"')) {
617
+ var inner = item.slice(1, -1).replace(/\\"/g, '"');
618
+
619
+ // Check if the inner content is ao-type encoded
620
+ var innerAoTypeMatch = inner.match(/^\(ao-type-(\w+)\)\s+(.+)$/);
621
+ if (innerAoTypeMatch) {
622
+ var _innerAoTypeMatch = _slicedToArray(innerAoTypeMatch, 3),
623
+ type = _innerAoTypeMatch[1],
624
+ value = _innerAoTypeMatch[2];
625
+ // The value here has already had escaped quotes converted to real quotes
626
+ // If it's wrapped in quotes, remove them
627
+ var cleanValue = value;
628
+ if (cleanValue.startsWith('"') && cleanValue.endsWith('"') || cleanValue.startsWith("'") && cleanValue.endsWith("'")) {
629
+ cleanValue = cleanValue.slice(1, -1);
630
+ }
631
+ return convertByType(cleanValue, type);
632
+ }
633
+ return inner;
634
+ }
635
+
636
+ // Handle ao-type encoded items without outer quotes
637
+ var aoTypeMatch = item.match(/^\(ao-type-(\w+)\)\s+(.+)$/);
638
+ if (aoTypeMatch) {
639
+ var _aoTypeMatch = _slicedToArray(aoTypeMatch, 3),
640
+ _type5 = _aoTypeMatch[1],
641
+ _value3 = _aoTypeMatch[2];
642
+ var _cleanValue = _value3;
643
+ // Handle escaped quotes
644
+ _cleanValue = _cleanValue.replace(/\\"/g, '"');
645
+ // If wrapped in quotes, remove them
646
+ if (_cleanValue.startsWith('"') && _cleanValue.endsWith('"') || _cleanValue.startsWith("'") && _cleanValue.endsWith("'")) {
647
+ _cleanValue = _cleanValue.slice(1, -1);
648
+ }
649
+ return convertByType(_cleanValue, _type5);
650
+ }
651
+
652
+ // Boolean
653
+ if (item === "?1") return true;
654
+ if (item === "?0") return false;
655
+
656
+ // Number
657
+ if (/^-?\d+$/.test(item)) {
658
+ return parseInt(item, 10);
659
+ }
660
+ if (/^-?\d+\.\d+$/.test(item)) {
661
+ return parseFloat(item);
662
+ }
663
+
664
+ // Nested list
665
+ if (item.startsWith("(") && item.endsWith(")")) {
666
+ return parseStructuredList(item);
667
+ }
668
+ return item;
669
+ };
670
+
671
+ /**
672
+ * Parse structured field dictionary
673
+ */
674
+ var parseStructuredDict = function parseStructuredDict(value) {
675
+ var decoded = (0, _signerUtils.decodeSigInput)(value);
676
+ var result = {};
677
+ for (var _i9 = 0, _Object$entries9 = Object.entries(decoded); _i9 < _Object$entries9.length; _i9++) {
678
+ var _Object$entries9$_i = _slicedToArray(_Object$entries9[_i9], 2),
679
+ key = _Object$entries9$_i[0],
680
+ info = _Object$entries9$_i[1];
681
+ if (info && info.components && info.components.length > 0) {
682
+ result[key] = parseStructuredItem(info.components[0]);
683
+ } else {
684
+ result[key] = true;
685
+ }
686
+ }
687
+ return result;
688
+ };
689
+
690
+ /**
691
+ * Parse body-keys list
692
+ */
693
+ var parseBodyKeysList = function parseBodyKeysList(value) {
694
+ var matches = _toConsumableArray(value.matchAll(/"([^"]+)"/g));
695
+ return matches.map(function (m) {
696
+ return m[1];
697
+ });
698
+ };
699
+
700
+ /**
701
+ * Parse multipart body
702
+ */
703
+ var parseMultipartBody = function parseMultipartBody(body, boundary) {
704
+ var result = {};
705
+
706
+ // Split by boundary lines
707
+ var parts = body.split("--".concat(boundary));
708
+ for (var i = 0; i < parts.length; i++) {
709
+ var part = parts[i];
710
+
711
+ // Skip empty parts and the terminating part
712
+ if (!part || part === "--" || part === "--\r\n" || part.trim() === "") continue;
713
+
714
+ // Remove leading \r\n if present
715
+ var content = part;
716
+ if (content.startsWith("\r\n")) {
717
+ content = content.substring(2);
718
+ }
719
+
720
+ // Remove trailing \r\n or -- if present
721
+ if (content.endsWith("\r\n")) {
722
+ content = content.substring(0, content.length - 2);
723
+ }
724
+ if (!content) continue;
725
+
726
+ // Parse all lines
727
+ var lines = content.split("\r\n");
728
+ var partData = {};
729
+ var partName = null;
730
+ var _iterator5 = _createForOfIteratorHelper(lines),
731
+ _step5;
732
+ try {
733
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
734
+ var line = _step5.value;
735
+ if (!line) continue;
736
+ var colonIndex = line.indexOf(": ");
737
+ if (colonIndex > -1) {
738
+ var name = line.substring(0, colonIndex);
739
+ var value = line.substring(colonIndex + 2);
740
+
741
+ // Check if this is content-disposition to extract part name
742
+ if (name.toLowerCase() === "content-disposition") {
743
+ var nameMatch = value.match(/name="([^"]+)"/);
744
+ if (nameMatch) {
745
+ partName = nameMatch[1];
746
+ }
747
+ } else {
748
+ // Store all other headers/fields
749
+ partData[name] = value;
750
+ }
751
+ }
752
+ }
753
+
754
+ // Store the part data under its name
755
+ } catch (err) {
756
+ _iterator5.e(err);
757
+ } finally {
758
+ _iterator5.f();
759
+ }
760
+ if (partName && Object.keys(partData).length > 0) {
761
+ result[partName] = partData;
762
+ }
763
+ }
764
+ return result;
765
+ };
766
+
767
+ /**
768
+ * Unflatten paths with '/'
769
+ */
770
+ var unflattenPaths = function unflattenPaths(obj) {
771
+ var typeMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
772
+ var result = {};
773
+
774
+ // Check if there are any paths to unflatten
775
+ var hasPathsToUnflatten = Object.keys(obj).some(function (key) {
776
+ return key.includes("/");
777
+ });
778
+
779
+ // If no paths to unflatten, return the object as-is
780
+ if (!hasPathsToUnflatten) {
781
+ return obj;
782
+ }
783
+
784
+ // First pass: collect all keys and sort them to process parents before children
785
+ var sortedKeys = Object.keys(obj).sort();
786
+ var _iterator6 = _createForOfIteratorHelper(sortedKeys),
787
+ _step6;
788
+ try {
789
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
790
+ var key = _step6.value;
791
+ var value = obj[key];
792
+ if (key.includes("/")) {
793
+ var parts = key.split("/");
794
+ var current = result;
795
+ var i = 0;
796
+ while (i < parts.length - 1) {
797
+ var part = parts[i];
798
+
799
+ // Check if we have consecutive empty parts (multiple slashes)
800
+ if (part === "" && i + 1 < parts.length && parts[i + 1] === "") {
801
+ // Skip empty parts until we find a non-empty one or reach the end
802
+ var j = i;
803
+ while (j < parts.length && parts[j] === "") {
804
+ j++;
805
+ }
806
+ // Use "/" as the key for multiple slashes
807
+ part = "/";
808
+ i = j - 1; // Will be incremented at the end of loop
809
+ } else if (part === "") {
810
+ // Single empty part at the beginning or middle, skip it
811
+ i++;
812
+ continue;
813
+ }
814
+ if (!current[part]) {
815
+ current[part] = {};
816
+ }
817
+ current = current[part];
818
+ i++;
819
+ }
820
+
821
+ // Handle the final part
822
+ var finalPart = parts[parts.length - 1];
823
+ current[finalPart] = value;
824
+ } else {
825
+ result[key] = value;
826
+ }
827
+ }
828
+
829
+ // Second pass: convert objects with numeric keys to arrays only if they have type="list"
830
+ } catch (err) {
831
+ _iterator6.e(err);
832
+ } finally {
833
+ _iterator6.f();
834
+ }
835
+ var _convertToArraysRecursive = function convertToArraysRecursive(obj) {
836
+ var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
837
+ if (Array.isArray(obj)) {
838
+ return obj.map(function (item, index) {
839
+ return _convertToArraysRecursive(item, "".concat(parentKey, "/").concat(index + 1));
840
+ });
841
+ } else if (obj && _typeof(obj) === "object") {
842
+ // Check if this object has type="list" in typeMap
843
+ var hasListType = typeMap[parentKey] === "list";
844
+
845
+ // Only convert to array if it has numeric keys AND type="list"
846
+ if (hasListType) {
847
+ var converted = maybeConvertToArray(obj);
848
+ if (Array.isArray(converted)) {
849
+ return converted.map(function (item, index) {
850
+ return _convertToArraysRecursive(item, "".concat(parentKey, "/").concat(index + 1));
851
+ });
852
+ }
853
+ }
854
+
855
+ // Otherwise, keep as object and recurse
856
+ var _result = {};
857
+ for (var _i0 = 0, _Object$entries0 = Object.entries(obj); _i0 < _Object$entries0.length; _i0++) {
858
+ var _Object$entries0$_i = _slicedToArray(_Object$entries0[_i0], 2),
859
+ key = _Object$entries0$_i[0],
860
+ value = _Object$entries0$_i[1];
861
+ var childKey = parentKey ? "".concat(parentKey, "/").concat(key) : key;
862
+ _result[key] = _convertToArraysRecursive(value, childKey);
863
+ }
864
+ return _result;
865
+ }
866
+ return obj;
867
+ };
868
+ return _convertToArraysRecursive(result);
869
+ };
870
+
871
+ /**
872
+ * Helper to check if a key pattern suggests an array structure
873
+ */
874
+ var isArrayKey = function isArrayKey(obj, currentKey, partIndex) {
875
+ var parts = currentKey.split("/");
876
+ var prefix = parts.slice(0, partIndex + 1).join("/");
877
+
878
+ // Check if there are other keys with the same prefix but numeric suffixes
879
+ for (var _i1 = 0, _Object$keys = Object.keys(obj); _i1 < _Object$keys.length; _i1++) {
880
+ var key = _Object$keys[_i1];
881
+ if (key.startsWith(prefix + "/") && key !== currentKey) {
882
+ var otherParts = key.split("/");
883
+ if (otherParts.length > partIndex + 1 && /^\d+$/.test(otherParts[partIndex + 1])) {
884
+ return true;
885
+ }
886
+ }
887
+ }
888
+ return false;
889
+ };
890
+
891
+ /**
892
+ * Check if a string contains binary data (non-printable characters)
893
+ * @param {string} str - The string to check
894
+ * @returns {boolean} True if binary data detected
895
+ */
896
+ var isBinaryString = function isBinaryString(str) {
897
+ if (!str || typeof str !== "string") return false;
898
+
899
+ // Check for non-printable characters (excluding common whitespace)
900
+ for (var i = 0; i < str.length; i++) {
901
+ var code = str.charCodeAt(i);
902
+ // Allow tab (9), newline (10), carriage return (13), and printable ASCII (32-126)
903
+ if (code < 9 || code > 13 && code < 32 || code > 126) {
904
+ return true;
905
+ }
906
+ }
907
+ return false;
908
+ };
909
+
910
+ /**
911
+ * Convert binary string to Buffer
912
+ * @param {string} str - Binary string to convert
913
+ * @returns {Buffer} Buffer representation of the string
914
+ */
915
+ var stringToBuffer = function stringToBuffer(str) {
916
+ var buffer = Buffer.alloc(str.length);
917
+ for (var i = 0; i < str.length; i++) {
918
+ buffer[i] = str.charCodeAt(i);
919
+ }
920
+ return buffer;
921
+ };
922
+ var toMsg = /*#__PURE__*/function () {
923
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(req) {
924
+ var _req$headers;
925
+ var msg, arrayBuffer;
926
+ return _regenerator().w(function (_context) {
927
+ while (1) switch (_context.n) {
928
+ case 0:
929
+ msg = {};
930
+ req === null || req === void 0 || (_req$headers = req.headers) === null || _req$headers === void 0 || _req$headers.forEach(function (v, k) {
931
+ msg[k] = v;
932
+ });
933
+ if (!req.body) {
934
+ _context.n = 2;
935
+ break;
936
+ }
937
+ _context.n = 1;
938
+ return req.arrayBuffer();
939
+ case 1:
940
+ arrayBuffer = _context.v;
941
+ msg.body = typeof Buffer !== "undefined" ? Buffer.from(arrayBuffer) : new Uint8Array(arrayBuffer);
942
+ case 2:
943
+ return _context.a(2, msg);
944
+ }
945
+ }, _callee);
946
+ }));
947
+ return function toMsg(_x) {
948
+ return _ref.apply(this, arguments);
949
+ };
950
+ }();
951
+ var result = exports.result = /*#__PURE__*/function () {
952
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(response) {
953
+ var _from$signer, _from$hashpath;
954
+ var headers, msg, tabm, out, body, http, _from;
955
+ return _regenerator().w(function (_context2) {
956
+ while (1) switch (_context2.n) {
957
+ case 0:
958
+ headers = {};
959
+ response.headers.forEach(function (v, k) {
960
+ return headers[k] = v;
961
+ });
962
+ _context2.n = 1;
963
+ return toMsg(response);
964
+ case 1:
965
+ msg = _context2.v;
966
+ tabm = (0, _httpsig.httpsig_from)(msg);
967
+ out = (0, _structured.structured_to)(tabm);
968
+ body = Buffer.from(msg.body).toString();
969
+ http = {
970
+ headers: headers,
971
+ body: body
972
+ };
973
+ _from = from(http);
974
+ return _context2.a(2, {
975
+ signer: (_from$signer = _from === null || _from === void 0 ? void 0 : _from.signer) !== null && _from$signer !== void 0 ? _from$signer : null,
976
+ hashpath: (_from$hashpath = _from === null || _from === void 0 ? void 0 : _from.hashpath) !== null && _from$hashpath !== void 0 ? _from$hashpath : null,
977
+ headers: headers,
978
+ status: response.status,
979
+ body: body,
980
+ out: out["ao-result"] ? _from === null || _from === void 0 ? void 0 : _from.out : out
981
+ });
982
+ }
983
+ }, _callee2);
984
+ }));
985
+ return function result(_x2) {
986
+ return _ref2.apply(this, arguments);
987
+ };
988
+ }();
989
+ var from = exports.from = function from(http) {
990
+ var input = http.headers["signature-input"] || http.headers["Signature-Input"];
991
+ if (!input) return null;
992
+
993
+ // Decode signature inputs
994
+ var inputs = (0, _signerUtils.decodeSigInput)(input);
995
+ // Process the first signature (following the original logic)
996
+ for (var k in inputs) {
997
+ var _sigData$params$tag, _sigData$params;
998
+ var sigData = inputs[k];
999
+ // Extract only the signed components
1000
+ var extractedComponents = extract(http, sigData.components);
1001
+ var ret = {
1002
+ hashpath: (_sigData$params$tag = sigData === null || sigData === void 0 || (_sigData$params = sigData.params) === null || _sigData$params === void 0 ? void 0 : _sigData$params.tag) !== null && _sigData$params$tag !== void 0 ? _sigData$params$tag : null
1003
+ };
1004
+ try {
1005
+ ret.signer = (0, _utils.toAddr)(sigData.params.keyid);
1006
+ } catch (e) {}
1007
+
1008
+ // Check if @path was in the signed components
1009
+ var hasPathComponent = sigData.components.some(function (c) {
1010
+ return c.replace(/"/g, "") === "@path";
1011
+ });
1012
+
1013
+ // If @path is signed, add the path header to extracted components
1014
+ if (hasPathComponent) {
1015
+ extractedComponents["path"] = http.headers.path;
1016
+ }
1017
+
1018
+ // Check if ao-result header is present
1019
+ var aoResult = http.headers["ao-result"] || http.headers["Ao-Result"];
1020
+
1021
+ // Handle ao-result pointing to body
1022
+ if (aoResult === "body") {
1023
+ // Handle empty body case
1024
+ if (!extractedComponents.body) {
1025
+ return _objectSpread({
1026
+ out: ""
1027
+ }, ret); // Return empty string for empty body
1028
+ }
1029
+ // Check if body is binary data
1030
+ if (isBinaryString(extractedComponents.body)) {
1031
+ return _objectSpread({
1032
+ out: stringToBuffer(extractedComponents.body)
1033
+ }, ret);
1034
+ }
1035
+ // Return body as-is if it's not binary
1036
+ return _objectSpread({
1037
+ out: extractedComponents.body
1038
+ }, ret);
1039
+ }
1040
+
1041
+ // Convert the extracted components to JSON format
1042
+ var _result2 = _toJSON(extractedComponents);
1043
+
1044
+ // Handle ao-result if present and pointing to other fields
1045
+ if (aoResult && aoResult !== "body") {
1046
+ // Return the value of the key specified by ao-result
1047
+ // If the key doesn't exist, return undefined (or could return null/empty string)
1048
+ return _objectSpread({
1049
+ out: _result2[aoResult] !== undefined ? _result2[aoResult] : ""
1050
+ }, ret);
1051
+ }
1052
+ return _objectSpread({
1053
+ out: _result2
1054
+ }, ret);
1055
+ }
1056
+ return {
1057
+ out: null,
1058
+ hashpath: null
1059
+ };
1060
+ };
1061
+
1062
+ /**
1063
+ * Extract all keys and signature information from HTTP signature message
1064
+ * @param {Object} http - HTTP message object with headers and body
1065
+ * @returns {Object} Object containing all extracted signature data
1066
+ */
1067
+ var extractKeys = exports.extractKeys = function extractKeys(http) {
1068
+ var result = {
1069
+ signatures: {},
1070
+ keys: {},
1071
+ boundary: null,
1072
+ requiresBody: false,
1073
+ body: http.body ? toBuffer(http.body) : null,
1074
+ bodyText: typeof http.body === "string" ? http.body : null
1075
+ };
1076
+
1077
+ // Get multipart boundary if present
1078
+ result.boundary = getBoundary(http);
1079
+
1080
+ // Get signature header
1081
+ var signatureHeader = http.headers.signature || http.headers.Signature;
1082
+ if (!signatureHeader) {
1083
+ return result;
1084
+ }
1085
+
1086
+ // Get signature-input header
1087
+ var signatureInput = http.headers["signature-input"] || http.headers["Signature-Input"];
1088
+ if (!signatureInput) {
1089
+ return result;
1090
+ }
1091
+
1092
+ // Decode all signature inputs
1093
+ var inputs = (0, _signerUtils.decodeSigInput)(signatureInput);
1094
+
1095
+ // Parse signature header to extract actual signatures
1096
+ // Format: sig1=:base64signature:, sig2=:base64signature:
1097
+ var signatures = {};
1098
+ var sigPattern = /([a-zA-Z0-9-]+)=:([^:]+):/g;
1099
+ var match;
1100
+ while ((match = sigPattern.exec(signatureHeader)) !== null) {
1101
+ signatures[match[1]] = match[2];
1102
+ }
1103
+
1104
+ // Process each signature
1105
+ for (var _i10 = 0, _Object$entries1 = Object.entries(inputs); _i10 < _Object$entries1.length; _i10++) {
1106
+ var _Object$entries1$_i = _slicedToArray(_Object$entries1[_i10], 2),
1107
+ sigName = _Object$entries1$_i[0],
1108
+ sigData = _Object$entries1$_i[1];
1109
+ var extractedValues = extract(http, sigData.components);
1110
+
1111
+ // Check if body is required
1112
+ if (extractedValues.__bodyRequired__) {
1113
+ result.requiresBody = true;
1114
+ }
1115
+ var signatureInfo = {
1116
+ name: sigName,
1117
+ signature: signatures[sigName] || null,
1118
+ components: sigData.components,
1119
+ params: sigData.params,
1120
+ extractedValues: extractedValues,
1121
+ hasContentDigest: sigData.components.some(function (c) {
1122
+ return c.replace(/"/g, "").toLowerCase() === "content-digest";
1123
+ })
1124
+ };
1125
+
1126
+ // If has content-digest, verify it
1127
+ if (signatureInfo.hasContentDigest && result.body) {
1128
+ var contentDigest = http.headers["content-digest"] || http.headers["Content-Digest"];
1129
+ if (contentDigest) {
1130
+ signatureInfo.contentDigestVerification = verifyContentDigest(contentDigest, result.body);
1131
+ }
1132
+ }
1133
+
1134
+ // Extract key information from params
1135
+ if (sigData.params.keyid) {
1136
+ try {
1137
+ var keyBuffer = _base64url["default"].toBuffer(sigData.params.keyid);
1138
+ result.keys[sigName] = {
1139
+ keyid: sigData.params.keyid,
1140
+ keyBuffer: keyBuffer,
1141
+ algorithm: sigData.params.alg || "unknown"
1142
+ };
1143
+ } catch (e) {
1144
+ // If keyid is not base64url encoded, store as-is
1145
+ result.keys[sigName] = {
1146
+ keyid: sigData.params.keyid,
1147
+ algorithm: sigData.params.alg || "unknown"
1148
+ };
1149
+ }
1150
+ }
1151
+ result.signatures[sigName] = signatureInfo;
1152
+ }
1153
+ return result;
1154
+ };
1155
+
1156
+ /**
1157
+ * Verify if a message has valid HTTP signature structure
1158
+ * @param {Object} http - HTTP message object
1159
+ * @returns {boolean} True if message has valid signature structure
1160
+ */
1161
+ var hasValidSignature = exports.hasValidSignature = function hasValidSignature(http) {
1162
+ var hasSignature = (http.headers.signature || http.headers.Signature) !== undefined;
1163
+ var hasSignatureInput = (http.headers["signature-input"] || http.headers["Signature-Input"]) !== undefined;
1164
+ return hasSignature && hasSignatureInput;
1165
+ };
1166
+
1167
+ /**
1168
+ * Verify content-digest header against body
1169
+ * @param {string} contentDigest - Content-Digest header value
1170
+ * @param {string|Buffer} body - Request/response body
1171
+ * @returns {Object} Verification result with digest info
1172
+ */
1173
+ var verifyContentDigest = exports.verifyContentDigest = function verifyContentDigest(contentDigest, body) {
1174
+ // Parse content-digest header format: algorithm=:base64digest:
1175
+ var match = contentDigest.match(/([^=]+)=:([^:]+):/);
1176
+ if (!match) {
1177
+ return {
1178
+ valid: false,
1179
+ error: "Invalid content-digest format"
1180
+ };
1181
+ }
1182
+ var _match3 = _slicedToArray(match, 3),
1183
+ algorithm = _match3[1],
1184
+ expectedDigest = _match3[2];
1185
+ try {
1186
+ // Convert body to Buffer if needed
1187
+ var bodyBuffer = typeof body === "string" ? Buffer.from(body, "utf-8") : body;
1188
+
1189
+ // Calculate digest based on algorithm
1190
+ var actualDigest;
1191
+ var crypto = require("crypto");
1192
+ if (algorithm === "sha-256") {
1193
+ var hash = crypto.createHash("sha256");
1194
+ hash.update(bodyBuffer);
1195
+ actualDigest = hash.digest("base64");
1196
+ } else if (algorithm === "sha-512") {
1197
+ var _hash = crypto.createHash("sha512");
1198
+ _hash.update(bodyBuffer);
1199
+ actualDigest = _hash.digest("base64");
1200
+ } else {
1201
+ return {
1202
+ valid: false,
1203
+ error: "Unsupported algorithm: ".concat(algorithm)
1204
+ };
1205
+ }
1206
+ return {
1207
+ valid: actualDigest === expectedDigest,
1208
+ algorithm: algorithm,
1209
+ expectedDigest: expectedDigest,
1210
+ actualDigest: actualDigest,
1211
+ matches: actualDigest === expectedDigest
1212
+ };
1213
+ } catch (error) {
1214
+ return {
1215
+ valid: false,
1216
+ error: error.message
1217
+ };
1218
+ }
1219
+ };
1220
+
1221
+ /**
1222
+ * Get all signature names from a message
1223
+ * @param {Object} http - HTTP message object
1224
+ * @returns {Array} Array of signature names
1225
+ */
1226
+ var getSignatureNames = exports.getSignatureNames = function getSignatureNames(http) {
1227
+ var signatureInput = http.headers["signature-input"] || http.headers["Signature-Input"];
1228
+ if (!signatureInput) return [];
1229
+ var inputs = (0, _signerUtils.decodeSigInput)(signatureInput);
1230
+ return Object.keys(inputs);
1231
+ };