@makaio/framework 1.0.0-dev-1779046984397

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 (410) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +363 -0
  3. package/dist/account-identity-Ce1Bwrqi.mjs +1 -0
  4. package/dist/adapter-CbyjCE2d.mjs +1 -0
  5. package/dist/adapters/acp-client/index.d.mts +209 -0
  6. package/dist/adapters/acp-client/index.mjs +1 -0
  7. package/dist/adapters/config/index.d.mts +429 -0
  8. package/dist/adapters/config/index.mjs +1 -0
  9. package/dist/adapters/index.d.mts +4175 -0
  10. package/dist/adapters/index.mjs +11 -0
  11. package/dist/adapters/node.d.mts +263 -0
  12. package/dist/adapters/node.mjs +4 -0
  13. package/dist/adapters/stream-session/index.d.mts +1384 -0
  14. package/dist/adapters/stream-session/index.mjs +1 -0
  15. package/dist/adapters/stream-session/testing/index.d.mts +29 -0
  16. package/dist/adapters/stream-session/testing/index.mjs +1 -0
  17. package/dist/base-orchestrator-9z8TuA5a.d.mts +772 -0
  18. package/dist/bus/index.d.mts +3331 -0
  19. package/dist/bus/index.mjs +1 -0
  20. package/dist/bus-B1seC4M_.mjs +2 -0
  21. package/dist/capability-service-tnpR_TaB.mjs +1 -0
  22. package/dist/chunk-Dc06z0qk.mjs +1 -0
  23. package/dist/chunk-cpUYaJdV.mjs +1 -0
  24. package/dist/cleanEnvForAdapter-DvcIGXTG.mjs +1 -0
  25. package/dist/client-Dh4x4GQN.mjs +1 -0
  26. package/dist/clients/index.d.mts +2786 -0
  27. package/dist/clients/index.mjs +1 -0
  28. package/dist/clients-namespace-B0xAPZ6J.d.mts +332 -0
  29. package/dist/config-namespace-DLSs83zr.d.mts +638 -0
  30. package/dist/config-namespace-MJT8P0Ud.mjs +1 -0
  31. package/dist/contracts/adapter/index.d.mts +3 -0
  32. package/dist/contracts/adapter/index.mjs +1 -0
  33. package/dist/contracts/adapter/schemas/session-lineage.d.mts +2 -0
  34. package/dist/contracts/adapter/schemas/session-lineage.mjs +1 -0
  35. package/dist/contracts/client/index.d.mts +3 -0
  36. package/dist/contracts/client/index.mjs +1 -0
  37. package/dist/contracts/common/index.d.mts +2 -0
  38. package/dist/contracts/common/index.mjs +1 -0
  39. package/dist/contracts/config/index.d.mts +455 -0
  40. package/dist/contracts/config/index.mjs +1 -0
  41. package/dist/contracts/extension/index.d.mts +3 -0
  42. package/dist/contracts/extension/index.mjs +1 -0
  43. package/dist/contracts/harness/index.d.mts +2 -0
  44. package/dist/contracts/harness/index.mjs +1 -0
  45. package/dist/contracts/host/index.d.mts +2 -0
  46. package/dist/contracts/host/index.mjs +1 -0
  47. package/dist/contracts/index.d.mts +12665 -0
  48. package/dist/contracts/index.mjs +1 -0
  49. package/dist/contracts/model-registry/index.d.mts +2 -0
  50. package/dist/contracts/model-registry/index.mjs +1 -0
  51. package/dist/contracts/native-session-supervisor/index.d.mts +2 -0
  52. package/dist/contracts/native-session-supervisor/index.mjs +1 -0
  53. package/dist/contracts/platform/index.d.mts +2 -0
  54. package/dist/contracts/platform/index.mjs +1 -0
  55. package/dist/contracts/provider/index.d.mts +3 -0
  56. package/dist/contracts/provider/index.mjs +1 -0
  57. package/dist/contracts/session/index.d.mts +3 -0
  58. package/dist/contracts/session/index.mjs +1 -0
  59. package/dist/contracts/shared/index.d.mts +2 -0
  60. package/dist/contracts/shared/index.mjs +1 -0
  61. package/dist/contracts/skill/index.d.mts +2 -0
  62. package/dist/contracts/skill/index.mjs +1 -0
  63. package/dist/contracts/toast/index.d.mts +198 -0
  64. package/dist/contracts/toast/index.mjs +1 -0
  65. package/dist/contracts/variant/index.d.mts +2 -0
  66. package/dist/contracts/variant/index.mjs +1 -0
  67. package/dist/core/index.d.mts +1001 -0
  68. package/dist/core/index.mjs +1 -0
  69. package/dist/credential-ref-DLCsoKVZ.mjs +1 -0
  70. package/dist/cursor-storage-DOQdvo9j.mjs +1 -0
  71. package/dist/definition-DkYy1PZz.mjs +1 -0
  72. package/dist/definition-DtUNiGom.d.mts +158 -0
  73. package/dist/definition-DxvZ9e22.d.mts +376 -0
  74. package/dist/drizzle-CWVVw7Er.mjs +1 -0
  75. package/dist/execution-target-BW_uiBVe.mjs +1 -0
  76. package/dist/extension-COqwS-2Q.mjs +1 -0
  77. package/dist/extension-Cbrl4YGX.mjs +1 -0
  78. package/dist/extension-namespace-zaGKi6Qj.mjs +1 -0
  79. package/dist/handlers-iGKUJ380.mjs +41 -0
  80. package/dist/harness-CEq1Zkf9.mjs +1 -0
  81. package/dist/hooks/index.d.mts +423 -0
  82. package/dist/hooks/index.mjs +1 -0
  83. package/dist/host-CXAUGGN0.mjs +1 -0
  84. package/dist/identity-B_A0mE63.mjs +1 -0
  85. package/dist/index-6lyShOoU.d.mts +225 -0
  86. package/dist/index-7sXlairn2.d.mts +43 -0
  87. package/dist/index-BAKM2GMH2.d.mts +535 -0
  88. package/dist/index-BB419vv-.d.mts +3897 -0
  89. package/dist/index-BJOfdtbw.d.mts +729 -0
  90. package/dist/index-BXP9GK5q.d.mts +1075 -0
  91. package/dist/index-BdPwu6c0.d.mts +1730 -0
  92. package/dist/index-BePI0ckL.d.mts +40 -0
  93. package/dist/index-Bigx81Kr.d.mts +37 -0
  94. package/dist/index-BnNqbx2I.d.mts +134 -0
  95. package/dist/index-Bv15sNLn.d.mts +389 -0
  96. package/dist/index-C-myW_aK.d.mts +412 -0
  97. package/dist/index-C9F3Fc1A.d.mts +2938 -0
  98. package/dist/index-CNxS4Tlu.d.mts +1 -0
  99. package/dist/index-CVA0m1g9.d.mts +995 -0
  100. package/dist/index-C_kS2aqV2.d.mts +438 -0
  101. package/dist/index-Ch3ph52M2.d.mts +40 -0
  102. package/dist/index-CnZOKNjU.d.mts +89 -0
  103. package/dist/index-D1T-PPqF.d.mts +67 -0
  104. package/dist/index-D7T8XCku.d.mts +341 -0
  105. package/dist/index-DBQtpFLE.d.mts +4843 -0
  106. package/dist/index-DEw90pa2.d.mts +183 -0
  107. package/dist/index-DQRsGXb5.d.mts +109 -0
  108. package/dist/index-Dd5s4MSm.d.mts +72 -0
  109. package/dist/index-DubqLGH8.d.mts +1002 -0
  110. package/dist/index-ESSDWIB7.d.mts +11 -0
  111. package/dist/index-N5K1NOYs.d.mts +184 -0
  112. package/dist/index-PdUSmPT2.d.mts +180 -0
  113. package/dist/index-SzSiyG61.d.mts +117 -0
  114. package/dist/index-T0471kWA.d.mts +6760 -0
  115. package/dist/index-WKjrpcA_.d.mts +218 -0
  116. package/dist/index-hapw9_En.d.mts +13592 -0
  117. package/dist/index-iID2R9G1.d.mts +1490 -0
  118. package/dist/kernel/cli/index.d.mts +141 -0
  119. package/dist/kernel/cli/index.mjs +1 -0
  120. package/dist/kernel/cli/schemas.d.mts +63 -0
  121. package/dist/kernel/cli/schemas.mjs +1 -0
  122. package/dist/kernel/extension/index.d.mts +2 -0
  123. package/dist/kernel/extension/index.mjs +1 -0
  124. package/dist/kernel/index.d.mts +296 -0
  125. package/dist/kernel/index.mjs +1 -0
  126. package/dist/kernel/namespace/index.d.mts +2 -0
  127. package/dist/kernel/namespace/index.mjs +1 -0
  128. package/dist/kernel/observability/index.d.mts +2 -0
  129. package/dist/kernel/observability/index.mjs +1 -0
  130. package/dist/kernel/providers/index.d.mts +2 -0
  131. package/dist/kernel/providers/index.mjs +1 -0
  132. package/dist/kernel/window/index.d.mts +2 -0
  133. package/dist/kernel/window/index.mjs +1 -0
  134. package/dist/model-registry-BNzpR6TU.mjs +1 -0
  135. package/dist/model-registry-CIscwC52.mjs +1 -0
  136. package/dist/namespace-0yuzAKlr.mjs +1 -0
  137. package/dist/namespace-8cNguvIp.mjs +1 -0
  138. package/dist/namespace-BK2erxpV.d.mts +921 -0
  139. package/dist/namespace-Bmc7AW4J2.mjs +1 -0
  140. package/dist/namespace-C2ufjgaQ.d.mts +767 -0
  141. package/dist/namespace-C54Oj025.d.mts +159 -0
  142. package/dist/namespace-CCDEOwmW.d.mts +1313 -0
  143. package/dist/namespace-CfEWMXBx.mjs +1 -0
  144. package/dist/namespace-CkLUtc0g.d.mts +580 -0
  145. package/dist/namespace-D5Wrt7YU.mjs +1 -0
  146. package/dist/namespace-DZcuLwEA.d.mts +51 -0
  147. package/dist/namespace-Db-p67Rg.mjs +1 -0
  148. package/dist/namespace-FWx6HxaW.d.mts +611 -0
  149. package/dist/namespace-GLGGcWPH.d.mts +43 -0
  150. package/dist/namespace-N0dfwSg6.mjs +1 -0
  151. package/dist/namespace-O5SNY-LV.d.mts +2226 -0
  152. package/dist/namespace-ZbthBQVt.d.mts +142 -0
  153. package/dist/namespace-bq4Prtzn.d.mts +2046 -0
  154. package/dist/namespace-pNcSglBS.mjs +1 -0
  155. package/dist/namespace-ptv-pw_g.d.mts +3019 -0
  156. package/dist/namespace-xkvVw3hf2.d.mts +189 -0
  157. package/dist/native-session-supervisor-L-UIaEfd.mjs +1 -0
  158. package/dist/node/bus-server/index.d.mts +178 -0
  159. package/dist/node/bus-server/index.mjs +1 -0
  160. package/dist/node/bus-server/server-lifecycle.d.mts +2 -0
  161. package/dist/node/bus-server/server-lifecycle.mjs +1 -0
  162. package/dist/node/machine-identity/index.d.mts +85 -0
  163. package/dist/node/machine-identity/index.mjs +3 -0
  164. package/dist/node/transports/index.d.mts +1752 -0
  165. package/dist/node/transports/index.mjs +2 -0
  166. package/dist/orchestrator-shared-DrjtTXYh.d.mts +249 -0
  167. package/dist/orchestrator-shared-Wv1GI2mW.mjs +1 -0
  168. package/dist/platform-BbSLVg5b.mjs +1 -0
  169. package/dist/profile-4StaDQW0.mjs +1 -0
  170. package/dist/provider-context-CNRQ4d5m.mjs +1 -0
  171. package/dist/providers/index.d.mts +135 -0
  172. package/dist/providers/index.mjs +1 -0
  173. package/dist/providers-Cr4Za8a1.mjs +1 -0
  174. package/dist/providers-namespace-CDwxY_DV.d.mts +583 -0
  175. package/dist/schema-BwzXEtT2.d.mts +837 -0
  176. package/dist/schema-CAw_BqaG.mjs +1 -0
  177. package/dist/schema-introspection-D61TT_7b.mjs +1 -0
  178. package/dist/schema-uSGW-6oM.mjs +1 -0
  179. package/dist/schemas-BXstpWVp.mjs +1 -0
  180. package/dist/schemas-BdMU-gew.d.mts +160 -0
  181. package/dist/schemas-C40ZAJ33.mjs +1 -0
  182. package/dist/schemas-C5xtVqdb.d.mts +46 -0
  183. package/dist/schemas-CGZy_rU6.d.mts +13 -0
  184. package/dist/schemas-CLxtoKFy.mjs +1 -0
  185. package/dist/schemas-Co_sVhzz.mjs +1 -0
  186. package/dist/schemas-D9108Iv1.d.mts +182 -0
  187. package/dist/schemas-DENVYyds.d.mts +463 -0
  188. package/dist/schemas-DbWs_hj8.d.mts +174 -0
  189. package/dist/schemas-Di0XnnMX.d.mts +73 -0
  190. package/dist/schemas-KMA1efQg.d.mts +944 -0
  191. package/dist/schemas-qmn5SWPU.d.mts +312 -0
  192. package/dist/schemas-sshQEF3l.d.mts +237 -0
  193. package/dist/server-lifecycle-Cf_SZ27k.d.mts +160 -0
  194. package/dist/server-lifecycle-DbFwlrTW.mjs +1 -0
  195. package/dist/service-base/index.d.mts +98 -0
  196. package/dist/service-base/index.mjs +1 -0
  197. package/dist/services/adapter-runtime/index.d.mts +4 -0
  198. package/dist/services/adapter-runtime/index.mjs +1 -0
  199. package/dist/services/adapter-runtime/namespace.d.mts +2 -0
  200. package/dist/services/adapter-runtime/namespace.mjs +1 -0
  201. package/dist/services/adapter-runtime/schemas.d.mts +2 -0
  202. package/dist/services/adapter-runtime/schemas.mjs +1 -0
  203. package/dist/services/adapter-subsystem/index.d.mts +3 -0
  204. package/dist/services/adapter-subsystem/index.mjs +1 -0
  205. package/dist/services/adapter-subsystem/namespace.d.mts +2 -0
  206. package/dist/services/adapter-subsystem/namespace.mjs +1 -0
  207. package/dist/services/agent-runtime/index.d.mts +3 -0
  208. package/dist/services/agent-runtime/index.mjs +1 -0
  209. package/dist/services/agent-runtime/namespace.d.mts +2 -0
  210. package/dist/services/agent-runtime/namespace.mjs +1 -0
  211. package/dist/services/agent-runtime/schemas.d.mts +2 -0
  212. package/dist/services/agent-runtime/schemas.mjs +1 -0
  213. package/dist/services/capability/index.d.mts +2 -0
  214. package/dist/services/capability/index.mjs +1 -0
  215. package/dist/services/cli-detection/namespace.d.mts +56 -0
  216. package/dist/services/cli-detection/namespace.mjs +1 -0
  217. package/dist/services/codebase/index.d.mts +3 -0
  218. package/dist/services/codebase/index.mjs +1 -0
  219. package/dist/services/codebase/namespace.d.mts +2 -0
  220. package/dist/services/codebase/namespace.mjs +1 -0
  221. package/dist/services/codebase/schemas.d.mts +2 -0
  222. package/dist/services/codebase/schemas.mjs +1 -0
  223. package/dist/services/compression/index.d.mts +3 -0
  224. package/dist/services/compression/index.mjs +1 -0
  225. package/dist/services/compression/namespace.d.mts +2 -0
  226. package/dist/services/compression/namespace.mjs +1 -0
  227. package/dist/services/compression/schemas.d.mts +2 -0
  228. package/dist/services/compression/schemas.mjs +1 -0
  229. package/dist/services/context-rules/index.d.mts +412 -0
  230. package/dist/services/context-rules/index.mjs +1 -0
  231. package/dist/services/credential-change/index.d.mts +17 -0
  232. package/dist/services/credential-change/index.mjs +1 -0
  233. package/dist/services/definition/index.d.mts +2 -0
  234. package/dist/services/definition/index.mjs +1 -0
  235. package/dist/services/definition/namespace.d.mts +71 -0
  236. package/dist/services/definition/namespace.mjs +1 -0
  237. package/dist/services/definition/schemas.d.mts +38 -0
  238. package/dist/services/definition/schemas.mjs +1 -0
  239. package/dist/services/dialog/namespace.d.mts +105 -0
  240. package/dist/services/dialog/namespace.mjs +1 -0
  241. package/dist/services/dialog/schemas.d.mts +109 -0
  242. package/dist/services/dialog/schemas.mjs +1 -0
  243. package/dist/services/execution-target/index.d.mts +4 -0
  244. package/dist/services/execution-target/index.mjs +1 -0
  245. package/dist/services/execution-target/namespace.d.mts +2 -0
  246. package/dist/services/execution-target/namespace.mjs +1 -0
  247. package/dist/services/execution-target/schemas.d.mts +2 -0
  248. package/dist/services/execution-target/schemas.mjs +1 -0
  249. package/dist/services/filesystem/namespace.d.mts +432 -0
  250. package/dist/services/filesystem/namespace.mjs +1 -0
  251. package/dist/services/filesystem/schemas.d.mts +240 -0
  252. package/dist/services/filesystem/schemas.mjs +1 -0
  253. package/dist/services/harness/index.d.mts +861 -0
  254. package/dist/services/harness/index.mjs +1 -0
  255. package/dist/services/harness/storage/schema.d.mts +424 -0
  256. package/dist/services/harness/storage/schema.mjs +1 -0
  257. package/dist/services/index.d.mts +5703 -0
  258. package/dist/services/index.mjs +1 -0
  259. package/dist/services/local-notification/index.d.mts +25 -0
  260. package/dist/services/local-notification/index.mjs +1 -0
  261. package/dist/services/local-notification/namespace.d.mts +73 -0
  262. package/dist/services/local-notification/namespace.mjs +1 -0
  263. package/dist/services/local-notification/schemas.d.mts +88 -0
  264. package/dist/services/local-notification/schemas.mjs +1 -0
  265. package/dist/services/log-import/browser.d.mts +3 -0
  266. package/dist/services/log-import/browser.mjs +1 -0
  267. package/dist/services/log-import/index.d.mts +275 -0
  268. package/dist/services/log-import/index.mjs +2 -0
  269. package/dist/services/log-import/log-import.d.mts +3 -0
  270. package/dist/services/log-import/log-import.mjs +1 -0
  271. package/dist/services/log-import/namespace.d.mts +327 -0
  272. package/dist/services/log-import/namespace.mjs +1 -0
  273. package/dist/services/log-import/schemas.d.mts +217 -0
  274. package/dist/services/log-import/schemas.mjs +1 -0
  275. package/dist/services/model-registry/index.d.mts +2 -0
  276. package/dist/services/model-registry/index.mjs +1 -0
  277. package/dist/services/preferences/index.d.mts +3 -0
  278. package/dist/services/preferences/index.mjs +1 -0
  279. package/dist/services/preferences/schemas.d.mts +2 -0
  280. package/dist/services/preferences/schemas.mjs +1 -0
  281. package/dist/services/preferences/storage-namespace.d.mts +3 -0
  282. package/dist/services/preferences/storage-namespace.mjs +1 -0
  283. package/dist/services/provider-context/index.d.mts +2 -0
  284. package/dist/services/provider-context/index.mjs +1 -0
  285. package/dist/services/provider-runtime/index.d.mts +136 -0
  286. package/dist/services/provider-runtime/index.mjs +1 -0
  287. package/dist/services/session/handlers/index.d.mts +2 -0
  288. package/dist/services/session/handlers/index.mjs +1 -0
  289. package/dist/services/session/index.d.mts +10 -0
  290. package/dist/services/session/index.mjs +1 -0
  291. package/dist/services/session/messages/namespace.d.mts +2 -0
  292. package/dist/services/session/messages/namespace.mjs +1 -0
  293. package/dist/services/session/orchestrator-testing/index.d.mts +2 -0
  294. package/dist/services/session/orchestrator-testing/index.mjs +1 -0
  295. package/dist/services/session/session-events/namespace.d.mts +2 -0
  296. package/dist/services/session/session-events/namespace.mjs +1 -0
  297. package/dist/services/session/storage/namespace.d.mts +2 -0
  298. package/dist/services/session/storage/namespace.mjs +1 -0
  299. package/dist/services/session/storage/schema.d.mts +2 -0
  300. package/dist/services/session/storage/schema.mjs +1 -0
  301. package/dist/services/session/testing/index.d.mts +35 -0
  302. package/dist/services/session/testing/index.mjs +52 -0
  303. package/dist/services/session/testing/orchestrator-shared.d.mts +2 -0
  304. package/dist/services/session/testing/orchestrator-shared.mjs +1 -0
  305. package/dist/services/session/turns/namespace.d.mts +2 -0
  306. package/dist/services/session/turns/namespace.mjs +1 -0
  307. package/dist/services/session-editor/index.d.mts +119 -0
  308. package/dist/services/session-editor/index.mjs +1 -0
  309. package/dist/services/settings/index.d.mts +47 -0
  310. package/dist/services/settings/index.mjs +1 -0
  311. package/dist/services/settings/namespace.d.mts +662 -0
  312. package/dist/services/settings/namespace.mjs +1 -0
  313. package/dist/services/settings/storage/clients-namespace.d.mts +2 -0
  314. package/dist/services/settings/storage/clients-namespace.mjs +1 -0
  315. package/dist/services/settings/storage/extension-configs/namespace.d.mts +184 -0
  316. package/dist/services/settings/storage/extension-configs/namespace.mjs +1 -0
  317. package/dist/services/settings/storage/index.d.mts +4 -0
  318. package/dist/services/settings/storage/index.mjs +1 -0
  319. package/dist/services/settings/storage/providers-namespace.d.mts +2 -0
  320. package/dist/services/settings/storage/providers-namespace.mjs +1 -0
  321. package/dist/services/tool-approval/index.d.mts +2 -0
  322. package/dist/services/tool-approval/index.mjs +1 -0
  323. package/dist/services/tools/index.d.mts +2 -0
  324. package/dist/services/tools/index.mjs +1 -0
  325. package/dist/services/tray-menu/index.d.mts +4 -0
  326. package/dist/services/tray-menu/index.mjs +1 -0
  327. package/dist/services/tray-menu/namespace.d.mts +2 -0
  328. package/dist/services/tray-menu/namespace.mjs +1 -0
  329. package/dist/services/tray-menu/schemas.d.mts +2 -0
  330. package/dist/services/tray-menu/schemas.mjs +1 -0
  331. package/dist/services/turn/index.d.mts +2 -0
  332. package/dist/services/turn/index.mjs +1 -0
  333. package/dist/services/turn/namespace.d.mts +2 -0
  334. package/dist/services/turn/namespace.mjs +1 -0
  335. package/dist/services/turn/schemas.d.mts +335 -0
  336. package/dist/services/turn/schemas.mjs +1 -0
  337. package/dist/services/worker/index.d.mts +3 -0
  338. package/dist/services/worker/index.mjs +1 -0
  339. package/dist/services/worker/namespace.d.mts +2 -0
  340. package/dist/services/worker/namespace.mjs +1 -0
  341. package/dist/services/worker/schemas.d.mts +2 -0
  342. package/dist/services/worker/schemas.mjs +1 -0
  343. package/dist/session-Do6lDZM4.mjs +123 -0
  344. package/dist/session-lineage-Eev4uo4I.d.mts +65 -0
  345. package/dist/session-piI1R5rP.mjs +1 -0
  346. package/dist/shared-DxHLl9UP.mjs +1 -0
  347. package/dist/shared-schemas-BgQv_tnu.mjs +1 -0
  348. package/dist/skill-CB5h-ZFQ.mjs +1 -0
  349. package/dist/storage/drizzle/client.d.mts +78 -0
  350. package/dist/storage/drizzle/client.mjs +1 -0
  351. package/dist/storage/drizzle/index.d.mts +98 -0
  352. package/dist/storage/drizzle/index.mjs +1 -0
  353. package/dist/storage/handlers/drizzle/index.d.mts +2 -0
  354. package/dist/storage/handlers/drizzle/index.mjs +1 -0
  355. package/dist/storage/handlers/index.d.mts +33 -0
  356. package/dist/storage/handlers/index.mjs +1 -0
  357. package/dist/storage/index.d.mts +192 -0
  358. package/dist/storage/index.mjs +1 -0
  359. package/dist/storage-namespace-ADwyijoe.mjs +1 -0
  360. package/dist/storage-namespace-DAm8iWEj.d.mts +221 -0
  361. package/dist/storage-namespace-definition-CHu2k14q.mjs +1 -0
  362. package/dist/storage-namespace-definition-CJgqyXH1.d.mts +17 -0
  363. package/dist/style.css +3782 -0
  364. package/dist/testing/drizzle-harness.d.mts +130 -0
  365. package/dist/testing/drizzle-harness.mjs +1 -0
  366. package/dist/testing/index.d.mts +106 -0
  367. package/dist/testing/index.mjs +1 -0
  368. package/dist/tool-approval-service-BcBSUZCO.mjs +1 -0
  369. package/dist/tools/index.d.mts +825 -0
  370. package/dist/tools/index.mjs +1 -0
  371. package/dist/tools/testing/index.d.mts +53 -0
  372. package/dist/tools/testing/index.mjs +1 -0
  373. package/dist/tools-CDSgj0ee.mjs +1 -0
  374. package/dist/tray-menu-service-CTXC1Elg.mjs +1 -0
  375. package/dist/types-6WxLfoM3.d.mts +31 -0
  376. package/dist/types-BjToUrHp.d.mts +6619 -0
  377. package/dist/types-CD1LJwPc.d.mts +1009 -0
  378. package/dist/types-Cvrj2ogm.d.mts +305 -0
  379. package/dist/types-DYF5LxZY.d.mts +233 -0
  380. package/dist/types-t295YC6T.d.mts +262 -0
  381. package/dist/types-vNpkAe4Y.d.mts +128 -0
  382. package/dist/ui-components/index.d.mts +2342 -0
  383. package/dist/ui-components/index.mjs +8 -0
  384. package/dist/ui-config-CXmbsqZV.mjs +1 -0
  385. package/dist/ui-hooks/index.d.mts +1805 -0
  386. package/dist/ui-hooks/index.mjs +1 -0
  387. package/dist/ui-kernel/index.d.mts +2793 -0
  388. package/dist/ui-kernel/index.mjs +1 -0
  389. package/dist/ui-kernel/pages/namespace.d.mts +88 -0
  390. package/dist/ui-kernel/pages/namespace.mjs +1 -0
  391. package/dist/ui-kernel/pages/schemas.d.mts +2 -0
  392. package/dist/ui-kernel/pages/schemas.mjs +1 -0
  393. package/dist/ui-views/index.d.mts +487 -0
  394. package/dist/ui-views/index.mjs +30 -0
  395. package/dist/utils/health-probe.d.mts +26 -0
  396. package/dist/utils/health-probe.mjs +1 -0
  397. package/dist/utils/index.d.mts +227 -0
  398. package/dist/utils/index.mjs +2 -0
  399. package/dist/utils/keychain.d.mts +31 -0
  400. package/dist/utils/keychain.mjs +1 -0
  401. package/dist/utils/resolve-package-root.d.mts +12 -0
  402. package/dist/utils/resolve-package-root.mjs +1 -0
  403. package/dist/utils/workspace-root.d.mts +27 -0
  404. package/dist/utils/workspace-root.mjs +2 -0
  405. package/dist/variant-D5kSrL3m.mjs +1 -0
  406. package/dist/version-CjS20oXi.mjs +1 -0
  407. package/dist/visibility-CZu8ooOA.mjs +1 -0
  408. package/dist/window-registry-CUftmDr3.mjs +1 -0
  409. package/dist/window-registry-C_IJmY8_.d.mts +130 -0
  410. package/package.json +346 -0
