@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,207 @@
1
+ /**
2
+ * BalanceMonitorService: periodic native-token balance check for all active wallets.
3
+ *
4
+ * Checks all ACTIVE wallets at a configurable interval (default 5 minutes).
5
+ * When a wallet's native balance drops below the chain-specific threshold,
6
+ * a LOW_BALANCE notification is sent via NotificationService.
7
+ *
8
+ * Features:
9
+ * - Chain-specific thresholds (SOL 0.01, ETH 0.005)
10
+ * - 24-hour cooldown to prevent duplicate alerts (BMON-03)
11
+ * - Recovery detection: re-alert if balance recovers then drops again (BMON-04)
12
+ * - Per-wallet error isolation: one wallet failure does not block others
13
+ * - Runtime configuration updates (updateConfig)
14
+ *
15
+ * @see BMON-01, BMON-02, BMON-03, BMON-04, BMON-05, BMON-06 requirements
16
+ */
17
+ import { getDefaultNetwork } from '@waiaas/core';
18
+ import { resolveRpcUrl } from '../../infrastructure/adapter-pool.js';
19
+ export const DEFAULT_BALANCE_MONITOR_CONFIG = {
20
+ checkIntervalSec: 300,
21
+ lowBalanceThresholdSol: 0.01,
22
+ lowBalanceThresholdEth: 0.005,
23
+ cooldownHours: 24,
24
+ enabled: true,
25
+ };
26
+ // ---------------------------------------------------------------------------
27
+ // BalanceMonitorService
28
+ // ---------------------------------------------------------------------------
29
+ export class BalanceMonitorService {
30
+ sqlite;
31
+ adapterPool;
32
+ rpcConfig;
33
+ notificationService;
34
+ config;
35
+ // Duplicate alert prevention: Map<walletId, NotifyState>
36
+ lastNotified = new Map();
37
+ // Periodic check timer
38
+ checkTimer = null;
39
+ constructor(opts) {
40
+ this.sqlite = opts.sqlite;
41
+ this.adapterPool = opts.adapterPool;
42
+ this.rpcConfig = opts.config.rpc;
43
+ this.notificationService = opts.notificationService;
44
+ this.config = { ...DEFAULT_BALANCE_MONITOR_CONFIG, ...opts.monitorConfig };
45
+ }
46
+ // -----------------------------------------------------------------------
47
+ // Lifecycle
48
+ // -----------------------------------------------------------------------
49
+ /** Start periodic balance checking. */
50
+ start() {
51
+ if (!this.config.enabled)
52
+ return;
53
+ this.checkTimer = setInterval(() => {
54
+ void this.checkAllWallets();
55
+ }, this.config.checkIntervalSec * 1000);
56
+ }
57
+ /** Stop periodic balance checking. */
58
+ stop() {
59
+ if (this.checkTimer) {
60
+ clearInterval(this.checkTimer);
61
+ this.checkTimer = null;
62
+ }
63
+ }
64
+ // -----------------------------------------------------------------------
65
+ // Core: check all wallets
66
+ // -----------------------------------------------------------------------
67
+ /** Check balances of all ACTIVE wallets. */
68
+ async checkAllWallets() {
69
+ const wallets = this.sqlite
70
+ .prepare("SELECT id, chain, environment, default_network, public_key FROM wallets WHERE status = 'ACTIVE'")
71
+ .all();
72
+ for (const wallet of wallets) {
73
+ try {
74
+ await this.checkWallet(wallet);
75
+ }
76
+ catch {
77
+ // Per-wallet error isolation: log but don't stop
78
+ }
79
+ }
80
+ }
81
+ // -----------------------------------------------------------------------
82
+ // Per-wallet check
83
+ // -----------------------------------------------------------------------
84
+ async checkWallet(wallet) {
85
+ const chain = wallet.chain;
86
+ const env = wallet.environment;
87
+ const network = (wallet.default_network ??
88
+ getDefaultNetwork(chain, env));
89
+ const rpcUrl = resolveRpcUrl(this.rpcConfig, chain, network);
90
+ if (!rpcUrl)
91
+ return; // No RPC URL configured -- skip
92
+ const adapter = await this.adapterPool.resolve(chain, network, rpcUrl);
93
+ const balanceInfo = await adapter.getBalance(wallet.public_key);
94
+ // Convert from smallest unit to decimal
95
+ const decimalBalance = Number(balanceInfo.balance) / 10 ** balanceInfo.decimals;
96
+ const threshold = this.getThreshold(chain);
97
+ const currency = balanceInfo.symbol;
98
+ if (decimalBalance <= threshold) {
99
+ // Balance is low
100
+ if (this.shouldNotify(wallet.id)) {
101
+ this.notifyLowBalance(wallet.id, decimalBalance, currency, threshold);
102
+ }
103
+ // Mark as low (regardless of notification)
104
+ this.lastNotified.set(wallet.id, {
105
+ timestamp: Date.now(),
106
+ wasLow: true,
107
+ });
108
+ }
109
+ else {
110
+ // Balance is above threshold -- mark recovered if it was low
111
+ this.markRecovered(wallet.id);
112
+ }
113
+ }
114
+ // -----------------------------------------------------------------------
115
+ // Threshold resolution
116
+ // -----------------------------------------------------------------------
117
+ getThreshold(chain) {
118
+ switch (chain) {
119
+ case 'solana':
120
+ return this.config.lowBalanceThresholdSol;
121
+ case 'ethereum':
122
+ return this.config.lowBalanceThresholdEth;
123
+ default:
124
+ return this.config.lowBalanceThresholdSol; // fallback
125
+ }
126
+ }
127
+ // -----------------------------------------------------------------------
128
+ // Duplicate alert prevention (BMON-03)
129
+ // -----------------------------------------------------------------------
130
+ shouldNotify(walletId) {
131
+ const state = this.lastNotified.get(walletId);
132
+ if (!state)
133
+ return true; // Never notified
134
+ // If balance recovered since last notification, allow new alert (BMON-04)
135
+ if (!state.wasLow)
136
+ return true;
137
+ // Cooldown check: 24 hours since last notification
138
+ const cooldownMs = this.config.cooldownHours * 3600 * 1000;
139
+ return Date.now() - state.timestamp >= cooldownMs;
140
+ }
141
+ // -----------------------------------------------------------------------
142
+ // Notification
143
+ // -----------------------------------------------------------------------
144
+ notifyLowBalance(walletId, balance, currency, threshold) {
145
+ void this.notificationService?.notify('LOW_BALANCE', walletId, {
146
+ walletId,
147
+ balance: String(balance),
148
+ currency,
149
+ threshold: String(threshold),
150
+ });
151
+ this.lastNotified.set(walletId, {
152
+ timestamp: Date.now(),
153
+ wasLow: true,
154
+ });
155
+ }
156
+ // -----------------------------------------------------------------------
157
+ // Recovery detection (BMON-04)
158
+ // -----------------------------------------------------------------------
159
+ markRecovered(walletId) {
160
+ const state = this.lastNotified.get(walletId);
161
+ if (state && state.wasLow) {
162
+ state.wasLow = false;
163
+ // Keep timestamp -- cooldown does not reset on recovery.
164
+ // But shouldNotify() checks wasLow first, so recovery + re-drop = new alert.
165
+ }
166
+ }
167
+ // -----------------------------------------------------------------------
168
+ // Runtime configuration update
169
+ // -----------------------------------------------------------------------
170
+ /** Update configuration at runtime (e.g., from Admin Settings). */
171
+ updateConfig(config) {
172
+ if (config.lowBalanceThresholdSol !== undefined) {
173
+ this.config.lowBalanceThresholdSol = config.lowBalanceThresholdSol;
174
+ }
175
+ if (config.lowBalanceThresholdEth !== undefined) {
176
+ this.config.lowBalanceThresholdEth = config.lowBalanceThresholdEth;
177
+ }
178
+ if (config.cooldownHours !== undefined) {
179
+ this.config.cooldownHours = config.cooldownHours;
180
+ }
181
+ if (config.enabled !== undefined) {
182
+ this.config.enabled = config.enabled;
183
+ }
184
+ if (config.checkIntervalSec !== undefined) {
185
+ this.config.checkIntervalSec = config.checkIntervalSec;
186
+ // Restart timer with new interval
187
+ if (this.checkTimer) {
188
+ clearInterval(this.checkTimer);
189
+ this.checkTimer = setInterval(() => {
190
+ void this.checkAllWallets();
191
+ }, config.checkIntervalSec * 1000);
192
+ }
193
+ }
194
+ }
195
+ // -----------------------------------------------------------------------
196
+ // Monitoring / status
197
+ // -----------------------------------------------------------------------
198
+ /** Get current monitoring status for debugging. */
199
+ getStatus() {
200
+ return {
201
+ enabled: this.config.enabled,
202
+ config: { ...this.config },
203
+ trackedWallets: this.lastNotified.size,
204
+ };
205
+ }
206
+ }
207
+ //# sourceMappingURL=balance-monitor-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balance-monitor-service.js","sourceRoot":"","sources":["../../../src/services/monitoring/balance-monitor-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAerE,MAAM,CAAC,MAAM,8BAA8B,GAAyB;IAClE,gBAAgB,EAAE,GAAG;IACrB,sBAAsB,EAAE,IAAI;IAC5B,sBAAsB,EAAE,KAAK;IAC7B,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE,IAAI;CACd,CAAC;AAmBF,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAAW;IACjB,WAAW,CAAc;IACzB,SAAS,CAAyB;IAClC,mBAAmB,CAAuB;IAC1C,MAAM,CAAuB;IAErC,yDAAyD;IACjD,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEtD,uBAAuB;IACf,UAAU,GAA0C,IAAI,CAAC;IAEjE,YAAY,IAMX;QACC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,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,CAAC,UAAU,CAAC,CAAC;gBAC/B,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;oBACjC,KAAK,IAAI,CAAC,eAAe,EAAE,CAAC;gBAC9B,CAAC,EAAE,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,sBAAsB;IACtB,0EAA0E;IAE1E,mDAAmD;IACnD,SAAS;QAKP,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE;YAC1B,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI;SACvC,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * WcSessionService - WalletConnect SignClient lifecycle wrapper.
3
+ *
4
+ * Manages SignClient initialization, shutdown, session mapping,
5
+ * pairing creation, session info retrieval, and disconnect.
6
+ * Designed for fail-soft integration with DaemonLifecycle (Step 4c-6).
7
+ *
8
+ * Key responsibilities:
9
+ * - Initialize SignClient with SQLite-backed IKeyValueStorage
10
+ * - Register event listeners for session_delete / session_expire
11
+ * - Maintain in-memory walletId -> session topic mapping (restored from DB on startup)
12
+ * - Create WC pairings with QR code generation (createPairing)
13
+ * - Manage session lifecycle (getSessionInfo, getPairingStatus, disconnectSession)
14
+ *
15
+ * @see packages/daemon/src/services/wc-storage.ts
16
+ * @see packages/daemon/src/infrastructure/database/migrate.ts (v16: wc_sessions table)
17
+ */
18
+ import SignClientModule from '@walletconnect/sign-client';
19
+ import type { Database } from 'better-sqlite3';
20
+ declare const SignClient: typeof SignClientModule;
21
+ type SignClientInstance = InstanceType<typeof SignClient>;
22
+ import type { SettingsService } from '../infrastructure/settings/settings-service.js';
23
+ /** CAIP-2 chain identifiers for WalletConnect v2 */
24
+ export declare const CAIP2_CHAIN_IDS: Record<string, string>;
25
+ export interface WcSessionServiceDeps {
26
+ sqlite: Database;
27
+ settingsService: SettingsService;
28
+ }
29
+ export interface PairingResult {
30
+ uri: string;
31
+ qrDataUrl: string;
32
+ expiresAt: number;
33
+ }
34
+ export interface WcSessionInfo {
35
+ walletId: string;
36
+ topic: string;
37
+ peerName: string | null;
38
+ peerUrl: string | null;
39
+ chainId: string;
40
+ ownerAddress: string;
41
+ expiry: number;
42
+ createdAt: number;
43
+ }
44
+ export type PairingStatus = 'pending' | 'connected' | 'expired' | 'none';
45
+ /** Mutable ref object shared between routes, bridge, and hot-reloader. */
46
+ export interface WcServiceRef {
47
+ current: WcSessionService | null;
48
+ }
49
+ export declare class WcSessionService {
50
+ private signClient;
51
+ private storage;
52
+ private readonly sqlite;
53
+ private readonly settingsService;
54
+ /** walletId -> session topic mapping (in-memory cache) */
55
+ private readonly sessionMap;
56
+ /** Tracking pending pairing attempts per wallet */
57
+ private readonly pendingPairing;
58
+ constructor(deps: WcSessionServiceDeps);
59
+ /**
60
+ * Initialize SignClient with SQLite storage.
61
+ * No-op if walletconnect.project_id is not configured.
62
+ */
63
+ initialize(): Promise<void>;
64
+ /**
65
+ * Restore walletId -> topic mappings from wc_sessions table.
66
+ */
67
+ private restoreSessions;
68
+ /**
69
+ * Check if a wallet has an active WC session.
70
+ */
71
+ hasActiveSession(walletId: string): boolean;
72
+ /**
73
+ * Get the underlying SignClient instance (for route handlers / pairing).
74
+ * Returns null if WC is not initialized.
75
+ */
76
+ getSignClient(): SignClientInstance | null;
77
+ /**
78
+ * Get the session topic for a wallet (public accessor).
79
+ * Returns null if no active session exists.
80
+ */
81
+ getSessionTopic(walletId: string): string | null;
82
+ /**
83
+ * Create a new WC pairing for a wallet.
84
+ * Returns URI + QR code immediately. Session settlement happens asynchronously.
85
+ *
86
+ * @param walletId - Wallet UUID
87
+ * @param network - Network name (e.g., 'devnet', 'ethereum-sepolia')
88
+ * @param chain - Chain type ('solana' or 'ethereum')
89
+ */
90
+ createPairing(walletId: string, network: string, chain: string): Promise<PairingResult>;
91
+ /**
92
+ * Background approval waiter. Saves session to DB when external wallet approves.
93
+ * On failure/timeout, cleans up pending pairing state.
94
+ */
95
+ private waitForApproval;
96
+ /**
97
+ * Get session info for a wallet from DB.
98
+ * Returns null if no session exists.
99
+ */
100
+ getSessionInfo(walletId: string): WcSessionInfo | null;
101
+ /**
102
+ * Get the current pairing/session status for a wallet.
103
+ */
104
+ getPairingStatus(walletId: string): PairingStatus;
105
+ /**
106
+ * Disconnect a wallet's WC session.
107
+ * Removes from relay, DB, and in-memory map.
108
+ */
109
+ disconnectSession(walletId: string): Promise<void>;
110
+ /**
111
+ * Gracefully shut down SignClient resources.
112
+ * Clears in-memory state but does NOT delete DB sessions
113
+ * (they'll be restored on next startup).
114
+ */
115
+ shutdown(): Promise<void>;
116
+ /**
117
+ * Handle session deletion/expiration from WC relay.
118
+ * Removes from both DB and in-memory map.
119
+ */
120
+ private handleSessionDelete;
121
+ }
122
+ export {};
123
+ //# sourceMappingURL=wc-session-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wc-session-service.d.ts","sourceRoot":"","sources":["../../src/services/wc-session-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK/C,QAAA,MAAM,UAAU,EAAE,OAAO,gBAC8B,CAAC;AACxD,KAAK,kBAAkB,GAAG,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAUtF,oDAAoD;AACpD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAgBlD,CAAC;AAMF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,QAAQ,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,MAAM,WAAW,aAAa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