@waiaas/daemon 2.11.0-rc.8 → 2.11.0
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/README.md +5 -5
- package/dist/api/middleware/address-validation.d.ts +6 -33
- package/dist/api/middleware/address-validation.d.ts.map +1 -1
- package/dist/api/middleware/address-validation.js +5 -129
- package/dist/api/middleware/address-validation.js.map +1 -1
- package/dist/api/middleware/host-guard.d.ts +1 -1
- package/dist/api/middleware/host-guard.js +2 -2
- package/dist/api/middleware/host-guard.js.map +1 -1
- package/dist/api/middleware/index.d.ts +1 -0
- package/dist/api/middleware/index.d.ts.map +1 -1
- package/dist/api/middleware/index.js +1 -0
- package/dist/api/middleware/index.js.map +1 -1
- package/dist/api/middleware/master-auth.d.ts +2 -5
- package/dist/api/middleware/master-auth.d.ts.map +1 -1
- package/dist/api/middleware/master-auth.js.map +1 -1
- package/dist/api/middleware/rate-limiter.d.ts +51 -0
- package/dist/api/middleware/rate-limiter.d.ts.map +1 -0
- package/dist/api/middleware/rate-limiter.js +146 -0
- package/dist/api/middleware/rate-limiter.js.map +1 -0
- package/dist/api/middleware/siwe-verify.d.ts +6 -26
- package/dist/api/middleware/siwe-verify.d.ts.map +1 -1
- package/dist/api/middleware/siwe-verify.js +5 -50
- package/dist/api/middleware/siwe-verify.js.map +1 -1
- package/dist/api/routes/actions.d.ts +1 -0
- package/dist/api/routes/actions.d.ts.map +1 -1
- package/dist/api/routes/actions.js +52 -4
- package/dist/api/routes/actions.js.map +1 -1
- package/dist/api/routes/admin-actions.d.ts +1 -0
- package/dist/api/routes/admin-actions.d.ts.map +1 -1
- package/dist/api/routes/admin-actions.js +3 -3
- package/dist/api/routes/admin-actions.js.map +1 -1
- package/dist/api/routes/admin-auth.d.ts.map +1 -1
- package/dist/api/routes/admin-auth.js +12 -7
- package/dist/api/routes/admin-auth.js.map +1 -1
- package/dist/api/routes/admin-credentials.js +2 -2
- package/dist/api/routes/admin-credentials.js.map +1 -1
- package/dist/api/routes/admin-monitoring.d.ts +10 -0
- package/dist/api/routes/admin-monitoring.d.ts.map +1 -1
- package/dist/api/routes/admin-monitoring.js +59 -14
- package/dist/api/routes/admin-monitoring.js.map +1 -1
- package/dist/api/routes/admin-notifications.d.ts.map +1 -1
- package/dist/api/routes/admin-notifications.js +2 -15
- package/dist/api/routes/admin-notifications.js.map +1 -1
- package/dist/api/routes/admin-settings.d.ts.map +1 -1
- package/dist/api/routes/admin-settings.js +90 -1
- package/dist/api/routes/admin-settings.js.map +1 -1
- package/dist/api/routes/admin-wallets.d.ts +16 -1
- package/dist/api/routes/admin-wallets.d.ts.map +1 -1
- package/dist/api/routes/admin-wallets.js +64 -75
- package/dist/api/routes/admin-wallets.js.map +1 -1
- package/dist/api/routes/admin.d.ts +1 -0
- package/dist/api/routes/admin.d.ts.map +1 -1
- package/dist/api/routes/admin.js.map +1 -1
- package/dist/api/routes/credentials.js +2 -2
- package/dist/api/routes/credentials.js.map +1 -1
- package/dist/api/routes/defi-positions.js.map +1 -1
- package/dist/api/routes/nfts.js.map +1 -1
- package/dist/api/routes/openapi-schemas.d.ts +412 -12
- package/dist/api/routes/openapi-schemas.d.ts.map +1 -1
- package/dist/api/routes/openapi-schemas.js +38 -5
- package/dist/api/routes/openapi-schemas.js.map +1 -1
- package/dist/api/routes/policies.d.ts +2 -0
- package/dist/api/routes/policies.d.ts.map +1 -1
- package/dist/api/routes/policies.js +55 -6
- package/dist/api/routes/policies.js.map +1 -1
- package/dist/api/routes/rpc-proxy.js.map +1 -1
- package/dist/api/routes/sessions.d.ts.map +1 -1
- package/dist/api/routes/sessions.js +47 -28
- package/dist/api/routes/sessions.js.map +1 -1
- package/dist/api/routes/staking.d.ts.map +1 -1
- package/dist/api/routes/staking.js +4 -76
- package/dist/api/routes/staking.js.map +1 -1
- package/dist/api/routes/tokens.d.ts.map +1 -1
- package/dist/api/routes/tokens.js.map +1 -1
- package/dist/api/routes/transactions.d.ts +1 -0
- package/dist/api/routes/transactions.d.ts.map +1 -1
- package/dist/api/routes/transactions.js +8 -2
- package/dist/api/routes/transactions.js.map +1 -1
- package/dist/api/routes/userop.d.ts.map +1 -1
- package/dist/api/routes/userop.js +0 -2
- package/dist/api/routes/userop.js.map +1 -1
- package/dist/api/routes/wallet-apps.d.ts.map +1 -1
- package/dist/api/routes/wallet-apps.js +20 -13
- package/dist/api/routes/wallet-apps.js.map +1 -1
- package/dist/api/routes/wallet.js.map +1 -1
- package/dist/api/routes/wallets.d.ts.map +1 -1
- package/dist/api/routes/wallets.js +3 -0
- package/dist/api/routes/wallets.js.map +1 -1
- package/dist/api/routes/wc.d.ts.map +1 -1
- package/dist/api/routes/wc.js +13 -8
- package/dist/api/routes/wc.js.map +1 -1
- package/dist/api/routes/x402.d.ts.map +1 -1
- package/dist/api/routes/x402.js +1 -2
- package/dist/api/routes/x402.js.map +1 -1
- package/dist/api/server.d.ts +8 -4
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +46 -5
- package/dist/api/server.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/infrastructure/action/action-provider-registry.d.ts.map +1 -1
- package/dist/infrastructure/action/action-provider-registry.js +2 -3
- package/dist/infrastructure/action/action-provider-registry.js.map +1 -1
- package/dist/infrastructure/action/builtin-metadata.d.ts +22 -0
- package/dist/infrastructure/action/builtin-metadata.d.ts.map +1 -0
- package/dist/infrastructure/action/builtin-metadata.js +29 -0
- package/dist/infrastructure/action/builtin-metadata.js.map +1 -0
- package/dist/infrastructure/adapter-pool.d.ts +2 -1
- package/dist/infrastructure/adapter-pool.d.ts.map +1 -1
- package/dist/infrastructure/adapter-pool.js.map +1 -1
- package/dist/infrastructure/auth/address-validation.d.ts +38 -0
- package/dist/infrastructure/auth/address-validation.d.ts.map +1 -0
- package/dist/infrastructure/auth/address-validation.js +134 -0
- package/dist/infrastructure/auth/address-validation.js.map +1 -0
- package/dist/infrastructure/auth/siwe-verify.d.ts +34 -0
- package/dist/infrastructure/auth/siwe-verify.d.ts.map +1 -0
- package/dist/infrastructure/auth/siwe-verify.js +58 -0
- package/dist/infrastructure/auth/siwe-verify.js.map +1 -0
- package/dist/infrastructure/auth/types.d.ts +12 -0
- package/dist/infrastructure/auth/types.d.ts.map +1 -0
- package/dist/infrastructure/auth/types.js +8 -0
- package/dist/infrastructure/auth/types.js.map +1 -0
- package/dist/infrastructure/config/loader.d.ts +1 -10
- package/dist/infrastructure/config/loader.d.ts.map +1 -1
- package/dist/infrastructure/config/loader.js +0 -2
- package/dist/infrastructure/config/loader.js.map +1 -1
- package/dist/infrastructure/database/migrate.d.ts +6 -18
- package/dist/infrastructure/database/migrate.d.ts.map +1 -1
- package/dist/infrastructure/database/migrate.js +25 -2856
- package/dist/infrastructure/database/migrate.js.map +1 -1
- package/dist/infrastructure/database/migrations/v11-v20.d.ts +17 -0
- package/dist/infrastructure/database/migrations/v11-v20.d.ts.map +1 -0
- package/dist/infrastructure/database/migrations/v11-v20.js +295 -0
- package/dist/infrastructure/database/migrations/v11-v20.js.map +1 -0
- package/dist/infrastructure/database/migrations/v2-v10.d.ts +16 -0
- package/dist/infrastructure/database/migrations/v2-v10.d.ts.map +1 -0
- package/dist/infrastructure/database/migrations/v2-v10.js +539 -0
- package/dist/infrastructure/database/migrations/v2-v10.js.map +1 -0
- package/dist/infrastructure/database/migrations/v21-v30.d.ts +17 -0
- package/dist/infrastructure/database/migrations/v21-v30.d.ts.map +1 -0
- package/dist/infrastructure/database/migrations/v21-v30.js +507 -0
- package/dist/infrastructure/database/migrations/v21-v30.js.map +1 -0
- package/dist/infrastructure/database/migrations/v31-v40.d.ts +17 -0
- package/dist/infrastructure/database/migrations/v31-v40.d.ts.map +1 -0
- package/dist/infrastructure/database/migrations/v31-v40.js +203 -0
- package/dist/infrastructure/database/migrations/v31-v40.js.map +1 -0
- package/dist/infrastructure/database/migrations/v41-v50.d.ts +17 -0
- package/dist/infrastructure/database/migrations/v41-v50.d.ts.map +1 -0
- package/dist/infrastructure/database/migrations/v41-v50.js +188 -0
- package/dist/infrastructure/database/migrations/v41-v50.js.map +1 -0
- package/dist/infrastructure/database/migrations/v51-v59.d.ts +17 -0
- package/dist/infrastructure/database/migrations/v51-v59.d.ts.map +1 -0
- package/dist/infrastructure/database/migrations/v51-v59.js +420 -0
- package/dist/infrastructure/database/migrations/v51-v59.js.map +1 -0
- package/dist/infrastructure/database/schema-ddl.d.ts +24 -0
- package/dist/infrastructure/database/schema-ddl.d.ts.map +1 -0
- package/dist/infrastructure/database/schema-ddl.js +596 -0
- package/dist/infrastructure/database/schema-ddl.js.map +1 -0
- package/dist/infrastructure/database/schema.d.ts +38 -0
- package/dist/infrastructure/database/schema.d.ts.map +1 -1
- package/dist/infrastructure/database/schema.js +2 -0
- package/dist/infrastructure/database/schema.js.map +1 -1
- package/dist/infrastructure/jwt/jwt-secret-manager.d.ts.map +1 -1
- package/dist/infrastructure/jwt/jwt-secret-manager.js +16 -3
- package/dist/infrastructure/jwt/jwt-secret-manager.js.map +1 -1
- package/dist/infrastructure/nft/alchemy-nft-indexer.d.ts.map +1 -1
- package/dist/infrastructure/nft/alchemy-nft-indexer.js +0 -1
- package/dist/infrastructure/nft/alchemy-nft-indexer.js.map +1 -1
- package/dist/infrastructure/nft/helius-nft-indexer.d.ts.map +1 -1
- package/dist/infrastructure/nft/helius-nft-indexer.js +1 -2
- package/dist/infrastructure/nft/helius-nft-indexer.js.map +1 -1
- package/dist/infrastructure/nft/nft-indexer-client.d.ts.map +1 -1
- package/dist/infrastructure/nft/nft-indexer-client.js +0 -2
- package/dist/infrastructure/nft/nft-indexer-client.js.map +1 -1
- package/dist/infrastructure/security/ssrf-guard.d.ts +33 -0
- package/dist/infrastructure/security/ssrf-guard.d.ts.map +1 -0
- package/dist/infrastructure/security/ssrf-guard.js +244 -0
- package/dist/infrastructure/security/ssrf-guard.js.map +1 -0
- package/dist/infrastructure/settings/hot-reload.d.ts +1 -1
- package/dist/infrastructure/settings/hot-reload.d.ts.map +1 -1
- package/dist/infrastructure/settings/hot-reload.js +0 -2
- package/dist/infrastructure/settings/hot-reload.js.map +1 -1
- package/dist/infrastructure/settings/index.d.ts +2 -2
- package/dist/infrastructure/settings/index.d.ts.map +1 -1
- package/dist/infrastructure/settings/index.js +1 -1
- package/dist/infrastructure/settings/index.js.map +1 -1
- package/dist/infrastructure/settings/setting-keys.d.ts +14 -0
- package/dist/infrastructure/settings/setting-keys.d.ts.map +1 -1
- package/dist/infrastructure/settings/setting-keys.js +296 -214
- package/dist/infrastructure/settings/setting-keys.js.map +1 -1
- package/dist/infrastructure/settings/settings-service.d.ts +6 -1
- package/dist/infrastructure/settings/settings-service.d.ts.map +1 -1
- package/dist/infrastructure/settings/settings-service.js +15 -5
- package/dist/infrastructure/settings/settings-service.js.map +1 -1
- package/dist/infrastructure/telegram/telegram-bot-service.d.ts.map +1 -1
- package/dist/infrastructure/telegram/telegram-bot-service.js +3 -2
- package/dist/infrastructure/telegram/telegram-bot-service.js.map +1 -1
- package/dist/infrastructure/token-registry/builtin-tokens.d.ts.map +1 -1
- package/dist/infrastructure/token-registry/builtin-tokens.js +4 -7
- package/dist/infrastructure/token-registry/builtin-tokens.js.map +1 -1
- package/dist/lifecycle/daemon-pipeline.d.ts +49 -0
- package/dist/lifecycle/daemon-pipeline.d.ts.map +1 -0
- package/dist/lifecycle/daemon-pipeline.js +281 -0
- package/dist/lifecycle/daemon-pipeline.js.map +1 -0
- package/dist/lifecycle/daemon-shutdown.d.ts +14 -0
- package/dist/lifecycle/daemon-shutdown.d.ts.map +1 -0
- package/dist/lifecycle/daemon-shutdown.js +176 -0
- package/dist/lifecycle/daemon-shutdown.js.map +1 -0
- package/dist/lifecycle/daemon-startup.d.ts +15 -0
- package/dist/lifecycle/daemon-startup.d.ts.map +1 -0
- package/dist/lifecycle/daemon-startup.js +1527 -0
- package/dist/lifecycle/daemon-startup.js.map +1 -0
- package/dist/lifecycle/daemon.d.ts +171 -114
- package/dist/lifecycle/daemon.d.ts.map +1 -1
- package/dist/lifecycle/daemon.js +22 -1904
- package/dist/lifecycle/daemon.js.map +1 -1
- package/dist/notifications/channels/discord.d.ts.map +1 -1
- package/dist/notifications/channels/discord.js +1 -0
- package/dist/notifications/channels/discord.js.map +1 -1
- package/dist/notifications/channels/slack.d.ts.map +1 -1
- package/dist/notifications/channels/slack.js +1 -0
- package/dist/notifications/channels/slack.js.map +1 -1
- package/dist/notifications/index.d.ts +0 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +0 -1
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/notification-service.d.ts.map +1 -1
- package/dist/notifications/notification-service.js +8 -6
- package/dist/notifications/notification-service.js.map +1 -1
- package/dist/pipeline/database-policy-engine.d.ts +18 -438
- package/dist/pipeline/database-policy-engine.d.ts.map +1 -1
- package/dist/pipeline/database-policy-engine.js +154 -1321
- package/dist/pipeline/database-policy-engine.js.map +1 -1
- package/dist/pipeline/dry-run.d.ts +5 -2
- package/dist/pipeline/dry-run.d.ts.map +1 -1
- package/dist/pipeline/dry-run.js +102 -8
- package/dist/pipeline/dry-run.js.map +1 -1
- package/dist/pipeline/evaluators/allowed-tokens.d.ts +28 -0
- package/dist/pipeline/evaluators/allowed-tokens.d.ts.map +1 -0
- package/dist/pipeline/evaluators/allowed-tokens.js +129 -0
- package/dist/pipeline/evaluators/allowed-tokens.js.map +1 -0
- package/dist/pipeline/evaluators/approved-spenders.d.ts +26 -0
- package/dist/pipeline/evaluators/approved-spenders.d.ts.map +1 -0
- package/dist/pipeline/evaluators/approved-spenders.js +115 -0
- package/dist/pipeline/evaluators/approved-spenders.js.map +1 -0
- package/dist/pipeline/evaluators/contract-whitelist.d.ts +28 -0
- package/dist/pipeline/evaluators/contract-whitelist.d.ts.map +1 -0
- package/dist/pipeline/evaluators/contract-whitelist.js +168 -0
- package/dist/pipeline/evaluators/contract-whitelist.js.map +1 -0
- package/dist/pipeline/evaluators/helpers.d.ts +9 -0
- package/dist/pipeline/evaluators/helpers.d.ts.map +1 -0
- package/dist/pipeline/evaluators/helpers.js +13 -0
- package/dist/pipeline/evaluators/helpers.js.map +1 -0
- package/dist/pipeline/evaluators/lending-asset-whitelist.d.ts +18 -0
- package/dist/pipeline/evaluators/lending-asset-whitelist.d.ts.map +1 -0
- package/dist/pipeline/evaluators/lending-asset-whitelist.js +44 -0
- package/dist/pipeline/evaluators/lending-asset-whitelist.js.map +1 -0
- package/dist/pipeline/evaluators/lending-ltv-limit.d.ts +24 -0
- package/dist/pipeline/evaluators/lending-ltv-limit.d.ts.map +1 -0
- package/dist/pipeline/evaluators/lending-ltv-limit.js +130 -0
- package/dist/pipeline/evaluators/lending-ltv-limit.js.map +1 -0
- package/dist/pipeline/evaluators/spending-limit.d.ts +46 -0
- package/dist/pipeline/evaluators/spending-limit.d.ts.map +1 -0
- package/dist/pipeline/evaluators/spending-limit.js +241 -0
- package/dist/pipeline/evaluators/spending-limit.js.map +1 -0
- package/dist/pipeline/evaluators/types.d.ts +71 -0
- package/dist/pipeline/evaluators/types.d.ts.map +1 -0
- package/dist/pipeline/evaluators/types.js +7 -0
- package/dist/pipeline/evaluators/types.js.map +1 -0
- package/dist/pipeline/external-action-pipeline.js.map +1 -1
- package/dist/pipeline/gas-condition-tracker.d.ts +1 -1
- package/dist/pipeline/gas-condition-tracker.js +1 -1
- package/dist/pipeline/pipeline-helpers.d.ts +146 -0
- package/dist/pipeline/pipeline-helpers.d.ts.map +1 -0
- package/dist/pipeline/pipeline-helpers.js +260 -0
- package/dist/pipeline/pipeline-helpers.js.map +1 -0
- package/dist/pipeline/pipeline.d.ts +1 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -1
- package/dist/pipeline/pipeline.js +3 -2
- package/dist/pipeline/pipeline.js.map +1 -1
- package/dist/pipeline/resolve-effective-amount-usd.d.ts.map +1 -1
- package/dist/pipeline/resolve-effective-amount-usd.js +4 -10
- package/dist/pipeline/resolve-effective-amount-usd.js.map +1 -1
- package/dist/pipeline/sign-message.js +1 -1
- package/dist/pipeline/sign-message.js.map +1 -1
- package/dist/pipeline/sleep.d.ts +1 -5
- package/dist/pipeline/sleep.d.ts.map +1 -1
- package/dist/pipeline/sleep.js +2 -7
- package/dist/pipeline/sleep.js.map +1 -1
- package/dist/pipeline/stage1-validate.d.ts +8 -0
- package/dist/pipeline/stage1-validate.d.ts.map +1 -0
- package/dist/pipeline/stage1-validate.js +69 -0
- package/dist/pipeline/stage1-validate.js.map +1 -0
- package/dist/pipeline/stage2-auth.d.ts +12 -0
- package/dist/pipeline/stage2-auth.d.ts.map +1 -0
- package/dist/pipeline/stage2-auth.js +18 -0
- package/dist/pipeline/stage2-auth.js.map +1 -0
- package/dist/pipeline/stage3-policy.d.ts +26 -0
- package/dist/pipeline/stage3-policy.d.ts.map +1 -0
- package/dist/pipeline/stage3-policy.js +384 -0
- package/dist/pipeline/stage3-policy.js.map +1 -0
- package/dist/pipeline/stage4-wait.d.ts +8 -0
- package/dist/pipeline/stage4-wait.d.ts.map +1 -0
- package/dist/pipeline/stage4-wait.js +87 -0
- package/dist/pipeline/stage4-wait.js.map +1 -0
- package/dist/pipeline/stage5-execute.d.ts +120 -0
- package/dist/pipeline/stage5-execute.d.ts.map +1 -0
- package/dist/pipeline/stage5-execute.js +1070 -0
- package/dist/pipeline/stage5-execute.js.map +1 -0
- package/dist/pipeline/stage6-confirm.d.ts +11 -0
- package/dist/pipeline/stage6-confirm.d.ts.map +1 -0
- package/dist/pipeline/stage6-confirm.js +110 -0
- package/dist/pipeline/stage6-confirm.js.map +1 -0
- package/dist/pipeline/stages.d.ts +11 -245
- package/dist/pipeline/stages.d.ts.map +1 -1
- package/dist/pipeline/stages.js +11 -1896
- package/dist/pipeline/stages.js.map +1 -1
- package/dist/rpc-proxy/sync-pipeline.js +2 -2
- package/dist/rpc-proxy/sync-pipeline.js.map +1 -1
- package/dist/services/autostop/autostop-service.d.ts +4 -1
- package/dist/services/autostop/autostop-service.d.ts.map +1 -1
- package/dist/services/autostop/autostop-service.js +27 -7
- package/dist/services/autostop/autostop-service.js.map +1 -1
- package/dist/services/defi/position-tracker.d.ts +5 -0
- package/dist/services/defi/position-tracker.d.ts.map +1 -1
- package/dist/services/defi/position-tracker.js +41 -6
- package/dist/services/defi/position-tracker.js.map +1 -1
- package/dist/services/defi/position-write-queue.d.ts.map +1 -1
- package/dist/services/defi/position-write-queue.js +3 -2
- package/dist/services/defi/position-write-queue.js.map +1 -1
- package/dist/services/incoming/__tests__/integration-wiring.test.js +58 -0
- package/dist/services/incoming/__tests__/integration-wiring.test.js.map +1 -1
- package/dist/services/incoming/incoming-tx-monitor-service.d.ts.map +1 -1
- package/dist/services/incoming/incoming-tx-monitor-service.js +11 -14
- package/dist/services/incoming/incoming-tx-monitor-service.js.map +1 -1
- package/dist/services/incoming/incoming-tx-workers.d.ts +2 -2
- package/dist/services/incoming/incoming-tx-workers.d.ts.map +1 -1
- package/dist/services/incoming/incoming-tx-workers.js +1 -1
- package/dist/services/incoming/incoming-tx-workers.js.map +1 -1
- package/dist/services/incoming/safety-rules.d.ts.map +1 -1
- package/dist/services/incoming/safety-rules.js +3 -2
- package/dist/services/incoming/safety-rules.js.map +1 -1
- package/dist/services/incoming/subscription-multiplexer.d.ts +2 -6
- package/dist/services/incoming/subscription-multiplexer.d.ts.map +1 -1
- package/dist/services/incoming/subscription-multiplexer.js +1 -3
- package/dist/services/incoming/subscription-multiplexer.js.map +1 -1
- package/dist/services/monitoring/balance-monitor-service.d.ts.map +1 -1
- package/dist/services/monitoring/balance-monitor-service.js +2 -2
- package/dist/services/monitoring/balance-monitor-service.js.map +1 -1
- package/dist/services/signing-sdk/approval-channel-router.d.ts +7 -7
- package/dist/services/signing-sdk/approval-channel-router.d.ts.map +1 -1
- package/dist/services/signing-sdk/approval-channel-router.js +13 -13
- package/dist/services/signing-sdk/approval-channel-router.js.map +1 -1
- package/dist/services/signing-sdk/channels/index.d.ts +2 -2
- package/dist/services/signing-sdk/channels/index.d.ts.map +1 -1
- package/dist/services/signing-sdk/channels/index.js +1 -1
- package/dist/services/signing-sdk/channels/index.js.map +1 -1
- package/dist/services/signing-sdk/channels/push-relay-signing-channel.d.ts +59 -0
- package/dist/services/signing-sdk/channels/push-relay-signing-channel.d.ts.map +1 -0
- package/dist/services/signing-sdk/channels/push-relay-signing-channel.js +190 -0
- package/dist/services/signing-sdk/channels/push-relay-signing-channel.js.map +1 -0
- package/dist/services/signing-sdk/channels/telegram-signing-channel.d.ts +1 -1
- package/dist/services/signing-sdk/channels/telegram-signing-channel.js +1 -1
- package/dist/services/signing-sdk/channels/wallet-notification-channel.d.ts +6 -7
- package/dist/services/signing-sdk/channels/wallet-notification-channel.d.ts.map +1 -1
- package/dist/services/signing-sdk/channels/wallet-notification-channel.js +38 -55
- package/dist/services/signing-sdk/channels/wallet-notification-channel.js.map +1 -1
- package/dist/services/signing-sdk/index.d.ts +3 -3
- package/dist/services/signing-sdk/index.d.ts.map +1 -1
- package/dist/services/signing-sdk/index.js +2 -2
- package/dist/services/signing-sdk/index.js.map +1 -1
- package/dist/services/signing-sdk/preset-auto-setup.js +2 -2
- package/dist/services/signing-sdk/preset-auto-setup.js.map +1 -1
- package/dist/services/signing-sdk/sign-request-builder.d.ts +2 -2
- package/dist/services/signing-sdk/sign-request-builder.d.ts.map +1 -1
- package/dist/services/signing-sdk/sign-request-builder.js +17 -25
- package/dist/services/signing-sdk/sign-request-builder.js.map +1 -1
- package/dist/services/signing-sdk/wallet-app-service.d.ts +4 -0
- package/dist/services/signing-sdk/wallet-app-service.d.ts.map +1 -1
- package/dist/services/signing-sdk/wallet-app-service.js +12 -5
- package/dist/services/signing-sdk/wallet-app-service.js.map +1 -1
- package/dist/services/staking/aggregate-staking-balance.d.ts +24 -0
- package/dist/services/staking/aggregate-staking-balance.d.ts.map +1 -0
- package/dist/services/staking/aggregate-staking-balance.js +82 -0
- package/dist/services/staking/aggregate-staking-balance.js.map +1 -0
- package/dist/services/wc-session-service.d.ts.map +1 -1
- package/dist/services/wc-session-service.js +2 -1
- package/dist/services/wc-session-service.js.map +1 -1
- package/dist/services/wc-signing-bridge.js +2 -2
- package/dist/services/wc-signing-bridge.js.map +1 -1
- package/dist/services/x402/payment-signer.d.ts.map +1 -1
- package/dist/services/x402/payment-signer.js +2 -5
- package/dist/services/x402/payment-signer.js.map +1 -1
- package/dist/services/x402/ssrf-guard.d.ts +4 -23
- package/dist/services/x402/ssrf-guard.d.ts.map +1 -1
- package/dist/services/x402/ssrf-guard.js +3 -232
- package/dist/services/x402/ssrf-guard.js.map +1 -1
- package/dist/signing/capabilities/eip712-signer.d.ts.map +1 -1
- package/dist/signing/capabilities/eip712-signer.js +2 -0
- package/dist/signing/capabilities/eip712-signer.js.map +1 -1
- package/package.json +5 -5
- package/public/admin/assets/index-CpFF2lCo.js +3 -0
- package/public/admin/index.html +1 -1
- package/dist/notifications/channels/ntfy.d.ts +0 -13
- package/dist/notifications/channels/ntfy.d.ts.map +0 -1
- package/dist/notifications/channels/ntfy.js +0 -74
- package/dist/notifications/channels/ntfy.js.map +0 -1
- package/dist/services/signing-sdk/channels/ntfy-signing-channel.d.ts +0 -66
- package/dist/services/signing-sdk/channels/ntfy-signing-channel.d.ts.map +0 -1
- package/dist/services/signing-sdk/channels/ntfy-signing-channel.js +0 -270
- package/dist/services/signing-sdk/channels/ntfy-signing-channel.js.map +0 -1
- package/public/admin/assets/index-CQ3i4P2U.js +0 -3
|
@@ -1,40 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DatabasePolicyEngine - v1.2 DB-backed policy engine with network scoping.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* ALLOWED_NETWORKS (network whitelist, permissive default),
|
|
7
|
-
* ALLOWED_TOKENS (token transfer whitelist, default deny),
|
|
8
|
-
* CONTRACT_WHITELIST (contract call whitelist, default deny),
|
|
9
|
-
* METHOD_WHITELIST (optional method-level restriction for contract calls),
|
|
10
|
-
* APPROVED_SPENDERS (approve spender whitelist, default deny),
|
|
11
|
-
* APPROVE_AMOUNT_LIMIT (unlimited approve block + amount cap),
|
|
12
|
-
* and APPROVE_TIER_OVERRIDE (forced tier for APPROVE transactions).
|
|
13
|
-
*
|
|
14
|
-
* Algorithm:
|
|
15
|
-
* 1. Load enabled policies for wallet (wallet-specific + global), ORDER BY priority DESC
|
|
16
|
-
* 2. If no policies found, return INSTANT passthrough (Phase 7 compat)
|
|
17
|
-
* 3. Resolve overrides: 4-level priority (wallet+network > wallet+null > global+network > global+null)
|
|
18
|
-
* 4. Evaluate WHITELIST: deny if toAddress not in allowed_addresses
|
|
19
|
-
* 4a.5. Evaluate ALLOWED_NETWORKS: deny if network not in allowed list (permissive default)
|
|
20
|
-
* 4b. Evaluate ALLOWED_TOKENS: deny TOKEN_TRANSFER if no policy or token not whitelisted
|
|
21
|
-
* 4c. Evaluate CONTRACT_WHITELIST: deny CONTRACT_CALL if no policy or contract not whitelisted
|
|
22
|
-
* 4d. Evaluate METHOD_WHITELIST: deny CONTRACT_CALL if method selector not whitelisted (optional)
|
|
23
|
-
* 4e. Evaluate APPROVED_SPENDERS: deny APPROVE if no policy or spender not approved
|
|
24
|
-
* 4f. Evaluate APPROVE_AMOUNT_LIMIT: deny APPROVE if unlimited or exceeds max amount
|
|
25
|
-
* 4g. Evaluate APPROVE_TIER_OVERRIDE: force tier for APPROVE (defaults to APPROVAL, skips SPENDING_LIMIT)
|
|
26
|
-
* 4h. Evaluate LENDING_ASSET_WHITELIST: deny lending action if asset not whitelisted (default-deny)
|
|
27
|
-
* 4h-b. Evaluate LENDING_LTV_LIMIT: deny borrow if projected LTV exceeds maxLtv
|
|
28
|
-
* 4i. Evaluate PERP_ALLOWED_MARKETS: deny perp action if market not whitelisted (default-deny)
|
|
29
|
-
* 4i-b. Evaluate PERP_MAX_LEVERAGE: deny open/modify if leverage exceeds max
|
|
30
|
-
* 4i-c. Evaluate PERP_MAX_POSITION_USD: deny open/modify if position USD exceeds max
|
|
31
|
-
* 5. Evaluate SPENDING_LIMIT: classify amount into INSTANT/NOTIFY/DELAY/APPROVAL
|
|
32
|
-
* (skip for non-spending lending actions: supply/repay/withdraw)
|
|
4
|
+
* This file contains the orchestration class that dispatches to evaluator modules
|
|
5
|
+
* in the evaluators/ directory. Each policy type has its own evaluator file.
|
|
33
6
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
7
|
+
* Evaluates transactions against policies stored in the policies table.
|
|
8
|
+
* Supports SPENDING_LIMIT, WHITELIST, ALLOWED_NETWORKS, ALLOWED_TOKENS,
|
|
9
|
+
* CONTRACT_WHITELIST, METHOD_WHITELIST, APPROVED_SPENDERS, APPROVE_AMOUNT_LIMIT,
|
|
10
|
+
* APPROVE_TIER_OVERRIDE, LENDING_ASSET_WHITELIST, LENDING_LTV_LIMIT,
|
|
11
|
+
* PERP_ALLOWED_MARKETS, PERP_MAX_LEVERAGE, PERP_MAX_POSITION_USD,
|
|
12
|
+
* VENUE_WHITELIST, ACTION_CATEGORY_LIMIT, and REPUTATION_THRESHOLD.
|
|
38
13
|
*
|
|
39
14
|
* @see docs/33-time-lock-approval-mechanism.md
|
|
40
15
|
* @see docs/71-policy-engine-network-extension-design.md
|
|
@@ -45,66 +20,8 @@ import type { Database as SQLiteDatabase } from 'better-sqlite3';
|
|
|
45
20
|
import type * as schema from '../infrastructure/database/schema.js';
|
|
46
21
|
import type { SettingsService } from '../infrastructure/settings/settings-service.js';
|
|
47
22
|
import type { ReputationCacheService } from '../services/erc8004/reputation-cache-service.js';
|
|
48
|
-
|
|
49
|
-
export
|
|
50
|
-
maxLeverage: number;
|
|
51
|
-
warningLeverage?: number;
|
|
52
|
-
}
|
|
53
|
-
/** Perp max position USD restriction rules (Phase 297). */
|
|
54
|
-
export interface PerpMaxPositionUsdRules {
|
|
55
|
-
maxPositionUsd: number;
|
|
56
|
-
warningPositionUsd?: number;
|
|
57
|
-
}
|
|
58
|
-
/** Perp allowed markets whitelist rules (Phase 297). */
|
|
59
|
-
export interface PerpAllowedMarketsRules {
|
|
60
|
-
markets: Array<{
|
|
61
|
-
market: string;
|
|
62
|
-
name?: string;
|
|
63
|
-
}>;
|
|
64
|
-
}
|
|
65
|
-
/** Transaction parameter for policy evaluation. */
|
|
66
|
-
interface TransactionParam {
|
|
67
|
-
type: string;
|
|
68
|
-
amount: string;
|
|
69
|
-
toAddress: string;
|
|
70
|
-
chain: string;
|
|
71
|
-
/** Resolved network for ALLOWED_NETWORKS evaluation + network scoping. */
|
|
72
|
-
network?: string;
|
|
73
|
-
/** Token address for ALLOWED_TOKENS evaluation (TOKEN_TRANSFER only). */
|
|
74
|
-
tokenAddress?: string;
|
|
75
|
-
/** CAIP-19 asset identifier for ALLOWED_TOKENS 4-scenario matching (TOKEN_TRANSFER only). */
|
|
76
|
-
assetId?: string;
|
|
77
|
-
/** Contract address for CONTRACT_WHITELIST evaluation (CONTRACT_CALL only). */
|
|
78
|
-
contractAddress?: string;
|
|
79
|
-
/** Function selector (4-byte hex, e.g. '0x12345678') for METHOD_WHITELIST evaluation (CONTRACT_CALL only). */
|
|
80
|
-
selector?: string;
|
|
81
|
-
/** Spender address for APPROVED_SPENDERS evaluation (APPROVE only). */
|
|
82
|
-
spenderAddress?: string;
|
|
83
|
-
/** Approve amount in raw units for APPROVE_AMOUNT_LIMIT evaluation (APPROVE only). */
|
|
84
|
-
approveAmount?: string;
|
|
85
|
-
/** Token decimals for token_limits human-readable conversion (TOKEN_TRANSFER/APPROVE only). */
|
|
86
|
-
tokenDecimals?: number;
|
|
87
|
-
/** Action provider name for provider-trust policy bypass (set by ActionProviderRegistry). */
|
|
88
|
-
actionProvider?: string;
|
|
89
|
-
/** Action name for lending policy evaluation (supply/borrow/repay/withdraw). Set by ActionProviderRegistry. */
|
|
90
|
-
actionName?: string;
|
|
91
|
-
/** Leverage for perp policy evaluation (open_position/modify_position). Set by ActionProviderRegistry. */
|
|
92
|
-
perpLeverage?: number;
|
|
93
|
-
/** Position size in USD for perp policy evaluation. Set by ActionProviderRegistry. */
|
|
94
|
-
perpSizeUsd?: number;
|
|
95
|
-
/** Venue identifier for VENUE_WHITELIST evaluation (signedData/signedHttp only). */
|
|
96
|
-
venue?: string;
|
|
97
|
-
/** Action category for ACTION_CATEGORY_LIMIT evaluation (e.g., 'trade', 'withdraw'). */
|
|
98
|
-
actionCategory?: string;
|
|
99
|
-
/** Notional USD value for ACTION_CATEGORY_LIMIT evaluation. */
|
|
100
|
-
notionalUsd?: number;
|
|
101
|
-
/** Leverage for off-chain action (for policy context). */
|
|
102
|
-
leverage?: number;
|
|
103
|
-
/** Expiry timestamp (ISO string) for off-chain action. */
|
|
104
|
-
expiry?: string;
|
|
105
|
-
/** Whether the off-chain action has withdrawal capability. */
|
|
106
|
-
hasWithdrawCapability?: boolean;
|
|
107
|
-
}
|
|
23
|
+
import type { PolicyRow, TransactionParam, ParseRulesContext } from './evaluators/types.js';
|
|
24
|
+
export type { PolicyRow, TransactionParam, ParseRulesContext };
|
|
108
25
|
/**
|
|
109
26
|
* DB-backed policy engine with SPENDING_LIMIT 4-tier, WHITELIST, ALLOWED_NETWORKS,
|
|
110
27
|
* ALLOWED_TOKENS, CONTRACT_WHITELIST, METHOD_WHITELIST, APPROVED_SPENDERS,
|
|
@@ -112,9 +29,6 @@ interface TransactionParam {
|
|
|
112
29
|
*
|
|
113
30
|
* Network scoping: policies can target specific networks via the `network` column.
|
|
114
31
|
* 4-level override priority: wallet+network > wallet+null > global+network > global+null.
|
|
115
|
-
*
|
|
116
|
-
* Constructor takes a Drizzle DB instance typed with the full schema,
|
|
117
|
-
* and optionally a raw better-sqlite3 Database instance for BEGIN IMMEDIATE transactions.
|
|
118
32
|
*/
|
|
119
33
|
export declare class DatabasePolicyEngine implements IPolicyEngine {
|
|
120
34
|
private readonly db;
|
|
@@ -122,364 +36,30 @@ export declare class DatabasePolicyEngine implements IPolicyEngine {
|
|
|
122
36
|
private readonly settingsService;
|
|
123
37
|
private readonly reputationCacheService;
|
|
124
38
|
constructor(db: BetterSQLite3Database<typeof schema>, sqlite?: SQLiteDatabase, settingsService?: SettingsService, reputationCacheService?: ReputationCacheService);
|
|
39
|
+
/** Evaluator context with parseRules + settingsService access. */
|
|
40
|
+
private get ctx();
|
|
125
41
|
/**
|
|
126
|
-
*
|
|
42
|
+
* Parse policy rules JSON with Zod validation.
|
|
43
|
+
* Throws POLICY_RULES_CORRUPT on invalid JSON or schema mismatch.
|
|
127
44
|
*/
|
|
128
|
-
|
|
45
|
+
private parseRules;
|
|
129
46
|
/**
|
|
130
|
-
* Evaluate a
|
|
131
|
-
*
|
|
132
|
-
* Phase A: Evaluate each instruction individually against its applicable policies.
|
|
133
|
-
* All-or-Nothing: if any instruction is denied, entire batch is denied.
|
|
134
|
-
*
|
|
135
|
-
* Phase B: Sum native amounts (TRANSFER.amount) and evaluate
|
|
136
|
-
* aggregate against SPENDING_LIMIT. If batch contains APPROVE, apply
|
|
137
|
-
* APPROVE_TIER_OVERRIDE and take max(amount tier, approve tier).
|
|
138
|
-
*
|
|
139
|
-
* @param walletId - Wallet whose policies to evaluate
|
|
140
|
-
* @param instructions - Array of instruction parameters (same shape as TransactionParam)
|
|
141
|
-
* @returns PolicyEvaluation with final tier or denial with violation details
|
|
47
|
+
* Evaluate a transaction against DB-stored policies.
|
|
142
48
|
*/
|
|
49
|
+
evaluate(walletId: string, transaction: TransactionParam): Promise<PolicyEvaluation>;
|
|
143
50
|
evaluateBatch(walletId: string, instructions: TransactionParam[], batchUsdAmount?: number): Promise<PolicyEvaluation>;
|
|
144
|
-
/**
|
|
145
|
-
* Evaluate applicable policies for a single instruction in a batch.
|
|
146
|
-
*
|
|
147
|
-
* Only evaluates type-specific policies:
|
|
148
|
-
* - TRANSFER: WHITELIST
|
|
149
|
-
* - TOKEN_TRANSFER: WHITELIST + ALLOWED_TOKENS
|
|
150
|
-
* - CONTRACT_CALL: CONTRACT_WHITELIST + METHOD_WHITELIST
|
|
151
|
-
* - APPROVE: APPROVED_SPENDERS + APPROVE_AMOUNT_LIMIT
|
|
152
|
-
*
|
|
153
|
-
* Does NOT evaluate SPENDING_LIMIT (that's Phase B aggregate) or
|
|
154
|
-
* APPROVE_TIER_OVERRIDE (that's Phase B).
|
|
155
|
-
*
|
|
156
|
-
* Returns null if all policies pass, PolicyEvaluation with allowed=false if denied.
|
|
157
|
-
*/
|
|
158
51
|
private evaluateInstructionPolicies;
|
|
159
|
-
/**
|
|
160
|
-
* Evaluate transaction and reserve amount atomically using BEGIN IMMEDIATE.
|
|
161
|
-
*
|
|
162
|
-
* This method:
|
|
163
|
-
* 1. Begins an IMMEDIATE transaction (exclusive write lock)
|
|
164
|
-
* 2. Loads policies (same as evaluate)
|
|
165
|
-
* 3. For SPENDING_LIMIT: computes current reserved total from PENDING/QUEUED txs
|
|
166
|
-
* 4. Adds current request amount to reserved total
|
|
167
|
-
* 5. Evaluates against limits with reserved total considered
|
|
168
|
-
* 6. If allowed: sets reserved_amount on the transaction row
|
|
169
|
-
* 7. Commits
|
|
170
|
-
*
|
|
171
|
-
* @param walletId - The wallet whose policies to evaluate
|
|
172
|
-
* @param transaction - Transaction details for evaluation
|
|
173
|
-
* @param txId - The transaction ID to update with reserved_amount
|
|
174
|
-
* @returns PolicyEvaluation result
|
|
175
|
-
* @throws Error if sqlite instance not provided in constructor
|
|
176
|
-
*/
|
|
177
52
|
evaluateAndReserve(walletId: string, transaction: TransactionParam, txId: string, usdAmount?: number, reputationFloorTier?: PolicyTier): PolicyEvaluation;
|
|
178
|
-
/**
|
|
179
|
-
* Release a reserved amount on a transaction.
|
|
180
|
-
* Called when transaction reaches FAILED/CANCELLED/EXPIRED state.
|
|
181
|
-
*
|
|
182
|
-
* @param txId - The transaction ID to clear reservation for
|
|
183
|
-
*/
|
|
184
53
|
releaseReservation(txId: string): void;
|
|
185
|
-
/**
|
|
186
|
-
* Get cumulative USD spent by wallet within a time window.
|
|
187
|
-
* Includes both confirmed amounts (amount_usd) and pending reservations (reserved_amount_usd).
|
|
188
|
-
*
|
|
189
|
-
* CONFIRMED/SIGNED: counted via amount_usd (confirmed or about to be broadcasted).
|
|
190
|
-
* PENDING/QUEUED: counted via reserved_amount_usd (awaiting processing, not yet confirmed).
|
|
191
|
-
* Deduplication: SIGNED is in the first query only (amount_usd). PENDING/QUEUED in second only.
|
|
192
|
-
*/
|
|
193
54
|
private getCumulativeUsdSpent;
|
|
194
|
-
/**
|
|
195
|
-
* Resolve policy overrides with 4-level priority:
|
|
196
|
-
* 1. wallet-specific + network-specific (highest)
|
|
197
|
-
* 2. wallet-specific + all-networks
|
|
198
|
-
* 3. global + network-specific
|
|
199
|
-
* 4. global + all-networks (lowest)
|
|
200
|
-
*
|
|
201
|
-
* For each policy type, one policy is selected.
|
|
202
|
-
* Lower priority entries are inserted first, higher priority entries overwrite.
|
|
203
|
-
* Key: typeMap[row.type] (same as current -- no composite key needed, PLCY-D03).
|
|
204
|
-
*
|
|
205
|
-
* Backward compat: when all policies have network=NULL,
|
|
206
|
-
* phases 2+4 collapse into current 2-level (wallet > global) behavior.
|
|
207
|
-
*/
|
|
208
55
|
private resolveOverrides;
|
|
209
|
-
/**
|
|
210
|
-
* Evaluate ALLOWED_NETWORKS policy.
|
|
211
|
-
*
|
|
212
|
-
* Logic:
|
|
213
|
-
* - Applies to ALL 5 transaction types (TRANSFER, TOKEN_TRANSFER, CONTRACT_CALL, APPROVE, BATCH)
|
|
214
|
-
* - If no ALLOWED_NETWORKS policy exists: return null (permissive default -- all networks allowed)
|
|
215
|
-
* - If policy exists: check if resolvedNetwork is in rules.networks[].network
|
|
216
|
-
* -> If found: return null (continue to next evaluation)
|
|
217
|
-
* -> If not found: deny with reason 'Network not in allowed list'
|
|
218
|
-
* - Comparison: case-insensitive (toLowerCase)
|
|
219
|
-
* - Tier: INSTANT (immediate denial)
|
|
220
|
-
*
|
|
221
|
-
* Returns PolicyEvaluation if denied, null if allowed (or no policy).
|
|
222
|
-
*/
|
|
223
|
-
private evaluateAllowedNetworks;
|
|
224
|
-
/**
|
|
225
|
-
* Evaluate WHITELIST policy.
|
|
226
|
-
* Returns PolicyEvaluation if denied, null if allowed (or no whitelist).
|
|
227
|
-
*/
|
|
228
|
-
private evaluateWhitelist;
|
|
229
|
-
/**
|
|
230
|
-
* Evaluate ALLOWED_TOKENS policy with 4-scenario matching matrix (PLCY-03).
|
|
231
|
-
*
|
|
232
|
-
* Logic:
|
|
233
|
-
* - Only applies to TOKEN_TRANSFER transaction type
|
|
234
|
-
* - If transaction type is TOKEN_TRANSFER and no ALLOWED_TOKENS policy exists:
|
|
235
|
-
* -> deny with reason 'Token transfer not allowed: no ALLOWED_TOKENS policy configured'
|
|
236
|
-
* - If ALLOWED_TOKENS policy exists, match using 4-scenario matrix:
|
|
237
|
-
* Scenario 1: Policy assetId + TX assetId -> exact CAIP-19 string match
|
|
238
|
-
* Scenario 2: Policy assetId + TX address only -> extract address from policy assetId, compare lowercase
|
|
239
|
-
* Scenario 3: Policy address only + TX assetId -> extract address from TX assetId, compare lowercase
|
|
240
|
-
* Scenario 4: Policy address only + TX address only -> current behavior (case-insensitive)
|
|
241
|
-
* - EVM addresses normalized to lowercase for comparison (PLCY-04)
|
|
242
|
-
*
|
|
243
|
-
* Returns PolicyEvaluation if denied, null if allowed (or not applicable).
|
|
244
|
-
*/
|
|
245
|
-
private evaluateAllowedTokens;
|
|
246
|
-
/**
|
|
247
|
-
* Evaluate CONTRACT_WHITELIST policy.
|
|
248
|
-
*
|
|
249
|
-
* Logic:
|
|
250
|
-
* - Only applies to CONTRACT_CALL transaction type
|
|
251
|
-
* - Provider-trust: if transaction has actionProvider and the provider is enabled
|
|
252
|
-
* in SettingsService, skip CONTRACT_WHITELIST entirely (trusted provider bypass)
|
|
253
|
-
* - If transaction type is CONTRACT_CALL and no CONTRACT_WHITELIST policy exists:
|
|
254
|
-
* -> deny with reason 'Contract calls disabled: no CONTRACT_WHITELIST policy configured'
|
|
255
|
-
* - If CONTRACT_WHITELIST policy exists, check if contract address is in rules.contracts[].address:
|
|
256
|
-
* -> If found: return null (continue to next evaluation)
|
|
257
|
-
* -> If not found: deny with reason 'Contract not whitelisted: {address}'
|
|
258
|
-
* - For non-CONTRACT_CALL types: return null (not applicable)
|
|
259
|
-
*
|
|
260
|
-
* Returns PolicyEvaluation if denied, null if allowed (or not applicable).
|
|
261
|
-
*/
|
|
262
|
-
private evaluateContractWhitelist;
|
|
263
|
-
/**
|
|
264
|
-
* Evaluate METHOD_WHITELIST policy.
|
|
265
|
-
*
|
|
266
|
-
* Logic:
|
|
267
|
-
* - Only applies to CONTRACT_CALL transaction type
|
|
268
|
-
* - If no METHOD_WHITELIST policy exists: return null (method restriction is optional)
|
|
269
|
-
* - If METHOD_WHITELIST policy exists, find matching entry for transaction's contract address:
|
|
270
|
-
* -> If no entry for this contract: return null (no method restriction for this contract)
|
|
271
|
-
* -> If entry found, check if transaction's selector is in entry.selectors:
|
|
272
|
-
* -> If found: return null (method allowed)
|
|
273
|
-
* -> If not found: deny with reason 'Method not whitelisted: {selector} on contract {address}'
|
|
274
|
-
*
|
|
275
|
-
* Returns PolicyEvaluation if denied, null if allowed (or not applicable).
|
|
276
|
-
*/
|
|
277
|
-
private evaluateMethodWhitelist;
|
|
278
|
-
/**
|
|
279
|
-
* Evaluate APPROVED_SPENDERS policy.
|
|
280
|
-
*
|
|
281
|
-
* Logic:
|
|
282
|
-
* - Only applies to APPROVE transaction type
|
|
283
|
-
* - If transaction type is APPROVE and no APPROVED_SPENDERS policy exists:
|
|
284
|
-
* -> deny with reason 'Token approvals disabled: no APPROVED_SPENDERS policy configured'
|
|
285
|
-
* - If APPROVED_SPENDERS policy exists, check if transaction's spenderAddress is in rules.spenders[]:
|
|
286
|
-
* -> If found: return null (continue evaluation)
|
|
287
|
-
* -> If not found: deny with reason 'Spender not in approved list: {address}'
|
|
288
|
-
* - Case-insensitive comparison (EVM addresses)
|
|
289
|
-
*
|
|
290
|
-
* Returns PolicyEvaluation if denied, null if allowed (or not applicable).
|
|
291
|
-
*/
|
|
292
|
-
private evaluateApprovedSpenders;
|
|
293
|
-
/**
|
|
294
|
-
* Evaluate APPROVE_AMOUNT_LIMIT policy.
|
|
295
|
-
*
|
|
296
|
-
* Logic:
|
|
297
|
-
* - Only applies to APPROVE transaction type
|
|
298
|
-
* - Checks for unlimited approve amounts (>= UNLIMITED_THRESHOLD)
|
|
299
|
-
* - Checks for amount cap (maxAmount)
|
|
300
|
-
* - If no policy exists: default block_unlimited=true (block unlimited approvals)
|
|
301
|
-
*
|
|
302
|
-
* Returns PolicyEvaluation if denied, null if allowed (or not applicable).
|
|
303
|
-
*/
|
|
304
|
-
private evaluateApproveAmountLimit;
|
|
305
|
-
/**
|
|
306
|
-
* Evaluate APPROVE_TIER_OVERRIDE policy.
|
|
307
|
-
*
|
|
308
|
-
* Logic:
|
|
309
|
-
* - Only applies to APPROVE transaction type
|
|
310
|
-
* - If APPROVE_TIER_OVERRIDE policy exists: return configured tier (FINAL, skips SPENDING_LIMIT)
|
|
311
|
-
* - If no APPROVE_TIER_OVERRIDE policy exists: return null (Phase 236: fall through to SPENDING_LIMIT
|
|
312
|
-
* for token_limits evaluation; if no SPENDING_LIMIT either, INSTANT passthrough)
|
|
313
|
-
*
|
|
314
|
-
* Phase 236 change: Previously defaulted to APPROVAL when no override policy existed.
|
|
315
|
-
* Now falls through to SPENDING_LIMIT to allow token_limits evaluation for APPROVE transactions.
|
|
316
|
-
*
|
|
317
|
-
* Returns PolicyEvaluation if override policy exists, null otherwise.
|
|
318
|
-
*/
|
|
319
|
-
private evaluateApproveTierOverride;
|
|
320
|
-
/**
|
|
321
|
-
* Evaluate SPENDING_LIMIT policy.
|
|
322
|
-
* Returns PolicyEvaluation with tier classification, or null if no spending limit.
|
|
323
|
-
*
|
|
324
|
-
* Phase 127: usdAmount가 전달되고 rules에 USD 임계값이 설정되어 있으면,
|
|
325
|
-
* 네이티브 티어와 USD 티어 중 더 보수적인(높은) 티어를 채택한다.
|
|
326
|
-
*
|
|
327
|
-
* Phase 236: tokenContext가 전달되고 rules에 token_limits가 설정되어 있으면,
|
|
328
|
-
* evaluateTokenTier()를 사용하여 토큰별 human-readable 한도를 평가한다.
|
|
329
|
-
*/
|
|
330
|
-
private evaluateSpendingLimit;
|
|
331
|
-
/**
|
|
332
|
-
* Evaluate token-specific tier using token_limits with CAIP-19 key matching.
|
|
333
|
-
* Returns PolicyTier if a matching token limit is found, null otherwise (-> raw fallback).
|
|
334
|
-
*
|
|
335
|
-
* Matching priority:
|
|
336
|
-
* 1. Exact CAIP-19 asset ID match (TOKEN_TRANSFER, APPROVE)
|
|
337
|
-
* 2. "native:{chain}" match (TRANSFER)
|
|
338
|
-
* 3. "native" shorthand match (TRANSFER, only when policy has network set)
|
|
339
|
-
* 4. No match -> return null (caller falls back to raw fields)
|
|
340
|
-
*/
|
|
341
|
-
private evaluateTokenTier;
|
|
342
|
-
/**
|
|
343
|
-
* Evaluate native amount tier (extracted from evaluateSpendingLimit).
|
|
344
|
-
* Phase 236: proper undefined guards for optional raw fields.
|
|
345
|
-
*/
|
|
346
|
-
private evaluateNativeTier;
|
|
347
|
-
/**
|
|
348
|
-
* Check if rules have any USD thresholds configured.
|
|
349
|
-
*/
|
|
350
|
-
private hasUsdThresholds;
|
|
351
|
-
/**
|
|
352
|
-
* Evaluate USD amount tier.
|
|
353
|
-
*/
|
|
354
|
-
private evaluateUsdTier;
|
|
355
|
-
/**
|
|
356
|
-
* Build tokenContext from TransactionParam for evaluateTokenTier().
|
|
357
|
-
* Phase 236: Extracts relevant fields and attaches the policy's network.
|
|
358
|
-
*/
|
|
359
|
-
private buildTokenContext;
|
|
360
|
-
/**
|
|
361
|
-
* Evaluate LENDING_ASSET_WHITELIST policy.
|
|
362
|
-
*
|
|
363
|
-
* Logic:
|
|
364
|
-
* - Only applies to lending actions (supply/borrow/repay/withdraw)
|
|
365
|
-
* - If no LENDING_ASSET_WHITELIST policy exists: deny (default-deny per CLAUDE.md)
|
|
366
|
-
* - If policy exists: check if target contract address is in rules.assets[].address
|
|
367
|
-
*
|
|
368
|
-
* Returns PolicyEvaluation if denied, null if allowed (or not applicable).
|
|
369
|
-
*/
|
|
370
|
-
private evaluateLendingAssetWhitelist;
|
|
371
|
-
/**
|
|
372
|
-
* Evaluate LENDING_LTV_LIMIT policy for borrow actions.
|
|
373
|
-
*
|
|
374
|
-
* Logic:
|
|
375
|
-
* - Only applies to borrow actions
|
|
376
|
-
* - Reads cached LENDING positions from defi_positions table
|
|
377
|
-
* - Calculates projected LTV = (currentDebtUsd + newBorrowUsd) / totalCollateralUsd
|
|
378
|
-
* - Denies if projected LTV > maxLtv
|
|
379
|
-
* - Returns DELAY tier if projected LTV > warningLtv
|
|
380
|
-
*
|
|
381
|
-
* @param usdAmount - USD value of the new borrow (from pipeline IPriceOracle, LEND-09)
|
|
382
|
-
* Returns PolicyEvaluation if denied/escalated, null if allowed (or not applicable).
|
|
383
|
-
*/
|
|
384
|
-
private evaluateLendingLtvLimit;
|
|
385
|
-
/**
|
|
386
|
-
* Evaluate PERP_ALLOWED_MARKETS policy.
|
|
387
|
-
*
|
|
388
|
-
* Logic:
|
|
389
|
-
* - Only applies to perp actions (suffix matching: open_position, close_position,
|
|
390
|
-
* modify_position, add_margin, withdraw_margin)
|
|
391
|
-
* - If no PERP_ALLOWED_MARKETS policy exists: deny (default-deny per CLAUDE.md)
|
|
392
|
-
* - If policy exists: check if transaction's market (from actionName prefix or params)
|
|
393
|
-
* is in rules.markets[].market (case-insensitive)
|
|
394
|
-
*
|
|
395
|
-
* Market identification: TransactionParam.contractAddress is used as the market
|
|
396
|
-
* identifier for perp actions (the protocol program/contract address).
|
|
397
|
-
*/
|
|
398
|
-
private evaluatePerpAllowedMarkets;
|
|
399
|
-
/**
|
|
400
|
-
* Evaluate PERP_MAX_LEVERAGE policy.
|
|
401
|
-
*
|
|
402
|
-
* Logic:
|
|
403
|
-
* - Only applies to open_position and modify_position (suffix matching)
|
|
404
|
-
* - Reads perpLeverage from TransactionParam
|
|
405
|
-
* - Denies if perpLeverage > rules.maxLeverage
|
|
406
|
-
* - Returns DELAY tier if perpLeverage > rules.warningLeverage (optional)
|
|
407
|
-
*/
|
|
408
|
-
private evaluatePerpMaxLeverage;
|
|
409
|
-
/**
|
|
410
|
-
* Evaluate PERP_MAX_POSITION_USD policy.
|
|
411
|
-
*
|
|
412
|
-
* Logic:
|
|
413
|
-
* - Only applies to open_position and modify_position (suffix matching)
|
|
414
|
-
* - Reads perpSizeUsd from TransactionParam
|
|
415
|
-
* - Denies if perpSizeUsd > rules.maxPositionUsd
|
|
416
|
-
* - Returns DELAY tier if perpSizeUsd > rules.warningPositionUsd (optional)
|
|
417
|
-
*/
|
|
418
|
-
private evaluatePerpMaxPositionUsd;
|
|
419
|
-
/**
|
|
420
|
-
* Evaluate REPUTATION_THRESHOLD policy.
|
|
421
|
-
*
|
|
422
|
-
* Logic:
|
|
423
|
-
* - Find REPUTATION_THRESHOLD policy in resolved list
|
|
424
|
-
* - If not found or check_counterparty=false, return null (skip)
|
|
425
|
-
* - Resolve counterparty agentId from toAddress via agent_identities table
|
|
426
|
-
* - If no agentId found, treat as unrated
|
|
427
|
-
* - If no reputationCacheService, treat as unrated
|
|
428
|
-
* - Lookup reputation score via cache
|
|
429
|
-
* - If null (unrated/RPC failure), return unrated_tier
|
|
430
|
-
* - If score < min_score, return below_threshold_tier
|
|
431
|
-
* - If score >= min_score, return null (pass, continue evaluation)
|
|
432
|
-
*
|
|
433
|
-
* Returns the reputation floor tier (PolicyTier) or null if no escalation needed.
|
|
434
|
-
* The caller applies maxTier to the final result.
|
|
435
|
-
*/
|
|
436
56
|
private evaluateReputationThreshold;
|
|
437
|
-
/**
|
|
438
|
-
* Resolve ERC-8004 agentId from a counterparty address.
|
|
439
|
-
*
|
|
440
|
-
* Looks up agent_identities table via wallet publicKey join to find
|
|
441
|
-
* the chain_agent_id for the counterparty. Case-insensitive for EVM addresses.
|
|
442
|
-
*
|
|
443
|
-
* @returns chain_agent_id string if found, null otherwise
|
|
444
|
-
*/
|
|
445
57
|
private resolveAgentIdFromAddress;
|
|
446
|
-
/**
|
|
447
|
-
* Pre-fetch reputation floor tier for use in evaluateAndReserve (synchronous context).
|
|
448
|
-
*
|
|
449
|
-
* Called from stage3Policy before entering the IMMEDIATE transaction, since
|
|
450
|
-
* evaluateReputationThreshold is async (RPC call) but evaluateAndReserve is sync.
|
|
451
|
-
*
|
|
452
|
-
* @returns Object with tier and notification context if escalation needed, undefined otherwise
|
|
453
|
-
*/
|
|
454
58
|
prefetchReputationTier(walletId: string, transaction: TransactionParam, reputationCache: ReputationCacheService): Promise<{
|
|
455
59
|
tier: PolicyTier;
|
|
456
60
|
score?: string;
|
|
457
61
|
threshold?: string;
|
|
458
62
|
} | undefined>;
|
|
459
|
-
|
|
460
|
-
* Evaluate VENUE_WHITELIST policy (default-deny when enabled).
|
|
461
|
-
*
|
|
462
|
-
* Logic:
|
|
463
|
-
* - If transaction has no venue (contractCall) -> return null (skip)
|
|
464
|
-
* - If venue_whitelist_enabled setting is not 'true' -> return null (disabled)
|
|
465
|
-
* - Find VENUE_WHITELIST policy in resolved list
|
|
466
|
-
* - If no policy found + venue present -> DENY (default-deny)
|
|
467
|
-
* - If policy found + venue in whitelist -> return null (allowed)
|
|
468
|
-
* - If policy found + venue not in whitelist -> DENY
|
|
469
|
-
*/
|
|
470
|
-
private evaluateVenueWhitelist;
|
|
471
|
-
/**
|
|
472
|
-
* Evaluate ACTION_CATEGORY_LIMIT policy (per-action, daily, monthly USD limits).
|
|
473
|
-
*
|
|
474
|
-
* Logic:
|
|
475
|
-
* - If transaction has no actionCategory or notionalUsd -> return null (skip)
|
|
476
|
-
* - Find ACTION_CATEGORY_LIMIT policies matching transaction.actionCategory
|
|
477
|
-
* - Check per_action_limit_usd: deny if notionalUsd exceeds
|
|
478
|
-
* - Check daily_limit_usd: query cumulative notionalUsd for category today
|
|
479
|
-
* - Check monthly_limit_usd: query cumulative notionalUsd for category this month
|
|
480
|
-
* - On exceed: return tier_on_exceed (default 'DELAY')
|
|
481
|
-
*/
|
|
482
|
-
private evaluateActionCategoryLimit;
|
|
63
|
+
private buildTokenContext;
|
|
483
64
|
}
|
|
484
|
-
export {};
|
|
485
65
|
//# sourceMappingURL=database-policy-engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-policy-engine.d.ts","sourceRoot":"","sources":["../../src/pipeline/database-policy-engine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"database-policy-engine.d.ts","sourceRoot":"","sources":["../../src/pipeline/database-policy-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAShF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,KAAK,KAAK,MAAM,MAAM,sCAAsC,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AAU9F,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAmB,MAAM,uBAAuB,CAAC;AAG7G,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC;AAM/D;;;;;;;GAOG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IAMtD,OAAO,CAAC,QAAQ,CAAC,EAAE;IALrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAgC;gBAGpD,EAAE,EAAE,qBAAqB,CAAC,OAAO,MAAM,CAAC,EACzD,MAAM,CAAC,EAAE,cAAc,EACvB,eAAe,CAAC,EAAE,eAAe,EACjC,sBAAsB,CAAC,EAAE,sBAAsB;IAOjD,kEAAkE;IAClE,OAAO,KAAK,GAAG,GAKd;IAED;;;OAGG;IACH,OAAO,CAAC,UAAU;IAQlB;;OAEG;IACG,QAAQ,CACZ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,gBAAgB,GAC5B,OAAO,CAAC,gBAAgB,CAAC;IAoJtB,aAAa,CACjB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,gBAAgB,EAAE,EAChC,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,gBAAgB,CAAC;IA4F5B,OAAO,CAAC,2BAA2B;IAuDnC,kBAAkB,CAChB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,gBAAgB,EAC7B,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,EAClB,mBAAmB,CAAC,EAAE,UAAU,GAC/B,gBAAgB;IAyNnB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IActC,OAAO,CAAC,qBAAqB;IA0B7B,OAAO,CAAC,gBAAgB;YA8CV,2BAA2B;IAsCzC,OAAO,CAAC,yBAAyB;IAwB3B,sBAAsB,CAC1B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,gBAAgB,EAC7B,eAAe,EAAE,sBAAsB,GACtC,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAwDhF,OAAO,CAAC,iBAAiB;CAoB1B"}
|