@@ -0,0 +1,1752 @@
1
+ import { PayloadFilter, TransportReceiveContext } from "@makaio/framework/core";
2
+ import { BusBroadcastMessage, BusEventMessage, BusMessage, BusReceiveHandler, BusRequestMessage, BusTransport, BusTransportError } from "@makaio/framework/bus";
3
+
4
+ //#region transports/ws/src/auth/interface.d.ts
5
+ /**
6
+ * Transport authentication strategy.
7
+ *
8
+ * Implementations authenticate WebSocket connections and manage auth lifecycle.
9
+ * Auth messages are handled during a pre-connect phase before normal message flow begins.
10
+ */
11
+ interface TransportAuth {
12
+ /**
13
+ * Authenticate a client connection.
14
+ *
15
+ * Called during the pre-connect phase after the WebSocket is open but before
16
+ * normal message handling begins. Auth messages flow through handleAuthMessage().
17
+ * @param send - Function to send auth messages to the server
18
+ * @throws Error if authentication fails
19
+ */
20
+ authenticateClient(send: (message: unknown) => void): Promise<void>;
21
+ /**
22
+ * Authenticate a server connection with a specific client socket.
23
+ *
24
+ * Called when a new client connects to the server, during the pre-connect phase.
25
+ * @param socket - The client WebSocket connection to authenticate
26
+ * @param send - Function to send auth messages to the client
27
+ * @throws Error if authentication fails
28
+ */
29
+ authenticateServer(socket: WebSocketLike, send: (message: unknown) => void): Promise<void>;
30
+ /**
31
+ * Handle incoming message during authentication phase.
32
+ *
33
+ * This is called by the transport's message handler to route auth messages
34
+ * to the auth implementation during the pre-connect phase.
35
+ * @param message - Parsed message object
36
+ * @param socket - Optional socket identifier for server-side multi-client scenarios
37
+ * @returns true if the message was an auth message and was handled, false otherwise
38
+ */
39
+ handleAuthMessage(message: unknown, socket?: WebSocketLike): boolean;
40
+ /**
41
+ * Return trusted receive context for a socket after authentication.
42
+ *
43
+ * Server transports call this when routing inbound bus messages from the
44
+ * socket. Undefined means the auth strategy has no context to expose.
45
+ * @param socket - Optional socket for server-side multi-client transports
46
+ * @returns Trusted local receive context, or undefined
47
+ */
48
+ getReceiveContext?(socket?: WebSocketLike): TransportReceiveContext | undefined;
49
+ /**
50
+ * Clean up authentication resources for a specific socket.
51
+ *
52
+ * Called when a socket disconnects to immediately release per-socket resources like:
53
+ * - Pending authentication state
54
+ * - Authentication timers for that socket
55
+ * - Socket-specific auth data
56
+ *
57
+ * This prevents memory leaks when sockets disconnect during authentication.
58
+ * @param socket - The socket to clean up auth resources for
59
+ */
60
+ cleanupSocket(socket: WebSocketLike): void;
61
+ /**
62
+ * Clean up authentication resources.
63
+ *
64
+ * Called during disconnect() to release resources like:
65
+ * - Authentication timers
66
+ * - Token refresh intervals
67
+ * - Event listeners
68
+ * - Cached credentials
69
+ */
70
+ cleanup(): void;
71
+ }
72
+ //#endregion
73
+ //#region transports/ws/src/auth/hmac-auth.d.ts
74
+ /**
75
+ * HMAC authentication configuration.
76
+ */
77
+ interface HmacAuthOptions {
78
+ /**
79
+ * Shared secret for HMAC computation.
80
+ *
81
+ * IMPORTANT: This should be a strong, randomly-generated secret.
82
+ * Both client and server must use the same secret.
83
+ */
84
+ secret: string;
85
+ /**
86
+ * HMAC algorithm to use.
87
+ * @defaultValue 'sha256'
88
+ */
89
+ algorithm?: string;
90
+ /**
91
+ * Timeout for authentication challenge in milliseconds.
92
+ *
93
+ * If client doesn't respond within this time, authentication fails.
94
+ * @defaultValue 5000
95
+ */
96
+ challengeTimeout?: number;
97
+ }
98
+ /**
99
+ * HMAC challenge/response authentication implementation.
100
+ * @example
101
+ * ```typescript
102
+ * const auth = new HmacAuth({
103
+ * secret: process.env.WEBSOCKET_SECRET,
104
+ * algorithm: 'sha256',
105
+ * challengeTimeout: 5000,
106
+ * });
107
+ *
108
+ * const transport = createClientTransport({
109
+ * websocket: ws,
110
+ * auth,
111
+ * });
112
+ * ```
113
+ */
114
+ declare class HmacAuth implements TransportAuth {
115
+ private readonly secret;
116
+ private readonly algorithm;
117
+ private readonly challengeTimeout;
118
+ private pendingChallenge?;
119
+ private pendingResult?;
120
+ private queuedChallengeNonce;
121
+ private queuedResult;
122
+ private clientAuthComplete;
123
+ private serverPendingResponses;
124
+ constructor(options: HmacAuthOptions);
125
+ /**
126
+ * Server-side authentication flow.
127
+ *
128
+ * 1. Generate random nonce
129
+ * 2. Send auth-challenge to client
130
+ * 3. Wait for auth-response with signature (via handleAuthMessage)
131
+ * 4. Verify signature matches HMAC(secret, nonce)
132
+ * 5. Send auth-result
133
+ * @param socket - The client WebSocket connection to authenticate
134
+ * @param send - Function to send auth messages to the client
135
+ * @throws Error if authentication fails
136
+ */
137
+ authenticateServer(socket: WebSocketLike, send: (message: unknown) => void): Promise<void>;
138
+ /**
139
+ * Client-side authentication flow.
140
+ *
141
+ * 1. Wait for auth-challenge from server (via handleAuthMessage)
142
+ * 2. Compute signature = HMAC(secret, nonce)
143
+ * 3. Send auth-response with signature
144
+ * 4. Wait for auth-result (via handleAuthMessage)
145
+ * 5. Throw if authentication failed
146
+ * @param send - Function to send auth messages to the server
147
+ * @throws Error if authentication fails
148
+ */
149
+ authenticateClient(send: (message: unknown) => void): Promise<void>;
150
+ /**
151
+ * Handle incoming message during authentication phase.
152
+ *
153
+ * Routes auth messages to the appropriate pending operation.
154
+ * ALWAYS consumes auth message types to prevent them from leaking to regular handlers.
155
+ * @param message - Parsed message object
156
+ * @param socket - Optional socket identifier for server-side multi-client scenarios
157
+ * @returns true if the message was an auth message (consumed regardless of pending state)
158
+ */
159
+ handleAuthMessage(message: unknown, socket?: WebSocketLike): boolean;
160
+ /**
161
+ * Wait for auth-challenge message from server.
162
+ *
163
+ * Message will be delivered via handleAuthMessage().
164
+ * @returns The nonce from the challenge
165
+ * @throws Error if timeout
166
+ */
167
+ private waitForAuthChallenge;
168
+ /**
169
+ * Wait for auth-response message from client.
170
+ *
171
+ * Message will be delivered via handleAuthMessage().
172
+ * @param socket - The client socket to track
173
+ * @returns The signature from the response
174
+ * @throws Error if timeout
175
+ */
176
+ private waitForAuthResponse;
177
+ /**
178
+ * Wait for auth-result message from server.
179
+ *
180
+ * Message will be delivered via handleAuthMessage().
181
+ * @returns The authentication result
182
+ * @throws Error if timeout
183
+ */
184
+ private waitForAuthResult;
185
+ /**
186
+ * Compute HMAC signature for a nonce using Web Crypto API.
187
+ * @param nonce - The nonce to sign
188
+ * @returns Promise resolving to hex-encoded HMAC signature
189
+ */
190
+ private computeHmac;
191
+ /**
192
+ * Send auth result messages without masking the original auth error.
193
+ *
194
+ * Disconnect races can make `send` throw after auth already failed; callers
195
+ * should still observe the original failure reason.
196
+ * @param send - Transport send function
197
+ * @param message - Auth result message payload
198
+ */
199
+ private sendAuthResultBestEffort;
200
+ /**
201
+ * Clean up authentication resources for a specific socket.
202
+ *
203
+ * Called when a socket disconnects to immediately release resources
204
+ * and prevent memory leaks during the authentication timeout window.
205
+ * @param socket - The socket to clean up
206
+ */
207
+ cleanupSocket(socket: WebSocketLike): void;
208
+ /**
209
+ * Clean up authentication resources.
210
+ *
211
+ * Clears any pending authentication operations and their timeouts.
212
+ */
213
+ cleanup(): void;
214
+ }
215
+ //#endregion
216
+ //#region transports/ws/src/auth/e2e-auth.d.ts
217
+ /**
218
+ * E2E authentication configuration.
219
+ */
220
+ interface E2EAuthOptions {
221
+ /** Our static identity keypair for signing (ECDSA P-256) */
222
+ signingKeyPair: CryptoKeyPair;
223
+ /** Our identifier (deviceId for browser, machineId for server) */
224
+ identityId: string;
225
+ /** Expected peer identifier (required for browser connections; machineId from QR payload) */
226
+ peerId?: string;
227
+ /** Lookup peer's signing public key by their identity */
228
+ getPeerSigningKey: (peerId: string) => Promise<CryptoKey | null>;
229
+ /** Auth timeout in milliseconds. @defaultValue 10000 */
230
+ timeout?: number;
231
+ }
232
+ /**
233
+ * E2E authenticated encryption implementation.
234
+ */
235
+ declare class E2EAuth implements TransportAuth {
236
+ private readonly signingKeyPair;
237
+ private readonly identityId;
238
+ private readonly peerId?;
239
+ private readonly getPeerSigningKey;
240
+ private readonly timeout;
241
+ private pendingKeyExchange?;
242
+ private pendingResult?;
243
+ private clientSession?;
244
+ private clientEphemeralKeyPair?;
245
+ private serverPendingKeyExchange;
246
+ private serverSessions;
247
+ private serverEphemeralKeyPairs;
248
+ constructor(options: E2EAuthOptions);
249
+ /**
250
+ * Client-side authentication flow.
251
+ *
252
+ * If an error occurs after pending promises are created, they are cleaned up
253
+ * before rethrowing to prevent unhandled rejections from lingering timeouts.
254
+ * @param send - Function to send auth messages to the server
255
+ */
256
+ authenticateClient(send: (message: unknown) => void): Promise<void>;
257
+ /**
258
+ * Server-side authentication flow.
259
+ * @param socket - The client WebSocket connection to authenticate
260
+ * @param send - Function to send auth messages to the client
261
+ */
262
+ authenticateServer(socket: WebSocketLike, send: (message: unknown) => void): Promise<void>;
263
+ /**
264
+ * Handle incoming message during authentication phase.
265
+ * @param message - Parsed message object
266
+ * @param socket - Optional socket identifier for server-side
267
+ * @returns true if the message was an E2E auth message
268
+ */
269
+ handleAuthMessage(message: unknown, socket?: WebSocketLike): boolean;
270
+ private waitForKeyExchangeResponse;
271
+ private waitForAuthResult;
272
+ private waitForClientKeyExchange;
273
+ /**
274
+ * Get the derived AES-256-GCM session key for encrypting/decrypting payloads.
275
+ * @param socket - Optional socket (server-side only)
276
+ * @returns Session key if authenticated, null otherwise
277
+ */
278
+ getSessionKey(socket?: WebSocketLike): CryptoKey | null;
279
+ /**
280
+ * Get the peer's identity ID authenticated during handshake.
281
+ * @param socket - Optional socket (server-side only)
282
+ * @returns Peer ID if authenticated, null otherwise
283
+ */
284
+ getPeerId(socket?: WebSocketLike): string | null;
285
+ /**
286
+ * Clean up authentication resources for a specific socket.
287
+ * @param socket - The socket to clean up
288
+ */
289
+ cleanupSocket(socket: WebSocketLike): void;
290
+ /**
291
+ * Clean up authentication resources.
292
+ */
293
+ cleanup(): void;
294
+ }
295
+ //#endregion
296
+ //#region transports/ws/src/auth/e2e-relay-auth.d.ts
297
+ type RelayAuthMode = 'initiator' | 'responder';
298
+ /**
299
+ * Configuration for relay-mode E2E authentication.
300
+ */
301
+ interface E2ERelayAuthOptions {
302
+ /** Static ECDSA signing keypair */
303
+ signingKeyPair: CryptoKeyPair;
304
+ /** Local identity ID */
305
+ identityId: string;
306
+ /** Lookup peer signing key by identity */
307
+ getPeerSigningKey: (peerId: string) => Promise<CryptoKey | null>;
308
+ /** Auth timeout in milliseconds. @defaultValue 10000 */
309
+ timeout?: number;
310
+ /**
311
+ * Relay handshake mode.
312
+ * - initiator: sends exchange immediately (browser)
313
+ * - responder: waits for peer exchange before responding (machine)
314
+ * @defaultValue "initiator"
315
+ */
316
+ mode?: RelayAuthMode;
317
+ /**
318
+ * Whether authenticateClient should block until handshake completes.
319
+ * Use false for machine-side relay connections to avoid startup stalls
320
+ * when no browser is connected.
321
+ * @defaultValue true
322
+ */
323
+ blocking?: boolean;
324
+ }
325
+ /**
326
+ * Relay-mode E2E authentication implementation.
327
+ */
328
+ declare class E2ERelayAuth implements TransportAuth {
329
+ private readonly signingKeyPair;
330
+ private readonly identityId;
331
+ private readonly getPeerSigningKey;
332
+ private readonly timeout;
333
+ private readonly mode;
334
+ private readonly blocking;
335
+ private pendingPeer?;
336
+ private sessionKey?;
337
+ private peerId?;
338
+ private localEphemeral?;
339
+ private localExchangeMessage?;
340
+ private sentLocalExchange;
341
+ private earlyPeer?;
342
+ private sendAuthMessage?;
343
+ /**
344
+ * Monotonically increasing counter to invalidate stale async
345
+ * `processPeerExchange` tasks from previous sessions.
346
+ */
347
+ private authGeneration;
348
+ /**
349
+ * True while a non-blocking `processPeerExchange` is in flight.
350
+ * Prevents duplicate dispatches when the initiator sends its exchange
351
+ * twice (initial + confirmation after deriving its own key).
352
+ */
353
+ private processingExchange;
354
+ constructor(options: E2ERelayAuthOptions);
355
+ /**
356
+ * Client-side authentication flow (relay mode).
357
+ *
358
+ * Resets all derived session state before starting a fresh handshake so that
359
+ * this instance can be reused across WebSocketClientTransport reconnections.
360
+ * Constructor-time config (`signingKeyPair`, `identityId`, `getPeerSigningKey`,
361
+ * `mode`, `blocking`) is intentionally preserved by `cleanup()`.
362
+ * @param send - Function to send auth messages to peer via relay
363
+ */
364
+ authenticateClient(send: (message: unknown) => void): Promise<void>;
365
+ /**
366
+ * Server-side auth is not used in relay mode.
367
+ *
368
+ * No `cleanup()` call is needed here: this method throws unconditionally
369
+ * before setting any session state, so there is nothing to reset.
370
+ * @param _socket - WebSocket connection (unused)
371
+ * @param _send - Auth send function (unused)
372
+ */
373
+ authenticateServer(_socket: WebSocketLike, _send: (message: unknown) => void): Promise<void>;
374
+ /**
375
+ * Handle incoming message during authentication phase.
376
+ * @param message - Parsed message
377
+ * @returns true if handled
378
+ */
379
+ handleAuthMessage(message: unknown): boolean;
380
+ cleanupSocket(_socket: WebSocketLike): void;
381
+ cleanup(): void;
382
+ /**
383
+ * Fire-and-forget `processPeerExchange` with `processingExchange` tracking
384
+ * and generation-guarded cleanup.
385
+ * @param peer - Peer key-exchange message
386
+ * @param generation - Auth generation at dispatch time
387
+ */
388
+ private dispatchPeerExchange;
389
+ /**
390
+ * Get derived session key after handshake.
391
+ * @returns Session key or null
392
+ */
393
+ getSessionKey(): CryptoKey | null;
394
+ /**
395
+ * Get peer identity ID after handshake.
396
+ * @returns Peer identity ID or null
397
+ */
398
+ getPeerId(): string | null;
399
+ private waitForPeerExchange;
400
+ private ensureLocalExchangeMessage;
401
+ private sendLocalExchange;
402
+ /**
403
+ * Retry the latest queued peer exchange after an in-flight attempt settles.
404
+ *
405
+ * Non-blocking relay auth can receive a newer peer exchange while the current
406
+ * one is still deriving keys. WebSocketClientTransport reconnects are already
407
+ * generation-scoped; this helper only re-dispatches messages queued within the
408
+ * same live auth session so newer exchanges are not stranded behind a failure.
409
+ * @param generation - Auth generation that just finished processing
410
+ */
411
+ private retryQueuedPeerExchange;
412
+ /**
413
+ * Verify the peer's exchange, derive the shared session key, and store it.
414
+ *
415
+ * The `generation` parameter prevents stale async tasks from a previous
416
+ * session from overwriting the current session's keys. Each call to
417
+ * `authenticateClient` increments `authGeneration`; if a task's generation
418
+ * no longer matches, it silently aborts before writing any state.
419
+ * @param peer - Peer key-exchange message
420
+ * @param generation - Auth generation at dispatch time
421
+ */
422
+ private processPeerExchange;
423
+ }
424
+ //#endregion
425
+ //#region transports/ws/src/auth/dispatching-auth.d.ts
426
+ /**
427
+ * Options for creating a dispatching auth strategy.
428
+ */
429
+ interface DispatchingAuthOptions {
430
+ /** Auth strategy for HMAC challenge/response clients. */
431
+ hmac?: TransportAuth;
432
+ /** Auth strategy for E2E key-exchange clients. */
433
+ e2e?: TransportAuth;
434
+ }
435
+ /**
436
+ * Auth dispatcher that routes to the appropriate strategy based on the first
437
+ * auth message type received from the client.
438
+ *
439
+ * Enables a single bus server port to accept both HMAC-authenticated
440
+ * connections (e.g., Electron) and E2E-authenticated connections (e.g., mobile).
441
+ *
442
+ * ### How it works
443
+ *
444
+ * HMAC auth is server-initiated (the server sends a challenge before any client
445
+ * message arrives). E2E auth is client-initiated (the client sends `e2e-key-exchange`
446
+ * as its first message). This creates a dispatch ordering problem: the dispatcher
447
+ * cannot wait for the client's first message before deciding which strategy to use,
448
+ * because HMAC requires the server to act first.
449
+ *
450
+ * The solution:
451
+ *
452
+ * **Single strategy**: If only one strategy is configured, `authenticateServer`
453
+ * delegates immediately — no dispatch needed, no ordering constraint.
454
+ *
455
+ * **Both strategies**: `authenticateServer` calls `hmac.authenticateServer()`
456
+ * eagerly so HMAC can send its challenge right away. It then waits for the
457
+ * client's first message to determine the winner:
458
+ * - `auth-response` → HMAC is already running; forward and let it complete.
459
+ * - `e2e-key-exchange` → E2E wins; cancel HMAC (its pending promise is
460
+ * rejected via `cleanupSocket`), start `e2e.authenticateServer()`, and
461
+ * forward the message to E2E.
462
+ *
463
+ * A cancellation flag on the `send` wrapper given to HMAC prevents HMAC's
464
+ * error path from sending spurious `auth-result: false` to E2E clients.
465
+ * @example
466
+ * ```typescript
467
+ * const auth = new DispatchingAuth({
468
+ * hmac: new HmacAuth({ secret: process.env.BUS_SECRET! }),
469
+ * e2e: new E2EAuth({ ... }),
470
+ * });
471
+ *
472
+ * const server = createBusServer({ websocket: wss, auth });
473
+ * ```
474
+ */
475
+ declare class DispatchingAuth implements TransportAuth {
476
+ private readonly hmac;
477
+ private e2e;
478
+ /** Maps each socket to its resolved auth strategy after the first message. */
479
+ private readonly socketStrategy;
480
+ /**
481
+ * Maps each socket to its pending server-auth state while we wait for the
482
+ * first client message to determine the appropriate strategy.
483
+ */
484
+ private readonly pendingServerAuth;
485
+ /**
486
+ * Per-socket cancellation flags for eagerly-started HMAC auth.
487
+ *
488
+ * When E2E wins the dispatch race, the flag is set to `true` so the `send`
489
+ * wrapper passed to HMAC becomes a no-op, preventing spurious `auth-result`
490
+ * failure messages from reaching the E2E client.
491
+ */
492
+ private readonly hmacCancelled;
493
+ /**
494
+ * @param options - Auth strategies to dispatch between
495
+ */
496
+ constructor(options: DispatchingAuthOptions);
497
+ /**
498
+ * Set or replace the E2E authentication strategy after construction.
499
+ *
500
+ * Used in transport-first boot sequences where the bus server starts with
501
+ * HMAC-only auth and E2E auth is wired in later, once machine identity
502
+ * (e.g. LAN keypair) becomes available. Only affects new connection
503
+ * handshakes — in-flight authentications are unaffected.
504
+ * @param e2e - The E2E auth strategy to register
505
+ */
506
+ setE2EAuth(e2e: TransportAuth): void;
507
+ /**
508
+ * Authenticate a client connection.
509
+ *
510
+ * The dispatcher is a server-side concern; clients always know which strategy
511
+ * they are using. This method delegates to the first configured strategy as a
512
+ * fallback, or throws if no strategy is configured.
513
+ * @param send - Function to send auth messages to the server
514
+ * @returns Promise that resolves when client authentication is complete
515
+ * @throws Error if no auth strategy is configured
516
+ */
517
+ authenticateClient(send: (message: unknown) => void): Promise<void>;
518
+ /**
519
+ * Authenticate a server connection with a specific client socket.
520
+ *
521
+ * **Single strategy**: delegates immediately to the configured strategy.
522
+ *
523
+ * **Both strategies**: starts HMAC eagerly (so it can send its challenge),
524
+ * then parks a pending promise that resolves or rejects once
525
+ * `handleAuthMessage` receives the first client message and determines the
526
+ * winner. If E2E wins, HMAC is cancelled via `cleanupSocket`.
527
+ * @param socket - The client WebSocket connection to authenticate
528
+ * @param send - Function to send auth messages to the client
529
+ * @returns Promise that resolves when server authentication is complete
530
+ * @throws Error if no strategy matches the client's auth type, or if the
531
+ * delegated strategy rejects authentication
532
+ */
533
+ authenticateServer(socket: WebSocketLike, send: (message: unknown) => void): Promise<void>;
534
+ /**
535
+ * Handle incoming message during authentication phase.
536
+ *
537
+ * On the first message for an unknown socket, peeks at `message.type` to
538
+ * select a strategy, then delegates `authenticateServer` and this message
539
+ * to the selected strategy. Subsequent messages for the same socket are
540
+ * forwarded directly.
541
+ * @param message - Parsed message object
542
+ * @param socket - Optional socket identifier for server-side multi-client scenarios
543
+ * @returns true if the message was handled as an auth message, false otherwise
544
+ */
545
+ handleAuthMessage(message: unknown, socket?: WebSocketLike): boolean;
546
+ /**
547
+ * Clean up authentication resources for a specific socket.
548
+ *
549
+ * Delegates to the resolved strategy if one was selected, then removes
550
+ * all per-socket state held by the dispatcher itself.
551
+ * @param socket - The socket to clean up auth resources for
552
+ */
553
+ cleanupSocket(socket: WebSocketLike): void;
554
+ /**
555
+ * Clean up all authentication resources.
556
+ *
557
+ * Calls `cleanup` on both configured strategies (if present) and clears
558
+ * all internal maps.
559
+ */
560
+ cleanup(): void;
561
+ /**
562
+ * Peek at the `type` field of an unknown message without a full parse.
563
+ * @param message - Raw parsed message object
564
+ * @returns The string value of `message.type`, or `undefined`
565
+ */
566
+ private peekType;
567
+ /**
568
+ * Returns the single configured strategy, or `undefined` if both or neither
569
+ * are configured.
570
+ *
571
+ * Used by `authenticateServer` to short-circuit dispatch when only one
572
+ * strategy is present.
573
+ * @returns The sole configured strategy, or `undefined`
574
+ */
575
+ private resolveSingleStrategy;
576
+ /**
577
+ * Select the appropriate strategy based on the first auth message type.
578
+ *
579
+ * HMAC clients send `auth-response` as their first message (the server
580
+ * already sent `auth-challenge` eagerly). E2E clients send `e2e-key-exchange`.
581
+ * @param message - The first auth message received from the client
582
+ * @returns The matching strategy, or `undefined` if none matches
583
+ */
584
+ private resolveStrategy;
585
+ /**
586
+ * Cancel the eagerly-started HMAC authentication for a socket.
587
+ *
588
+ * Sets the cancellation flag (preventing spurious `send` calls from HMAC's
589
+ * error path) and calls `hmac.cleanupSocket` to reject HMAC's pending
590
+ * response promise and release its resources.
591
+ * @param socket - The socket whose HMAC auth should be cancelled
592
+ */
593
+ private cancelHmac;
594
+ }
595
+ //#endregion
596
+ //#region transports/ws/src/types.d.ts
597
+ /**
598
+ * Transport-level close event shape.
599
+ *
600
+ * Browser `CloseEvent` is not available in every runtime that implements this
601
+ * duck-typed WebSocket contract (for example Bun server handlers running under
602
+ * Node-based test runners), but transport consumers only rely on the close
603
+ * code and reason.
604
+ */
605
+ interface WebSocketCloseEvent extends Event {
606
+ /**
607
+ * WebSocket close status code.
608
+ */
609
+ readonly code: number;
610
+ /**
611
+ * Human-readable close reason.
612
+ */
613
+ readonly reason: string;
614
+ }
615
+ /**
616
+ * Create a transport-level close event without depending on the browser-only
617
+ * `CloseEvent` global.
618
+ * @param code - WebSocket close code.
619
+ * @param reason - Human-readable close reason.
620
+ * @returns Portable close event for {@link WebSocketLike} listeners.
621
+ */
622
+ declare function createWebSocketCloseEvent(code?: number, reason?: string): WebSocketCloseEvent;
623
+ /**
624
+ * Client-side WebSocket interface.
625
+ *
626
+ * Compatible with browser WebSocket API and ws.WebSocket.
627
+ */
628
+ interface WebSocketLike {
629
+ /**
630
+ * Send data over the WebSocket connection.
631
+ * @param data - Data to send (string, binary buffer, or Blob)
632
+ */
633
+ send(data: string | BufferSource | Blob): void;
634
+ /**
635
+ * Close the WebSocket connection.
636
+ * @param code - Close code (optional)
637
+ * @param reason - Close reason (optional)
638
+ */
639
+ close(code?: number, reason?: string): void;
640
+ /**
641
+ * Add an event listener.
642
+ * @param event - Event type
643
+ * @param listener - Event listener function
644
+ */
645
+ addEventListener(event: 'message', listener: (event: MessageEvent) => void): void;
646
+ addEventListener(event: 'error', listener: (event: Event) => void): void;
647
+ addEventListener(event: 'close', listener: (event: WebSocketCloseEvent) => void): void;
648
+ addEventListener(event: 'open', listener: (event: Event) => void): void;
649
+ /**
650
+ * Remove an event listener.
651
+ * @param event - Event type
652
+ * @param listener - Event listener function
653
+ */
654
+ removeEventListener(event: 'message', listener: (event: MessageEvent) => void): void;
655
+ removeEventListener(event: 'error', listener: (event: Event) => void): void;
656
+ removeEventListener(event: 'close', listener: (event: WebSocketCloseEvent) => void): void;
657
+ removeEventListener(event: 'open', listener: (event: Event) => void): void;
658
+ /**
659
+ * Current connection state.
660
+ */
661
+ readonly readyState: number;
662
+ }
663
+ /**
664
+ * Server-side WebSocketServer interface.
665
+ *
666
+ * Compatible with ws.WebSocketServer.
667
+ */
668
+ interface WebSocketServerLike {
669
+ /**
670
+ * Register a connection handler.
671
+ * @param event - Event type
672
+ * @param listener - Event listener function
673
+ */
674
+ on(event: 'connection', listener: (socket: WebSocketLike) => void): void;
675
+ on(event: 'error', listener: (error: Error) => void): void;
676
+ on(event: 'close', listener: () => void): void;
677
+ /**
678
+ * Remove an event listener.
679
+ * @param event - Event type
680
+ * @param listener - Event listener function
681
+ */
682
+ off(event: 'connection', listener: (socket: WebSocketLike) => void): void;
683
+ off(event: 'error', listener: (error: Error) => void): void;
684
+ off(event: 'close', listener: () => void): void;
685
+ /**
686
+ * Close the WebSocket server.
687
+ * @param callback - Callback when server is closed
688
+ */
689
+ close(callback?: (err?: Error) => void): void;
690
+ }
691
+ /**
692
+ * Shared WebSocket transport configuration.
693
+ */
694
+ interface WebSocketTransportOptionsBase {
695
+ /**
696
+ * Optional authentication strategy.
697
+ */
698
+ auth?: TransportAuth;
699
+ /**
700
+ * Enable debug logging.
701
+ */
702
+ debug?: boolean;
703
+ }
704
+ /**
705
+ * Client-mode WebSocket transport configuration.
706
+ */
707
+ interface WebSocketClientTransportOptions$1 extends WebSocketTransportOptionsBase {
708
+ /**
709
+ * Transport mode: client.
710
+ */
711
+ mode: 'client';
712
+ /**
713
+ * WebSocket instance for client mode.
714
+ */
715
+ websocket: WebSocketLike;
716
+ }
717
+ /**
718
+ * Server-mode WebSocket transport configuration.
719
+ */
720
+ interface WebSocketServerTransportOptions extends WebSocketTransportOptionsBase {
721
+ /**
722
+ * Transport mode: server.
723
+ */
724
+ mode: 'server';
725
+ /**
726
+ * WebSocketServer instance for server mode.
727
+ */
728
+ websocket: WebSocketServerLike;
729
+ }
730
+ /**
731
+ * WebSocket transport configuration (discriminated union).
732
+ */
733
+ type WebSocketTransportOptions = WebSocketClientTransportOptions$1 | WebSocketServerTransportOptions;
734
+ /**
735
+ * Codec for encoding and decoding bus messages on the wire.
736
+ *
737
+ * Implement this interface to add transport-level encryption, custom framing,
738
+ * or any other wire-format transformation. Both client transports
739
+ * (`createClientTransport` and `WebSocketClientTransport`) accept an optional
740
+ * codec and fall back to a plain JSON codec when none is provided.
741
+ */
742
+ interface ClientTransportCodec {
743
+ /**
744
+ * Encode a bus message for transmission.
745
+ * @param message - Bus message to encode
746
+ * @returns Encoded payload to send over the socket
747
+ */
748
+ encode(message: BusMessage): Promise<string | BufferSource>;
749
+ /**
750
+ * Decode a parsed wire message into a bus message.
751
+ * @param message - Parsed message object
752
+ * @returns Bus message
753
+ */
754
+ decode(message: unknown): Promise<BusMessage>;
755
+ }
756
+ //#endregion
757
+ //#region transports/ws/src/ws-client-reconnect.d.ts
758
+ /**
759
+ * Reconnection utilities for `WebSocketClientTransport`.
760
+ *
761
+ * Pure helpers for exponential-backoff timing used by the reconnect loop
762
+ * inside `WebSocketClientTransport`. Kept separate so the main transport
763
+ * module stays focused on the `BusTransport` contract.
764
+ */
765
+ /**
766
+ * Reconnection configuration for `WebSocketClientTransport`.
767
+ *
768
+ * Controls exponential-backoff timing. Pass `false` to the parent options to
769
+ * disable automatic reconnection entirely.
770
+ */
771
+ interface WebSocketClientTransportReconnectOptions {
772
+ /**
773
+ * Base delay in milliseconds for the first reconnect attempt.
774
+ * The effective minimum is 100 ms regardless of the value specified.
775
+ * @defaultValue 1000
776
+ */
777
+ baseMs?: number;
778
+ /**
779
+ * Maximum delay cap in milliseconds.
780
+ * @defaultValue 10000
781
+ */
782
+ maxMs?: number;
783
+ }
784
+ //#endregion
785
+ //#region transports/ws/src/ws-client-options.d.ts
786
+ /**
787
+ * Configuration options for `WebSocketClientTransport`.
788
+ */
789
+ interface WebSocketClientTransportOptions {
790
+ /**
791
+ * WebSocket server URL.
792
+ *
793
+ * The transport creates and recreates the WebSocket internally — callers
794
+ * never pass a `WebSocket` instance directly.
795
+ * @example 'ws://localhost:8080/bus'
796
+ */
797
+ url: string;
798
+ /**
799
+ * Transport identity used for registration in the bus transport registry.
800
+ * @defaultValue 'ws-client'
801
+ */
802
+ name?: string;
803
+ /**
804
+ * Authentication strategy for HMAC or E2E handshakes.
805
+ */
806
+ auth?: TransportAuth;
807
+ /**
808
+ * Wire codec for encryption or custom framing.
809
+ *
810
+ * Defaults to a plain JSON codec with no transformation.
811
+ */
812
+ codec?: ClientTransportCodec;
813
+ /**
814
+ * Optional async transform applied to every incoming message after codec
815
+ * decoding, before correlation tracking and handler dispatch.
816
+ *
817
+ * Use this to inject E2E decryption or message normalization.
818
+ * @param message - Decoded bus message from the wire
819
+ * @returns Transformed message (may be the same reference if unchanged)
820
+ */
821
+ messageTransform?: (message: BusMessage) => Promise<BusMessage>;
822
+ /**
823
+ * Automatic reconnection configuration. Defaults to exponential backoff
824
+ * starting at 1 s and capped at 10 s. Pass `false` to disable automatic
825
+ * reconnection.
826
+ *
827
+ * Note: this configures the reconnection *policy* and is distinct from the
828
+ * imperative {@link WebSocketClientTransport.reconnect} method, which triggers
829
+ * an immediate reconnect attempt.
830
+ * @defaultValue `{ baseMs: 1000, maxMs: 10000 }`
831
+ */
832
+ autoReconnect?: WebSocketClientTransportReconnectOptions | false;
833
+ /**
834
+ * WebSocket constructor factory.
835
+ *
836
+ * Defaults to the `ws` package's `WebSocket` loaded via dynamic import.
837
+ * Override this to provide a browser `WebSocket`, a mock for testing, or any
838
+ * other `WebSocketLike` implementation. The factory may be async so that
839
+ * callers can defer module loading until the first connection attempt.
840
+ * @param url - WebSocket server URL
841
+ * @returns A `WebSocketLike` instance (not yet opened), or a Promise thereof
842
+ */
843
+ createWebSocket?: (url: string) => WebSocketLike | Promise<WebSocketLike>;
844
+ /**
845
+ * Called each time the transport establishes a connection (initial or reconnect).
846
+ *
847
+ * Fired after the socket is open, authentication is complete, and subscriptions
848
+ * have been replayed. Use this to trigger application-level reconnect recovery.
849
+ */
850
+ onConnected?: () => void;
851
+ /**
852
+ * Called each time the transport loses its connection.
853
+ *
854
+ * Fired when the socket closes unexpectedly (not on a clean `disconnect()` call).
855
+ * Use this to activate application-level disconnect recovery logic.
856
+ */
857
+ onDisconnected?: () => void;
858
+ /**
859
+ * Enable verbose debug logging to the console.
860
+ * @defaultValue false
861
+ */
862
+ debug?: boolean;
863
+ }
864
+ //#endregion
865
+ //#region transports/ws/src/ws-client-transport.d.ts
866
+ /**
867
+ * URL-based WebSocket client transport with built-in reconnection.
868
+ *
869
+ * Takes a URL and owns the full connection lifecycle — socket creation,
870
+ * authentication, subscription replay, and exponential-backoff reconnection.
871
+ * Callers never create or pass a `WebSocket` directly.
872
+ * @example
873
+ * ```typescript
874
+ * const transport = new WebSocketClientTransport({ url: 'ws://localhost:8080/bus' });
875
+ * await transport.connect();
876
+ * await transport.subscribe('adapter.*');
877
+ * ```
878
+ */
879
+ declare class WebSocketClientTransport implements BusTransport {
880
+ /** Transport identity for the bus registry. */
881
+ readonly name: string;
882
+ private readonly url;
883
+ private readonly auth;
884
+ private readonly codec;
885
+ private readonly messageTransform;
886
+ private readonly autoReconnectConfig;
887
+ private readonly wsFactory;
888
+ private readonly debug;
889
+ private readonly onConnectedCallback;
890
+ private readonly onDisconnectedCallback;
891
+ private socket;
892
+ private authComplete;
893
+ private readonly correlations;
894
+ private readonly handlers;
895
+ private readonly localSubscriptions;
896
+ private messageListener;
897
+ private closeListener;
898
+ /** AbortController for the active reconnect loop; `null` when not connected. */
899
+ private reconnectAbort;
900
+ /** AbortController for the current backoff sleep; aborting wakes the sleep early. */
901
+ private backoffWakeAbort;
902
+ /**
903
+ * Whether `runReconnectLoop` is currently executing.
904
+ * Used by `reconnect()` to distinguish mid-attempt (no-op) from loop-never-started (retry).
905
+ */
906
+ private reconnectLoopRunning;
907
+ /** Resolver for the current ready promise; `null` once resolved. */
908
+ private readyResolve;
909
+ /** Resolves when the subscribe-sync-complete handshake is received; reset on each reconnect. */
910
+ ready: Promise<void>;
911
+ /** Set by the transport registry to track each session's ready promise for dispatch gating. */
912
+ onNewReadySession: ((promise: Promise<void>) => void) | undefined;
913
+ /** Set by the transport registry; called after auth + subscription replay on each connect. */
914
+ onConnected: (() => void) | undefined;
915
+ /** Set by the transport registry; called when the connection drops unexpectedly. */
916
+ onDisconnected: (() => void) | undefined;
917
+ /**
918
+ * Create a new `WebSocketClientTransport`.
919
+ * @param options - Transport configuration
920
+ */
921
+ constructor(options: WebSocketClientTransportOptions);
922
+ /**
923
+ * Connect to the bus server, authenticate, replay subscriptions, and start
924
+ * the reconnect loop if enabled.
925
+ * @returns Promise that resolves when the initial connection is established
926
+ */
927
+ connect(): Promise<void>;
928
+ /**
929
+ * Disconnect and clean up: stops the reconnect loop, closes the socket,
930
+ * and releases auth, correlation, and handler state.
931
+ * @returns Promise that resolves when the transport is fully disconnected
932
+ */
933
+ disconnect(): Promise<void>;
934
+ /**
935
+ * Send a message over the WebSocket connection.
936
+ * @param message - Bus message to send
937
+ * @param timeout - Correlation timeout in milliseconds; `0` means no automatic timeout
938
+ * @returns Promise resolving to response (requests), results array (broadcasts), or boolean (events)
939
+ */
940
+ send<TMessage extends BusMessage>(message: TMessage, timeout?: number): Promise<TMessage extends BusRequestMessage ? unknown : TMessage extends BusBroadcastMessage ? Array<{
941
+ nodeId: string;
942
+ payload: unknown;
943
+ }> : boolean>;
944
+ /**
945
+ * Register a handler for all inbound messages.
946
+ * @param handler - Invoked for each decoded inbound message
947
+ * @returns Unsubscribe function
948
+ */
949
+ onReceive(handler: (message: BusMessage) => Promise<void>): () => void;
950
+ /**
951
+ * Subscribe to a subject on the server with an optional payload filter.
952
+ *
953
+ * Buffers the subscription for reconnect replay. Sends immediately when the
954
+ * socket is open. See {@link addSubscription} for full semantics.
955
+ * @param subject - Subject pattern (supports wildcards like `'adapter.*'`)
956
+ * @param filter - Optional payload filter for server-side smart-routing
957
+ * @param priorities - Handler priorities registered for this subject
958
+ * @returns Promise that resolves when buffering (and optional send) is complete
959
+ */
960
+ subscribe(subject: string, filter?: PayloadFilter, priorities?: number[]): Promise<void>;
961
+ /**
962
+ * Unsubscribe from a subject on the server.
963
+ *
964
+ * Removes the subject from the replay buffer. Sends immediately when the
965
+ * socket is open. See {@link removeSubscription} for full semantics.
966
+ * @param subject - Subject to unsubscribe from
967
+ * @returns Promise that resolves when the removal (and optional send) is complete
968
+ */
969
+ unsubscribe(subject: string): Promise<void>;
970
+ /** @returns Set of subject patterns currently subscribed. */
971
+ getSubscriptions(): Set<string>;
972
+ /**
973
+ * Cancel a pending correlated request.
974
+ * @param correlationId - Correlation ID to cancel
975
+ * @param error - Optional cancellation error
976
+ */
977
+ cancelRequest(correlationId: string, error?: Error): void;
978
+ /**
979
+ * Returns `true` when the socket is open (`readyState === 1`) and auth has completed.
980
+ * @returns `true` if the transport can send messages
981
+ */
982
+ isReady(): boolean;
983
+ /**
984
+ * Trigger an immediate reconnection attempt.
985
+ *
986
+ * Cancels an active backoff wait, starts the reconnect loop if it stalled,
987
+ * or performs a one-shot connect when auto-reconnect is disabled.
988
+ * @returns Promise that resolves when the attempt is initiated (loop) or completes (one-shot)
989
+ */
990
+ reconnect(): Promise<void>;
991
+ /**
992
+ * Start the background reconnect loop; thin wrapper around `runReconnectLoop`.
993
+ * @param signal - AbortSignal that stops the loop (fires on `disconnect()`)
994
+ * @returns Promise that resolves when the loop exits (signal aborted)
995
+ */
996
+ private startReconnectLoop;
997
+ /**
998
+ * Build a `SubscriptionDeps` snapshot for the subscription helpers.
999
+ * @returns Subscription dependency context bound to this transport instance
1000
+ */
1001
+ private subscriptionDeps;
1002
+ /**
1003
+ * Build the `ConnectionDeps` context for connection lifecycle helpers.
1004
+ * @returns Connection dependency context bound to this transport instance
1005
+ */
1006
+ private connectionDeps;
1007
+ /**
1008
+ * Default `ws`-package WebSocket factory (dynamic import avoids bundling in browsers).
1009
+ * @param url - WebSocket server URL
1010
+ * @returns Promise resolving to a `WebSocketLike` instance
1011
+ */
1012
+ private readonly defaultWsFactory;
1013
+ /**
1014
+ * Wire the no-reconnect close listener; resets `reconnectAbort` on close
1015
+ * so `connect()` can be called again.
1016
+ * @param ws - The connected socket to watch for closure
1017
+ */
1018
+ private wireNoReconnectClose;
1019
+ }
1020
+ //#endregion
1021
+ //#region transports/ws/src/server-transport.d.ts
1022
+ interface ServerTransportOptions {
1023
+ websocket: WebSocketServerLike;
1024
+ /**
1025
+ * Transport identity used as the registry key when registered on a bus.
1026
+ * @defaultValue 'websocket'
1027
+ */
1028
+ name?: string;
1029
+ auth?: TransportAuth;
1030
+ debug?: boolean;
1031
+ }
1032
+ /**
1033
+ * Server-mode WebSocket transport.
1034
+ *
1035
+ * Manages multiple client connections and broadcasts messages to all connected clients.
1036
+ * @example
1037
+ * ```typescript
1038
+ * import { WebSocketServer } from 'ws';
1039
+ *
1040
+ * const wss = new WebSocketServer({ port: 8080 });
1041
+ * const transport = new ServerTransport({
1042
+ * websocket: wss,
1043
+ * });
1044
+ *
1045
+ * await transport.connect();
1046
+ * ```
1047
+ */
1048
+ declare class ServerTransport implements BusTransport {
1049
+ /** Transport identity used as the registry key when registered on a bus. */
1050
+ readonly name: string;
1051
+ private readonly wss;
1052
+ private readonly auth;
1053
+ private readonly debug;
1054
+ private readonly handlers;
1055
+ private readonly registry;
1056
+ /** Server-local handler subjects + priorities, advertised to connected clients. */
1057
+ private readonly serverSubscriptions;
1058
+ private readonly broadcastAggregator;
1059
+ private readonly correlations;
1060
+ private connectionListener;
1061
+ /**
1062
+ * @param options - Server transport configuration
1063
+ */
1064
+ constructor(options: ServerTransportOptions);
1065
+ /**
1066
+ * Send serialized data to a client without letting one socket failure disrupt fan-out.
1067
+ * @param client - Target client socket
1068
+ * @param data - Serialized message payload
1069
+ */
1070
+ private sendToClientSafely;
1071
+ /**
1072
+ * Start listening for client connections.
1073
+ * @throws Error when called while the transport is already connected
1074
+ */
1075
+ connect(): Promise<void>;
1076
+ /**
1077
+ * Stop listening and disconnect all clients.
1078
+ */
1079
+ disconnect(): Promise<void>;
1080
+ /**
1081
+ * Send a broadcast message to all interested clients and aggregate responses.
1082
+ * @param message - Broadcast message to fan out
1083
+ * @param timeout - Broadcast response aggregation timeout in milliseconds. Use `0` to disable automatic timeout and
1084
+ * finalization, which can leave the returned promise pending until every target client responds or disconnects
1085
+ * @returns Promise resolving to aggregated results from all responding handlers
1086
+ */
1087
+ send(message: BusBroadcastMessage, timeout?: number): Promise<Array<{
1088
+ nodeId: string;
1089
+ payload: unknown;
1090
+ }>>;
1091
+ /**
1092
+ * Send a request to connected clients and return the first response.
1093
+ * @param message - Request message
1094
+ * @param timeout - Correlation timeout in milliseconds; `0` means no automatic timeout
1095
+ * @returns Promise resolving to the handler response payload
1096
+ */
1097
+ send(message: BusRequestMessage, timeout?: number): Promise<unknown>;
1098
+ /**
1099
+ * Send an event or other message to all interested clients.
1100
+ * @param message - Bus message to deliver
1101
+ * @param timeout - Correlation timeout in milliseconds; `0` means no automatic timeout
1102
+ * @returns Promise resolving to `true` if delivered to at least one client, `false` otherwise
1103
+ */
1104
+ send(message: BusMessage, timeout?: number): Promise<boolean>;
1105
+ /**
1106
+ * Register a handler for incoming messages from clients.
1107
+ * @param handler - Handler function for incoming messages
1108
+ * @returns Unsubscribe function
1109
+ */
1110
+ onReceive(handler: BusReceiveHandler): () => void;
1111
+ /**
1112
+ * Cancel a pending correlated server-initiated request.
1113
+ * @param correlationId - Correlation ID to cancel
1114
+ * @param error - Optional cancellation error
1115
+ */
1116
+ cancelRequest(correlationId: string, error?: Error): void;
1117
+ /**
1118
+ * Receive aggregated broadcast results from the transport registry.
1119
+ *
1120
+ * Called directly by the transport registry after executing local handlers
1121
+ * and relay transports for a client-initiated broadcast, replacing the
1122
+ * legacy send() side-channel.
1123
+ * @param correlationId - Correlation ID of the originating broadcast
1124
+ * @param results - Aggregated results from local handlers and relay transports
1125
+ * @param error - Optional structured error propagated to the originator
1126
+ */
1127
+ onBroadcastResults(correlationId: string, results: ReadonlyArray<{
1128
+ nodeId: string;
1129
+ payload: unknown;
1130
+ }>, error?: BusTransportError): void;
1131
+ /**
1132
+ * Advertise a server-local handler to all connected WebSocket clients.
1133
+ *
1134
+ * Called by the transport registry when a handler registers on this bus via
1135
+ * `bus.on()`. The full accumulated priority set for the subject is received
1136
+ * (replace semantics, not incremental).
1137
+ * @param subject - Subject pattern
1138
+ * @param filter - Optional payload filter
1139
+ * @param priorities - Handler priorities for priority-based dispatch
1140
+ */
1141
+ subscribe(subject: string, filter?: PayloadFilter, priorities?: number[]): Promise<void>;
1142
+ /**
1143
+ * Return the number of currently authenticated and connected clients.
1144
+ *
1145
+ * Clients that are still in the authentication phase are not counted.
1146
+ * @returns Number of fully connected clients
1147
+ */
1148
+ getConnectionCount(): number;
1149
+ /**
1150
+ * Remove a server-local handler advertisement from all connected clients.
1151
+ * @param subject - Subject pattern to unsubscribe
1152
+ */
1153
+ unsubscribe(subject: string): Promise<void>;
1154
+ }
1155
+ //#endregion
1156
+ //#region transports/ws/src/transport-helpers.d.ts
1157
+ /**
1158
+ * Extract an error message from a WebSocket error event.
1159
+ *
1160
+ * Node `ws` fires `ErrorEvent` (has `.message`), browsers fire a plain `Event`
1161
+ * without it. This helper normalises both shapes into a string.
1162
+ * @param event - The error event from a WebSocket `error` listener
1163
+ * @param fallback - Fallback message when no `.message` property exists
1164
+ * @returns Human-readable error message
1165
+ */
1166
+ declare function extractSocketErrorMessage(event: Event, fallback?: string): string;
1167
+ //#endregion
1168
+ //#region transports/ws/src/create-e2e-transport.d.ts
1169
+ /**
1170
+ * E2E transport configuration.
1171
+ *
1172
+ * The `e2eAuth` instance serves as both the TransportAuth (for the handshake)
1173
+ * and the session key provider (for message encryption/decryption).
1174
+ *
1175
+ * Provide a pre-created `websocket` to wrap a caller-owned socket. All other
1176
+ * options are forwarded to `WebSocketClientTransport` (excluding `auth`,
1177
+ * `messageTransform`, `url`, `createWebSocket`, and `autoReconnect`, which
1178
+ * are managed internally by this factory).
1179
+ */
1180
+ interface E2ETransportOptions extends Omit<WebSocketClientTransportOptions, 'auth' | 'messageTransform' | 'url' | 'createWebSocket' | 'autoReconnect'> {
1181
+ /**
1182
+ * Pre-created WebSocket instance to wrap.
1183
+ *
1184
+ * The factory treats this socket as caller-owned and disables
1185
+ * auto-reconnect. When reconnect is needed, the caller is responsible for
1186
+ * creating new sockets.
1187
+ */
1188
+ websocket: WebSocketLike;
1189
+ /**
1190
+ * E2E auth instance used for both handshake and encryption.
1191
+ */
1192
+ e2eAuth: E2EAuth;
1193
+ }
1194
+ //#endregion
1195
+ //#region transports/ws/src/e2e-client-transport.d.ts
1196
+ /**
1197
+ * E2E client transport configuration.
1198
+ *
1199
+ * The `e2eAuth` instance serves as both the TransportAuth (for the handshake)
1200
+ * and the session key provider (for message encryption/decryption).
1201
+ */
1202
+ type E2EClientTransportOptions = E2ETransportOptions;
1203
+ /**
1204
+ * Create an E2E encrypted client transport.
1205
+ *
1206
+ * Wraps a `WebSocketClientTransport` to transparently encrypt/decrypt
1207
+ * application payload/result/error fields using the session key established
1208
+ * during E2E auth.
1209
+ *
1210
+ * Decryption runs in the `messageTransform` pipeline, so response
1211
+ * correlation sees decrypted results and errors.
1212
+ * @param options - E2E client transport configuration
1213
+ * @returns BusTransport with E2E encryption
1214
+ * @example
1215
+ * ```typescript
1216
+ * const e2eAuth = new E2EAuth({
1217
+ * signingKeyPair,
1218
+ * identityId: deviceId,
1219
+ * peerId: machineId,
1220
+ * getPeerSigningKey: async () => machinePublicKey,
1221
+ * });
1222
+ *
1223
+ * const transport = createE2EClientTransport({
1224
+ * websocket: ws,
1225
+ * e2eAuth,
1226
+ * });
1227
+ *
1228
+ * await transport.connect(); // Runs E2E handshake
1229
+ * // Subsequent application payload/result/error fields are encrypted automatically.
1230
+ * ```
1231
+ */
1232
+ declare function createE2EClientTransport(options: E2EClientTransportOptions): BusTransport;
1233
+ //#endregion
1234
+ //#region transports/ws/src/relay-control-registry.d.ts
1235
+ /**
1236
+ * Registry for relay control subjects.
1237
+ *
1238
+ * Maps namespace/subject pairs to their plaintext (control-plane) classification.
1239
+ * Host code registers control subjects at boot time before freezing the
1240
+ * registry. Once frozen, no further registrations are allowed — this enforces
1241
+ * the security invariant that the plaintext subject set cannot change after the
1242
+ * transport handshake begins.
1243
+ */
1244
+ /**
1245
+ * Mutable-then-frozen registry mapping relay control namespaces and subjects.
1246
+ *
1247
+ * Callers register event subjects and request namespaces before calling
1248
+ * {@link RelayControlRegistry.freeze}. After freezing, all `register*` methods
1249
+ * throw so the set cannot be widened post-handshake.
1250
+ */
1251
+ interface RelayControlRegistry {
1252
+ /**
1253
+ * Register a set of plaintext event subjects for a namespace.
1254
+ *
1255
+ * May be called multiple times for the same namespace — subjects accumulate.
1256
+ * @param namespace - Bus namespace (e.g. `'relay'`)
1257
+ * @param subjects - Subject names to classify as control events
1258
+ * @throws When called after {@link freeze}
1259
+ */
1260
+ registerEventSubjects(namespace: string, subjects: readonly string[]): void;
1261
+ /**
1262
+ * Register an explicit allowlist of plaintext request subjects for a namespace.
1263
+ *
1264
+ * Only the listed subjects will be classified as control-plane (plaintext)
1265
+ * traffic for the given namespace. An explicit allowlist is required — there
1266
+ * is no allow-all mode — to enforce least-privilege classification.
1267
+ * @param namespace - Bus namespace (e.g. `'tunnel'`)
1268
+ * @param subjects - Explicit subject allowlist; must be non-empty
1269
+ * @throws When called after {@link freeze}
1270
+ */
1271
+ registerRequestNamespace(namespace: string, subjects: readonly string[]): void;
1272
+ /**
1273
+ * Freeze the registry.
1274
+ *
1275
+ * After freezing, `registerEventSubjects` and `registerRequestNamespace`
1276
+ * throw on any call. Must be called before passing the registry to the
1277
+ * transport so the security invariant (no post-handshake plaintext injection)
1278
+ * is enforced.
1279
+ */
1280
+ freeze(): void;
1281
+ /**
1282
+ * Check whether the registry has been frozen.
1283
+ *
1284
+ * The transport asserts this is `true` inside `connect()` to guarantee
1285
+ * the plaintext subject set cannot be widened after the handshake begins.
1286
+ * @returns `true` after {@link freeze} has been called
1287
+ */
1288
+ isFrozen(): boolean;
1289
+ /**
1290
+ * Check whether an event message on the given namespace/subject is a control event.
1291
+ * @param namespace - Bus namespace of the event
1292
+ * @param subject - Subject of the event
1293
+ * @returns `true` when this namespace/subject pair is registered as a control event
1294
+ */
1295
+ isControlEvent(namespace: string, subject: string): boolean;
1296
+ /**
1297
+ * Check whether a request on the given namespace/subject is a control request.
1298
+ * @param namespace - Bus namespace of the request
1299
+ * @param subject - Subject of the request
1300
+ * @returns `true` when this namespace/subject pair is registered as a control request
1301
+ */
1302
+ isControlRequest(namespace: string, subject: string): boolean;
1303
+ }
1304
+ /**
1305
+ * Create a new mutable relay control registry.
1306
+ *
1307
+ * The registry starts unfrozen. Call `registerEventSubjects` and
1308
+ * `registerRequestNamespace` to populate it, then call `freeze()` before
1309
+ * passing it to the transport.
1310
+ * @returns A fresh, unfrozen {@link RelayControlRegistry}
1311
+ */
1312
+ declare function createRelayControlRegistry(): RelayControlRegistry;
1313
+ //#endregion
1314
+ //#region transports/ws/src/e2e-relay-client-transport.d.ts
1315
+ /**
1316
+ * E2E relay client transport configuration.
1317
+ *
1318
+ * Provide a pre-created `websocket` to wrap a caller-owned socket. All other
1319
+ * options are forwarded to `WebSocketClientTransport` (excluding `auth`,
1320
+ * `messageTransform`, `url`, `codec`, `createWebSocket`, and `autoReconnect`,
1321
+ * which are managed internally by this factory).
1322
+ */
1323
+ interface E2ERelayClientTransportOptions extends Omit<WebSocketClientTransportOptions, 'auth' | 'messageTransform' | 'url' | 'createWebSocket' | 'codec' | 'autoReconnect'> {
1324
+ /**
1325
+ * Pre-created WebSocket instance to wrap.
1326
+ *
1327
+ * The factory treats this socket as caller-owned and disables
1328
+ * auto-reconnect. When reconnect is needed, the caller is responsible for
1329
+ * creating new sockets.
1330
+ */
1331
+ websocket: WebSocketLike;
1332
+ /**
1333
+ * Relay-mode E2E auth instance.
1334
+ */
1335
+ e2eAuth: E2ERelayAuth;
1336
+ /**
1337
+ * Frozen relay control registry that classifies plaintext control subjects.
1338
+ *
1339
+ * Must be frozen before the transport begins connecting. Determines which
1340
+ * namespace/subject pairs are routed as relay-control envelopes rather than
1341
+ * E2E encrypted messages.
1342
+ */
1343
+ registry: RelayControlRegistry;
1344
+ }
1345
+ /**
1346
+ * Return value of {@link createE2ERelayCodec}.
1347
+ *
1348
+ * The `reset` method clears all tracked relay-control correlation IDs so that
1349
+ * stale IDs from a previous WebSocket session do not bleed into the next E2E
1350
+ * session when the codec is reused across reconnections.
1351
+ */
1352
+ interface E2ERelayCodecHandle {
1353
+ /** Wire codec for E2E relay encryption. */
1354
+ codec: ClientTransportCodec;
1355
+ /**
1356
+ * Clear all relay-control correlation IDs.
1357
+ *
1358
+ * Must be called at the start of each new connection attempt when the same
1359
+ * codec instance is reused across {@link WebSocketClientTransport}
1360
+ * reconnections (e.g. inside `authenticateClient`).
1361
+ */
1362
+ reset: () => void;
1363
+ }
1364
+ /**
1365
+ * Create the wire codec for an E2E encrypted relay transport.
1366
+ *
1367
+ * The codec handles message encryption/decryption and relay-control envelope
1368
+ * routing. Use this when constructing a `WebSocketClientTransport` with E2E
1369
+ * relay encryption instead of the lower-level `createE2ERelayClientTransport`.
1370
+ *
1371
+ * The returned `reset()` method **must** be called at the start of each new
1372
+ * connection attempt when the codec is reused across reconnections. Failing to
1373
+ * reset allows relay-control correlation IDs from a previous session to
1374
+ * influence routing decisions in the new E2E session.
1375
+ * @param e2eAuth - Relay-mode E2E auth instance
1376
+ * @param registry - Frozen relay control registry for subject classification
1377
+ * @param debug - Enable diagnostic logging
1378
+ * @returns Codec handle containing the wire codec and a session-reset function
1379
+ */
1380
+ declare function createE2ERelayCodec(e2eAuth: E2ERelayAuth, registry: RelayControlRegistry, debug?: boolean): E2ERelayCodecHandle;
1381
+ /**
1382
+ * Create an E2E encrypted relay client transport.
1383
+ * @param options - Transport configuration
1384
+ * @returns BusTransport with relay-mode E2E encryption
1385
+ */
1386
+ declare function createE2ERelayClientTransport(options: E2ERelayClientTransportOptions): BusTransport;
1387
+ //#endregion
1388
+ //#region transports/ws/src/relay-control-envelope.d.ts
1389
+ /**
1390
+ * Relay control envelope message shape used on the wire.
1391
+ */
1392
+ interface RelayControlEnvelopeMessage {
1393
+ type: 'relay-control';
1394
+ payload: RelayControlBusMessage;
1395
+ v: 1;
1396
+ }
1397
+ /** Bus message type that may be wrapped in a relay control envelope. */
1398
+ type RelayControlBusMessage = BusEventMessage | BusRequestMessage;
1399
+ /**
1400
+ * Return value of {@link createRelayControlHelpers}.
1401
+ *
1402
+ * All three helpers share the same {@link RelayControlRegistry} captured in
1403
+ * their common closure.
1404
+ */
1405
+ interface RelayControlHelpers {
1406
+ /**
1407
+ * Create a relay control envelope for a relay-owned bus message.
1408
+ *
1409
+ * Throws when the message is not classified as a control message by the
1410
+ * registry (i.e. would not pass {@link isRelayControlBusMessage}).
1411
+ * @param message - Relay bus message to wrap
1412
+ * @returns Relay control envelope message
1413
+ */
1414
+ createRelayControlEnvelope(message: RelayControlBusMessage): RelayControlEnvelopeMessage;
1415
+ /**
1416
+ * Check whether a parsed wire value is a relay control envelope.
1417
+ * @param message - Parsed message candidate
1418
+ * @returns `true` if the value is a relay control envelope
1419
+ */
1420
+ isRelayControlEnvelopeMessage(message: unknown): message is RelayControlEnvelopeMessage;
1421
+ /**
1422
+ * Check whether a bus message is a relay control event or request.
1423
+ * @param message - Bus message candidate
1424
+ * @returns `true` when the message is classified as a relay control message
1425
+ */
1426
+ isRelayControlBusMessage(message: unknown): message is RelayControlBusMessage;
1427
+ }
1428
+ /**
1429
+ * Create relay control envelope helpers bound to a specific registry.
1430
+ *
1431
+ * The registry must be {@link RelayControlRegistry.freeze | frozen} before
1432
+ * calling this function — or at minimum before the transport begins
1433
+ * processing messages — so the security invariant (no post-handshake
1434
+ * plaintext injection) is upheld.
1435
+ * @param registry - Frozen relay control registry
1436
+ * @returns Helper functions with the registry captured in their closure
1437
+ */
1438
+ declare function createRelayControlHelpers(registry: RelayControlRegistry): RelayControlHelpers;
1439
+ //#endregion
1440
+ //#region transports/ws/src/crypto/ecdh.d.ts
1441
+ /**
1442
+ * ECDH (Elliptic Curve Diffie-Hellman) key management using Web Crypto API.
1443
+ *
1444
+ * Implements ECDH P-256 for secure key exchange in E2E encryption.
1445
+ * Uses Web Crypto API for browser and Node.js compatibility.
1446
+ */
1447
+ /**
1448
+ * Generate an ECDH P-256 keypair.
1449
+ *
1450
+ * Creates a new elliptic curve keypair for ECDH key exchange.
1451
+ * The P-256 curve is universally supported by Web Crypto API.
1452
+ * @param extractable - Whether the private key can be exported. Set to false for browser device keys (security), true for Node.js server keys (persistence).
1453
+ * @returns Promise resolving to CryptoKeyPair
1454
+ */
1455
+ declare function generateECDHKeyPair(extractable?: boolean): Promise<CryptoKeyPair>;
1456
+ /**
1457
+ * Export public key to base64url (SPKI format).
1458
+ * @param key - Public CryptoKey to export
1459
+ * @returns Promise resolving to base64url-encoded public key
1460
+ */
1461
+ declare function exportPublicKey(key: CryptoKey): Promise<string>;
1462
+ /**
1463
+ * Export ECDH public key to base64url (raw format).
1464
+ * @param key - Public CryptoKey to export
1465
+ * @returns Base64url-encoded raw public key
1466
+ */
1467
+ declare function exportPublicKeyRaw(key: CryptoKey): Promise<string>;
1468
+ /**
1469
+ * Import ECDH public key from base64url raw format.
1470
+ * @param base64url - Base64url-encoded raw public key
1471
+ * @returns Imported CryptoKey for ECDH operations
1472
+ */
1473
+ declare function importPublicKeyRaw(base64url: string): Promise<CryptoKey>;
1474
+ /**
1475
+ * Import public key from base64url (SPKI format).
1476
+ * @param base64url - Base64url-encoded public key (SPKI format)
1477
+ * @param usages - Key usages (default: empty for public keys used only in deriveBits)
1478
+ * @returns Promise resolving to imported CryptoKey
1479
+ */
1480
+ declare function importPublicKey(base64url: string, usages?: KeyUsage[]): Promise<CryptoKey>;
1481
+ /**
1482
+ * Export private key to PKCS8 PEM format (for Node.js file storage).
1483
+ * @param key - Private CryptoKey to export
1484
+ * @returns Promise resolving to PEM string
1485
+ * @throws Error if key is non-extractable
1486
+ */
1487
+ declare function exportPrivateKeyPEM(key: CryptoKey): Promise<string>;
1488
+ /**
1489
+ * Import private key from PKCS8 PEM format.
1490
+ * @param pem - PEM-encoded private key string
1491
+ * @returns Promise resolving to imported CryptoKey
1492
+ */
1493
+ declare function importPrivateKeyPEM(pem: string): Promise<CryptoKey>;
1494
+ /**
1495
+ * Derive shared secret via ECDH.
1496
+ *
1497
+ * Performs ECDH key agreement: combines own private key with peer's public key
1498
+ * to derive a shared secret. Both parties derive the same secret.
1499
+ * @param privateKey - Own private key
1500
+ * @param publicKey - Peer's public key
1501
+ * @returns Promise resolving to raw shared secret as ArrayBuffer
1502
+ */
1503
+ declare function deriveSharedSecret(privateKey: CryptoKey, publicKey: CryptoKey): Promise<ArrayBuffer>;
1504
+ //#endregion
1505
+ //#region transports/ws/src/crypto/aes-gcm.d.ts
1506
+ /**
1507
+ * AES-256-GCM encryption and decryption using Web Crypto API.
1508
+ *
1509
+ * AES-GCM provides authenticated encryption: both confidentiality
1510
+ * and integrity protection in a single operation.
1511
+ */
1512
+ /**
1513
+ * Encrypt plaintext with AES-256-GCM.
1514
+ *
1515
+ * Generates a random 12-byte nonce and encrypts data.
1516
+ * The nonce must be transmitted alongside the ciphertext for decryption.
1517
+ * @param key - AES-256 CryptoKey
1518
+ * @param plaintext - Data to encrypt (Uint8Array)
1519
+ * @returns Promise resolving to object with ciphertext and nonce
1520
+ * @example
1521
+ * ```typescript
1522
+ * const sessionKey = await deriveSessionKey(...);
1523
+ * const plaintext = encodeText(JSON.stringify(payload));
1524
+ * const { ciphertext, nonce } = await encrypt(sessionKey, plaintext);
1525
+ * // Send both ciphertext and nonce to peer
1526
+ * ```
1527
+ */
1528
+ declare function encrypt(key: CryptoKey, plaintext: Uint8Array): Promise<{
1529
+ ciphertext: Uint8Array;
1530
+ nonce: Uint8Array;
1531
+ }>;
1532
+ /**
1533
+ * Decrypt ciphertext with AES-256-GCM.
1534
+ *
1535
+ * Decrypts data using the same nonce that was used for encryption.
1536
+ * Automatically verifies the authentication tag - throws if data was tampered with.
1537
+ * @param key - AES-256 CryptoKey
1538
+ * @param ciphertext - Encrypted data
1539
+ * @param nonce - 12-byte nonce used during encryption
1540
+ * @returns Promise resolving to decrypted Uint8Array
1541
+ * @throws Error if authentication fails (data tampered with)
1542
+ * @example
1543
+ * ```typescript
1544
+ * const plaintext = await decrypt(sessionKey, ciphertext, nonce);
1545
+ * const payload = JSON.parse(decodeText(plaintext));
1546
+ * ```
1547
+ */
1548
+ declare function decrypt(key: CryptoKey, ciphertext: Uint8Array, nonce: Uint8Array): Promise<Uint8Array>;
1549
+ /**
1550
+ * Import raw AES-256-GCM key.
1551
+ *
1552
+ * Converts raw key material (from HKDF) into a CryptoKey for encryption/decryption.
1553
+ * @param rawKey - 32-byte raw key material (256 bits)
1554
+ * @returns Promise resolving to AES-256 CryptoKey
1555
+ * @example
1556
+ * ```typescript
1557
+ * const rawSessionKey = await deriveSessionKeyRaw(...);
1558
+ * const sessionKey = await importAESKey(rawSessionKey);
1559
+ * ```
1560
+ */
1561
+ declare function importAESKey(rawKey: ArrayBuffer): Promise<CryptoKey>;
1562
+ //#endregion
1563
+ //#region transports/ws/src/crypto/hkdf.d.ts
1564
+ /**
1565
+ * HKDF (HMAC-based Key Derivation Function) using Web Crypto API.
1566
+ *
1567
+ * Derives a session encryption key from ECDH shared secret.
1568
+ * HKDF provides key stretching and domain separation.
1569
+ */
1570
+ /**
1571
+ * Derive AES-256 key from shared secret using HKDF-SHA256.
1572
+ *
1573
+ * Performs HKDF key derivation to convert raw ECDH shared secret
1574
+ * into a proper AES-256 session key. Uses salt for randomness
1575
+ * and info for domain separation.
1576
+ * @param sharedSecret - Raw shared secret from ECDH (ArrayBuffer)
1577
+ * @param salt - Salt bytes (can be random or fixed context). Recommended: 16+ bytes of randomness.
1578
+ * @param info - Context string for domain separation (e.g., "makaio-e2e-session-v1")
1579
+ * @returns Promise resolving to AES-256 CryptoKey
1580
+ * @example
1581
+ * ```typescript
1582
+ * const sharedSecret = await deriveSharedSecret(myPrivateKey, peerPublicKey);
1583
+ * const salt = crypto.getRandomValues(new Uint8Array(16));
1584
+ * const sessionKey = await deriveSessionKey(sharedSecret, salt, "makaio-e2e-session-v1");
1585
+ * ```
1586
+ */
1587
+ declare function deriveSessionKey(sharedSecret: ArrayBuffer, salt: Uint8Array, info: string): Promise<CryptoKey>;
1588
+ //#endregion
1589
+ //#region transports/ws/src/crypto/ecdsa.d.ts
1590
+ /**
1591
+ * ECDSA (Elliptic Curve Digital Signature Algorithm) using Web Crypto API.
1592
+ *
1593
+ * Implements ECDSA P-256 SHA-256 for signing ephemeral public keys
1594
+ * during E2E authentication handshake.
1595
+ */
1596
+ /**
1597
+ * Generate an ECDSA P-256 signing keypair.
1598
+ *
1599
+ * Creates a new elliptic curve keypair for digital signatures.
1600
+ * The P-256 curve with SHA-256 is universally supported by Web Crypto API.
1601
+ * @param extractable - Whether the private key can be exported. Set to false for browser device keys (security), true for Node.js server keys (persistence).
1602
+ * @returns Promise resolving to CryptoKeyPair
1603
+ */
1604
+ declare function generateSigningKeyPair(extractable?: boolean): Promise<CryptoKeyPair>;
1605
+ /**
1606
+ * Sign data with ECDSA P-256 SHA-256.
1607
+ *
1608
+ * Creates a digital signature over the data using the private key.
1609
+ * @param privateKey - Signing private key
1610
+ * @param data - Data to sign (Uint8Array)
1611
+ * @returns Promise resolving to signature as Uint8Array
1612
+ */
1613
+ declare function sign(privateKey: CryptoKey, data: Uint8Array): Promise<Uint8Array>;
1614
+ /**
1615
+ * Verify ECDSA P-256 SHA-256 signature.
1616
+ *
1617
+ * Verifies that the signature was created by the holder of the private key
1618
+ * corresponding to the public key.
1619
+ * @param publicKey - Verification public key
1620
+ * @param signature - Signature to verify
1621
+ * @param data - Original data that was signed
1622
+ * @returns Promise resolving to true if signature is valid, false otherwise
1623
+ */
1624
+ declare function verify(publicKey: CryptoKey, signature: Uint8Array, data: Uint8Array): Promise<boolean>;
1625
+ /**
1626
+ * Export signing public key to base64url (SPKI format).
1627
+ * @param key - Public CryptoKey to export
1628
+ * @returns Promise resolving to base64url-encoded public key
1629
+ */
1630
+ declare function exportSigningPublicKey(key: CryptoKey): Promise<string>;
1631
+ /**
1632
+ * Import signing public key from base64url for verification.
1633
+ * @param base64url - Base64url-encoded public key (SPKI format)
1634
+ * @returns Promise resolving to imported CryptoKey for verification
1635
+ */
1636
+ declare function importSigningPublicKey(base64url: string): Promise<CryptoKey>;
1637
+ /**
1638
+ * Export signing public key to base64url (raw format).
1639
+ * @param key - Public CryptoKey to export
1640
+ * @returns Base64url-encoded raw public key
1641
+ */
1642
+ declare function exportSigningPublicKeyRaw(key: CryptoKey): Promise<string>;
1643
+ /**
1644
+ * Import signing public key from base64url raw format.
1645
+ * @param base64url - Base64url-encoded raw public key
1646
+ * @returns Imported CryptoKey for verification
1647
+ */
1648
+ declare function importSigningPublicKeyRaw(base64url: string): Promise<CryptoKey>;
1649
+ /**
1650
+ * Export signing private key to PKCS8 PEM format (for Node.js file storage).
1651
+ * @param key - Private CryptoKey to export
1652
+ * @returns Promise resolving to PEM string
1653
+ * @throws Error if key is non-extractable
1654
+ */
1655
+ declare function exportSigningPrivateKeyPEM(key: CryptoKey): Promise<string>;
1656
+ /**
1657
+ * Import signing private key from PKCS8 PEM format.
1658
+ * @param pem - PEM-encoded private key string
1659
+ * @returns Promise resolving to imported CryptoKey
1660
+ */
1661
+ declare function importSigningPrivateKeyPEM(pem: string): Promise<CryptoKey>;
1662
+ //#endregion
1663
+ //#region transports/ws/src/crypto/encoding.d.ts
1664
+ /**
1665
+ * Base64url encoding utilities for cryptographic data.
1666
+ *
1667
+ * Uses URL-safe base64 encoding (RFC 4648) without padding.
1668
+ * Standard for encoding binary crypto material in JSON/URLs.
1669
+ */
1670
+ /**
1671
+ * Encode Uint8Array to base64url string.
1672
+ *
1673
+ * Converts binary data to URL-safe base64 string without padding.
1674
+ * Uses chunked approach to avoid call stack overflow on large payloads.
1675
+ * @param data - Binary data to encode
1676
+ * @returns Base64url-encoded string
1677
+ * @example
1678
+ * ```typescript
1679
+ * const nonce = crypto.getRandomValues(new Uint8Array(12));
1680
+ * const encoded = toBase64Url(nonce); // "Zj4Qr..." (no padding)
1681
+ * ```
1682
+ */
1683
+ declare function toBase64Url(data: Uint8Array): string;
1684
+ /**
1685
+ * Decode base64url string to Uint8Array.
1686
+ *
1687
+ * Converts URL-safe base64 string back to binary data.
1688
+ * @param base64url - Base64url-encoded string
1689
+ * @returns Binary data as Uint8Array
1690
+ * @throws Error if input is not valid base64url
1691
+ * @example
1692
+ * ```typescript
1693
+ * const data = fromBase64Url("Zj4Qr...");
1694
+ * ```
1695
+ */
1696
+ declare function fromBase64Url(base64url: string): Uint8Array;
1697
+ /**
1698
+ * Encode string to Uint8Array (UTF-8).
1699
+ *
1700
+ * Converts text to binary using UTF-8 encoding.
1701
+ * @param text - String to encode
1702
+ * @returns UTF-8 encoded bytes
1703
+ * @example
1704
+ * ```typescript
1705
+ * const data = encodeText("Hello, world!");
1706
+ * ```
1707
+ */
1708
+ declare function encodeText(text: string): Uint8Array;
1709
+ /**
1710
+ * Decode Uint8Array to string (UTF-8).
1711
+ *
1712
+ * Converts binary data to text using UTF-8 decoding.
1713
+ * @param data - Binary data to decode
1714
+ * @returns Decoded string
1715
+ * @example
1716
+ * ```typescript
1717
+ * const text = decodeText(data);
1718
+ * ```
1719
+ */
1720
+ declare function decodeText(data: Uint8Array): string;
1721
+ declare namespace index_d_exports {
1722
+ export { decodeText, decrypt, deriveSessionKey, deriveSharedSecret, encodeText, encrypt, exportPrivateKeyPEM, exportPublicKey, exportPublicKeyRaw, exportSigningPrivateKeyPEM, exportSigningPublicKey, exportSigningPublicKeyRaw, fromBase64Url, generateECDHKeyPair, generateSigningKeyPair, importAESKey, importPrivateKeyPEM, importPublicKey, importPublicKeyRaw, importSigningPrivateKeyPEM, importSigningPublicKey, importSigningPublicKeyRaw, sign, toBase64Url, verify };
1723
+ }
1724
+ //#endregion
1725
+ //#region transports/ws/src/index.d.ts
1726
+ /**
1727
+ * Create a WebSocket transport for the specified mode.
1728
+ *
1729
+ * For client mode the transport wraps a pre-created `WebSocket` via
1730
+ * `WebSocketClientTransport`. Because this factory accepts an already-created
1731
+ * socket, caller-supplied dial-time `connectionOptions` cannot be honored here;
1732
+ * use `WebSocketClientTransport` directly when you need reconnect or socket
1733
+ * creation options.
1734
+ * @param options - Transport configuration
1735
+ * @returns BusTransport instance
1736
+ */
1737
+ declare function createWebSocketTransport(options: WebSocketTransportOptions): BusTransport;
1738
+ /**
1739
+ * Module augmentation for BusTransportRegistry.
1740
+ *
1741
+ * This enables type-safe access to the WebSocket transport:
1742
+ * ```typescript
1743
+ * const transport = getTransport('websocket'); // Type: BusTransport
1744
+ * ```
1745
+ */
1746
+ declare module '@makaio/framework/bus' {
1747
+ interface BusTransportRegistry {
1748
+ websocket: BusTransport;
1749
+ }
1750
+ }
1751
+ //#endregion
1752
+ export { type ClientTransportCodec, DispatchingAuth, E2EAuth, E2ERelayAuth, type E2ERelayAuthOptions, HmacAuth, type RelayControlBusMessage, type RelayControlEnvelopeMessage, type RelayControlHelpers, type RelayControlRegistry, ServerTransport, type TransportAuth, WebSocketClientTransport, type WebSocketClientTransportOptions, type WebSocketClientTransportReconnectOptions, type WebSocketCloseEvent, type WebSocketLike, type WebSocketServerLike, createE2EClientTransport, createE2ERelayClientTransport, createE2ERelayCodec, createRelayControlHelpers, createRelayControlRegistry, createWebSocketCloseEvent, createWebSocketTransport, index_d_exports as crypto, extractSocketErrorMessage };