@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,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WcSigningBridge - Fire-and-forget WC signing request bridge.
|
|
3
|
+
*
|
|
4
|
+
* When an APPROVAL tier transaction is created and the wallet has an active
|
|
5
|
+
* WalletConnect session, this bridge sends a signing request to the Owner
|
|
6
|
+
* wallet (via personal_sign for EVM / solana_signMessage for Solana).
|
|
7
|
+
*
|
|
8
|
+
* On successful signature response, it verifies the signature using the
|
|
9
|
+
* existing ownerAuth verification logic (verifySIWE / Ed25519) and calls
|
|
10
|
+
* approvalWorkflow.approve() or .reject() accordingly.
|
|
11
|
+
*
|
|
12
|
+
* Key design decisions:
|
|
13
|
+
* - Fire-and-forget: requestSignature() is called with `void` prefix,
|
|
14
|
+
* never blocking the pipeline.
|
|
15
|
+
* - Timeout sync: WC request expiry is derived from pending_approvals.expires_at.
|
|
16
|
+
* - Optional dependency: Pipeline works without WcSigningBridge (checked via ctx.wcSigningBridge?.)
|
|
17
|
+
*
|
|
18
|
+
* @see packages/daemon/src/pipeline/stages.ts (stage4Wait APPROVAL branch)
|
|
19
|
+
* @see packages/daemon/src/services/wc-session-service.ts
|
|
20
|
+
* @see packages/daemon/src/workflow/approval-workflow.ts
|
|
21
|
+
*/
|
|
22
|
+
import { randomBytes } from 'node:crypto';
|
|
23
|
+
import { createRequire } from 'node:module';
|
|
24
|
+
import { createSiweMessage } from 'viem/siwe';
|
|
25
|
+
import { verifySIWE } from '../api/middleware/siwe-verify.js';
|
|
26
|
+
import { decodeBase58 } from '../api/middleware/address-validation.js';
|
|
27
|
+
const require = createRequire(import.meta.url);
|
|
28
|
+
function loadSodium() {
|
|
29
|
+
return require('sodium-native');
|
|
30
|
+
}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// WC error code constants
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
/** WC user rejection error codes (4001 = standard, 5000 = legacy) */
|
|
35
|
+
const WC_USER_REJECTED = [4001, 5000];
|
|
36
|
+
/** WC request expired error code */
|
|
37
|
+
const WC_REQUEST_EXPIRED = 8000;
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Base58 encode (Bitcoin alphabet) -- inline to avoid import of unexported fn
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
42
|
+
function encodeBase58(buf) {
|
|
43
|
+
let zeroes = 0;
|
|
44
|
+
for (let i = 0; i < buf.length && buf[i] === 0; i++) {
|
|
45
|
+
zeroes++;
|
|
46
|
+
}
|
|
47
|
+
const size = Math.ceil((buf.length * 138) / 100) + 1;
|
|
48
|
+
const b58 = new Uint8Array(size);
|
|
49
|
+
let length = 0;
|
|
50
|
+
for (let i = zeroes; i < buf.length; i++) {
|
|
51
|
+
let carry = buf[i];
|
|
52
|
+
let j = 0;
|
|
53
|
+
for (let k = size - 1; k >= 0 && (carry !== 0 || j < length); k--, j++) {
|
|
54
|
+
carry += 256 * (b58[k] ?? 0);
|
|
55
|
+
b58[k] = carry % 58;
|
|
56
|
+
carry = Math.floor(carry / 58);
|
|
57
|
+
}
|
|
58
|
+
length = j;
|
|
59
|
+
}
|
|
60
|
+
let start = size - length;
|
|
61
|
+
while (start < size && b58[start] === 0) {
|
|
62
|
+
start++;
|
|
63
|
+
}
|
|
64
|
+
let result = '1'.repeat(zeroes);
|
|
65
|
+
for (let i = start; i < size; i++) {
|
|
66
|
+
result += BASE58_ALPHABET[b58[i]];
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// WcSigningBridge
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
export class WcSigningBridge {
|
|
74
|
+
wcServiceRef;
|
|
75
|
+
approvalWorkflow;
|
|
76
|
+
sqlite;
|
|
77
|
+
notificationService;
|
|
78
|
+
eventBus;
|
|
79
|
+
constructor(deps) {
|
|
80
|
+
this.wcServiceRef = deps.wcServiceRef;
|
|
81
|
+
this.approvalWorkflow = deps.approvalWorkflow;
|
|
82
|
+
this.sqlite = deps.sqlite;
|
|
83
|
+
this.notificationService = deps.notificationService;
|
|
84
|
+
this.eventBus = deps.eventBus;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Send a WC signing request to the Owner wallet (fire-and-forget).
|
|
88
|
+
*
|
|
89
|
+
* Silently returns if WC is not initialized or no session exists.
|
|
90
|
+
* On signature response: verify + approve/reject via ApprovalWorkflow.
|
|
91
|
+
* On error: reject if user-rejected, ignore if expired (approval-expired worker handles it).
|
|
92
|
+
*/
|
|
93
|
+
async requestSignature(walletId, txId, chain) {
|
|
94
|
+
try {
|
|
95
|
+
// Guard: WC not initialized
|
|
96
|
+
const wcService = this.wcServiceRef.current;
|
|
97
|
+
if (!wcService) {
|
|
98
|
+
this.fallbackToTelegram(walletId, txId, 'wc_not_initialized');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const signClient = wcService.getSignClient();
|
|
102
|
+
if (!signClient) {
|
|
103
|
+
this.fallbackToTelegram(walletId, txId, 'wc_not_initialized');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Guard: no session for this wallet
|
|
107
|
+
const topic = wcService.getSessionTopic(walletId);
|
|
108
|
+
if (!topic) {
|
|
109
|
+
this.fallbackToTelegram(walletId, txId, 'no_wc_session');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// Guard: no session info (should not happen if topic exists, but defensive)
|
|
113
|
+
const sessionInfo = wcService.getSessionInfo(walletId);
|
|
114
|
+
if (!sessionInfo) {
|
|
115
|
+
this.fallbackToTelegram(walletId, txId, 'no_session_info');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const { ownerAddress, chainId } = sessionInfo;
|
|
119
|
+
// Build chain-specific signing request
|
|
120
|
+
const signRequest = this.buildSignRequest(chain, ownerAddress, txId, chainId);
|
|
121
|
+
// Update approval_channel to 'walletconnect'
|
|
122
|
+
this.sqlite
|
|
123
|
+
.prepare(`UPDATE pending_approvals SET approval_channel = 'walletconnect'
|
|
124
|
+
WHERE tx_id = ? AND approved_at IS NULL AND rejected_at IS NULL`)
|
|
125
|
+
.run(txId);
|
|
126
|
+
// Calculate WC expiry from pending_approvals.expires_at
|
|
127
|
+
const timeoutSeconds = this.resolveWcExpiry(txId);
|
|
128
|
+
// Send WC signing request
|
|
129
|
+
const result = await signClient.request({
|
|
130
|
+
topic,
|
|
131
|
+
chainId,
|
|
132
|
+
request: {
|
|
133
|
+
method: signRequest.method,
|
|
134
|
+
params: signRequest.params,
|
|
135
|
+
},
|
|
136
|
+
expiry: timeoutSeconds,
|
|
137
|
+
});
|
|
138
|
+
// Handle successful signature response
|
|
139
|
+
await this.handleSignatureResponse(chain, walletId, txId, signRequest.message, result, ownerAddress);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
// Handle WC errors (rejection, timeout, etc.)
|
|
143
|
+
this.handleSignatureError(walletId, txId, error);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// -------------------------------------------------------------------------
|
|
147
|
+
// Private: build chain-specific signing request
|
|
148
|
+
// -------------------------------------------------------------------------
|
|
149
|
+
buildSignRequest(chain, ownerAddress, txId, chainId) {
|
|
150
|
+
if (chain === 'ethereum') {
|
|
151
|
+
return this.buildEvmSignRequest(ownerAddress, txId, chainId);
|
|
152
|
+
}
|
|
153
|
+
return this.buildSolanaSignRequest(ownerAddress, txId);
|
|
154
|
+
}
|
|
155
|
+
buildEvmSignRequest(ownerAddress, txId, chainId) {
|
|
156
|
+
const nonce = randomBytes(16).toString('hex');
|
|
157
|
+
const numericChainId = parseInt(chainId.split(':')[1] ?? '1', 10);
|
|
158
|
+
const siweMessage = createSiweMessage({
|
|
159
|
+
domain: 'waiaas.local',
|
|
160
|
+
address: ownerAddress,
|
|
161
|
+
uri: 'http://localhost:3000',
|
|
162
|
+
version: '1',
|
|
163
|
+
chainId: numericChainId,
|
|
164
|
+
nonce,
|
|
165
|
+
statement: `Approve transaction ${txId}`,
|
|
166
|
+
expirationTime: new Date(Date.now() + 300_000),
|
|
167
|
+
});
|
|
168
|
+
// personal_sign params: [hexMessage, address]
|
|
169
|
+
const hexMessage = '0x' + Buffer.from(siweMessage, 'utf8').toString('hex');
|
|
170
|
+
const params = [hexMessage, ownerAddress];
|
|
171
|
+
return { message: siweMessage, method: 'personal_sign', params };
|
|
172
|
+
}
|
|
173
|
+
buildSolanaSignRequest(ownerAddress, txId) {
|
|
174
|
+
const message = `WAIaaS: Approve transaction ${txId}`;
|
|
175
|
+
// WC Solana spec: base58-encoded message bytes
|
|
176
|
+
const base58Message = encodeBase58(Buffer.from(message, 'utf8'));
|
|
177
|
+
const params = { message: base58Message, pubkey: ownerAddress };
|
|
178
|
+
return { message, method: 'solana_signMessage', params };
|
|
179
|
+
}
|
|
180
|
+
// -------------------------------------------------------------------------
|
|
181
|
+
// Private: resolve WC expiry from pending_approvals
|
|
182
|
+
// -------------------------------------------------------------------------
|
|
183
|
+
resolveWcExpiry(txId) {
|
|
184
|
+
try {
|
|
185
|
+
const row = this.sqlite
|
|
186
|
+
.prepare(`SELECT expires_at FROM pending_approvals
|
|
187
|
+
WHERE tx_id = ? AND approved_at IS NULL AND rejected_at IS NULL`)
|
|
188
|
+
.get(txId);
|
|
189
|
+
if (row) {
|
|
190
|
+
const now = Math.floor(Date.now() / 1000);
|
|
191
|
+
const remaining = row.expires_at - now;
|
|
192
|
+
// WC requires positive expiry; minimum 60s to avoid instant expiry
|
|
193
|
+
return Math.max(remaining, 60);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
// Fallback on query error
|
|
198
|
+
}
|
|
199
|
+
return 300; // 5 minutes default
|
|
200
|
+
}
|
|
201
|
+
// -------------------------------------------------------------------------
|
|
202
|
+
// Private: handle signature response (verify + approve)
|
|
203
|
+
// -------------------------------------------------------------------------
|
|
204
|
+
async handleSignatureResponse(chain, _walletId, txId, message, result, ownerAddress) {
|
|
205
|
+
if (chain === 'ethereum') {
|
|
206
|
+
await this.handleEvmSignatureResponse(txId, message, result, ownerAddress);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
this.handleSolanaSignatureResponse(txId, message, result, ownerAddress);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async handleEvmSignatureResponse(txId, message, result, ownerAddress) {
|
|
213
|
+
// result is 0x-prefixed hex signature string
|
|
214
|
+
const signature = typeof result === 'string' ? result : '';
|
|
215
|
+
const verification = await verifySIWE({
|
|
216
|
+
message,
|
|
217
|
+
signature,
|
|
218
|
+
expectedAddress: ownerAddress,
|
|
219
|
+
});
|
|
220
|
+
if (verification.valid) {
|
|
221
|
+
try {
|
|
222
|
+
this.approvalWorkflow.approve(txId, signature);
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
console.warn(`[WcSigningBridge] approve failed for ${txId}:`, err);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
console.warn(`[WcSigningBridge] EVM signature verification failed for ${txId}: ${verification.error}`);
|
|
230
|
+
// Do NOT reject -- Owner may retry via REST API or WC
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
handleSolanaSignatureResponse(txId, message, result, ownerAddress) {
|
|
234
|
+
// result is { signature: 'base58-string' } or raw string
|
|
235
|
+
const resultObj = result;
|
|
236
|
+
const sig58 = typeof resultObj === 'string'
|
|
237
|
+
? resultObj
|
|
238
|
+
: (resultObj?.signature ?? '');
|
|
239
|
+
if (!sig58) {
|
|
240
|
+
console.warn(`[WcSigningBridge] Empty Solana signature for ${txId}`);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
// Convert base58 signature to base64 (ownerAuth expects base64)
|
|
245
|
+
const signatureBytes = decodeBase58(sig58);
|
|
246
|
+
const base64Sig = signatureBytes.toString('base64');
|
|
247
|
+
// Ed25519 verification (reuse owner-auth.ts pattern)
|
|
248
|
+
const sodium = loadSodium();
|
|
249
|
+
const messageBytes = Buffer.from(message, 'utf8');
|
|
250
|
+
const publicKeyBytes = decodeBase58(ownerAddress);
|
|
251
|
+
const valid = sodium.crypto_sign_verify_detached(signatureBytes, messageBytes, publicKeyBytes);
|
|
252
|
+
if (valid) {
|
|
253
|
+
try {
|
|
254
|
+
this.approvalWorkflow.approve(txId, base64Sig);
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
console.warn(`[WcSigningBridge] approve failed for ${txId}:`, err);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
console.warn(`[WcSigningBridge] Solana Ed25519 verification failed for ${txId}`);
|
|
262
|
+
// Do NOT reject -- Owner may retry
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
console.warn(`[WcSigningBridge] Solana signature handling error for ${txId}:`, err);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// -------------------------------------------------------------------------
|
|
270
|
+
// Private: handle WC errors
|
|
271
|
+
// -------------------------------------------------------------------------
|
|
272
|
+
handleSignatureError(walletId, txId, error) {
|
|
273
|
+
const errorCode = error?.code;
|
|
274
|
+
if (typeof errorCode === 'number' && WC_USER_REJECTED.includes(errorCode)) {
|
|
275
|
+
// User rejected in wallet -- reject the approval
|
|
276
|
+
try {
|
|
277
|
+
this.approvalWorkflow.reject(txId);
|
|
278
|
+
// Update approval_channel to reflect rejection came via WC
|
|
279
|
+
this.sqlite
|
|
280
|
+
.prepare(`UPDATE pending_approvals SET approval_channel = 'walletconnect'
|
|
281
|
+
WHERE tx_id = ? AND rejected_at IS NOT NULL`)
|
|
282
|
+
.run(txId);
|
|
283
|
+
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
console.warn(`[WcSigningBridge] reject failed for ${txId}:`, err);
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (errorCode === WC_REQUEST_EXPIRED) {
|
|
290
|
+
// Request expired -- fallback to Telegram if approval still pending
|
|
291
|
+
console.warn(`[WcSigningBridge] WC request expired for ${txId}`);
|
|
292
|
+
this.fallbackToTelegram(walletId, txId, 'wc_timeout');
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
// Other errors -- fallback to Telegram if approval still pending
|
|
296
|
+
console.warn(`[WcSigningBridge] WC signing error for ${txId}:`, error?.message ?? error);
|
|
297
|
+
this.fallbackToTelegram(walletId, txId, 'wc_error');
|
|
298
|
+
}
|
|
299
|
+
// -------------------------------------------------------------------------
|
|
300
|
+
// Private: check if approval is still pending
|
|
301
|
+
// -------------------------------------------------------------------------
|
|
302
|
+
isApprovalStillPending(txId) {
|
|
303
|
+
const row = this.sqlite
|
|
304
|
+
.prepare('SELECT 1 FROM pending_approvals WHERE tx_id = ? AND approved_at IS NULL AND rejected_at IS NULL')
|
|
305
|
+
.get(txId);
|
|
306
|
+
return !!row;
|
|
307
|
+
}
|
|
308
|
+
// -------------------------------------------------------------------------
|
|
309
|
+
// Private: fallback to Telegram channel
|
|
310
|
+
// -------------------------------------------------------------------------
|
|
311
|
+
fallbackToTelegram(walletId, txId, reason) {
|
|
312
|
+
// Only act if approval is still pending
|
|
313
|
+
if (!this.isApprovalStillPending(txId))
|
|
314
|
+
return;
|
|
315
|
+
// Update approval_channel to 'telegram'
|
|
316
|
+
this.sqlite
|
|
317
|
+
.prepare(`UPDATE pending_approvals SET approval_channel = 'telegram'
|
|
318
|
+
WHERE tx_id = ? AND approved_at IS NULL AND rejected_at IS NULL`)
|
|
319
|
+
.run(txId);
|
|
320
|
+
// Emit EventBus event
|
|
321
|
+
this.eventBus?.emit('approval:channel-switched', {
|
|
322
|
+
walletId,
|
|
323
|
+
txId,
|
|
324
|
+
fromChannel: 'walletconnect',
|
|
325
|
+
toChannel: 'telegram',
|
|
326
|
+
reason,
|
|
327
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
328
|
+
});
|
|
329
|
+
// Send channel-switched notification
|
|
330
|
+
void this.notificationService?.notify('APPROVAL_CHANNEL_SWITCHED', walletId, { from_channel: 'walletconnect', to_channel: 'telegram', reason }, { txId });
|
|
331
|
+
console.log(`[WcSigningBridge] Fallback to Telegram for ${txId}: ${reason}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=wc-signing-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wc-signing-bridge.js","sourceRoot":"","sources":["../../src/services/wc-signing-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAOvE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,SAAS,UAAU;IACjB,OAAO,OAAO,CAAC,eAAe,CAAiB,CAAC;AAClD,CAAC;AAED,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E,qEAAqE;AACrE,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtC,oCAAoC;AACpC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAE9E,MAAM,eAAe,GAAG,4DAA4D,CAAC;AAErF,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACpD,MAAM,EAAE,CAAC;IACX,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,C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rB,MAAM;YACN,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;SACzC,CAAC,CAAC;QAEH,qCAAqC;QACrC,KAAK,IAAI,CAAC,mBAAmB,EAAE,MAAM,CACnC,2BAA2B,EAC3B,QAAQ,EACR,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,EACjE,EAAE,IAAI,EAAE,CACT,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,8CAA8C,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;IAC/E,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite-backed IKeyValueStorage implementation for WalletConnect SDK.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the default FileSystemStorage to ensure WC session/pairing data
|
|
5
|
+
* is persisted in the WAIaaS SQLite database (data/waiaas.db). This guarantees
|
|
6
|
+
* session survival across daemon restarts and Docker container recreation.
|
|
7
|
+
*
|
|
8
|
+
* All data is stored in the `wc_store` table (created by DB v16 migration).
|
|
9
|
+
*
|
|
10
|
+
* @see packages/daemon/src/infrastructure/database/migrate.ts (v16)
|
|
11
|
+
*/
|
|
12
|
+
import type { Database } from 'better-sqlite3';
|
|
13
|
+
export interface IKeyValueStorage {
|
|
14
|
+
getKeys(): Promise<string[]>;
|
|
15
|
+
getEntries<T = any>(): Promise<[string, T][]>;
|
|
16
|
+
getItem<T = any>(key: string): Promise<T | undefined>;
|
|
17
|
+
setItem<T = any>(key: string, value: T): Promise<void>;
|
|
18
|
+
removeItem(key: string): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare class SqliteKeyValueStorage implements IKeyValueStorage {
|
|
21
|
+
private readonly sqlite;
|
|
22
|
+
private closed;
|
|
23
|
+
constructor(sqlite: Database);
|
|
24
|
+
/** Mark storage as closed so subsequent WC SDK callbacks are silently ignored. */
|
|
25
|
+
close(): void;
|
|
26
|
+
getKeys(): Promise<string[]>;
|
|
27
|
+
getEntries<T = any>(): Promise<[string, T][]>;
|
|
28
|
+
getItem<T = any>(key: string): Promise<T | undefined>;
|
|
29
|
+
setItem<T = any>(key: string, value: T): Promise<void>;
|
|
30
|
+
removeItem(key: string): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=wc-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wc-storage.d.ts","sourceRoot":"","sources":["../../src/services/wc-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO/C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7B,UAAU,CAAC,CAAC,GAAG,GAAG,KAAK,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACtD,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAMD,qBAAa,qBAAsB,YAAW,gBAAgB;IAGhD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,MAAM,CAAS;gBAEM,MAAM,EAAE,QAAQ;IAE7C,kFAAkF;IAClF,KAAK,IAAI,IAAI;IAIP,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ5B,UAAU,CAAC,CAAC,GAAG,GAAG,KAAK,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;IAQ7C,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAQrD,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM7C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite-backed IKeyValueStorage implementation for WalletConnect SDK.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the default FileSystemStorage to ensure WC session/pairing data
|
|
5
|
+
* is persisted in the WAIaaS SQLite database (data/waiaas.db). This guarantees
|
|
6
|
+
* session survival across daemon restarts and Docker container recreation.
|
|
7
|
+
*
|
|
8
|
+
* All data is stored in the `wc_store` table (created by DB v16 migration).
|
|
9
|
+
*
|
|
10
|
+
* @see packages/daemon/src/infrastructure/database/migrate.ts (v16)
|
|
11
|
+
*/
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// SqliteKeyValueStorage
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
export class SqliteKeyValueStorage {
|
|
16
|
+
sqlite;
|
|
17
|
+
closed = false;
|
|
18
|
+
constructor(sqlite) {
|
|
19
|
+
this.sqlite = sqlite;
|
|
20
|
+
}
|
|
21
|
+
/** Mark storage as closed so subsequent WC SDK callbacks are silently ignored. */
|
|
22
|
+
close() {
|
|
23
|
+
this.closed = true;
|
|
24
|
+
}
|
|
25
|
+
async getKeys() {
|
|
26
|
+
if (this.closed)
|
|
27
|
+
return [];
|
|
28
|
+
const rows = this.sqlite
|
|
29
|
+
.prepare('SELECT key FROM wc_store')
|
|
30
|
+
.all();
|
|
31
|
+
return rows.map((r) => r.key);
|
|
32
|
+
}
|
|
33
|
+
async getEntries() {
|
|
34
|
+
if (this.closed)
|
|
35
|
+
return [];
|
|
36
|
+
const rows = this.sqlite
|
|
37
|
+
.prepare('SELECT key, value FROM wc_store')
|
|
38
|
+
.all();
|
|
39
|
+
return rows.map((r) => [r.key, JSON.parse(r.value)]);
|
|
40
|
+
}
|
|
41
|
+
async getItem(key) {
|
|
42
|
+
if (this.closed)
|
|
43
|
+
return undefined;
|
|
44
|
+
const row = this.sqlite
|
|
45
|
+
.prepare('SELECT value FROM wc_store WHERE key = ?')
|
|
46
|
+
.get(key);
|
|
47
|
+
return row ? JSON.parse(row.value) : undefined;
|
|
48
|
+
}
|
|
49
|
+
async setItem(key, value) {
|
|
50
|
+
if (this.closed)
|
|
51
|
+
return;
|
|
52
|
+
this.sqlite
|
|
53
|
+
.prepare('INSERT OR REPLACE INTO wc_store (key, value) VALUES (?, ?)')
|
|
54
|
+
.run(key, JSON.stringify(value));
|
|
55
|
+
}
|
|
56
|
+
async removeItem(key) {
|
|
57
|
+
if (this.closed)
|
|
58
|
+
return;
|
|
59
|
+
this.sqlite
|
|
60
|
+
.prepare('DELETE FROM wc_store WHERE key = ?')
|
|
61
|
+
.run(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=wc-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wc-storage.js","sourceRoot":"","sources":["../../src/services/wc-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAiBH,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E,MAAM,OAAO,qBAAqB;IAGH;IAFrB,MAAM,GAAG,KAAK,CAAC;IAEvB,YAA6B,MAAgB;QAAhB,WAAM,GAAN,MAAM,CAAU;IAAG,CAAC;IAEjD,kFAAkF;IAClF,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,EA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C,MAAM;aACR,OAAO,CAAC,oCAAoC,CAAC;aAC7C,GAAG,CAAC,GAAG,CAAC,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment Signer -- x402 chain-specific payment signature generation.
|
|
3
|
+
*
|
|
4
|
+
* Provides signPayment() which delegates to:
|
|
5
|
+
* - signEip3009() for EVM chains (EIP-3009 transferWithAuthorization via EIP-712 signTypedData)
|
|
6
|
+
* - signSolanaTransferChecked() for Solana chains (SPL TransferChecked partial signing)
|
|
7
|
+
*
|
|
8
|
+
* Key management follows the decrypt -> sign -> finally release pattern
|
|
9
|
+
* from sign-only.ts Step 9 and stages.ts Stage 5c.
|
|
10
|
+
*
|
|
11
|
+
* Does NOT go through IChainAdapter -- EIP-3009 is typed data signing (not tx),
|
|
12
|
+
* and Solana partial signing uses a different feePayer (facilitator, not wallet).
|
|
13
|
+
*
|
|
14
|
+
* @see packages/daemon/src/pipeline/sign-only.ts (Step 9)
|
|
15
|
+
* @see docs/32-pipeline-design.md
|
|
16
|
+
*/
|
|
17
|
+
import type { PaymentRequirements } from '@waiaas/core';
|
|
18
|
+
/** Minimal keystore interface for payment signing. */
|
|
19
|
+
export interface PaymentKeyStore {
|
|
20
|
+
decryptPrivateKey(walletId: string, masterPassword: string): Promise<Uint8Array>;
|
|
21
|
+
releaseKey(key: Uint8Array): void;
|
|
22
|
+
}
|
|
23
|
+
/** EIP-712 domain for USDC contracts. */
|
|
24
|
+
export interface Eip712Domain {
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
chainId: number;
|
|
28
|
+
verifyingContract: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* USDC v2 contract domain separators by CAIP-2 network identifier.
|
|
32
|
+
*
|
|
33
|
+
* Each EVM chain has a unique USDC contract with its own EIP-712 domain separator.
|
|
34
|
+
* These are the Circle native USDC v2 contracts that support EIP-3009.
|
|
35
|
+
*
|
|
36
|
+
* Source: USDC v2 contracts + EIP-3009 standard + x402 reference implementation.
|
|
37
|
+
*/
|
|
38
|
+
export declare const USDC_DOMAINS: Record<string, Eip712Domain>;
|
|
39
|
+
/**
|
|
40
|
+
* Sign a payment based on chain-specific strategy.
|
|
41
|
+
*
|
|
42
|
+
* Key management pattern (identical to sign-only.ts Step 9):
|
|
43
|
+
* 1. Decrypt private key from keystore
|
|
44
|
+
* 2. Sign using chain-specific strategy
|
|
45
|
+
* 3. Finally block: release key (sodium_memzero)
|
|
46
|
+
*
|
|
47
|
+
* @param requirements - x402 PaymentRequirements from 402 response
|
|
48
|
+
* @param keyStore - Keystore for key decrypt/release
|
|
49
|
+
* @param walletId - Wallet ID for key lookup
|
|
50
|
+
* @param walletAddress - Wallet public address
|
|
51
|
+
* @param masterPassword - Master password for key decryption
|
|
52
|
+
* @param rpc - Solana RPC client (required for Solana chains)
|
|
53
|
+
* @returns PaymentPayload compatible with @x402/core PaymentPayloadV2Schema
|
|
54
|
+
*/
|
|
55
|
+
export declare function signPayment(requirements: PaymentRequirements, keyStore: PaymentKeyStore, walletId: string, walletAddress: string, masterPassword: string, rpc?: unknown): Promise<Record<string, unknown>>;
|
|
56
|
+
/**
|
|
57
|
+
* Sign EVM EIP-3009 transferWithAuthorization via EIP-712 signTypedData.
|
|
58
|
+
*
|
|
59
|
+
* Uses viem's privateKeyToAccount + account.signTypedData for the EIP-712
|
|
60
|
+
* structured data signature. The signature authorizes a USDC transfer
|
|
61
|
+
* without requiring an on-chain transaction from the payer.
|
|
62
|
+
*
|
|
63
|
+
* @param requirements - Payment requirements (network, asset, amount, payTo)
|
|
64
|
+
* @param privateKey - Raw private key bytes (32 bytes for secp256k1)
|
|
65
|
+
* @param walletAddress - EVM wallet address (0x-prefixed EIP-55)
|
|
66
|
+
* @returns PaymentPayload with signature and authorization object
|
|
67
|
+
*/
|
|
68
|
+
export declare function signEip3009(requirements: PaymentRequirements, privateKey: Uint8Array, walletAddress: string): Promise<Record<string, unknown>>;
|
|
69
|
+
/**
|
|
70
|
+
* Sign Solana SPL TransferChecked as partial signature.
|
|
71
|
+
*
|
|
72
|
+
* The feePayer is the facilitator (from requirements.extra.feePayer), set as
|
|
73
|
+
* noopSigner so only a signature slot is created. The wallet signs the
|
|
74
|
+
* transaction message with its private key.
|
|
75
|
+
*
|
|
76
|
+
* The resulting base64-encoded transaction contains:
|
|
77
|
+
* - feePayer = facilitator address (noopSigner, unsigned)
|
|
78
|
+
* - authority = wallet (signed)
|
|
79
|
+
* - TransferChecked instruction for SPL token transfer
|
|
80
|
+
*
|
|
81
|
+
* @param requirements - Payment requirements with extra.feePayer and extra.decimals
|
|
82
|
+
* @param privateKey - Raw private key bytes (32 or 64 bytes)
|
|
83
|
+
* @param walletAddress - Solana wallet address (base58)
|
|
84
|
+
* @param rpc - Solana RPC client with getLatestBlockhash method
|
|
85
|
+
* @returns PaymentPayload with base64-encoded partial-signed transaction
|
|
86
|
+
*/
|
|
87
|
+
export declare function signSolanaTransferChecked(requirements: PaymentRequirements, privateKey: Uint8Array, _walletAddress: string, rpc: unknown): Promise<Record<string, unknown>>;
|
|
88
|
+
//# sourceMappingURL=payment-signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-signer.d.ts","sourceRoot":"","sources":["../../../src/services/x402/payment-signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA0BH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMxD,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACjF,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;CACnC;AAED,yCAAyC;AACzC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IACh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