@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.
- package/dist/api/error-hints.d.ts +15 -0
- package/dist/api/error-hints.d.ts.map +1 -0
- package/dist/api/error-hints.js +71 -0
- package/dist/api/error-hints.js.map +1 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +14 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/middleware/address-validation.d.ts +38 -0
- package/dist/api/middleware/address-validation.d.ts.map +1 -0
- package/dist/api/middleware/address-validation.js +134 -0
- package/dist/api/middleware/address-validation.js.map +1 -0
- package/dist/api/middleware/csp.d.ts +17 -0
- package/dist/api/middleware/csp.d.ts.map +1 -0
- package/dist/api/middleware/csp.js +31 -0
- package/dist/api/middleware/csp.js.map +1 -0
- package/dist/api/middleware/error-handler.d.ts +16 -0
- package/dist/api/middleware/error-handler.d.ts.map +1 -0
- package/dist/api/middleware/error-handler.js +46 -0
- package/dist/api/middleware/error-handler.js.map +1 -0
- package/dist/api/middleware/host-guard.d.ts +11 -0
- package/dist/api/middleware/host-guard.d.ts.map +1 -0
- package/dist/api/middleware/host-guard.js +25 -0
- package/dist/api/middleware/host-guard.js.map +1 -0
- package/dist/api/middleware/index.d.ts +13 -0
- package/dist/api/middleware/index.d.ts.map +1 -0
- package/dist/api/middleware/index.js +13 -0
- package/dist/api/middleware/index.js.map +1 -0
- package/dist/api/middleware/kill-switch-guard.d.ts +19 -0
- package/dist/api/middleware/kill-switch-guard.d.ts.map +1 -0
- package/dist/api/middleware/kill-switch-guard.js +49 -0
- package/dist/api/middleware/kill-switch-guard.js.map +1 -0
- package/dist/api/middleware/master-auth.d.ts +15 -0
- package/dist/api/middleware/master-auth.d.ts.map +1 -0
- package/dist/api/middleware/master-auth.js +35 -0
- package/dist/api/middleware/master-auth.js.map +1 -0
- package/dist/api/middleware/owner-auth.d.ts +30 -0
- package/dist/api/middleware/owner-auth.d.ts.map +1 -0
- package/dist/api/middleware/owner-auth.js +133 -0
- package/dist/api/middleware/owner-auth.js.map +1 -0
- package/dist/api/middleware/request-id.d.ts +10 -0
- package/dist/api/middleware/request-id.d.ts.map +1 -0
- package/dist/api/middleware/request-id.js +18 -0
- package/dist/api/middleware/request-id.js.map +1 -0
- package/dist/api/middleware/request-logger.d.ts +9 -0
- package/dist/api/middleware/request-logger.d.ts.map +1 -0
- package/dist/api/middleware/request-logger.js +18 -0
- package/dist/api/middleware/request-logger.js.map +1 -0
- package/dist/api/middleware/session-auth.d.ts +21 -0
- package/dist/api/middleware/session-auth.d.ts.map +1 -0
- package/dist/api/middleware/session-auth.js +51 -0
- package/dist/api/middleware/session-auth.js.map +1 -0
- package/dist/api/middleware/siwe-verify.d.ts +31 -0
- package/dist/api/middleware/siwe-verify.d.ts.map +1 -0
- package/dist/api/middleware/siwe-verify.js +55 -0
- package/dist/api/middleware/siwe-verify.js.map +1 -0
- package/dist/api/routes/actions.d.ts +56 -0
- package/dist/api/routes/actions.d.ts.map +1 -0
- package/dist/api/routes/actions.js +291 -0
- package/dist/api/routes/actions.js.map +1 -0
- package/dist/api/routes/admin.d.ts +99 -0
- package/dist/api/routes/admin.d.ts.map +1 -0
- package/dist/api/routes/admin.js +1304 -0
- package/dist/api/routes/admin.js.map +1 -0
- package/dist/api/routes/display-currency-helper.d.ts +26 -0
- package/dist/api/routes/display-currency-helper.d.ts.map +1 -0
- package/dist/api/routes/display-currency-helper.js +47 -0
- package/dist/api/routes/display-currency-helper.js.map +1 -0
- package/dist/api/routes/health.d.ts +14 -0
- package/dist/api/routes/health.d.ts.map +1 -0
- package/dist/api/routes/health.js +47 -0
- package/dist/api/routes/health.js.map +1 -0
- package/dist/api/routes/index.d.ts +15 -0
- package/dist/api/routes/index.d.ts.map +1 -0
- package/dist/api/routes/index.js +15 -0
- package/dist/api/routes/index.js.map +1 -0
- package/dist/api/routes/mcp.d.ts +30 -0
- package/dist/api/routes/mcp.d.ts.map +1 -0
- package/dist/api/routes/mcp.js +156 -0
- package/dist/api/routes/mcp.js.map +1 -0
- package/dist/api/routes/nonce.d.ts +20 -0
- package/dist/api/routes/nonce.d.ts.map +1 -0
- package/dist/api/routes/nonce.js +48 -0
- package/dist/api/routes/nonce.js.map +1 -0
- package/dist/api/routes/openapi-schemas.d.ts +2281 -0
- package/dist/api/routes/openapi-schemas.d.ts.map +1 -0
- package/dist/api/routes/openapi-schemas.js +770 -0
- package/dist/api/routes/openapi-schemas.js.map +1 -0
- package/dist/api/routes/policies.d.ts +29 -0
- package/dist/api/routes/policies.d.ts.map +1 -0
- package/dist/api/routes/policies.js +332 -0
- package/dist/api/routes/policies.js.map +1 -0
- package/dist/api/routes/sessions.d.ts +35 -0
- package/dist/api/routes/sessions.d.ts.map +1 -0
- package/dist/api/routes/sessions.js +347 -0
- package/dist/api/routes/sessions.js.map +1 -0
- package/dist/api/routes/skills.d.ts +9 -0
- package/dist/api/routes/skills.d.ts.map +1 -0
- package/dist/api/routes/skills.js +59 -0
- package/dist/api/routes/skills.js.map +1 -0
- package/dist/api/routes/tokens.d.ts +25 -0
- package/dist/api/routes/tokens.d.ts.map +1 -0
- package/dist/api/routes/tokens.js +161 -0
- package/dist/api/routes/tokens.js.map +1 -0
- package/dist/api/routes/transactions.d.ts +68 -0
- package/dist/api/routes/transactions.d.ts.map +1 -0
- package/dist/api/routes/transactions.js +576 -0
- package/dist/api/routes/transactions.js.map +1 -0
- package/dist/api/routes/utils.d.ts +9 -0
- package/dist/api/routes/utils.d.ts.map +1 -0
- package/dist/api/routes/utils.js +52 -0
- package/dist/api/routes/utils.js.map +1 -0
- package/dist/api/routes/wallet.d.ts +36 -0
- package/dist/api/routes/wallet.d.ts.map +1 -0
- package/dist/api/routes/wallet.js +358 -0
- package/dist/api/routes/wallet.js.map +1 -0
- package/dist/api/routes/wallets.d.ts +43 -0
- package/dist/api/routes/wallets.d.ts.map +1 -0
- package/dist/api/routes/wallets.js +630 -0
- package/dist/api/routes/wallets.js.map +1 -0
- package/dist/api/routes/wc.d.ts +46 -0
- package/dist/api/routes/wc.d.ts.map +1 -0
- package/dist/api/routes/wc.js +354 -0
- package/dist/api/routes/wc.js.map +1 -0
- package/dist/api/routes/x402.d.ts +61 -0
- package/dist/api/routes/x402.d.ts.map +1 -0
- package/dist/api/routes/x402.js +493 -0
- package/dist/api/routes/x402.js.map +1 -0
- package/dist/api/server.d.ts +81 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +406 -0
- package/dist/api/server.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/action/action-provider-registry.d.ts +77 -0
- package/dist/infrastructure/action/action-provider-registry.d.ts.map +1 -0
- package/dist/infrastructure/action/action-provider-registry.js +239 -0
- package/dist/infrastructure/action/action-provider-registry.js.map +1 -0
- package/dist/infrastructure/action/api-key-store.d.ts +60 -0
- package/dist/infrastructure/action/api-key-store.d.ts.map +1 -0
- package/dist/infrastructure/action/api-key-store.js +130 -0
- package/dist/infrastructure/action/api-key-store.js.map +1 -0
- package/dist/infrastructure/action/index.d.ts +10 -0
- package/dist/infrastructure/action/index.d.ts.map +1 -0
- package/dist/infrastructure/action/index.js +9 -0
- package/dist/infrastructure/action/index.js.map +1 -0
- package/dist/infrastructure/adapter-pool.d.ts +50 -0
- package/dist/infrastructure/adapter-pool.d.ts.map +1 -0
- package/dist/infrastructure/adapter-pool.js +110 -0
- package/dist/infrastructure/adapter-pool.js.map +1 -0
- package/dist/infrastructure/backup/backup-service.d.ts +53 -0
- package/dist/infrastructure/backup/backup-service.d.ts.map +1 -0
- package/dist/infrastructure/backup/backup-service.js +158 -0
- package/dist/infrastructure/backup/backup-service.js.map +1 -0
- package/dist/infrastructure/backup/index.d.ts +2 -0
- package/dist/infrastructure/backup/index.d.ts.map +1 -0
- package/dist/infrastructure/backup/index.js +2 -0
- package/dist/infrastructure/backup/index.js.map +1 -0
- package/dist/infrastructure/config/index.d.ts +8 -0
- package/dist/infrastructure/config/index.d.ts.map +1 -0
- package/dist/infrastructure/config/index.js +7 -0
- package/dist/infrastructure/config/index.js.map +1 -0
- package/dist/infrastructure/config/loader.d.ts +555 -0
- package/dist/infrastructure/config/loader.d.ts.map +1 -0
- package/dist/infrastructure/config/loader.js +311 -0
- package/dist/infrastructure/config/loader.js.map +1 -0
- package/dist/infrastructure/database/checks.d.ts +19 -0
- package/dist/infrastructure/database/checks.d.ts.map +1 -0
- package/dist/infrastructure/database/checks.js +27 -0
- package/dist/infrastructure/database/checks.js.map +1 -0
- package/dist/infrastructure/database/compatibility.d.ts +36 -0
- package/dist/infrastructure/database/compatibility.d.ts.map +1 -0
- package/dist/infrastructure/database/compatibility.js +75 -0
- package/dist/infrastructure/database/compatibility.js.map +1 -0
- package/dist/infrastructure/database/connection.d.ts +36 -0
- package/dist/infrastructure/database/connection.d.ts.map +1 -0
- package/dist/infrastructure/database/connection.js +47 -0
- package/dist/infrastructure/database/connection.js.map +1 -0
- package/dist/infrastructure/database/id.d.ts +17 -0
- package/dist/infrastructure/database/id.d.ts.map +1 -0
- package/dist/infrastructure/database/id.js +20 -0
- package/dist/infrastructure/database/id.js.map +1 -0
- package/dist/infrastructure/database/index.d.ts +15 -0
- package/dist/infrastructure/database/index.d.ts.map +1 -0
- package/dist/infrastructure/database/index.js +12 -0
- package/dist/infrastructure/database/index.js.map +1 -0
- package/dist/infrastructure/database/migrate.d.ts +76 -0
- package/dist/infrastructure/database/migrate.d.ts.map +1 -0
- package/dist/infrastructure/database/migrate.js +1214 -0
- package/dist/infrastructure/database/migrate.js.map +1 -0
- package/dist/infrastructure/database/schema.d.ts +2352 -0
- package/dist/infrastructure/database/schema.d.ts.map +1 -0
- package/dist/infrastructure/database/schema.js +288 -0
- package/dist/infrastructure/database/schema.js.map +1 -0
- package/dist/infrastructure/jwt/index.d.ts +2 -0
- package/dist/infrastructure/jwt/index.d.ts.map +1 -0
- package/dist/infrastructure/jwt/index.js +2 -0
- package/dist/infrastructure/jwt/index.js.map +1 -0
- package/dist/infrastructure/jwt/jwt-secret-manager.d.ts +58 -0
- package/dist/infrastructure/jwt/jwt-secret-manager.d.ts.map +1 -0
- package/dist/infrastructure/jwt/jwt-secret-manager.js +222 -0
- package/dist/infrastructure/jwt/jwt-secret-manager.js.map +1 -0
- package/dist/infrastructure/keystore/crypto.d.ts +62 -0
- package/dist/infrastructure/keystore/crypto.d.ts.map +1 -0
- package/dist/infrastructure/keystore/crypto.js +89 -0
- package/dist/infrastructure/keystore/crypto.js.map +1 -0
- package/dist/infrastructure/keystore/index.d.ts +4 -0
- package/dist/infrastructure/keystore/index.d.ts.map +1 -0
- package/dist/infrastructure/keystore/index.js +5 -0
- package/dist/infrastructure/keystore/index.js.map +1 -0
- package/dist/infrastructure/keystore/keystore.d.ts +115 -0
- package/dist/infrastructure/keystore/keystore.d.ts.map +1 -0
- package/dist/infrastructure/keystore/keystore.js +327 -0
- package/dist/infrastructure/keystore/keystore.js.map +1 -0
- package/dist/infrastructure/keystore/memory.d.ts +45 -0
- package/dist/infrastructure/keystore/memory.d.ts.map +1 -0
- package/dist/infrastructure/keystore/memory.js +105 -0
- package/dist/infrastructure/keystore/memory.js.map +1 -0
- package/dist/infrastructure/oracle/coingecko-forex.d.ts +35 -0
- package/dist/infrastructure/oracle/coingecko-forex.d.ts.map +1 -0
- package/dist/infrastructure/oracle/coingecko-forex.js +69 -0
- package/dist/infrastructure/oracle/coingecko-forex.js.map +1 -0
- package/dist/infrastructure/oracle/coingecko-oracle.d.ts +73 -0
- package/dist/infrastructure/oracle/coingecko-oracle.d.ts.map +1 -0
- package/dist/infrastructure/oracle/coingecko-oracle.js +199 -0
- package/dist/infrastructure/oracle/coingecko-oracle.js.map +1 -0
- package/dist/infrastructure/oracle/coingecko-platform-ids.d.ts +32 -0
- package/dist/infrastructure/oracle/coingecko-platform-ids.d.ts.map +1 -0
- package/dist/infrastructure/oracle/coingecko-platform-ids.js +30 -0
- package/dist/infrastructure/oracle/coingecko-platform-ids.js.map +1 -0
- package/dist/infrastructure/oracle/forex-currencies.d.ts +36 -0
- package/dist/infrastructure/oracle/forex-currencies.d.ts.map +1 -0
- package/dist/infrastructure/oracle/forex-currencies.js +71 -0
- package/dist/infrastructure/oracle/forex-currencies.js.map +1 -0
- package/dist/infrastructure/oracle/forex-rate-service.d.ts +51 -0
- package/dist/infrastructure/oracle/forex-rate-service.d.ts.map +1 -0
- package/dist/infrastructure/oracle/forex-rate-service.js +149 -0
- package/dist/infrastructure/oracle/forex-rate-service.js.map +1 -0
- package/dist/infrastructure/oracle/index.d.ts +18 -0
- package/dist/infrastructure/oracle/index.d.ts.map +1 -0
- package/dist/infrastructure/oracle/index.js +19 -0
- package/dist/infrastructure/oracle/index.js.map +1 -0
- package/dist/infrastructure/oracle/oracle-chain.d.ts +101 -0
- package/dist/infrastructure/oracle/oracle-chain.d.ts.map +1 -0
- package/dist/infrastructure/oracle/oracle-chain.js +163 -0
- package/dist/infrastructure/oracle/oracle-chain.js.map +1 -0
- package/dist/infrastructure/oracle/oracle-errors.d.ts +42 -0
- package/dist/infrastructure/oracle/oracle-errors.d.ts.map +1 -0
- package/dist/infrastructure/oracle/oracle-errors.js +53 -0
- package/dist/infrastructure/oracle/oracle-errors.js.map +1 -0
- package/dist/infrastructure/oracle/price-age.d.ts +38 -0
- package/dist/infrastructure/oracle/price-age.d.ts.map +1 -0
- package/dist/infrastructure/oracle/price-age.js +44 -0
- package/dist/infrastructure/oracle/price-age.js.map +1 -0
- package/dist/infrastructure/oracle/price-cache.d.ts +99 -0
- package/dist/infrastructure/oracle/price-cache.d.ts.map +1 -0
- package/dist/infrastructure/oracle/price-cache.js +173 -0
- package/dist/infrastructure/oracle/price-cache.js.map +1 -0
- package/dist/infrastructure/oracle/pyth-feed-ids.d.ts +31 -0
- package/dist/infrastructure/oracle/pyth-feed-ids.d.ts.map +1 -0
- package/dist/infrastructure/oracle/pyth-feed-ids.js +44 -0
- package/dist/infrastructure/oracle/pyth-feed-ids.js.map +1 -0
- package/dist/infrastructure/oracle/pyth-oracle.d.ts +69 -0
- package/dist/infrastructure/oracle/pyth-oracle.d.ts.map +1 -0
- package/dist/infrastructure/oracle/pyth-oracle.js +149 -0
- package/dist/infrastructure/oracle/pyth-oracle.js.map +1 -0
- package/dist/infrastructure/settings/hot-reload.d.ts +71 -0
- package/dist/infrastructure/settings/hot-reload.d.ts.map +1 -0
- package/dist/infrastructure/settings/hot-reload.js +315 -0
- package/dist/infrastructure/settings/hot-reload.js.map +1 -0
- package/dist/infrastructure/settings/index.d.ts +13 -0
- package/dist/infrastructure/settings/index.d.ts.map +1 -0
- package/dist/infrastructure/settings/index.js +10 -0
- package/dist/infrastructure/settings/index.js.map +1 -0
- package/dist/infrastructure/settings/setting-keys.d.ts +28 -0
- package/dist/infrastructure/settings/setting-keys.d.ts.map +1 -0
- package/dist/infrastructure/settings/setting-keys.js +105 -0
- package/dist/infrastructure/settings/setting-keys.js.map +1 -0
- package/dist/infrastructure/settings/settings-crypto.d.ts +39 -0
- package/dist/infrastructure/settings/settings-crypto.d.ts.map +1 -0
- package/dist/infrastructure/settings/settings-crypto.js +73 -0
- package/dist/infrastructure/settings/settings-crypto.js.map +1 -0
- package/dist/infrastructure/settings/settings-service.d.ts +82 -0
- package/dist/infrastructure/settings/settings-service.d.ts.map +1 -0
- package/dist/infrastructure/settings/settings-service.js +267 -0
- package/dist/infrastructure/settings/settings-service.js.map +1 -0
- package/dist/infrastructure/telegram/index.d.ts +6 -0
- package/dist/infrastructure/telegram/index.d.ts.map +1 -0
- package/dist/infrastructure/telegram/index.js +5 -0
- package/dist/infrastructure/telegram/index.js.map +1 -0
- package/dist/infrastructure/telegram/telegram-api.d.ts +35 -0
- package/dist/infrastructure/telegram/telegram-api.d.ts.map +1 -0
- package/dist/infrastructure/telegram/telegram-api.js +82 -0
- package/dist/infrastructure/telegram/telegram-api.js.map +1 -0
- package/dist/infrastructure/telegram/telegram-auth.d.ts +57 -0
- package/dist/infrastructure/telegram/telegram-auth.d.ts.map +1 -0
- package/dist/infrastructure/telegram/telegram-auth.js +88 -0
- package/dist/infrastructure/telegram/telegram-auth.js.map +1 -0
- package/dist/infrastructure/telegram/telegram-bot-service.d.ts +95 -0
- package/dist/infrastructure/telegram/telegram-bot-service.d.ts.map +1 -0
- package/dist/infrastructure/telegram/telegram-bot-service.js +564 -0
- package/dist/infrastructure/telegram/telegram-bot-service.js.map +1 -0
- package/dist/infrastructure/telegram/telegram-keyboard.d.ts +27 -0
- package/dist/infrastructure/telegram/telegram-keyboard.d.ts.map +1 -0
- package/dist/infrastructure/telegram/telegram-keyboard.js +52 -0
- package/dist/infrastructure/telegram/telegram-keyboard.js.map +1 -0
- package/dist/infrastructure/telegram/telegram-types.d.ts +43 -0
- package/dist/infrastructure/telegram/telegram-types.d.ts.map +1 -0
- package/dist/infrastructure/telegram/telegram-types.js +8 -0
- package/dist/infrastructure/telegram/telegram-types.js.map +1 -0
- package/dist/infrastructure/token-registry/builtin-tokens.d.ts +39 -0
- package/dist/infrastructure/token-registry/builtin-tokens.d.ts.map +1 -0
- package/dist/infrastructure/token-registry/builtin-tokens.js +135 -0
- package/dist/infrastructure/token-registry/builtin-tokens.js.map +1 -0
- package/dist/infrastructure/token-registry/index.d.ts +8 -0
- package/dist/infrastructure/token-registry/index.d.ts.map +1 -0
- package/dist/infrastructure/token-registry/index.js +8 -0
- package/dist/infrastructure/token-registry/index.js.map +1 -0
- package/dist/infrastructure/token-registry/token-registry-service.d.ts +49 -0
- package/dist/infrastructure/token-registry/token-registry-service.d.ts.map +1 -0
- package/dist/infrastructure/token-registry/token-registry-service.js +93 -0
- package/dist/infrastructure/token-registry/token-registry-service.js.map +1 -0
- package/dist/infrastructure/version/index.d.ts +5 -0
- package/dist/infrastructure/version/index.d.ts.map +1 -0
- package/dist/infrastructure/version/index.js +5 -0
- package/dist/infrastructure/version/index.js.map +1 -0
- package/dist/infrastructure/version/version-check-service.d.ts +35 -0
- package/dist/infrastructure/version/version-check-service.d.ts.map +1 -0
- package/dist/infrastructure/version/version-check-service.js +92 -0
- package/dist/infrastructure/version/version-check-service.js.map +1 -0
- package/dist/lifecycle/daemon.d.ts +103 -0
- package/dist/lifecycle/daemon.d.ts.map +1 -0
- package/dist/lifecycle/daemon.js +934 -0
- package/dist/lifecycle/daemon.js.map +1 -0
- package/dist/lifecycle/index.d.ts +9 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +9 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/lifecycle/signal-handler.d.ts +18 -0
- package/dist/lifecycle/signal-handler.d.ts.map +1 -0
- package/dist/lifecycle/signal-handler.js +37 -0
- package/dist/lifecycle/signal-handler.js.map +1 -0
- package/dist/lifecycle/workers.d.ts +46 -0
- package/dist/lifecycle/workers.d.ts.map +1 -0
- package/dist/lifecycle/workers.js +101 -0
- package/dist/lifecycle/workers.js.map +1 -0
- package/dist/notifications/channels/discord.d.ts +10 -0
- package/dist/notifications/channels/discord.d.ts.map +1 -0
- package/dist/notifications/channels/discord.js +54 -0
- package/dist/notifications/channels/discord.js.map +1 -0
- package/dist/notifications/channels/ntfy.d.ts +13 -0
- package/dist/notifications/channels/ntfy.d.ts.map +1 -0
- package/dist/notifications/channels/ntfy.js +58 -0
- package/dist/notifications/channels/ntfy.js.map +1 -0
- package/dist/notifications/channels/slack.d.ts +10 -0
- package/dist/notifications/channels/slack.d.ts.map +1 -0
- package/dist/notifications/channels/slack.js +55 -0
- package/dist/notifications/channels/slack.js.map +1 -0
- package/dist/notifications/channels/telegram.d.ts +10 -0
- package/dist/notifications/channels/telegram.d.ts.map +1 -0
- package/dist/notifications/channels/telegram.js +40 -0
- package/dist/notifications/channels/telegram.js.map +1 -0
- package/dist/notifications/index.d.ts +9 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +7 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notification-service.d.ts +75 -0
- package/dist/notifications/notification-service.d.ts.map +1 -0
- package/dist/notifications/notification-service.js +213 -0
- package/dist/notifications/notification-service.js.map +1 -0
- package/dist/notifications/templates/message-templates.d.ts +12 -0
- package/dist/notifications/templates/message-templates.d.ts.map +1 -0
- package/dist/notifications/templates/message-templates.js +22 -0
- package/dist/notifications/templates/message-templates.js.map +1 -0
- package/dist/pipeline/database-policy-engine.d.ts +286 -0
- package/dist/pipeline/database-policy-engine.d.ts.map +1 -0
- package/dist/pipeline/database-policy-engine.js +992 -0
- package/dist/pipeline/database-policy-engine.js.map +1 -0
- package/dist/pipeline/default-policy-engine.d.ts +26 -0
- package/dist/pipeline/default-policy-engine.d.ts.map +1 -0
- package/dist/pipeline/default-policy-engine.js +25 -0
- package/dist/pipeline/default-policy-engine.js.map +1 -0
- package/dist/pipeline/index.d.ts +9 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +9 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/network-resolver.d.ts +22 -0
- package/dist/pipeline/network-resolver.d.ts.map +1 -0
- package/dist/pipeline/network-resolver.js +32 -0
- package/dist/pipeline/network-resolver.js.map +1 -0
- package/dist/pipeline/pipeline.d.ts +72 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/pipeline.js +87 -0
- package/dist/pipeline/pipeline.js.map +1 -0
- package/dist/pipeline/resolve-effective-amount-usd.d.ts +41 -0
- package/dist/pipeline/resolve-effective-amount-usd.d.ts.map +1 -0
- package/dist/pipeline/resolve-effective-amount-usd.js +208 -0
- package/dist/pipeline/resolve-effective-amount-usd.js.map +1 -0
- package/dist/pipeline/sign-only.d.ts +99 -0
- package/dist/pipeline/sign-only.d.ts.map +1 -0
- package/dist/pipeline/sign-only.js +267 -0
- package/dist/pipeline/sign-only.js.map +1 -0
- package/dist/pipeline/sleep.d.ts +6 -0
- package/dist/pipeline/sleep.d.ts.map +1 -0
- package/dist/pipeline/sleep.js +8 -0
- package/dist/pipeline/sleep.js.map +1 -0
- package/dist/pipeline/stages.d.ts +82 -0
- package/dist/pipeline/stages.d.ts.map +1 -0
- package/dist/pipeline/stages.js +784 -0
- package/dist/pipeline/stages.js.map +1 -0
- package/dist/services/autostop-rules.d.ts +79 -0
- package/dist/services/autostop-rules.d.ts.map +1 -0
- package/dist/services/autostop-rules.js +174 -0
- package/dist/services/autostop-rules.js.map +1 -0
- package/dist/services/autostop-service.d.ts +82 -0
- package/dist/services/autostop-service.d.ts.map +1 -0
- package/dist/services/autostop-service.js +223 -0
- package/dist/services/autostop-service.js.map +1 -0
- package/dist/services/kill-switch-service.d.ts +118 -0
- package/dist/services/kill-switch-service.d.ts.map +1 -0
- package/dist/services/kill-switch-service.js +291 -0
- package/dist/services/kill-switch-service.js.map +1 -0
- package/dist/services/monitoring/balance-monitor-service.d.ts +65 -0
- package/dist/services/monitoring/balance-monitor-service.d.ts.map +1 -0
- package/dist/services/monitoring/balance-monitor-service.js +207 -0
- package/dist/services/monitoring/balance-monitor-service.js.map +1 -0
- package/dist/services/wc-session-service.d.ts +123 -0
- package/dist/services/wc-session-service.d.ts.map +1 -0
- package/dist/services/wc-session-service.js +363 -0
- package/dist/services/wc-session-service.js.map +1 -0
- package/dist/services/wc-signing-bridge.d.ts +60 -0
- package/dist/services/wc-signing-bridge.d.ts.map +1 -0
- package/dist/services/wc-signing-bridge.js +334 -0
- package/dist/services/wc-signing-bridge.js.map +1 -0
- package/dist/services/wc-storage.d.ts +32 -0
- package/dist/services/wc-storage.d.ts.map +1 -0
- package/dist/services/wc-storage.js +64 -0
- package/dist/services/wc-storage.js.map +1 -0
- package/dist/services/x402/payment-signer.d.ts +88 -0
- package/dist/services/x402/payment-signer.d.ts.map +1 -0
- package/dist/services/x402/payment-signer.js +311 -0
- package/dist/services/x402/payment-signer.js.map +1 -0
- package/dist/services/x402/ssrf-guard.d.ts +27 -0
- package/dist/services/x402/ssrf-guard.d.ts.map +1 -0
- package/dist/services/x402/ssrf-guard.js +236 -0
- package/dist/services/x402/ssrf-guard.js.map +1 -0
- package/dist/services/x402/x402-domain-policy.d.ts +50 -0
- package/dist/services/x402/x402-domain-policy.d.ts.map +1 -0
- package/dist/services/x402/x402-domain-policy.js +78 -0
- package/dist/services/x402/x402-domain-policy.js.map +1 -0
- package/dist/services/x402/x402-handler.d.ts +71 -0
- package/dist/services/x402/x402-handler.d.ts.map +1 -0
- package/dist/services/x402/x402-handler.js +195 -0
- package/dist/services/x402/x402-handler.js.map +1 -0
- package/dist/services/x402/x402-usd-resolver.d.ts +26 -0
- package/dist/services/x402/x402-usd-resolver.d.ts.map +1 -0
- package/dist/services/x402/x402-usd-resolver.js +79 -0
- package/dist/services/x402/x402-usd-resolver.js.map +1 -0
- package/dist/workflow/approval-workflow.d.ts +103 -0
- package/dist/workflow/approval-workflow.d.ts.map +1 -0
- package/dist/workflow/approval-workflow.js +202 -0
- package/dist/workflow/approval-workflow.js.map +1 -0
- package/dist/workflow/delay-queue.d.ts +78 -0
- package/dist/workflow/delay-queue.d.ts.map +1 -0
- package/dist/workflow/delay-queue.js +174 -0
- package/dist/workflow/delay-queue.js.map +1 -0
- package/dist/workflow/index.d.ts +11 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +9 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/owner-state.d.ts +97 -0
- package/dist/workflow/owner-state.d.ts.map +1 -0
- package/dist/workflow/owner-state.js +168 -0
- package/dist/workflow/owner-state.js.map +1 -0
- package/package.json +71 -0
- package/public/admin/assets/index-BPoUSH8W.css +1 -0
- package/public/admin/assets/index-CDi1qoXB.js +1 -0
- 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;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,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QACvC,CAAC;QACD,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;YACvD,kCAAkC;YAClC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,aAAa,CAAC,IAAI,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,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