@waiaas/daemon 2.0.0-rc.1

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 (480) hide show
  1. package/dist/api/error-hints.d.ts +15 -0
  2. package/dist/api/error-hints.d.ts.map +1 -0
  3. package/dist/api/error-hints.js +71 -0
  4. package/dist/api/error-hints.js.map +1 -0
  5. package/dist/api/index.d.ts +11 -0
  6. package/dist/api/index.d.ts.map +1 -0
  7. package/dist/api/index.js +14 -0
  8. package/dist/api/index.js.map +1 -0
  9. package/dist/api/middleware/address-validation.d.ts +38 -0
  10. package/dist/api/middleware/address-validation.d.ts.map +1 -0
  11. package/dist/api/middleware/address-validation.js +134 -0
  12. package/dist/api/middleware/address-validation.js.map +1 -0
  13. package/dist/api/middleware/csp.d.ts +17 -0
  14. package/dist/api/middleware/csp.d.ts.map +1 -0
  15. package/dist/api/middleware/csp.js +31 -0
  16. package/dist/api/middleware/csp.js.map +1 -0
  17. package/dist/api/middleware/error-handler.d.ts +16 -0
  18. package/dist/api/middleware/error-handler.d.ts.map +1 -0
  19. package/dist/api/middleware/error-handler.js +46 -0
  20. package/dist/api/middleware/error-handler.js.map +1 -0
  21. package/dist/api/middleware/host-guard.d.ts +11 -0
  22. package/dist/api/middleware/host-guard.d.ts.map +1 -0
  23. package/dist/api/middleware/host-guard.js +25 -0
  24. package/dist/api/middleware/host-guard.js.map +1 -0
  25. package/dist/api/middleware/index.d.ts +13 -0
  26. package/dist/api/middleware/index.d.ts.map +1 -0
  27. package/dist/api/middleware/index.js +13 -0
  28. package/dist/api/middleware/index.js.map +1 -0
  29. package/dist/api/middleware/kill-switch-guard.d.ts +19 -0
  30. package/dist/api/middleware/kill-switch-guard.d.ts.map +1 -0
  31. package/dist/api/middleware/kill-switch-guard.js +49 -0
  32. package/dist/api/middleware/kill-switch-guard.js.map +1 -0
  33. package/dist/api/middleware/master-auth.d.ts +15 -0
  34. package/dist/api/middleware/master-auth.d.ts.map +1 -0
  35. package/dist/api/middleware/master-auth.js +35 -0
  36. package/dist/api/middleware/master-auth.js.map +1 -0
  37. package/dist/api/middleware/owner-auth.d.ts +30 -0
  38. package/dist/api/middleware/owner-auth.d.ts.map +1 -0
  39. package/dist/api/middleware/owner-auth.js +133 -0
  40. package/dist/api/middleware/owner-auth.js.map +1 -0
  41. package/dist/api/middleware/request-id.d.ts +10 -0
  42. package/dist/api/middleware/request-id.d.ts.map +1 -0
  43. package/dist/api/middleware/request-id.js +18 -0
  44. package/dist/api/middleware/request-id.js.map +1 -0
  45. package/dist/api/middleware/request-logger.d.ts +9 -0
  46. package/dist/api/middleware/request-logger.d.ts.map +1 -0
  47. package/dist/api/middleware/request-logger.js +18 -0
  48. package/dist/api/middleware/request-logger.js.map +1 -0
  49. package/dist/api/middleware/session-auth.d.ts +21 -0
  50. package/dist/api/middleware/session-auth.d.ts.map +1 -0
  51. package/dist/api/middleware/session-auth.js +51 -0
  52. package/dist/api/middleware/session-auth.js.map +1 -0
  53. package/dist/api/middleware/siwe-verify.d.ts +31 -0
  54. package/dist/api/middleware/siwe-verify.d.ts.map +1 -0
  55. package/dist/api/middleware/siwe-verify.js +55 -0
  56. package/dist/api/middleware/siwe-verify.js.map +1 -0
  57. package/dist/api/routes/actions.d.ts +56 -0
  58. package/dist/api/routes/actions.d.ts.map +1 -0
  59. package/dist/api/routes/actions.js +291 -0
  60. package/dist/api/routes/actions.js.map +1 -0
  61. package/dist/api/routes/admin.d.ts +99 -0
  62. package/dist/api/routes/admin.d.ts.map +1 -0
  63. package/dist/api/routes/admin.js +1304 -0
  64. package/dist/api/routes/admin.js.map +1 -0
  65. package/dist/api/routes/display-currency-helper.d.ts +26 -0
  66. package/dist/api/routes/display-currency-helper.d.ts.map +1 -0
  67. package/dist/api/routes/display-currency-helper.js +47 -0
  68. package/dist/api/routes/display-currency-helper.js.map +1 -0
  69. package/dist/api/routes/health.d.ts +14 -0
  70. package/dist/api/routes/health.d.ts.map +1 -0
  71. package/dist/api/routes/health.js +47 -0
  72. package/dist/api/routes/health.js.map +1 -0
  73. package/dist/api/routes/index.d.ts +15 -0
  74. package/dist/api/routes/index.d.ts.map +1 -0
  75. package/dist/api/routes/index.js +15 -0
  76. package/dist/api/routes/index.js.map +1 -0
  77. package/dist/api/routes/mcp.d.ts +30 -0
  78. package/dist/api/routes/mcp.d.ts.map +1 -0
  79. package/dist/api/routes/mcp.js +156 -0
  80. package/dist/api/routes/mcp.js.map +1 -0
  81. package/dist/api/routes/nonce.d.ts +20 -0
  82. package/dist/api/routes/nonce.d.ts.map +1 -0
  83. package/dist/api/routes/nonce.js +48 -0
  84. package/dist/api/routes/nonce.js.map +1 -0
  85. package/dist/api/routes/openapi-schemas.d.ts +2281 -0
  86. package/dist/api/routes/openapi-schemas.d.ts.map +1 -0
  87. package/dist/api/routes/openapi-schemas.js +770 -0
  88. package/dist/api/routes/openapi-schemas.js.map +1 -0
  89. package/dist/api/routes/policies.d.ts +29 -0
  90. package/dist/api/routes/policies.d.ts.map +1 -0
  91. package/dist/api/routes/policies.js +332 -0
  92. package/dist/api/routes/policies.js.map +1 -0
  93. package/dist/api/routes/sessions.d.ts +35 -0
  94. package/dist/api/routes/sessions.d.ts.map +1 -0
  95. package/dist/api/routes/sessions.js +347 -0
  96. package/dist/api/routes/sessions.js.map +1 -0
  97. package/dist/api/routes/skills.d.ts +9 -0
  98. package/dist/api/routes/skills.d.ts.map +1 -0
  99. package/dist/api/routes/skills.js +59 -0
  100. package/dist/api/routes/skills.js.map +1 -0
  101. package/dist/api/routes/tokens.d.ts +25 -0
  102. package/dist/api/routes/tokens.d.ts.map +1 -0
  103. package/dist/api/routes/tokens.js +161 -0
  104. package/dist/api/routes/tokens.js.map +1 -0
  105. package/dist/api/routes/transactions.d.ts +68 -0
  106. package/dist/api/routes/transactions.d.ts.map +1 -0
  107. package/dist/api/routes/transactions.js +576 -0
  108. package/dist/api/routes/transactions.js.map +1 -0
  109. package/dist/api/routes/utils.d.ts +9 -0
  110. package/dist/api/routes/utils.d.ts.map +1 -0
  111. package/dist/api/routes/utils.js +52 -0
  112. package/dist/api/routes/utils.js.map +1 -0
  113. package/dist/api/routes/wallet.d.ts +36 -0
  114. package/dist/api/routes/wallet.d.ts.map +1 -0
  115. package/dist/api/routes/wallet.js +358 -0
  116. package/dist/api/routes/wallet.js.map +1 -0
  117. package/dist/api/routes/wallets.d.ts +43 -0
  118. package/dist/api/routes/wallets.d.ts.map +1 -0
  119. package/dist/api/routes/wallets.js +630 -0
  120. package/dist/api/routes/wallets.js.map +1 -0
  121. package/dist/api/routes/wc.d.ts +46 -0
  122. package/dist/api/routes/wc.d.ts.map +1 -0
  123. package/dist/api/routes/wc.js +354 -0
  124. package/dist/api/routes/wc.js.map +1 -0
  125. package/dist/api/routes/x402.d.ts +61 -0
  126. package/dist/api/routes/x402.d.ts.map +1 -0
  127. package/dist/api/routes/x402.js +493 -0
  128. package/dist/api/routes/x402.js.map +1 -0
  129. package/dist/api/server.d.ts +81 -0
  130. package/dist/api/server.d.ts.map +1 -0
  131. package/dist/api/server.js +406 -0
  132. package/dist/api/server.js.map +1 -0
  133. package/dist/index.d.ts +35 -0
  134. package/dist/index.d.ts.map +1 -0
  135. package/dist/index.js +43 -0
  136. package/dist/index.js.map +1 -0
  137. package/dist/infrastructure/action/action-provider-registry.d.ts +77 -0
  138. package/dist/infrastructure/action/action-provider-registry.d.ts.map +1 -0
  139. package/dist/infrastructure/action/action-provider-registry.js +239 -0
  140. package/dist/infrastructure/action/action-provider-registry.js.map +1 -0
  141. package/dist/infrastructure/action/api-key-store.d.ts +60 -0
  142. package/dist/infrastructure/action/api-key-store.d.ts.map +1 -0
  143. package/dist/infrastructure/action/api-key-store.js +130 -0
  144. package/dist/infrastructure/action/api-key-store.js.map +1 -0
  145. package/dist/infrastructure/action/index.d.ts +10 -0
  146. package/dist/infrastructure/action/index.d.ts.map +1 -0
  147. package/dist/infrastructure/action/index.js +9 -0
  148. package/dist/infrastructure/action/index.js.map +1 -0
  149. package/dist/infrastructure/adapter-pool.d.ts +50 -0
  150. package/dist/infrastructure/adapter-pool.d.ts.map +1 -0
  151. package/dist/infrastructure/adapter-pool.js +110 -0
  152. package/dist/infrastructure/adapter-pool.js.map +1 -0
  153. package/dist/infrastructure/backup/backup-service.d.ts +53 -0
  154. package/dist/infrastructure/backup/backup-service.d.ts.map +1 -0
  155. package/dist/infrastructure/backup/backup-service.js +158 -0
  156. package/dist/infrastructure/backup/backup-service.js.map +1 -0
  157. package/dist/infrastructure/backup/index.d.ts +2 -0
  158. package/dist/infrastructure/backup/index.d.ts.map +1 -0
  159. package/dist/infrastructure/backup/index.js +2 -0
  160. package/dist/infrastructure/backup/index.js.map +1 -0
  161. package/dist/infrastructure/config/index.d.ts +8 -0
  162. package/dist/infrastructure/config/index.d.ts.map +1 -0
  163. package/dist/infrastructure/config/index.js +7 -0
  164. package/dist/infrastructure/config/index.js.map +1 -0
  165. package/dist/infrastructure/config/loader.d.ts +555 -0
  166. package/dist/infrastructure/config/loader.d.ts.map +1 -0
  167. package/dist/infrastructure/config/loader.js +311 -0
  168. package/dist/infrastructure/config/loader.js.map +1 -0
  169. package/dist/infrastructure/database/checks.d.ts +19 -0
  170. package/dist/infrastructure/database/checks.d.ts.map +1 -0
  171. package/dist/infrastructure/database/checks.js +27 -0
  172. package/dist/infrastructure/database/checks.js.map +1 -0
  173. package/dist/infrastructure/database/compatibility.d.ts +36 -0
  174. package/dist/infrastructure/database/compatibility.d.ts.map +1 -0
  175. package/dist/infrastructure/database/compatibility.js +75 -0
  176. package/dist/infrastructure/database/compatibility.js.map +1 -0
  177. package/dist/infrastructure/database/connection.d.ts +36 -0
  178. package/dist/infrastructure/database/connection.d.ts.map +1 -0
  179. package/dist/infrastructure/database/connection.js +47 -0
  180. package/dist/infrastructure/database/connection.js.map +1 -0
  181. package/dist/infrastructure/database/id.d.ts +17 -0
  182. package/dist/infrastructure/database/id.d.ts.map +1 -0
  183. package/dist/infrastructure/database/id.js +20 -0
  184. package/dist/infrastructure/database/id.js.map +1 -0
  185. package/dist/infrastructure/database/index.d.ts +15 -0
  186. package/dist/infrastructure/database/index.d.ts.map +1 -0
  187. package/dist/infrastructure/database/index.js +12 -0
  188. package/dist/infrastructure/database/index.js.map +1 -0
  189. package/dist/infrastructure/database/migrate.d.ts +76 -0
  190. package/dist/infrastructure/database/migrate.d.ts.map +1 -0
  191. package/dist/infrastructure/database/migrate.js +1214 -0
  192. package/dist/infrastructure/database/migrate.js.map +1 -0
  193. package/dist/infrastructure/database/schema.d.ts +2352 -0
  194. package/dist/infrastructure/database/schema.d.ts.map +1 -0
  195. package/dist/infrastructure/database/schema.js +288 -0
  196. package/dist/infrastructure/database/schema.js.map +1 -0
  197. package/dist/infrastructure/jwt/index.d.ts +2 -0
  198. package/dist/infrastructure/jwt/index.d.ts.map +1 -0
  199. package/dist/infrastructure/jwt/index.js +2 -0
  200. package/dist/infrastructure/jwt/index.js.map +1 -0
  201. package/dist/infrastructure/jwt/jwt-secret-manager.d.ts +58 -0
  202. package/dist/infrastructure/jwt/jwt-secret-manager.d.ts.map +1 -0
  203. package/dist/infrastructure/jwt/jwt-secret-manager.js +222 -0
  204. package/dist/infrastructure/jwt/jwt-secret-manager.js.map +1 -0
  205. package/dist/infrastructure/keystore/crypto.d.ts +62 -0
  206. package/dist/infrastructure/keystore/crypto.d.ts.map +1 -0
  207. package/dist/infrastructure/keystore/crypto.js +89 -0
  208. package/dist/infrastructure/keystore/crypto.js.map +1 -0
  209. package/dist/infrastructure/keystore/index.d.ts +4 -0
  210. package/dist/infrastructure/keystore/index.d.ts.map +1 -0
  211. package/dist/infrastructure/keystore/index.js +5 -0
  212. package/dist/infrastructure/keystore/index.js.map +1 -0
  213. package/dist/infrastructure/keystore/keystore.d.ts +115 -0
  214. package/dist/infrastructure/keystore/keystore.d.ts.map +1 -0
  215. package/dist/infrastructure/keystore/keystore.js +327 -0
  216. package/dist/infrastructure/keystore/keystore.js.map +1 -0
  217. package/dist/infrastructure/keystore/memory.d.ts +45 -0
  218. package/dist/infrastructure/keystore/memory.d.ts.map +1 -0
  219. package/dist/infrastructure/keystore/memory.js +105 -0
  220. package/dist/infrastructure/keystore/memory.js.map +1 -0
  221. package/dist/infrastructure/oracle/coingecko-forex.d.ts +35 -0
  222. package/dist/infrastructure/oracle/coingecko-forex.d.ts.map +1 -0
  223. package/dist/infrastructure/oracle/coingecko-forex.js +69 -0
  224. package/dist/infrastructure/oracle/coingecko-forex.js.map +1 -0
  225. package/dist/infrastructure/oracle/coingecko-oracle.d.ts +73 -0
  226. package/dist/infrastructure/oracle/coingecko-oracle.d.ts.map +1 -0
  227. package/dist/infrastructure/oracle/coingecko-oracle.js +199 -0
  228. package/dist/infrastructure/oracle/coingecko-oracle.js.map +1 -0
  229. package/dist/infrastructure/oracle/coingecko-platform-ids.d.ts +32 -0
  230. package/dist/infrastructure/oracle/coingecko-platform-ids.d.ts.map +1 -0
  231. package/dist/infrastructure/oracle/coingecko-platform-ids.js +30 -0
  232. package/dist/infrastructure/oracle/coingecko-platform-ids.js.map +1 -0
  233. package/dist/infrastructure/oracle/forex-currencies.d.ts +36 -0
  234. package/dist/infrastructure/oracle/forex-currencies.d.ts.map +1 -0
  235. package/dist/infrastructure/oracle/forex-currencies.js +71 -0
  236. package/dist/infrastructure/oracle/forex-currencies.js.map +1 -0
  237. package/dist/infrastructure/oracle/forex-rate-service.d.ts +51 -0
  238. package/dist/infrastructure/oracle/forex-rate-service.d.ts.map +1 -0
  239. package/dist/infrastructure/oracle/forex-rate-service.js +149 -0
  240. package/dist/infrastructure/oracle/forex-rate-service.js.map +1 -0
  241. package/dist/infrastructure/oracle/index.d.ts +18 -0
  242. package/dist/infrastructure/oracle/index.d.ts.map +1 -0
  243. package/dist/infrastructure/oracle/index.js +19 -0
  244. package/dist/infrastructure/oracle/index.js.map +1 -0
  245. package/dist/infrastructure/oracle/oracle-chain.d.ts +101 -0
  246. package/dist/infrastructure/oracle/oracle-chain.d.ts.map +1 -0
  247. package/dist/infrastructure/oracle/oracle-chain.js +163 -0
  248. package/dist/infrastructure/oracle/oracle-chain.js.map +1 -0
  249. package/dist/infrastructure/oracle/oracle-errors.d.ts +42 -0
  250. package/dist/infrastructure/oracle/oracle-errors.d.ts.map +1 -0
  251. package/dist/infrastructure/oracle/oracle-errors.js +53 -0
  252. package/dist/infrastructure/oracle/oracle-errors.js.map +1 -0
  253. package/dist/infrastructure/oracle/price-age.d.ts +38 -0
  254. package/dist/infrastructure/oracle/price-age.d.ts.map +1 -0
  255. package/dist/infrastructure/oracle/price-age.js +44 -0
  256. package/dist/infrastructure/oracle/price-age.js.map +1 -0
  257. package/dist/infrastructure/oracle/price-cache.d.ts +99 -0
  258. package/dist/infrastructure/oracle/price-cache.d.ts.map +1 -0
  259. package/dist/infrastructure/oracle/price-cache.js +173 -0
  260. package/dist/infrastructure/oracle/price-cache.js.map +1 -0
  261. package/dist/infrastructure/oracle/pyth-feed-ids.d.ts +31 -0
  262. package/dist/infrastructure/oracle/pyth-feed-ids.d.ts.map +1 -0
  263. package/dist/infrastructure/oracle/pyth-feed-ids.js +44 -0
  264. package/dist/infrastructure/oracle/pyth-feed-ids.js.map +1 -0
  265. package/dist/infrastructure/oracle/pyth-oracle.d.ts +69 -0
  266. package/dist/infrastructure/oracle/pyth-oracle.d.ts.map +1 -0
  267. package/dist/infrastructure/oracle/pyth-oracle.js +149 -0
  268. package/dist/infrastructure/oracle/pyth-oracle.js.map +1 -0
  269. package/dist/infrastructure/settings/hot-reload.d.ts +71 -0
  270. package/dist/infrastructure/settings/hot-reload.d.ts.map +1 -0
  271. package/dist/infrastructure/settings/hot-reload.js +315 -0
  272. package/dist/infrastructure/settings/hot-reload.js.map +1 -0
  273. package/dist/infrastructure/settings/index.d.ts +13 -0
  274. package/dist/infrastructure/settings/index.d.ts.map +1 -0
  275. package/dist/infrastructure/settings/index.js +10 -0
  276. package/dist/infrastructure/settings/index.js.map +1 -0
  277. package/dist/infrastructure/settings/setting-keys.d.ts +28 -0
  278. package/dist/infrastructure/settings/setting-keys.d.ts.map +1 -0
  279. package/dist/infrastructure/settings/setting-keys.js +105 -0
  280. package/dist/infrastructure/settings/setting-keys.js.map +1 -0
  281. package/dist/infrastructure/settings/settings-crypto.d.ts +39 -0
  282. package/dist/infrastructure/settings/settings-crypto.d.ts.map +1 -0
  283. package/dist/infrastructure/settings/settings-crypto.js +73 -0
  284. package/dist/infrastructure/settings/settings-crypto.js.map +1 -0
  285. package/dist/infrastructure/settings/settings-service.d.ts +82 -0
  286. package/dist/infrastructure/settings/settings-service.d.ts.map +1 -0
  287. package/dist/infrastructure/settings/settings-service.js +267 -0
  288. package/dist/infrastructure/settings/settings-service.js.map +1 -0
  289. package/dist/infrastructure/telegram/index.d.ts +6 -0
  290. package/dist/infrastructure/telegram/index.d.ts.map +1 -0
  291. package/dist/infrastructure/telegram/index.js +5 -0
  292. package/dist/infrastructure/telegram/index.js.map +1 -0
  293. package/dist/infrastructure/telegram/telegram-api.d.ts +35 -0
  294. package/dist/infrastructure/telegram/telegram-api.d.ts.map +1 -0
  295. package/dist/infrastructure/telegram/telegram-api.js +82 -0
  296. package/dist/infrastructure/telegram/telegram-api.js.map +1 -0
  297. package/dist/infrastructure/telegram/telegram-auth.d.ts +57 -0
  298. package/dist/infrastructure/telegram/telegram-auth.d.ts.map +1 -0
  299. package/dist/infrastructure/telegram/telegram-auth.js +88 -0
  300. package/dist/infrastructure/telegram/telegram-auth.js.map +1 -0
  301. package/dist/infrastructure/telegram/telegram-bot-service.d.ts +95 -0
  302. package/dist/infrastructure/telegram/telegram-bot-service.d.ts.map +1 -0
  303. package/dist/infrastructure/telegram/telegram-bot-service.js +564 -0
  304. package/dist/infrastructure/telegram/telegram-bot-service.js.map +1 -0
  305. package/dist/infrastructure/telegram/telegram-keyboard.d.ts +27 -0
  306. package/dist/infrastructure/telegram/telegram-keyboard.d.ts.map +1 -0
  307. package/dist/infrastructure/telegram/telegram-keyboard.js +52 -0
  308. package/dist/infrastructure/telegram/telegram-keyboard.js.map +1 -0
  309. package/dist/infrastructure/telegram/telegram-types.d.ts +43 -0
  310. package/dist/infrastructure/telegram/telegram-types.d.ts.map +1 -0
  311. package/dist/infrastructure/telegram/telegram-types.js +8 -0
  312. package/dist/infrastructure/telegram/telegram-types.js.map +1 -0
  313. package/dist/infrastructure/token-registry/builtin-tokens.d.ts +39 -0
  314. package/dist/infrastructure/token-registry/builtin-tokens.d.ts.map +1 -0
  315. package/dist/infrastructure/token-registry/builtin-tokens.js +135 -0
  316. package/dist/infrastructure/token-registry/builtin-tokens.js.map +1 -0
  317. package/dist/infrastructure/token-registry/index.d.ts +8 -0
  318. package/dist/infrastructure/token-registry/index.d.ts.map +1 -0
  319. package/dist/infrastructure/token-registry/index.js +8 -0
  320. package/dist/infrastructure/token-registry/index.js.map +1 -0
  321. package/dist/infrastructure/token-registry/token-registry-service.d.ts +49 -0
  322. package/dist/infrastructure/token-registry/token-registry-service.d.ts.map +1 -0
  323. package/dist/infrastructure/token-registry/token-registry-service.js +93 -0
  324. package/dist/infrastructure/token-registry/token-registry-service.js.map +1 -0
  325. package/dist/infrastructure/version/index.d.ts +5 -0
  326. package/dist/infrastructure/version/index.d.ts.map +1 -0
  327. package/dist/infrastructure/version/index.js +5 -0
  328. package/dist/infrastructure/version/index.js.map +1 -0
  329. package/dist/infrastructure/version/version-check-service.d.ts +35 -0
  330. package/dist/infrastructure/version/version-check-service.d.ts.map +1 -0
  331. package/dist/infrastructure/version/version-check-service.js +92 -0
  332. package/dist/infrastructure/version/version-check-service.js.map +1 -0
  333. package/dist/lifecycle/daemon.d.ts +103 -0
  334. package/dist/lifecycle/daemon.d.ts.map +1 -0
  335. package/dist/lifecycle/daemon.js +934 -0
  336. package/dist/lifecycle/daemon.js.map +1 -0
  337. package/dist/lifecycle/index.d.ts +9 -0
  338. package/dist/lifecycle/index.d.ts.map +1 -0
  339. package/dist/lifecycle/index.js +9 -0
  340. package/dist/lifecycle/index.js.map +1 -0
  341. package/dist/lifecycle/signal-handler.d.ts +18 -0
  342. package/dist/lifecycle/signal-handler.d.ts.map +1 -0
  343. package/dist/lifecycle/signal-handler.js +37 -0
  344. package/dist/lifecycle/signal-handler.js.map +1 -0
  345. package/dist/lifecycle/workers.d.ts +46 -0
  346. package/dist/lifecycle/workers.d.ts.map +1 -0
  347. package/dist/lifecycle/workers.js +101 -0
  348. package/dist/lifecycle/workers.js.map +1 -0
  349. package/dist/notifications/channels/discord.d.ts +10 -0
  350. package/dist/notifications/channels/discord.d.ts.map +1 -0
  351. package/dist/notifications/channels/discord.js +54 -0
  352. package/dist/notifications/channels/discord.js.map +1 -0
  353. package/dist/notifications/channels/ntfy.d.ts +13 -0
  354. package/dist/notifications/channels/ntfy.d.ts.map +1 -0
  355. package/dist/notifications/channels/ntfy.js +58 -0
  356. package/dist/notifications/channels/ntfy.js.map +1 -0
  357. package/dist/notifications/channels/slack.d.ts +10 -0
  358. package/dist/notifications/channels/slack.d.ts.map +1 -0
  359. package/dist/notifications/channels/slack.js +55 -0
  360. package/dist/notifications/channels/slack.js.map +1 -0
  361. package/dist/notifications/channels/telegram.d.ts +10 -0
  362. package/dist/notifications/channels/telegram.d.ts.map +1 -0
  363. package/dist/notifications/channels/telegram.js +40 -0
  364. package/dist/notifications/channels/telegram.js.map +1 -0
  365. package/dist/notifications/index.d.ts +9 -0
  366. package/dist/notifications/index.d.ts.map +1 -0
  367. package/dist/notifications/index.js +7 -0
  368. package/dist/notifications/index.js.map +1 -0
  369. package/dist/notifications/notification-service.d.ts +75 -0
  370. package/dist/notifications/notification-service.d.ts.map +1 -0
  371. package/dist/notifications/notification-service.js +213 -0
  372. package/dist/notifications/notification-service.js.map +1 -0
  373. package/dist/notifications/templates/message-templates.d.ts +12 -0
  374. package/dist/notifications/templates/message-templates.d.ts.map +1 -0
  375. package/dist/notifications/templates/message-templates.js +22 -0
  376. package/dist/notifications/templates/message-templates.js.map +1 -0
  377. package/dist/pipeline/database-policy-engine.d.ts +286 -0
  378. package/dist/pipeline/database-policy-engine.d.ts.map +1 -0
  379. package/dist/pipeline/database-policy-engine.js +992 -0
  380. package/dist/pipeline/database-policy-engine.js.map +1 -0
  381. package/dist/pipeline/default-policy-engine.d.ts +26 -0
  382. package/dist/pipeline/default-policy-engine.d.ts.map +1 -0
  383. package/dist/pipeline/default-policy-engine.js +25 -0
  384. package/dist/pipeline/default-policy-engine.js.map +1 -0
  385. package/dist/pipeline/index.d.ts +9 -0
  386. package/dist/pipeline/index.d.ts.map +1 -0
  387. package/dist/pipeline/index.js +9 -0
  388. package/dist/pipeline/index.js.map +1 -0
  389. package/dist/pipeline/network-resolver.d.ts +22 -0
  390. package/dist/pipeline/network-resolver.d.ts.map +1 -0
  391. package/dist/pipeline/network-resolver.js +32 -0
  392. package/dist/pipeline/network-resolver.js.map +1 -0
  393. package/dist/pipeline/pipeline.d.ts +72 -0
  394. package/dist/pipeline/pipeline.d.ts.map +1 -0
  395. package/dist/pipeline/pipeline.js +87 -0
  396. package/dist/pipeline/pipeline.js.map +1 -0
  397. package/dist/pipeline/resolve-effective-amount-usd.d.ts +41 -0
  398. package/dist/pipeline/resolve-effective-amount-usd.d.ts.map +1 -0
  399. package/dist/pipeline/resolve-effective-amount-usd.js +208 -0
  400. package/dist/pipeline/resolve-effective-amount-usd.js.map +1 -0
  401. package/dist/pipeline/sign-only.d.ts +99 -0
  402. package/dist/pipeline/sign-only.d.ts.map +1 -0
  403. package/dist/pipeline/sign-only.js +267 -0
  404. package/dist/pipeline/sign-only.js.map +1 -0
  405. package/dist/pipeline/sleep.d.ts +6 -0
  406. package/dist/pipeline/sleep.d.ts.map +1 -0
  407. package/dist/pipeline/sleep.js +8 -0
  408. package/dist/pipeline/sleep.js.map +1 -0
  409. package/dist/pipeline/stages.d.ts +82 -0
  410. package/dist/pipeline/stages.d.ts.map +1 -0
  411. package/dist/pipeline/stages.js +784 -0
  412. package/dist/pipeline/stages.js.map +1 -0
  413. package/dist/services/autostop-rules.d.ts +79 -0
  414. package/dist/services/autostop-rules.d.ts.map +1 -0
  415. package/dist/services/autostop-rules.js +174 -0
  416. package/dist/services/autostop-rules.js.map +1 -0
  417. package/dist/services/autostop-service.d.ts +82 -0
  418. package/dist/services/autostop-service.d.ts.map +1 -0
  419. package/dist/services/autostop-service.js +223 -0
  420. package/dist/services/autostop-service.js.map +1 -0
  421. package/dist/services/kill-switch-service.d.ts +118 -0
  422. package/dist/services/kill-switch-service.d.ts.map +1 -0
  423. package/dist/services/kill-switch-service.js +291 -0
  424. package/dist/services/kill-switch-service.js.map +1 -0
  425. package/dist/services/monitoring/balance-monitor-service.d.ts +65 -0
  426. package/dist/services/monitoring/balance-monitor-service.d.ts.map +1 -0
  427. package/dist/services/monitoring/balance-monitor-service.js +207 -0
  428. package/dist/services/monitoring/balance-monitor-service.js.map +1 -0
  429. package/dist/services/wc-session-service.d.ts +123 -0
  430. package/dist/services/wc-session-service.d.ts.map +1 -0
  431. package/dist/services/wc-session-service.js +363 -0
  432. package/dist/services/wc-session-service.js.map +1 -0
  433. package/dist/services/wc-signing-bridge.d.ts +60 -0
  434. package/dist/services/wc-signing-bridge.d.ts.map +1 -0
  435. package/dist/services/wc-signing-bridge.js +334 -0
  436. package/dist/services/wc-signing-bridge.js.map +1 -0
  437. package/dist/services/wc-storage.d.ts +32 -0
  438. package/dist/services/wc-storage.d.ts.map +1 -0
  439. package/dist/services/wc-storage.js +64 -0
  440. package/dist/services/wc-storage.js.map +1 -0
  441. package/dist/services/x402/payment-signer.d.ts +88 -0
  442. package/dist/services/x402/payment-signer.d.ts.map +1 -0
  443. package/dist/services/x402/payment-signer.js +311 -0
  444. package/dist/services/x402/payment-signer.js.map +1 -0
  445. package/dist/services/x402/ssrf-guard.d.ts +27 -0
  446. package/dist/services/x402/ssrf-guard.d.ts.map +1 -0
  447. package/dist/services/x402/ssrf-guard.js +236 -0
  448. package/dist/services/x402/ssrf-guard.js.map +1 -0
  449. package/dist/services/x402/x402-domain-policy.d.ts +50 -0
  450. package/dist/services/x402/x402-domain-policy.d.ts.map +1 -0
  451. package/dist/services/x402/x402-domain-policy.js +78 -0
  452. package/dist/services/x402/x402-domain-policy.js.map +1 -0
  453. package/dist/services/x402/x402-handler.d.ts +71 -0
  454. package/dist/services/x402/x402-handler.d.ts.map +1 -0
  455. package/dist/services/x402/x402-handler.js +195 -0
  456. package/dist/services/x402/x402-handler.js.map +1 -0
  457. package/dist/services/x402/x402-usd-resolver.d.ts +26 -0
  458. package/dist/services/x402/x402-usd-resolver.d.ts.map +1 -0
  459. package/dist/services/x402/x402-usd-resolver.js +79 -0
  460. package/dist/services/x402/x402-usd-resolver.js.map +1 -0
  461. package/dist/workflow/approval-workflow.d.ts +103 -0
  462. package/dist/workflow/approval-workflow.d.ts.map +1 -0
  463. package/dist/workflow/approval-workflow.js +202 -0
  464. package/dist/workflow/approval-workflow.js.map +1 -0
  465. package/dist/workflow/delay-queue.d.ts +78 -0
  466. package/dist/workflow/delay-queue.d.ts.map +1 -0
  467. package/dist/workflow/delay-queue.js +174 -0
  468. package/dist/workflow/delay-queue.js.map +1 -0
  469. package/dist/workflow/index.d.ts +11 -0
  470. package/dist/workflow/index.d.ts.map +1 -0
  471. package/dist/workflow/index.js +9 -0
  472. package/dist/workflow/index.js.map +1 -0
  473. package/dist/workflow/owner-state.d.ts +97 -0
  474. package/dist/workflow/owner-state.d.ts.map +1 -0
  475. package/dist/workflow/owner-state.js +168 -0
  476. package/dist/workflow/owner-state.js.map +1 -0
  477. package/package.json +71 -0
  478. package/public/admin/assets/index-BPoUSH8W.css +1 -0
  479. package/public/admin/assets/index-CDi1qoXB.js +1 -0
  480. package/public/admin/index.html +13 -0
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Error hint templates for AI agent self-recovery.
3
+ * Hints are English-only (AI agent consumption).
4
+ * 31 of 40 actionable error codes have hints.
5
+ * 9 codes intentionally have no hint (security/permanent/info-only).
6
+ *
7
+ * @see docs/55-dx-improvement-spec.md section 2.2
8
+ */
9
+ export declare const errorHintMap: Record<string, string>;
10
+ /**
11
+ * Resolve hint for a given error code with optional variable substitution.
12
+ * Variables in {braces} are replaced from the context map.
13
+ */
14
+ export declare function resolveHint(code: string, context?: Record<string, string>): string | undefined;
15
+ //# sourceMappingURL=error-hints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-hints.d.ts","sourceRoot":"","sources":["../../src/api/error-hints.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuD/C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,MAAM,GAAG,SAAS,CAMpB"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Error hint templates for AI agent self-recovery.
3
+ * Hints are English-only (AI agent consumption).
4
+ * 31 of 40 actionable error codes have hints.
5
+ * 9 codes intentionally have no hint (security/permanent/info-only).
6
+ *
7
+ * @see docs/55-dx-improvement-spec.md section 2.2
8
+ */
9
+ export const errorHintMap = {
10
+ // AUTH domain (6 of 8)
11
+ INVALID_TOKEN: 'Create a new session via POST /v1/sessions with masterAuth credentials.',
12
+ TOKEN_EXPIRED: 'Renew the session via PUT /v1/sessions/{id}/renew, or create a new session.',
13
+ SESSION_REVOKED: 'Create a new session via POST /v1/sessions with masterAuth credentials.',
14
+ INVALID_SIGNATURE: 'Verify the Ed25519 signature format and the nonce from GET /v1/nonce.',
15
+ INVALID_NONCE: 'Fetch a fresh nonce from GET /v1/nonce and retry within 5 minutes.',
16
+ INVALID_MASTER_PASSWORD: 'Check the X-Master-Password header value.',
17
+ // MASTER_PASSWORD_LOCKED: no hint (wait 30min, no action)
18
+ // SYSTEM_LOCKED: no hint (Kill Switch, Owner recovery needed)
19
+ // SESSION domain (7 of 8)
20
+ SESSION_NOT_FOUND: 'The session may have been revoked. Create a new session via POST /v1/sessions.',
21
+ SESSION_EXPIRED: 'Create a new session via POST /v1/sessions with masterAuth credentials.',
22
+ SESSION_LIMIT_EXCEEDED: 'Revoke unused sessions via DELETE /v1/sessions/{id} and retry.',
23
+ CONSTRAINT_VIOLATED: 'Check session constraints (IP, operations). Create a session with correct constraints.',
24
+ RENEWAL_LIMIT_REACHED: 'Maximum renewals reached. Create a new session via POST /v1/sessions.',
25
+ SESSION_ABSOLUTE_LIFETIME_EXCEEDED: 'Absolute session lifetime exceeded. Create a new session via POST /v1/sessions.',
26
+ RENEWAL_TOO_EARLY: 'Wait until 50% of session TTL has elapsed before renewing.',
27
+ // SESSION_RENEWAL_MISMATCH: no hint (security issue)
28
+ // TX domain (7 of 21 actionable)
29
+ ABI_ENCODING_FAILED: 'Check that functionName exists in the provided ABI and args match the expected types. Use a JSON array of ABI fragments for the abi parameter.',
30
+ INSUFFICIENT_BALANCE: 'Fund the wallet. Check balance via GET /v1/wallet/balance.',
31
+ INVALID_ADDRESS: 'Verify the recipient address format for the target blockchain.',
32
+ TX_NOT_FOUND: 'Verify the transaction ID. List transactions via GET /v1/transactions.',
33
+ TX_EXPIRED: 'The transaction expired. Submit a new transaction via POST /v1/transactions/send.',
34
+ TX_ALREADY_PROCESSED: 'This transaction was already processed. Check status via GET /v1/transactions/{id}.',
35
+ CHAIN_ERROR: 'Blockchain RPC error. Retry after a short delay.',
36
+ // POLICY domain (4 of 5)
37
+ POLICY_NOT_FOUND: 'Verify the policy ID. List policies via GET /v1/policies.',
38
+ POLICY_DENIED: 'Transaction denied by policy. Review policies via GET /v1/policies.',
39
+ SPENDING_LIMIT_EXCEEDED: 'Spending limit exceeded for the current window. Wait for the window to reset or request a policy change.',
40
+ RATE_LIMIT_EXCEEDED: 'Too many requests. Wait and retry after the rate limit window resets.',
41
+ // WHITELIST_DENIED: no hint (security)
42
+ // OWNER domain (3 of 5)
43
+ OWNER_NOT_CONNECTED: 'Register an owner via PUT /v1/wallets/{walletId}/owner.',
44
+ APPROVAL_TIMEOUT: 'The approval request timed out. Submit a new transaction.',
45
+ APPROVAL_NOT_FOUND: 'No pending approval for this transaction. Check status via GET /v1/transactions/{id}.',
46
+ // OWNER_ALREADY_CONNECTED: no hint (state only)
47
+ // SYSTEM domain (4 of 6)
48
+ KEYSTORE_LOCKED: 'The keystore is temporarily locked. Retry after a short delay.',
49
+ CHAIN_NOT_SUPPORTED: 'This blockchain is not supported. Use SOLANA or EVM.',
50
+ SHUTTING_DOWN: 'The daemon is shutting down. Wait for restart.',
51
+ ADAPTER_NOT_AVAILABLE: 'Chain adapter is not available. The daemon may still be initializing. Retry.',
52
+ // KILL_SWITCH_ACTIVE: no hint (agent cannot recover)
53
+ // KILL_SWITCH_NOT_ACTIVE: no hint (info only)
54
+ // WALLET domain (2 of 3)
55
+ WALLET_NOT_FOUND: 'Verify the wallet ID. List wallets via GET /v1/wallets.',
56
+ WALLET_SUSPENDED: 'Wallet is suspended. Contact the administrator.',
57
+ // WALLET_TERMINATED: no hint (permanent)
58
+ };
59
+ /**
60
+ * Resolve hint for a given error code with optional variable substitution.
61
+ * Variables in {braces} are replaced from the context map.
62
+ */
63
+ export function resolveHint(code, context) {
64
+ const template = errorHintMap[code];
65
+ if (!template)
66
+ return undefined;
67
+ if (!context)
68
+ return template;
69
+ return template.replace(/\{(\w+)\}/g, (_, key) => context[key] ?? `{${key}}`);
70
+ }
71
+ //# sourceMappingURL=error-hints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-hints.js","sourceRoot":"","sources":["../../src/api/error-hints.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,YAAY,GAA2B;IAClD,uBAAuB;IACvB,aAAa,EAAE,yEAAyE;IACxF,aAAa,EAAE,6EAA6E;IAC5F,eAAe,EAAE,yEAAyE;IAC1F,iBAAiB,EAAE,uEAAuE;IAC1F,aAAa,EAAE,oEAAoE;IACnF,uBAAuB,EAAE,2CAA2C;IACpE,0DAA0D;IAC1D,8DAA8D;IAE9D,0BAA0B;IAC1B,iBA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GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * API module barrel export: server factory, middleware, routes.
3
+ */
4
+ export { createApp, type CreateAppDeps } from './server.js';
5
+ export { requestId, hostGuard, createKillSwitchGuard, requestLogger, errorHandler, type GetKillSwitchState, } from './middleware/index.js';
6
+ export { health } from './routes/health.js';
7
+ export { walletCrudRoutes, type WalletCrudRouteDeps } from './routes/wallets.js';
8
+ export { walletRoutes, type WalletRouteDeps } from './routes/wallet.js';
9
+ export { transactionRoutes, type TransactionRouteDeps } from './routes/transactions.js';
10
+ export { mcpTokenRoutes, type McpTokenRouteDeps } from './routes/mcp.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EACL,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,KAAK,kBAAkB,GACxB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * API module barrel export: server factory, middleware, routes.
3
+ */
4
+ // Server factory
5
+ export { createApp } from './server.js';
6
+ // Middleware
7
+ export { requestId, hostGuard, createKillSwitchGuard, requestLogger, errorHandler, } from './middleware/index.js';
8
+ // Routes
9
+ export { health } from './routes/health.js';
10
+ export { walletCrudRoutes } from './routes/wallets.js';
11
+ export { walletRoutes } from './routes/wallet.js';
12
+ export { transactionRoutes } from './routes/transactions.js';
13
+ export { mcpTokenRoutes } from './routes/mcp.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAsB,MAAM,aAAa,CAAC;AAE5D,aAAa;AACb,OAAO,EACL,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,aAAa,EACb,YAAY,GAEb,MAAM,uBAAuB,CAAC;AAE/B,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAA4B,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAA6B,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,cAAc,EAA0B,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * validateOwnerAddress: Chain-aware address validation utility.
3
+ *
4
+ * Validates and normalizes owner wallet addresses for both supported chains:
5
+ * - **Solana**: Base58-encoded 32-byte Ed25519 public key
6
+ * - **Ethereum**: 0x-prefixed EIP-55 checksum address (strict mode)
7
+ *
8
+ * **EIP-55 strict mode**: All-lowercase and all-uppercase addresses are rejected.
9
+ * This is intentional -- we require EIP-55 checksum format for security to prevent
10
+ * address typos from going undetected.
11
+ *
12
+ * The `decodeBase58` function is extracted from owner-auth.ts and exported here
13
+ * as the canonical location. owner-auth.ts will import from here in Plan 87-02.
14
+ *
15
+ * @see docs/52-auth-redesign.md
16
+ */
17
+ import type { ChainType } from '@waiaas/core';
18
+ export interface AddressValidationResult {
19
+ valid: boolean;
20
+ /** Normalized address (EIP-55 checksum for Ethereum, unchanged for Solana) */
21
+ normalized?: string;
22
+ /** Reason on failure */
23
+ error?: string;
24
+ }
25
+ /**
26
+ * Decode a Base58-encoded string (Bitcoin alphabet) to a Buffer.
27
+ * Characters not in the Base58 alphabet (0, O, I, l) cause an error.
28
+ */
29
+ export declare function decodeBase58(str: string): Buffer;
30
+ /**
31
+ * Validate and normalize an owner wallet address for the given chain.
32
+ *
33
+ * - Solana: Base58 32-byte Ed25519 public key
34
+ * - Ethereum: 0x + EIP-55 checksum (strict -- all-lowercase rejected)
35
+ * - Unknown chain: rejected
36
+ */
37
+ export declare function validateOwnerAddress(chain: ChainType, address: string): AddressValidationResult;
38
+ //# sourceMappingURL=address-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-validation.d.ts","sourceRoot":"","sources":["../../../src/api/middleware/address-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAO9C,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AASD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAyChD;AA8DD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,uBAAuB,CAS/F"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * validateOwnerAddress: Chain-aware address validation utility.
3
+ *
4
+ * Validates and normalizes owner wallet addresses for both supported chains:
5
+ * - **Solana**: Base58-encoded 32-byte Ed25519 public key
6
+ * - **Ethereum**: 0x-prefixed EIP-55 checksum address (strict mode)
7
+ *
8
+ * **EIP-55 strict mode**: All-lowercase and all-uppercase addresses are rejected.
9
+ * This is intentional -- we require EIP-55 checksum format for security to prevent
10
+ * address typos from going undetected.
11
+ *
12
+ * The `decodeBase58` function is extracted from owner-auth.ts and exported here
13
+ * as the canonical location. owner-auth.ts will import from here in Plan 87-02.
14
+ *
15
+ * @see docs/52-auth-redesign.md
16
+ */
17
+ import { isAddress, getAddress } from 'viem';
18
+ // ---------------------------------------------------------------------------
19
+ // Base58 decode (Bitcoin alphabet) -- canonical location
20
+ // Extracted from owner-auth.ts for reuse across address validation.
21
+ // ---------------------------------------------------------------------------
22
+ const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
23
+ /**
24
+ * Decode a Base58-encoded string (Bitcoin alphabet) to a Buffer.
25
+ * Characters not in the Base58 alphabet (0, O, I, l) cause an error.
26
+ */
27
+ export function decodeBase58(str) {
28
+ // Count leading '1's (zero bytes)
29
+ let zeroes = 0;
30
+ for (let i = 0; i < str.length && str[i] === '1'; i++) {
31
+ zeroes++;
32
+ }
33
+ // Allocate enough space in base256 representation
34
+ const size = Math.ceil((str.length * 733) / 1000) + 1;
35
+ const b256 = new Uint8Array(size);
36
+ let length = 0;
37
+ for (let i = zeroes; i < str.length; i++) {
38
+ const charIndex = BASE58_ALPHABET.indexOf(str[i]);
39
+ if (charIndex === -1) {
40
+ throw new Error(`Invalid Base58 character: ${str[i]}`);
41
+ }
42
+ let carry = charIndex;
43
+ let j = 0;
44
+ for (let k = size - 1; k >= 0 && (carry !== 0 || j < length); k--, j++) {
45
+ carry += 58 * (b256[k] ?? 0);
46
+ b256[k] = carry % 256;
47
+ carry = Math.floor(carry / 256);
48
+ }
49
+ length = j;
50
+ }
51
+ // Skip leading zeros in b256
52
+ let start = 0;
53
+ while (start < size && b256[start] === 0) {
54
+ start++;
55
+ }
56
+ // Build result with leading zero bytes
57
+ const result = Buffer.alloc(zeroes + (size - start));
58
+ for (let i = start; i < size; i++) {
59
+ result[zeroes + (i - start)] = b256[i];
60
+ }
61
+ return result;
62
+ }
63
+ // ---------------------------------------------------------------------------
64
+ // Solana address validation
65
+ // ---------------------------------------------------------------------------
66
+ function validateSolanaAddress(address) {
67
+ try {
68
+ const decoded = decodeBase58(address);
69
+ if (decoded.length !== 32) {
70
+ return {
71
+ valid: false,
72
+ error: `Invalid Solana address: expected 32 bytes, got ${String(decoded.length)}`,
73
+ };
74
+ }
75
+ return { valid: true, normalized: address };
76
+ }
77
+ catch (err) {
78
+ const msg = err instanceof Error ? err.message : String(err);
79
+ return { valid: false, error: `Invalid Solana address (Base58 decode failed): ${msg}` };
80
+ }
81
+ }
82
+ // ---------------------------------------------------------------------------
83
+ // Ethereum address validation
84
+ // ---------------------------------------------------------------------------
85
+ function validateEthereumAddress(address) {
86
+ // Check basic format first (0x prefix + hex)
87
+ if (!address.startsWith('0x')) {
88
+ return { valid: false, error: 'Invalid Ethereum address format: missing 0x prefix' };
89
+ }
90
+ // isAddress with strict=false checks format only (0x + 40 hex chars)
91
+ if (!isAddress(address, { strict: false })) {
92
+ return { valid: false, error: 'Invalid Ethereum address format' };
93
+ }
94
+ // Require EIP-55 mixed-case checksum format.
95
+ // viem isAddress(strict:true) still accepts all-lowercase/all-uppercase,
96
+ // so we explicitly reject those -- we require the checksummed mixed-case form
97
+ // for security (prevents undetected typos).
98
+ const hex = address.slice(2);
99
+ if (hex === hex.toLowerCase() || hex === hex.toUpperCase()) {
100
+ return { valid: false, error: 'Invalid EIP-55 checksum: all-lowercase or all-uppercase addresses are not accepted, use checksummed format' };
101
+ }
102
+ // Verify the mixed-case matches EIP-55 checksum exactly
103
+ try {
104
+ const checksummed = getAddress(address);
105
+ if (checksummed !== address) {
106
+ return { valid: false, error: 'Invalid EIP-55 checksum' };
107
+ }
108
+ return { valid: true, normalized: checksummed };
109
+ }
110
+ catch {
111
+ return { valid: false, error: 'Invalid EIP-55 checksum' };
112
+ }
113
+ }
114
+ // ---------------------------------------------------------------------------
115
+ // Public API
116
+ // ---------------------------------------------------------------------------
117
+ /**
118
+ * Validate and normalize an owner wallet address for the given chain.
119
+ *
120
+ * - Solana: Base58 32-byte Ed25519 public key
121
+ * - Ethereum: 0x + EIP-55 checksum (strict -- all-lowercase rejected)
122
+ * - Unknown chain: rejected
123
+ */
124
+ export function validateOwnerAddress(chain, address) {
125
+ switch (chain) {
126
+ case 'solana':
127
+ return validateSolanaAddress(address);
128
+ case 'ethereum':
129
+ return validateEthereumAddress(address);
130
+ default:
131
+ return { valid: false, error: `Unsupported chain: ${chain}` };
132
+ }
133
+ }
134
+ //# sourceMappingURL=address-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-validation.js","sourceRoot":"","sources":["../../../src/api/middleware/address-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAc7C,8EAA8E;AAC9E,yDAAyD;AACzD,oEAAoE;AACpE,8EAA8E;AAE9E,MAAM,eAAe,GAAG,4DAA4D,CAAC;AAErF;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,kCAAkC;IAClC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACtD,MAAM,EAAE,CAAC;IACX,CAAC;IAED,kDAAkD;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,K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* routes only. Uses strict CSP:
5
+ * - default-src 'none'
6
+ * - script-src 'self'
7
+ * - style-src 'self' 'unsafe-inline'
8
+ * - connect-src 'self'
9
+ * - img-src 'self' data:
10
+ * - font-src 'self'
11
+ * - base-uri 'self'
12
+ * - form-action 'self'
13
+ *
14
+ * @see docs/67-admin-web-ui-spec.md section 3
15
+ */
16
+ export declare const cspMiddleware: import("hono").MiddlewareHandler<any, string, {}, Response>;
17
+ //# sourceMappingURL=csp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csp.d.ts","sourceRoot":"","sources":["../../../src/api/middleware/csp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAeH,eAAO,MAAM,aAAa,6DAGxB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * CSP middleware: Content-Security-Policy header for Admin UI paths.
3
+ *
4
+ * Applied to /admin/* routes only. Uses strict CSP:
5
+ * - default-src 'none'
6
+ * - script-src 'self'
7
+ * - style-src 'self' 'unsafe-inline'
8
+ * - connect-src 'self'
9
+ * - img-src 'self' data:
10
+ * - font-src 'self'
11
+ * - base-uri 'self'
12
+ * - form-action 'self'
13
+ *
14
+ * @see docs/67-admin-web-ui-spec.md section 3
15
+ */
16
+ import { createMiddleware } from 'hono/factory';
17
+ const CSP_VALUE = [
18
+ "default-src 'none'",
19
+ "script-src 'self'",
20
+ "style-src 'self' 'unsafe-inline'",
21
+ "connect-src 'self'",
22
+ "img-src 'self' data:",
23
+ "font-src 'self'",
24
+ "base-uri 'self'",
25
+ "form-action 'self'",
26
+ ].join('; ');
27
+ export const cspMiddleware = createMiddleware(async (c, next) => {
28
+ await next();
29
+ c.res.headers.set('Content-Security-Policy', CSP_VALUE);
30
+ });
31
+ //# sourceMappingURL=csp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csp.js","sourceRoot":"","sources":["../../../src/api/middleware/csp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,SAAS,GAAG;IAChB,oBAAoB;IACpB,mBAAmB;IACnB,kCAAkC;IAClC,oBAAoB;IACpB,sBAAsB;IACtB,iBAAiB;IACjB,iBAAiB;IACjB,oBAAoB;CACrB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;IAC9D,MAAM,IAAI,EAAE,CAAC;IACb,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAC1D,CAAC,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Error handler: Hono onError handler converting errors to WAIaaSError-shaped JSON.
3
+ *
4
+ * - WAIaaSError: responds with error.httpStatus and error.toJSON()
5
+ * - Enriches response with hint field from error-hints.ts for AI agent self-recovery
6
+ * - ZodError: responds with 400 and formatted validation error
7
+ * - Generic Error: responds with 500 and SYSTEM_LOCKED error
8
+ *
9
+ * Always includes requestId from context in the error response.
10
+ *
11
+ * @see docs/37-rest-api-complete-spec.md section 10.12
12
+ * @see docs/55-dx-improvement-spec.md section 2.2
13
+ */
14
+ import type { ErrorHandler } from 'hono';
15
+ export declare const errorHandler: ErrorHandler;
16
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../../src/api/middleware/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAKzC,eAAO,MAAM,YAAY,EAAE,YAwC1B,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Error handler: Hono onError handler converting errors to WAIaaSError-shaped JSON.
3
+ *
4
+ * - WAIaaSError: responds with error.httpStatus and error.toJSON()
5
+ * - Enriches response with hint field from error-hints.ts for AI agent self-recovery
6
+ * - ZodError: responds with 400 and formatted validation error
7
+ * - Generic Error: responds with 500 and SYSTEM_LOCKED error
8
+ *
9
+ * Always includes requestId from context in the error response.
10
+ *
11
+ * @see docs/37-rest-api-complete-spec.md section 10.12
12
+ * @see docs/55-dx-improvement-spec.md section 2.2
13
+ */
14
+ import { WAIaaSError } from '@waiaas/core';
15
+ import { ZodError } from 'zod';
16
+ import { resolveHint } from '../error-hints.js';
17
+ export const errorHandler = (err, c) => {
18
+ const requestId = c.get('requestId');
19
+ if (err instanceof WAIaaSError) {
20
+ const body = err.toJSON();
21
+ const hint = err.hint ?? resolveHint(err.code);
22
+ return c.json({ ...body, requestId: requestId ?? body.requestId, ...(hint && { hint }) }, err.httpStatus);
23
+ }
24
+ if (err instanceof ZodError) {
25
+ return c.json({
26
+ code: 'ACTION_VALIDATION_FAILED',
27
+ message: 'Validation error',
28
+ details: {
29
+ issues: err.issues.map((issue) => ({
30
+ path: issue.path.join('.'),
31
+ message: issue.message,
32
+ })),
33
+ },
34
+ requestId,
35
+ retryable: false,
36
+ }, 400);
37
+ }
38
+ // Generic error -> 500
39
+ return c.json({
40
+ code: 'SYSTEM_LOCKED',
41
+ message: err instanceof Error ? err.message : 'Internal server error',
42
+ requestId,
43
+ retryable: false,
44
+ }, 500);
45
+ };
46
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/api/middleware/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,MAAM,YAAY,GAAiB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;IACnD,MAAM,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the Host header and only allows requests where the hostname
5
+ * starts with 127.0.0.1, localhost, or [::1].
6
+ * Non-localhost requests are rejected with 403 SYSTEM_LOCKED.
7
+ *
8
+ * @see docs/29-api-framework-design.md
9
+ */
10
+ export declare const hostGuard: import("hono").MiddlewareHandler<any, string, {}, Response>;
11
+ //# sourceMappingURL=host-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-guard.d.ts","sourceRoot":"","sources":["../../../src/api/middleware/host-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,eAAO,MAAM,SAAS,6DAgBpB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Host guard middleware: restricts requests to localhost only.
3
+ *
4
+ * Checks the Host header and only allows requests where the hostname
5
+ * starts with 127.0.0.1, localhost, or [::1].
6
+ * Non-localhost requests are rejected with 403 SYSTEM_LOCKED.
7
+ *
8
+ * @see docs/29-api-framework-design.md
9
+ */
10
+ import { createMiddleware } from 'hono/factory';
11
+ import { WAIaaSError } from '@waiaas/core';
12
+ const LOCALHOST_PATTERNS = ['127.0.0.1', 'localhost', '[::1]'];
13
+ export const hostGuard = createMiddleware(async (c, next) => {
14
+ const host = c.req.header('Host') ?? '';
15
+ // Extract hostname (strip port if present)
16
+ const hostname = host.replace(/:\d+$/, '');
17
+ const isLocalhost = LOCALHOST_PATTERNS.some((pattern) => hostname === pattern || hostname.startsWith(pattern));
18
+ if (!isLocalhost) {
19
+ throw new WAIaaSError('SYSTEM_LOCKED', {
20
+ message: 'Only localhost access allowed',
21
+ });
22
+ }
23
+ await next();
24
+ });
25
+ //# sourceMappingURL=host-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-guard.js","sourceRoot":"","sources":["../../../src/api/middleware/host-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;IAC1D,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACxC,2CAA2C;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAE3C,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CACzC,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,KAAK,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAClE,CAAC;IAEF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,WAAW,CAAC,eAAe,EAAE;YACrC,OAAO,EAAE,+BAA+B;SACzC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,IAAI,EAAE,CAAC;AACf,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Barrel export: all 5 middleware + error handler.
3
+ */
4
+ export { requestId } from './request-id.js';
5
+ export { hostGuard } from './host-guard.js';
6
+ export { createKillSwitchGuard, type GetKillSwitchState } from './kill-switch-guard.js';
7
+ export { requestLogger } from './request-logger.js';
8
+ export { errorHandler } from './error-handler.js';
9
+ export { createSessionAuth, type SessionAuthDeps } from './session-auth.js';
10
+ export { createMasterAuth, type MasterAuthDeps } from './master-auth.js';
11
+ export { createOwnerAuth, type OwnerAuthDeps } from './owner-auth.js';
12
+ export { cspMiddleware } from './csp.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/middleware/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Barrel export: all 5 middleware + error handler.
3
+ */
4
+ export { requestId } from './request-id.js';
5
+ export { hostGuard } from './host-guard.js';
6
+ export { createKillSwitchGuard } from './kill-switch-guard.js';
7
+ export { requestLogger } from './request-logger.js';
8
+ export { errorHandler } from './error-handler.js';
9
+ export { createSessionAuth } from './session-auth.js';
10
+ export { createMasterAuth } from './master-auth.js';
11
+ export { createOwnerAuth } from './owner-auth.js';
12
+ export { cspMiddleware } from './csp.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/middleware/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAA2B,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAwB,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAsB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Kill switch guard middleware: blocks requests when kill switch is
3
+ * SUSPENDED or LOCKED (3-state model).
4
+ *
5
+ * Accepts a factory function `getKillSwitchState` that returns the current
6
+ * kill switch state string. If SUSPENDED or LOCKED, rejects with 503
7
+ * SYSTEM_LOCKED.
8
+ *
9
+ * Bypass paths:
10
+ * - /health (always public)
11
+ * - /v1/admin/* (admin API for management/recovery)
12
+ * - /admin/* (Admin SPA for UI)
13
+ * - /v1/owner/* (owner kill-switch activation + recovery)
14
+ *
15
+ * @see docs/36-killswitch-evm-freeze.md
16
+ */
17
+ export type GetKillSwitchState = () => string;
18
+ export declare function createKillSwitchGuard(getState?: GetKillSwitchState): import("hono").MiddlewareHandler<any, string, {}, Response>;
19
+ //# sourceMappingURL=kill-switch-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill-switch-guard.d.ts","sourceRoot":"","sources":["../../../src/api/middleware/kill-switch-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,MAAM,MAAM,kBAAkB,GAAG,MAAM,MAAM,CAAC;AAI9C,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,kBAAsC,+DAiCrF"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Kill switch guard middleware: blocks requests when kill switch is
3
+ * SUSPENDED or LOCKED (3-state model).
4
+ *
5
+ * Accepts a factory function `getKillSwitchState` that returns the current
6
+ * kill switch state string. If SUSPENDED or LOCKED, rejects with 503
7
+ * SYSTEM_LOCKED.
8
+ *
9
+ * Bypass paths:
10
+ * - /health (always public)
11
+ * - /v1/admin/* (admin API for management/recovery)
12
+ * - /admin/* (Admin SPA for UI)
13
+ * - /v1/owner/* (owner kill-switch activation + recovery)
14
+ *
15
+ * @see docs/36-killswitch-evm-freeze.md
16
+ */
17
+ import { createMiddleware } from 'hono/factory';
18
+ import { WAIaaSError } from '@waiaas/core';
19
+ const DEFAULT_GET_STATE = () => 'ACTIVE';
20
+ export function createKillSwitchGuard(getState = DEFAULT_GET_STATE) {
21
+ return createMiddleware(async (c, next) => {
22
+ // /health always bypasses kill switch
23
+ if (c.req.path === '/health') {
24
+ await next();
25
+ return;
26
+ }
27
+ // Admin API paths bypass kill switch (need to manage kill switch state)
28
+ if (c.req.path.startsWith('/v1/admin/')) {
29
+ await next();
30
+ return;
31
+ }
32
+ // Admin SPA paths bypass kill switch (need to serve UI for recovery)
33
+ if (c.req.path === '/admin' || c.req.path.startsWith('/admin/')) {
34
+ await next();
35
+ return;
36
+ }
37
+ // Owner API paths bypass kill switch (owner kill-switch activation + recovery)
38
+ if (c.req.path.startsWith('/v1/owner/')) {
39
+ await next();
40
+ return;
41
+ }
42
+ const state = getState();
43
+ if (state === 'SUSPENDED' || state === 'LOCKED') {
44
+ throw new WAIaaSError('SYSTEM_LOCKED');
45
+ }
46
+ await next();
47
+ });
48
+ }
49
+ //# sourceMappingURL=kill-switch-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill-switch-guard.js","sourceRoot":"","sources":["../../../src/api/middleware/kill-switch-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3C,MAAM,iBAAiB,GAAuB,GAAG,EAAE,CAAC,QAAQ,CAAC;AAE7D,MAAM,UAAU,qBAAqB,CAAC,WAA+B,iBAAiB;IACpF,OAAO,gBAAgB,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACxC,sCAAsC;QACtC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,wEAAwE;QACxE,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,qEAAqE;QACrE,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAChE,MAAM,IAAI,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,+EAA+E;QAC/E,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;QACzB,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;YAChD,MAAM,IAAI,WAAW,CAAC,eAAe,CAAC,CAAC;QACzC,CAAC;QAED,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Master auth middleware: verifies X-Master-Password header against Argon2id hash.
3
+ *
4
+ * Protects administrative endpoints (agent creation, policy CRUD).
5
+ * The password is sent as plaintext in the header (localhost-only, secured by hostGuard).
6
+ *
7
+ * Factory pattern: createMasterAuth(deps) returns middleware.
8
+ *
9
+ * @see docs/52-auth-redesign.md
10
+ */
11
+ export interface MasterAuthDeps {
12
+ masterPasswordHash: string;
13
+ }
14
+ export declare function createMasterAuth(deps: MasterAuthDeps): import("hono").MiddlewareHandler<any, string, {}, Response>;
15
+ //# sourceMappingURL=master-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"master-auth.d.ts","sourceRoot":"","sources":["../../../src/api/middleware/master-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,MAAM,WAAW,cAAc;IAC7B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAMD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,+DAqBpD"}