@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,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sign-only pipeline module.
|
|
3
|
+
*
|
|
4
|
+
* Provides executeSignOnly() -- a standalone pipeline for signing external
|
|
5
|
+
* unsigned transactions after policy evaluation. Unlike the 6-stage send
|
|
6
|
+
* pipeline (stages.ts), this pipeline does NOT submit to chain.
|
|
7
|
+
*
|
|
8
|
+
* 10-step pipeline:
|
|
9
|
+
* 1. Parse unsigned tx (adapter.parseTransaction)
|
|
10
|
+
* 2. Map ParsedOperation[] to TransactionParam[] (for policy engine)
|
|
11
|
+
* 3. Generate UUID v7 transaction ID
|
|
12
|
+
* 4. INSERT DB record (type='SIGN', status='PENDING')
|
|
13
|
+
* 5. Policy evaluation (evaluateAndReserve / evaluateBatch / evaluate)
|
|
14
|
+
* 6. Check policy result (deny if !allowed)
|
|
15
|
+
* 7. Check tier (DELAY/APPROVAL -> immediate rejection)
|
|
16
|
+
* 8. Update tier on transaction row
|
|
17
|
+
* 9. Sign (keyStore.decrypt -> adapter.signExternalTransaction -> keyStore.release)
|
|
18
|
+
* 10. Update status='SIGNED', return result
|
|
19
|
+
*
|
|
20
|
+
* @see docs/32-pipeline-design.md
|
|
21
|
+
*/
|
|
22
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
23
|
+
import type { Database as SQLiteDatabase } from 'better-sqlite3';
|
|
24
|
+
import { type IChainAdapter, type IPolicyEngine, type ParsedOperation, type EventBus } from '@waiaas/core';
|
|
25
|
+
import type { LocalKeyStore } from '../infrastructure/keystore/keystore.js';
|
|
26
|
+
import type * as schema from '../infrastructure/database/schema.js';
|
|
27
|
+
import type { NotificationService } from '../notifications/notification-service.js';
|
|
28
|
+
export interface SignOnlyDeps {
|
|
29
|
+
db: BetterSQLite3Database<typeof schema>;
|
|
30
|
+
sqlite?: SQLiteDatabase;
|
|
31
|
+
adapter: IChainAdapter;
|
|
32
|
+
keyStore: LocalKeyStore;
|
|
33
|
+
policyEngine: IPolicyEngine;
|
|
34
|
+
masterPassword: string;
|
|
35
|
+
notificationService?: NotificationService;
|
|
36
|
+
eventBus?: EventBus;
|
|
37
|
+
}
|
|
38
|
+
export interface SignOnlyRequest {
|
|
39
|
+
transaction: string;
|
|
40
|
+
chain: string;
|
|
41
|
+
network?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface SignOnlyResult {
|
|
44
|
+
id: string;
|
|
45
|
+
signedTransaction: string;
|
|
46
|
+
txHash?: string;
|
|
47
|
+
operations: Array<{
|
|
48
|
+
type: string;
|
|
49
|
+
to?: string;
|
|
50
|
+
amount?: string;
|
|
51
|
+
token?: string;
|
|
52
|
+
programId?: string;
|
|
53
|
+
method?: string;
|
|
54
|
+
}>;
|
|
55
|
+
policyResult: {
|
|
56
|
+
tier: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
interface TransactionParam {
|
|
60
|
+
type: string;
|
|
61
|
+
amount: string;
|
|
62
|
+
toAddress: string;
|
|
63
|
+
chain: string;
|
|
64
|
+
network?: string;
|
|
65
|
+
tokenAddress?: string;
|
|
66
|
+
contractAddress?: string;
|
|
67
|
+
selector?: string;
|
|
68
|
+
spenderAddress?: string;
|
|
69
|
+
approveAmount?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert a ParsedOperation (from adapter parser) to a TransactionParam
|
|
73
|
+
* (for policy engine evaluation).
|
|
74
|
+
*
|
|
75
|
+
* Mapping:
|
|
76
|
+
* - NATIVE_TRANSFER -> TRANSFER (WHITELIST, SPENDING_LIMIT)
|
|
77
|
+
* - TOKEN_TRANSFER -> TOKEN_TRANSFER (WHITELIST, ALLOWED_TOKENS, SPENDING_LIMIT)
|
|
78
|
+
* - CONTRACT_CALL -> CONTRACT_CALL (CONTRACT_WHITELIST, METHOD_WHITELIST)
|
|
79
|
+
* - APPROVE -> APPROVE (APPROVED_SPENDERS, APPROVE_AMOUNT_LIMIT, APPROVE_TIER_OVERRIDE)
|
|
80
|
+
* - UNKNOWN -> CONTRACT_CALL (CONTRACT_WHITELIST default deny for unknown)
|
|
81
|
+
*/
|
|
82
|
+
export declare function mapOperationToParam(op: ParsedOperation, chain: string, network?: string): TransactionParam;
|
|
83
|
+
/**
|
|
84
|
+
* Execute the sign-only pipeline for an external unsigned transaction.
|
|
85
|
+
*
|
|
86
|
+
* Steps:
|
|
87
|
+
* 1. Parse -> 2. Map to policy params -> 3. Generate ID -> 4. INSERT DB ->
|
|
88
|
+
* 5. Evaluate policy -> 6. Check allowed -> 7. Check tier (reject DELAY/APPROVAL) ->
|
|
89
|
+
* 8. Update tier -> 9. Sign -> 10. Update status='SIGNED'
|
|
90
|
+
*
|
|
91
|
+
* @param deps - Pipeline dependencies (db, adapter, keyStore, policyEngine, etc.)
|
|
92
|
+
* @param walletId - The wallet whose key will sign
|
|
93
|
+
* @param request - Sign-only request (raw tx string, chain, network)
|
|
94
|
+
* @param sessionId - Optional session ID for audit trail
|
|
95
|
+
* @returns SignOnlyResult with signed transaction and metadata
|
|
96
|
+
*/
|
|
97
|
+
export declare function executeSignOnly(deps: SignOnlyDeps, walletId: string, request: SignOnlyRequest, sessionId?: string): Promise<SignOnlyResult>;
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=sign-only.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-only.d.ts","sourceRoot":"","sources":["../../src/pipeline/sign-only.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,aAAa,EAElB,KAAK,eAAe,EAEpB,KAAK,QAAQ,EACd,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,KAAK,KAAK,MAAM,MAAM,sCAAsC,CAAC;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAMpF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,qBAAqB,CAAC,OAAO,MAAM,C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C,EAAE,EAAE,eAAe,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,GACf,gBAAgB,CAyDlB;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,eAAe,EACxB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAqKzB"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sign-only pipeline module.
|
|
3
|
+
*
|
|
4
|
+
* Provides executeSignOnly() -- a standalone pipeline for signing external
|
|
5
|
+
* unsigned transactions after policy evaluation. Unlike the 6-stage send
|
|
6
|
+
* pipeline (stages.ts), this pipeline does NOT submit to chain.
|
|
7
|
+
*
|
|
8
|
+
* 10-step pipeline:
|
|
9
|
+
* 1. Parse unsigned tx (adapter.parseTransaction)
|
|
10
|
+
* 2. Map ParsedOperation[] to TransactionParam[] (for policy engine)
|
|
11
|
+
* 3. Generate UUID v7 transaction ID
|
|
12
|
+
* 4. INSERT DB record (type='SIGN', status='PENDING')
|
|
13
|
+
* 5. Policy evaluation (evaluateAndReserve / evaluateBatch / evaluate)
|
|
14
|
+
* 6. Check policy result (deny if !allowed)
|
|
15
|
+
* 7. Check tier (DELAY/APPROVAL -> immediate rejection)
|
|
16
|
+
* 8. Update tier on transaction row
|
|
17
|
+
* 9. Sign (keyStore.decrypt -> adapter.signExternalTransaction -> keyStore.release)
|
|
18
|
+
* 10. Update status='SIGNED', return result
|
|
19
|
+
*
|
|
20
|
+
* @see docs/32-pipeline-design.md
|
|
21
|
+
*/
|
|
22
|
+
import { eq } from 'drizzle-orm';
|
|
23
|
+
import { WAIaaSError, } from '@waiaas/core';
|
|
24
|
+
import { transactions } from '../infrastructure/database/schema.js';
|
|
25
|
+
import { generateId } from '../infrastructure/database/id.js';
|
|
26
|
+
import { DatabasePolicyEngine } from './database-policy-engine.js';
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Helper: map ParsedOperation to TransactionParam
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/**
|
|
31
|
+
* Convert a ParsedOperation (from adapter parser) to a TransactionParam
|
|
32
|
+
* (for policy engine evaluation).
|
|
33
|
+
*
|
|
34
|
+
* Mapping:
|
|
35
|
+
* - NATIVE_TRANSFER -> TRANSFER (WHITELIST, SPENDING_LIMIT)
|
|
36
|
+
* - TOKEN_TRANSFER -> TOKEN_TRANSFER (WHITELIST, ALLOWED_TOKENS, SPENDING_LIMIT)
|
|
37
|
+
* - CONTRACT_CALL -> CONTRACT_CALL (CONTRACT_WHITELIST, METHOD_WHITELIST)
|
|
38
|
+
* - APPROVE -> APPROVE (APPROVED_SPENDERS, APPROVE_AMOUNT_LIMIT, APPROVE_TIER_OVERRIDE)
|
|
39
|
+
* - UNKNOWN -> CONTRACT_CALL (CONTRACT_WHITELIST default deny for unknown)
|
|
40
|
+
*/
|
|
41
|
+
export function mapOperationToParam(op, chain, network) {
|
|
42
|
+
switch (op.type) {
|
|
43
|
+
case 'NATIVE_TRANSFER':
|
|
44
|
+
return {
|
|
45
|
+
type: 'TRANSFER',
|
|
46
|
+
amount: (op.amount ?? 0n).toString(),
|
|
47
|
+
toAddress: op.to ?? '',
|
|
48
|
+
chain,
|
|
49
|
+
network,
|
|
50
|
+
};
|
|
51
|
+
case 'TOKEN_TRANSFER':
|
|
52
|
+
return {
|
|
53
|
+
type: 'TOKEN_TRANSFER',
|
|
54
|
+
amount: (op.amount ?? 0n).toString(),
|
|
55
|
+
toAddress: op.to ?? '',
|
|
56
|
+
chain,
|
|
57
|
+
network,
|
|
58
|
+
tokenAddress: op.token,
|
|
59
|
+
};
|
|
60
|
+
case 'CONTRACT_CALL':
|
|
61
|
+
return {
|
|
62
|
+
type: 'CONTRACT_CALL',
|
|
63
|
+
amount: '0',
|
|
64
|
+
toAddress: op.programId ?? op.to ?? '',
|
|
65
|
+
chain,
|
|
66
|
+
network,
|
|
67
|
+
contractAddress: op.programId ?? op.to,
|
|
68
|
+
selector: op.method,
|
|
69
|
+
};
|
|
70
|
+
case 'APPROVE':
|
|
71
|
+
return {
|
|
72
|
+
type: 'APPROVE',
|
|
73
|
+
amount: (op.amount ?? 0n).toString(),
|
|
74
|
+
toAddress: op.to ?? '',
|
|
75
|
+
chain,
|
|
76
|
+
network,
|
|
77
|
+
spenderAddress: op.to,
|
|
78
|
+
approveAmount: (op.amount ?? 0n).toString(),
|
|
79
|
+
};
|
|
80
|
+
case 'UNKNOWN':
|
|
81
|
+
default:
|
|
82
|
+
// UNKNOWN operations are mapped to CONTRACT_CALL for CONTRACT_WHITELIST evaluation
|
|
83
|
+
// If CONTRACT_WHITELIST is active (default), this will be denied unless the programId is whitelisted
|
|
84
|
+
return {
|
|
85
|
+
type: 'CONTRACT_CALL',
|
|
86
|
+
amount: '0',
|
|
87
|
+
toAddress: op.programId ?? op.to ?? '',
|
|
88
|
+
chain,
|
|
89
|
+
network,
|
|
90
|
+
contractAddress: op.programId ?? op.to,
|
|
91
|
+
selector: op.method,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// executeSignOnly: 10-step sign-only pipeline
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
/**
|
|
99
|
+
* Execute the sign-only pipeline for an external unsigned transaction.
|
|
100
|
+
*
|
|
101
|
+
* Steps:
|
|
102
|
+
* 1. Parse -> 2. Map to policy params -> 3. Generate ID -> 4. INSERT DB ->
|
|
103
|
+
* 5. Evaluate policy -> 6. Check allowed -> 7. Check tier (reject DELAY/APPROVAL) ->
|
|
104
|
+
* 8. Update tier -> 9. Sign -> 10. Update status='SIGNED'
|
|
105
|
+
*
|
|
106
|
+
* @param deps - Pipeline dependencies (db, adapter, keyStore, policyEngine, etc.)
|
|
107
|
+
* @param walletId - The wallet whose key will sign
|
|
108
|
+
* @param request - Sign-only request (raw tx string, chain, network)
|
|
109
|
+
* @param sessionId - Optional session ID for audit trail
|
|
110
|
+
* @returns SignOnlyResult with signed transaction and metadata
|
|
111
|
+
*/
|
|
112
|
+
export async function executeSignOnly(deps, walletId, request, sessionId) {
|
|
113
|
+
// Step 1: Parse the unsigned transaction
|
|
114
|
+
let parsed;
|
|
115
|
+
try {
|
|
116
|
+
parsed = await deps.adapter.parseTransaction(request.transaction);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
throw new WAIaaSError('INVALID_TRANSACTION', {
|
|
120
|
+
message: err instanceof Error ? err.message : 'Failed to parse transaction',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Fire-and-forget: notify TX_REQUESTED (never blocks pipeline)
|
|
124
|
+
const firstOp = parsed.operations[0];
|
|
125
|
+
void deps.notificationService?.notify('TX_REQUESTED', walletId, {
|
|
126
|
+
amount: firstOp?.amount?.toString() ?? '0',
|
|
127
|
+
to: firstOp?.to ?? '',
|
|
128
|
+
type: 'SIGN',
|
|
129
|
+
display_amount: '', // sign-only: no USD conversion
|
|
130
|
+
}, { txId: 'pending', signOnly: true });
|
|
131
|
+
// v1.6: emit wallet:activity TX_REQUESTED event
|
|
132
|
+
deps.eventBus?.emit('wallet:activity', {
|
|
133
|
+
walletId,
|
|
134
|
+
activity: 'TX_REQUESTED',
|
|
135
|
+
details: { signOnly: true },
|
|
136
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
137
|
+
});
|
|
138
|
+
// Step 2: Convert ParsedOperation[] to TransactionParam[] for policy evaluation
|
|
139
|
+
const txParams = parsed.operations.map((op) => mapOperationToParam(op, request.chain, request.network));
|
|
140
|
+
// Step 3: Generate transaction ID
|
|
141
|
+
const txId = generateId();
|
|
142
|
+
const now = new Date(Math.floor(Date.now() / 1000) * 1000);
|
|
143
|
+
// Step 4: INSERT transaction record (type='SIGN', status='PENDING')
|
|
144
|
+
await deps.db.insert(transactions).values({
|
|
145
|
+
id: txId,
|
|
146
|
+
walletId,
|
|
147
|
+
chain: request.chain,
|
|
148
|
+
network: request.network ?? null,
|
|
149
|
+
type: 'SIGN',
|
|
150
|
+
status: 'PENDING',
|
|
151
|
+
amount: firstOp?.amount?.toString() ?? null,
|
|
152
|
+
toAddress: firstOp?.to ?? null,
|
|
153
|
+
sessionId: sessionId ?? null,
|
|
154
|
+
createdAt: now,
|
|
155
|
+
});
|
|
156
|
+
// Step 5: Policy evaluation (single op vs multi-op)
|
|
157
|
+
let evaluation;
|
|
158
|
+
if (txParams.length === 1 && deps.policyEngine instanceof DatabasePolicyEngine && deps.sqlite) {
|
|
159
|
+
// Single operation: use evaluateAndReserve for TOCTOU safety
|
|
160
|
+
evaluation = deps.policyEngine.evaluateAndReserve(walletId, txParams[0], txId);
|
|
161
|
+
}
|
|
162
|
+
else if (txParams.length > 1 && deps.policyEngine instanceof DatabasePolicyEngine) {
|
|
163
|
+
// Multiple operations: use evaluateBatch
|
|
164
|
+
evaluation = await deps.policyEngine.evaluateBatch(walletId, txParams);
|
|
165
|
+
// For batch: manually set reserved_amount on the tx row
|
|
166
|
+
if (evaluation.allowed && deps.sqlite) {
|
|
167
|
+
const totalAmount = txParams.reduce((sum, p) => sum + BigInt(p.amount), 0n);
|
|
168
|
+
deps.sqlite
|
|
169
|
+
.prepare('UPDATE transactions SET reserved_amount = ? WHERE id = ?')
|
|
170
|
+
.run(totalAmount.toString(), txId);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
evaluation = await deps.policyEngine.evaluate(walletId, txParams[0]);
|
|
175
|
+
}
|
|
176
|
+
// Step 6: Check policy result
|
|
177
|
+
if (!evaluation.allowed) {
|
|
178
|
+
await deps.db
|
|
179
|
+
.update(transactions)
|
|
180
|
+
.set({ status: 'CANCELLED', error: evaluation.reason ?? 'Policy denied' })
|
|
181
|
+
.where(eq(transactions.id, txId));
|
|
182
|
+
throw new WAIaaSError('POLICY_DENIED', {
|
|
183
|
+
message: evaluation.reason ?? 'Sign-only request denied by policy',
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
// Step 7: DELAY/APPROVAL tier = immediate rejection for sign-only
|
|
187
|
+
if (evaluation.tier === 'DELAY' || evaluation.tier === 'APPROVAL') {
|
|
188
|
+
await deps.db
|
|
189
|
+
.update(transactions)
|
|
190
|
+
.set({
|
|
191
|
+
status: 'CANCELLED',
|
|
192
|
+
tier: evaluation.tier,
|
|
193
|
+
error: `Sign-only does not support ${evaluation.tier} tier`,
|
|
194
|
+
})
|
|
195
|
+
.where(eq(transactions.id, txId));
|
|
196
|
+
throw new WAIaaSError('POLICY_DENIED', {
|
|
197
|
+
message: `Sign-only request requires ${evaluation.tier} tier which is not supported. Use POST /v1/transactions/send for high-value transactions.`,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
// Step 8: Update tier on transaction row
|
|
201
|
+
await deps.db
|
|
202
|
+
.update(transactions)
|
|
203
|
+
.set({ tier: evaluation.tier })
|
|
204
|
+
.where(eq(transactions.id, txId));
|
|
205
|
+
// Step 9: Sign the transaction
|
|
206
|
+
// CRITICAL: key MUST be released in finally block (see Pitfall 3)
|
|
207
|
+
let signed;
|
|
208
|
+
let privateKey = null;
|
|
209
|
+
try {
|
|
210
|
+
privateKey = await deps.keyStore.decryptPrivateKey(walletId, deps.masterPassword);
|
|
211
|
+
signed = await deps.adapter.signExternalTransaction(request.transaction, privateKey);
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
await deps.db
|
|
215
|
+
.update(transactions)
|
|
216
|
+
.set({ status: 'FAILED', error: err instanceof Error ? err.message : 'Signing failed' })
|
|
217
|
+
.where(eq(transactions.id, txId));
|
|
218
|
+
throw err instanceof WAIaaSError
|
|
219
|
+
? err
|
|
220
|
+
: new WAIaaSError('CHAIN_ERROR', {
|
|
221
|
+
message: err instanceof Error ? err.message : 'Failed to sign transaction',
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
if (privateKey) {
|
|
226
|
+
deps.keyStore.releaseKey(privateKey);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// Step 10: Update DB: status='SIGNED'
|
|
230
|
+
const executedAt = new Date(Math.floor(Date.now() / 1000) * 1000);
|
|
231
|
+
await deps.db
|
|
232
|
+
.update(transactions)
|
|
233
|
+
.set({ status: 'SIGNED', executedAt })
|
|
234
|
+
.where(eq(transactions.id, txId));
|
|
235
|
+
// Fire-and-forget: notify TX_SUBMITTED (sign complete, ready for external submission)
|
|
236
|
+
void deps.notificationService?.notify('TX_SUBMITTED', walletId, {
|
|
237
|
+
txHash: signed.txHash ?? '',
|
|
238
|
+
amount: firstOp?.amount?.toString() ?? '0',
|
|
239
|
+
to: firstOp?.to ?? '',
|
|
240
|
+
display_amount: '', // sign-only: no USD conversion
|
|
241
|
+
}, { txId, signOnly: true });
|
|
242
|
+
// v1.6: emit wallet:activity TX_SUBMITTED event (sign-only complete)
|
|
243
|
+
deps.eventBus?.emit('wallet:activity', {
|
|
244
|
+
walletId,
|
|
245
|
+
activity: 'TX_SUBMITTED',
|
|
246
|
+
details: { txId, signOnly: true, txHash: signed.txHash },
|
|
247
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
248
|
+
});
|
|
249
|
+
// Return result
|
|
250
|
+
return {
|
|
251
|
+
id: txId,
|
|
252
|
+
signedTransaction: signed.signedTransaction,
|
|
253
|
+
txHash: signed.txHash,
|
|
254
|
+
operations: parsed.operations.map((op) => ({
|
|
255
|
+
type: op.type,
|
|
256
|
+
to: op.to,
|
|
257
|
+
amount: op.amount?.toString(),
|
|
258
|
+
token: op.token,
|
|
259
|
+
programId: op.programId,
|
|
260
|
+
method: op.method,
|
|
261
|
+
})),
|
|
262
|
+
policyResult: {
|
|
263
|
+
tier: evaluation.tier,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=sign-only.js.map
|
|
@@ -0,0 +1 @@
|
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KAAK,EAAE,EAAE,CAAC,KAAK;YACf,SAAS,EAAE,EAAE,CAAC,SAAS;YACvB,MAAM,EAAE,EAAE,CAAC,MAAM;SAClB,CAAC,CAAC;QACH,YAAY,EAAE;YACZ,IAAI,EAAE,UAAU,CAAC,IAAI;SACtB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/pipeline/sleep.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/pipeline/sleep.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 6-stage transaction pipeline stages.
|
|
3
|
+
*
|
|
4
|
+
* Stage 1: Validate request + INSERT PENDING transaction (with sessionId audit trail)
|
|
5
|
+
* Stage 2: Auth (sessionId passthrough from route handler)
|
|
6
|
+
* Stage 3: Policy evaluation (evaluateAndReserve TOCTOU-safe + downgradeIfNoOwner)
|
|
7
|
+
* Stage 4: Wait (v1.1 passthrough, INSTANT tier only)
|
|
8
|
+
* Stage 5: On-chain execution (build -> simulate -> sign -> submit)
|
|
9
|
+
* Stage 6: Confirmation wait
|
|
10
|
+
*
|
|
11
|
+
* @see docs/32-pipeline-design.md
|
|
12
|
+
*/
|
|
13
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
14
|
+
import type { Database as SQLiteDatabase } from 'better-sqlite3';
|
|
15
|
+
import { type IChainAdapter, type IPolicyEngine, type PolicyTier, type UnsignedTransaction, type SubmitResult, type SendTransactionRequest, type TransactionRequest } from '@waiaas/core';
|
|
16
|
+
import type { LocalKeyStore } from '../infrastructure/keystore/keystore.js';
|
|
17
|
+
import type * as schema from '../infrastructure/database/schema.js';
|
|
18
|
+
import type { DelayQueue } from '../workflow/delay-queue.js';
|
|
19
|
+
import type { ApprovalWorkflow } from '../workflow/approval-workflow.js';
|
|
20
|
+
import type { NotificationService } from '../notifications/notification-service.js';
|
|
21
|
+
import type { SettingsService } from '../infrastructure/settings/settings-service.js';
|
|
22
|
+
import type { IPriceOracle, IForexRateService } from '@waiaas/core';
|
|
23
|
+
import { type EventBus } from '@waiaas/core';
|
|
24
|
+
import type { WcSigningBridge } from '../services/wc-signing-bridge.js';
|
|
25
|
+
declare const hintedTokens: Set<string>;
|
|
26
|
+
export { hintedTokens };
|
|
27
|
+
export interface PipelineContext {
|
|
28
|
+
db: BetterSQLite3Database<typeof schema>;
|
|
29
|
+
adapter: IChainAdapter;
|
|
30
|
+
keyStore: LocalKeyStore;
|
|
31
|
+
policyEngine: IPolicyEngine;
|
|
32
|
+
masterPassword: string;
|
|
33
|
+
walletId: string;
|
|
34
|
+
wallet: {
|
|
35
|
+
publicKey: string;
|
|
36
|
+
chain: string;
|
|
37
|
+
environment: string;
|
|
38
|
+
defaultNetwork: string | null;
|
|
39
|
+
};
|
|
40
|
+
resolvedNetwork: string;
|
|
41
|
+
request: SendTransactionRequest | TransactionRequest;
|
|
42
|
+
txId: string;
|
|
43
|
+
tier?: PolicyTier;
|
|
44
|
+
unsignedTx?: UnsignedTransaction;
|
|
45
|
+
signedTx?: Uint8Array;
|
|
46
|
+
submitResult?: SubmitResult;
|
|
47
|
+
sessionId?: string;
|
|
48
|
+
sqlite?: SQLiteDatabase;
|
|
49
|
+
delaySeconds?: number;
|
|
50
|
+
downgraded?: boolean;
|
|
51
|
+
delayQueue?: DelayQueue;
|
|
52
|
+
approvalWorkflow?: ApprovalWorkflow;
|
|
53
|
+
config?: {
|
|
54
|
+
policy_defaults_delay_seconds: number;
|
|
55
|
+
policy_defaults_approval_timeout: number;
|
|
56
|
+
};
|
|
57
|
+
notificationService?: NotificationService;
|
|
58
|
+
priceOracle?: IPriceOracle;
|
|
59
|
+
settingsService?: SettingsService;
|
|
60
|
+
forexRateService?: IForexRateService;
|
|
61
|
+
amountUsd?: number;
|
|
62
|
+
eventBus?: EventBus;
|
|
63
|
+
wcSigningBridge?: WcSigningBridge;
|
|
64
|
+
}
|
|
65
|
+
export declare function stage1Validate(ctx: PipelineContext): Promise<void>;
|
|
66
|
+
export declare function stage2Auth(_ctx: PipelineContext): Promise<void>;
|
|
67
|
+
export declare function stage3Policy(ctx: PipelineContext): Promise<void>;
|
|
68
|
+
export declare function stage4Wait(ctx: PipelineContext): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Stage 5: Build -> Simulate -> Sign -> Submit with CONC-01 retry logic.
|
|
71
|
+
*
|
|
72
|
+
* ChainError category-based retry:
|
|
73
|
+
* - PERMANENT: immediate FAILED, no retry
|
|
74
|
+
* - TRANSIENT: exponential backoff (1s, 2s, 4s), max 3 retries (retryCount >= 3 guard)
|
|
75
|
+
* - STALE: rebuild from Stage 5a, max 1 (retryCount >= 1 guard)
|
|
76
|
+
*
|
|
77
|
+
* retryCount is shared between TRANSIENT and STALE to limit total retry count.
|
|
78
|
+
* Total attempts: initial 1 + up to 3 retries = 4 max.
|
|
79
|
+
*/
|
|
80
|
+
export declare function stage5Execute(ctx: PipelineContext): Promise<void>;
|
|
81
|
+
export declare function stage6Confirm(ctx: PipelineContext): Promise<void>;
|
|
82
|
+
//# sourceMappingURL=stages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stages.d.ts","sourceRoot":"","sources":["../../src/pipeline/stages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM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