@oracle-agent/oracle 0.10.0 → 0.12.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/LICENSE +115 -201
- package/README.md +82 -91
- package/SECURITY.md +37 -12
- package/SETUP.md +207 -272
- package/dist/action-receipts.mjs +1 -0
- package/dist/action-semantics.mjs +1 -0
- package/dist/address-book.mjs +2 -0
- package/dist/bin/desk-server.mjs +14 -0
- package/dist/bin/oracle-data-mcp.mjs +8 -0
- package/dist/bin/oracle-init.mjs +24 -0
- package/dist/bin/oracle-public-server.mjs +5 -0
- package/dist/bin/oracle-route.mjs +22 -0
- package/dist/bin/oracle-scan.mjs +18 -0
- package/dist/bin/oracle-upgrade.mjs +21 -0
- package/dist/bin/oracle.mjs +68 -0
- package/dist/chains.mjs +1 -0
- package/dist/cli/commands/auth.mjs +16 -0
- package/dist/cli/commands/bootstrap.mjs +18 -0
- package/dist/cli/commands/chain.mjs +21 -0
- package/dist/cli/commands/chat.mjs +35 -0
- package/dist/cli/commands/credential.mjs +1 -0
- package/dist/cli/commands/data-mcp.mjs +2 -0
- package/dist/cli/commands/data.mjs +12 -0
- package/dist/cli/commands/doctor.mjs +5 -0
- package/dist/cli/commands/gate.mjs +13 -0
- package/dist/cli/commands/help.mjs +1 -0
- package/dist/cli/commands/init.mjs +3 -0
- package/dist/cli/commands/mcp.mjs +33 -0
- package/dist/cli/commands/model.mjs +44 -0
- package/dist/cli/commands/prepare.mjs +2 -0
- package/dist/cli/commands/public.mjs +3 -0
- package/dist/cli/commands/route.mjs +2 -0
- package/dist/cli/commands/runner.mjs +1 -0
- package/dist/cli/commands/scan.mjs +2 -0
- package/dist/cli/commands/setup.mjs +34 -0
- package/dist/cli/commands/sign.mjs +4 -0
- package/dist/cli/commands/signer.mjs +1 -0
- package/dist/cli/commands/upgrade.mjs +2 -0
- package/dist/cli/commands/vault.mjs +1 -0
- package/dist/cli/commands/version.mjs +2 -0
- package/dist/data/desk-data.mjs +12 -0
- package/dist/index.mjs +17 -0
- package/dist/nft-gas-war-guard.mjs +1 -0
- package/dist/onboarding/harness-configs.mjs +4 -0
- package/dist/portfolio-risk.mjs +1 -0
- package/dist/prepare-envelope.mjs +1 -0
- package/dist/public-control/policy-schema.mjs +1 -0
- package/dist/router/index.mjs +2 -0
- package/dist/scanner/index.mjs +4 -0
- package/dist/signals/index.mjs +1 -0
- package/dist/watch-preferences.mjs +1 -0
- package/package.json +27 -65
- package/public/oracle-splash/assets/cli-chain-hyperliquid.jpg +0 -0
- package/public/oracle-splash/brand/aave.webp +0 -0
- package/public/oracle-splash/brand/aavev2.webp +0 -0
- package/public/oracle-splash/brand/aborean.webp +0 -0
- package/public/oracle-splash/brand/across.webp +0 -0
- package/public/oracle-splash/brand/aerodrome.webp +0 -0
- package/public/oracle-splash/brand/afi.webp +0 -0
- package/public/oracle-splash/brand/arcus.webp +0 -0
- package/public/oracle-splash/brand/aster.webp +0 -0
- package/public/oracle-splash/brand/avant.webp +0 -0
- package/public/oracle-splash/brand/balancer.webp +0 -0
- package/public/oracle-splash/brand/beefy.webp +0 -0
- package/public/oracle-splash/brand/benqi.webp +0 -0
- package/public/oracle-splash/brand/bestinslot.ico +0 -0
- package/public/oracle-splash/brand/bitfi.webp +0 -0
- package/public/oracle-splash/brand/bonkswap.webp +0 -0
- package/public/oracle-splash/brand/bouncebit.webp +0 -0
- package/public/oracle-splash/brand/camelot.webp +0 -0
- package/public/oracle-splash/brand/compound.webp +0 -0
- package/public/oracle-splash/brand/concrete.webp +0 -0
- package/public/oracle-splash/brand/cow.webp +0 -0
- package/public/oracle-splash/brand/curve.webp +0 -0
- package/public/oracle-splash/brand/derive.webp +0 -0
- package/public/oracle-splash/brand/dolomite.webp +0 -0
- package/public/oracle-splash/brand/eigenlayer.webp +0 -0
- package/public/oracle-splash/brand/ekubo.webp +0 -0
- package/public/oracle-splash/brand/ethena.webp +0 -0
- package/public/oracle-splash/brand/etherfi.webp +0 -0
- package/public/oracle-splash/brand/etherfiborrow.webp +0 -0
- package/public/oracle-splash/brand/felix.webp +0 -0
- package/public/oracle-splash/brand/fluid.webp +0 -0
- package/public/oracle-splash/brand/fluxbeam.webp +0 -0
- package/public/oracle-splash/brand/folks.webp +0 -0
- package/public/oracle-splash/brand/fortyacres.webp +0 -0
- package/public/oracle-splash/brand/gainsnetwork.webp +0 -0
- package/public/oracle-splash/brand/gassss.webp +0 -0
- package/public/oracle-splash/brand/gmx.webp +0 -0
- package/public/oracle-splash/brand/harmonix.webp +0 -0
- package/public/oracle-splash/brand/hlorderbook.webp +0 -0
- package/public/oracle-splash/brand/hlp.webp +0 -0
- package/public/oracle-splash/brand/hop.webp +0 -0
- package/public/oracle-splash/brand/hyperbeat.webp +0 -0
- package/public/oracle-splash/brand/hyperlend.webp +0 -0
- package/public/oracle-splash/brand/hyperliquid.webp +0 -0
- package/public/oracle-splash/brand/hyperliquidhpl.webp +0 -0
- package/public/oracle-splash/brand/hyperliquidspot.webp +0 -0
- package/public/oracle-splash/brand/hyperswap.webp +0 -0
- package/public/oracle-splash/brand/hypha.webp +0 -0
- package/public/oracle-splash/brand/joedex.webp +0 -0
- package/public/oracle-splash/brand/jupiter.webp +0 -0
- package/public/oracle-splash/brand/kelp.webp +0 -0
- package/public/oracle-splash/brand/kinetiq.webp +0 -0
- package/public/oracle-splash/brand/kmhype.webp +0 -0
- package/public/oracle-splash/brand/kona.webp +0 -0
- package/public/oracle-splash/brand/konalend.webp +0 -0
- package/public/oracle-splash/brand/lfj.webp +0 -0
- package/public/oracle-splash/brand/lido.webp +0 -0
- package/public/oracle-splash/brand/lifi.webp +0 -0
- package/public/oracle-splash/brand/lighter.webp +0 -0
- package/public/oracle-splash/brand/lista.webp +0 -0
- package/public/oracle-splash/brand/loopedhype.webp +0 -0
- package/public/oracle-splash/brand/lorenzo.webp +0 -0
- package/public/oracle-splash/brand/magic-eden.webp +0 -0
- package/public/oracle-splash/brand/magiceden.webp +0 -0
- package/public/oracle-splash/brand/mempool.png +0 -0
- package/public/oracle-splash/brand/meteora.webp +0 -0
- package/public/oracle-splash/brand/morpho.webp +0 -0
- package/public/oracle-splash/brand/myriad.webp +0 -0
- package/public/oracle-splash/brand/noxa.webp +0 -0
- package/public/oracle-splash/brand/odos.webp +0 -0
- package/public/oracle-splash/brand/oneinch.webp +0 -0
- package/public/oracle-splash/brand/openbook.webp +0 -0
- package/public/oracle-splash/brand/opensea.webp +0 -0
- package/public/oracle-splash/brand/orca.webp +0 -0
- package/public/oracle-splash/brand/ordinals.png +0 -0
- package/public/oracle-splash/brand/ostium.webp +0 -0
- package/public/oracle-splash/brand/pancakeswap.webp +0 -0
- package/public/oracle-splash/brand/pendle.webp +0 -0
- package/public/oracle-splash/brand/perena.webp +0 -0
- package/public/oracle-splash/brand/pharaoh.webp +0 -0
- package/public/oracle-splash/brand/phoenix.webp +0 -0
- package/public/oracle-splash/brand/polymarket.webp +0 -0
- package/public/oracle-splash/brand/polynomial.webp +0 -0
- package/public/oracle-splash/brand/projectx.webp +0 -0
- package/public/oracle-splash/brand/pumpfun.webp +0 -0
- package/public/oracle-splash/brand/quickswap.webp +0 -0
- package/public/oracle-splash/brand/rain.webp +0 -0
- package/public/oracle-splash/brand/raydium.webp +0 -0
- package/public/oracle-splash/brand/relay.webp +0 -0
- package/public/oracle-splash/brand/rocketpool.webp +0 -0
- package/public/oracle-splash/brand/saber.webp +0 -0
- package/public/oracle-splash/brand/sakuraswap.webp +0 -0
- package/public/oracle-splash/brand/sanctum.webp +0 -0
- package/public/oracle-splash/brand/satflow.png +0 -0
- package/public/oracle-splash/brand/sierra.webp +0 -0
- package/public/oracle-splash/brand/sky.webp +0 -0
- package/public/oracle-splash/brand/solv.webp +0 -0
- package/public/oracle-splash/brand/spark.webp +0 -0
- package/public/oracle-splash/brand/sparksavings.webp +0 -0
- package/public/oracle-splash/brand/sphere.webp +0 -0
- package/public/oracle-splash/brand/ssv.webp +0 -0
- package/public/oracle-splash/brand/stabble.webp +0 -0
- package/public/oracle-splash/brand/stableswap.webp +0 -0
- package/public/oracle-splash/brand/stakewise.webp +0 -0
- package/public/oracle-splash/brand/stargate.webp +0 -0
- package/public/oracle-splash/brand/sthype.webp +0 -0
- package/public/oracle-splash/brand/sushiswap.webp +0 -0
- package/public/oracle-splash/brand/unisat.png +0 -0
- package/public/oracle-splash/brand/uniswap.webp +0 -0
- package/public/oracle-splash/brand/uniswapv2.webp +0 -0
- package/public/oracle-splash/brand/uniswapv4.webp +0 -0
- package/public/oracle-splash/brand/unit.webp +0 -0
- package/public/oracle-splash/brand/velodrome.webp +0 -0
- package/public/oracle-splash/brand/velora.webp +0 -0
- package/public/oracle-splash/brand/venus.webp +0 -0
- package/public/oracle-splash/brand/wbeth.webp +0 -0
- package/public/oracle-splash/brand/xsy.webp +0 -0
- package/public/oracle-splash/brand/yieldyak.webp +0 -0
- package/public/oracle-splash/brand/zerobase.webp +0 -0
- package/public/oracle-splash/brand/zerox.webp +0 -0
- package/public/oracle-splash/index.html +246 -169
- package/CONTRIBUTING.md +0 -98
- package/bin/desk-server.mjs +0 -440
- package/bin/oracle-data-mcp.mjs +0 -1010
- package/bin/oracle-init.mjs +0 -496
- package/bin/oracle-public-server.mjs +0 -36
- package/bin/oracle-route.mjs +0 -254
- package/bin/oracle-scan.mjs +0 -192
- package/bin/oracle-upgrade.mjs +0 -42
- package/bin/oracle.mjs +0 -33
- package/docs/adding-a-chain.md +0 -229
- package/docs/architecture.md +0 -136
- package/docs/cli.md +0 -47
- package/docs/connectors.md +0 -13
- package/docs/oracle-pack-standard.md +0 -29
- package/docs/profiles.md +0 -154
- package/examples/add-a-chain.mjs +0 -65
- package/examples/oracle-pack-template.mjs +0 -38
- package/examples/research-a-token.mjs +0 -70
- package/plugins/oracle-owner-gate/__init__.py +0 -227
- package/plugins/oracle-owner-gate/plugin.yaml +0 -9
- package/profiles/_template/SOUL.md +0 -54
- package/profiles/_template/profile.json +0 -22
- package/profiles/bitcoin-agent/SOUL.md +0 -31
- package/profiles/bitcoin-agent/profile.json +0 -32
- package/profiles/hyperliquid-agent/SOUL.md +0 -34
- package/profiles/hyperliquid-agent/profile.json +0 -37
- package/profiles/oracle/SOUL.md +0 -107
- package/profiles/oracle/profile.json +0 -39
- package/profiles/polymarket-agent/SOUL.md +0 -35
- package/profiles/polymarket-agent/profile.json +0 -34
- package/profiles/profile.schema.json +0 -90
- package/profiles/protocol-builder/SOUL.md +0 -57
- package/profiles/protocol-builder/profile.json +0 -39
- package/profiles/robinhood-agent/SOUL.md +0 -53
- package/profiles/robinhood-agent/profile.json +0 -40
- package/profiles/solana-agent/SOUL.md +0 -37
- package/profiles/solana-agent/profile.json +0 -37
- package/profiles/stable-agent/SOUL.md +0 -43
- package/profiles/stable-agent/profile.json +0 -37
- package/protocols/templates/safe-erc20/SECURITY.md +0 -16
- package/protocols/templates/safe-erc20/foundry.toml +0 -12
- package/protocols/templates/safe-erc20/remappings.txt +0 -2
- package/protocols/templates/safe-erc20/src/SafeERC20.sol +0 -53
- package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +0 -72
- package/scripts/adversarial-bench.mjs +0 -114
- package/scripts/build-inscription.py +0 -230
- package/scripts/check-doc-drift.mjs +0 -112
- package/scripts/check-test-count.mjs +0 -105
- package/scripts/e2e-hl-markets.mjs +0 -21
- package/scripts/e2e-hl-perps.mjs +0 -48
- package/scripts/e2e-hypercore-staking.mjs +0 -128
- package/scripts/e2e-solana-bitcoin.mjs +0 -183
- package/scripts/protocol-template-gate.mjs +0 -15
- package/scripts/public-api-scan.mjs +0 -23
- package/scripts/secret-scan.mjs +0 -181
- package/scripts/verify-v3-venues.mjs +0 -192
- package/skills/balance/SKILL.md +0 -176
- package/skills/oracle-action-semantics/SKILL.md +0 -40
- package/skills/oracle-best-execution/SKILL.md +0 -127
- package/skills/oracle-bitcoin/SKILL.md +0 -53
- package/skills/oracle-chain-graphs-telegram-cards/SKILL.md +0 -59
- package/skills/oracle-chat/SKILL.md +0 -61
- package/skills/oracle-chat/chain.SKILL.md +0 -31
- package/skills/oracle-chat/setup.SKILL.md +0 -37
- package/skills/oracle-circuit-breaker/SKILL.md +0 -51
- package/skills/oracle-contract-research/SKILL.md +0 -55
- package/skills/oracle-desk/SKILL.md +0 -58
- package/skills/oracle-dex-launch/SKILL.md +0 -38
- package/skills/oracle-grants/SKILL.md +0 -69
- package/skills/oracle-hypercore-staking/SKILL.md +0 -57
- package/skills/oracle-hyperliquid/SKILL.md +0 -56
- package/skills/oracle-meme-token-sniper/SKILL.md +0 -73
- package/skills/oracle-multichain-nft-launch/SKILL.md +0 -338
- package/skills/oracle-multichain-token-launch/SKILL.md +0 -300
- package/skills/oracle-nft-gacha-launch/SKILL.md +0 -48
- package/skills/oracle-nft-mint-gas-war/SKILL.md +0 -63
- package/skills/oracle-polymarket/SKILL.md +0 -60
- package/skills/oracle-protocol-builder/SKILL.md +0 -59
- package/skills/oracle-protocol-security/SKILL.md +0 -60
- package/skills/oracle-public-product/SKILL.md +0 -44
- package/skills/oracle-receipts/SKILL.md +0 -52
- package/skills/oracle-rfq-tokenized-assets/SKILL.md +0 -69
- package/skills/oracle-smart-wallet-scanner/SKILL.md +0 -49
- package/skills/oracle-solana/SKILL.md +0 -65
- package/skills/oracle-solana-nft/SKILL.md +0 -54
- package/skills/oracle-token-research/SKILL.md +0 -67
- package/skins/oracle.yaml +0 -56
- package/src/action-receipts.mjs +0 -168
- package/src/action-semantics.mjs +0 -62
- package/src/address-book.mjs +0 -208
- package/src/agent-auth.mjs +0 -206
- package/src/approval-guard.mjs +0 -282
- package/src/attestation-secret.mjs +0 -88
- package/src/audit-log.mjs +0 -196
- package/src/auth/oauth.mjs +0 -672
- package/src/auto-slippage.mjs +0 -378
- package/src/capability-posture.mjs +0 -125
- package/src/chains.mjs +0 -62
- package/src/cli/chain-catalog.mjs +0 -215
- package/src/cli/chain-state.mjs +0 -74
- package/src/cli/commands/auth.mjs +0 -193
- package/src/cli/commands/bootstrap.mjs +0 -87
- package/src/cli/commands/chain.mjs +0 -143
- package/src/cli/commands/chat.mjs +0 -434
- package/src/cli/commands/credential.mjs +0 -9
- package/src/cli/commands/data-mcp.mjs +0 -18
- package/src/cli/commands/data.mjs +0 -73
- package/src/cli/commands/doctor.mjs +0 -126
- package/src/cli/commands/help.mjs +0 -7
- package/src/cli/commands/init.mjs +0 -27
- package/src/cli/commands/mcp.mjs +0 -142
- package/src/cli/commands/model.mjs +0 -99
- package/src/cli/commands/prepare.mjs +0 -12
- package/src/cli/commands/public.mjs +0 -20
- package/src/cli/commands/route.mjs +0 -12
- package/src/cli/commands/runner.mjs +0 -9
- package/src/cli/commands/scan.mjs +0 -12
- package/src/cli/commands/setup.mjs +0 -275
- package/src/cli/commands/sign.mjs +0 -21
- package/src/cli/commands/signer.mjs +0 -9
- package/src/cli/commands/upgrade.mjs +0 -12
- package/src/cli/commands/vault.mjs +0 -9
- package/src/cli/commands/version.mjs +0 -22
- package/src/cli/first-run.mjs +0 -23
- package/src/cli/kernel.mjs +0 -239
- package/src/cli/mcp-targets/chatgpt.mjs +0 -51
- package/src/cli/mcp-targets/claude-code.mjs +0 -39
- package/src/cli/mcp-targets/claude-desktop.mjs +0 -24
- package/src/cli/mcp-targets/codex.mjs +0 -41
- package/src/cli/mcp-targets/shared.mjs +0 -61
- package/src/cli/messaging-platforms.mjs +0 -209
- package/src/cli/model-config.mjs +0 -70
- package/src/cli/operator-dispatch.mjs +0 -258
- package/src/cli/oracle-harness.py +0 -415
- package/src/cli/paths.mjs +0 -83
- package/src/cli/runtime.mjs +0 -351
- package/src/cli/setup-state.mjs +0 -168
- package/src/cli/spawn-child.mjs +0 -43
- package/src/data/catalog.mjs +0 -554
- package/src/data/desk-data.mjs +0 -683
- package/src/data/http.mjs +0 -253
- package/src/data/provider-endpoint.mjs +0 -94
- package/src/data/providers/aerodrome.mjs +0 -245
- package/src/data/providers/balancer.mjs +0 -209
- package/src/data/providers/bitcoin-esplora.mjs +0 -216
- package/src/data/providers/bitcoin-meta.mjs +0 -378
- package/src/data/providers/blockscout.mjs +0 -14
- package/src/data/providers/bridges.mjs +0 -242
- package/src/data/providers/cowswap.mjs +0 -415
- package/src/data/providers/curve.mjs +0 -201
- package/src/data/providers/defillama.mjs +0 -88
- package/src/data/providers/dexscreener.mjs +0 -43
- package/src/data/providers/evm-rpc.mjs +0 -222
- package/src/data/providers/geckoterminal.mjs +0 -34
- package/src/data/providers/gmx.mjs +0 -496
- package/src/data/providers/hl-assets.mjs +0 -165
- package/src/data/providers/hl-info.mjs +0 -108
- package/src/data/providers/hl-markets.mjs +0 -210
- package/src/data/providers/hl-outcome.mjs +0 -61
- package/src/data/providers/hl-perps.mjs +0 -387
- package/src/data/providers/hl-staking.mjs +0 -353
- package/src/data/providers/hl-ws.mjs +0 -119
- package/src/data/providers/hyperevm-dex.mjs +0 -49
- package/src/data/providers/jupiter.mjs +0 -183
- package/src/data/providers/lifi.mjs +0 -151
- package/src/data/providers/magiceden-sol.mjs +0 -393
- package/src/data/providers/morpho.mjs +0 -173
- package/src/data/providers/nft-gallery.mjs +0 -163
- package/src/data/providers/nft-portfolio.mjs +0 -494
- package/src/data/providers/odos.mjs +0 -156
- package/src/data/providers/oneinch.mjs +0 -174
- package/src/data/providers/opensea-multichain.mjs +0 -136
- package/src/data/providers/opensea-nft.mjs +0 -371
- package/src/data/providers/paraswap.mjs +0 -118
- package/src/data/providers/pendle.mjs +0 -187
- package/src/data/providers/poly-clob.mjs +0 -283
- package/src/data/providers/poly-public.mjs +0 -96
- package/src/data/providers/poly-ws.mjs +0 -103
- package/src/data/providers/portfolio-history.mjs +0 -394
- package/src/data/providers/portfolio.mjs +0 -594
- package/src/data/providers/rfq.mjs +0 -15
- package/src/data/providers/rh-agent.mjs +0 -59
- package/src/data/providers/satflow.mjs +0 -338
- package/src/data/providers/solana-rpc.mjs +0 -197
- package/src/data/providers/uniswap-v3.mjs +0 -320
- package/src/data/providers/zerox.mjs +0 -167
- package/src/data/public-api-scan.mjs +0 -61
- package/src/data/quote-placeholder.mjs +0 -31
- package/src/exact-integer.mjs +0 -72
- package/src/exec-policy.mjs +0 -455
- package/src/flags.mjs +0 -15
- package/src/fresh-window.mjs +0 -76
- package/src/gmx-attestation.mjs +0 -176
- package/src/index.mjs +0 -100
- package/src/nft-gas-war-guard.mjs +0 -139
- package/src/onboarding/agent-keys.mjs +0 -161
- package/src/onboarding/harness-configs.mjs +0 -102
- package/src/onboarding/index.mjs +0 -18
- package/src/onboarding/tiers.mjs +0 -139
- package/src/oracle-env.mjs +0 -47
- package/src/portfolio-risk.mjs +0 -170
- package/src/prepare-envelope.mjs +0 -186
- package/src/profile-upgrade.mjs +0 -277
- package/src/protocol-execution.mjs +0 -84
- package/src/protocol-templates/gate.mjs +0 -179
- package/src/protocol-templates/prepare-deploy.mjs +0 -81
- package/src/public-api/buzz-integration.mjs +0 -256
- package/src/public-api/connect-agent.mjs +0 -416
- package/src/public-api/grants.mjs +0 -142
- package/src/public-api/http.mjs +0 -389
- package/src/public-control/aa-adapter.mjs +0 -402
- package/src/public-control/build-registry.mjs +0 -227
- package/src/public-control/bundler-client.mjs +0 -357
- package/src/public-control/grant-indexer.mjs +0 -296
- package/src/public-control/policy-render.mjs +0 -69
- package/src/public-control/policy-schema.mjs +0 -318
- package/src/public-control/runtime-config.mjs +0 -275
- package/src/public-control/session-key-model.mjs +0 -374
- package/src/public-control/session-orchestrator.mjs +0 -412
- package/src/rfq/intent.mjs +0 -180
- package/src/rfq/sources.mjs +0 -181
- package/src/route-attestation.mjs +0 -132
- package/src/router/best-execution.mjs +0 -326
- package/src/router/index.mjs +0 -226
- package/src/router/prepare-bridge.mjs +0 -289
- package/src/router/prepare-route.mjs +0 -381
- package/src/router/proposal.mjs +0 -311
- package/src/router/risk-classifier.mjs +0 -119
- package/src/router/route-sources.mjs +0 -329
- package/src/scanner/chains.config.mjs +0 -430
- package/src/scanner/contract.mjs +0 -270
- package/src/scanner/evm-scanner.mjs +0 -394
- package/src/scanner/index.mjs +0 -9
- package/src/scanner/v2-venue.mjs +0 -335
- package/src/scanner/v3-venue.mjs +0 -290
- package/src/scopes.mjs +0 -44
- package/src/sell-simulation.mjs +0 -167
- package/src/signals/engine.mjs +0 -146
- package/src/signals/index.mjs +0 -1
- package/src/token-transfer-guard.mjs +0 -188
- package/src/tui/app.mjs +0 -438
- package/src/tui/backend.mjs +0 -145
- package/src/tui/format.mjs +0 -272
- package/src/tui/gateway-client.mjs +0 -177
- package/src/tui/input.mjs +0 -501
- package/src/tui/renderer.mjs +0 -443
- package/src/tui/standalone-client.mjs +0 -666
- package/src/tui/theme.mjs +0 -81
- package/src/vault-attestation.mjs +0 -146
- package/src/venues.mjs +0 -206
- package/src/watch-preferences.mjs +0 -85
package/CONTRIBUTING.md
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# Contributing to Oracle
|
|
2
|
-
|
|
3
|
-
Thanks for looking. Oracle is a control plane for money movement, so the review
|
|
4
|
-
bar is about safety and honesty more than style.
|
|
5
|
-
|
|
6
|
-
## Before you start
|
|
7
|
-
|
|
8
|
-
Run the suite:
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm install
|
|
12
|
-
npm test
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
391 tests, all green. If they aren't green on a clean checkout, that's a bug —
|
|
16
|
-
please report it.
|
|
17
|
-
|
|
18
|
-
## The one rule that matters
|
|
19
|
-
|
|
20
|
-
**The public plane may never reach a private key or a house signer.**
|
|
21
|
-
|
|
22
|
-
Oracle ships the data plane, the policy plane, and the control plane. It does not
|
|
23
|
-
ship the executor. A PR that imports signer or keystore code into public modules
|
|
24
|
-
will fail `test/custody-boundary.test.mjs`, and the fix is not to edit the
|
|
25
|
-
forbidden list.
|
|
26
|
-
|
|
27
|
-
If your feature seems to need a key, restructure it: build an unsigned
|
|
28
|
-
transaction or a typed-data intent and hand it back to the caller to sign.
|
|
29
|
-
|
|
30
|
-
## What we want
|
|
31
|
-
|
|
32
|
-
- **Real bugs, fixed at the class level.** Reproduce it, point at the line, fix
|
|
33
|
-
every sibling call path — not just the one that was reported.
|
|
34
|
-
- **New chains and providers.** This is the most useful contribution. See below.
|
|
35
|
-
- **Honest capability tiers.** If a provider can only quote, mark it
|
|
36
|
-
`quote-only`. Do not mark it `prepare` because a prepare function exists but
|
|
37
|
-
was never validated against a live route.
|
|
38
|
-
- **Tests that assert invariants**, not snapshots. `assert` that a minimum output
|
|
39
|
-
is enforced; don't freeze today's provider list into an equality check.
|
|
40
|
-
- **Guards recomputed before signing.** A quote-time check that isn't re-verified
|
|
41
|
-
at broadcast is decoration.
|
|
42
|
-
|
|
43
|
-
## What gets rejected
|
|
44
|
-
|
|
45
|
-
- A signer, private key, or house-custody path in the public tree.
|
|
46
|
-
- A destination allowlist that defaults to permissive, or an empty allowlist read
|
|
47
|
-
as "allow all."
|
|
48
|
-
- Slippage widened past the 100 bps cap to make a trade go through. Block,
|
|
49
|
-
requote, or split instead.
|
|
50
|
-
- A claim of execution support with no live prepare/simulate evidence.
|
|
51
|
-
- Secrets in code, tests, fixtures, or docs — including a real wallet address as
|
|
52
|
-
a default `from` for quotes. Use `src/data/quote-placeholder.mjs`.
|
|
53
|
-
- "It worked when I ran it" with no test.
|
|
54
|
-
|
|
55
|
-
## Adding a provider
|
|
56
|
-
|
|
57
|
-
1. Create `src/data/providers/<name>.mjs`.
|
|
58
|
-
2. Export a `health()` plus the ops you actually implement.
|
|
59
|
-
3. Register it in `src/data/catalog.mjs` with truthful `chainIds`, `auth`, `ops`,
|
|
60
|
-
and `execution` tier.
|
|
61
|
-
4. Add a test with a mocked transport. Do not require a live network for CI.
|
|
62
|
-
5. If it needs a key, the health check must report
|
|
63
|
-
`{ ok: false, configured: false }` rather than throwing.
|
|
64
|
-
|
|
65
|
-
## Adding a chain
|
|
66
|
-
|
|
67
|
-
1. Add an entry to `CHAINS` in `src/chains.mjs` with its `rpcEnv` names.
|
|
68
|
-
2. Verify every router/venue address on-chain (`eth_getCode` must return real
|
|
69
|
-
bytecode) before adding it to `src/venues.mjs`.
|
|
70
|
-
3. Comment each venue addition with how you verified it and when.
|
|
71
|
-
4. An unverified chain stays fail-closed. That is a safe state, not a gap.
|
|
72
|
-
|
|
73
|
-
Never allowlist a router you found only in a blog post or a model's answer. The
|
|
74
|
-
destination allowlist is the highest-leverage control in the system.
|
|
75
|
-
|
|
76
|
-
## Commits and PRs
|
|
77
|
-
|
|
78
|
-
Conventional prefixes: `fix:`, `feat:`, `refactor:`, `docs:`, `test:`, `chore:`.
|
|
79
|
-
|
|
80
|
-
In the PR body, state:
|
|
81
|
-
|
|
82
|
-
- what broke or what's new
|
|
83
|
-
- how you verified it (paste the real command output)
|
|
84
|
-
- whether anything touches the custody boundary
|
|
85
|
-
|
|
86
|
-
Small, reviewable PRs get merged. A 3000-line PR mixing a refactor with a policy
|
|
87
|
-
change will sit.
|
|
88
|
-
|
|
89
|
-
## Style
|
|
90
|
-
|
|
91
|
-
- ES modules, Node 20+, no build step.
|
|
92
|
-
- No new runtime dependency without a reason in the PR description.
|
|
93
|
-
- Comments explain *why*, not *what*. If a line encodes a hard-won fact — a
|
|
94
|
-
provider's unit quirk, a revert cause — say so, and say how it was learned.
|
|
95
|
-
|
|
96
|
-
## License
|
|
97
|
-
|
|
98
|
-
Contributions are accepted under [Apache-2.0](LICENSE).
|
package/bin/desk-server.mjs
DELETED
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Desk HTTP surface: read-only data plane + onboarding (scoped keys only).
|
|
3
|
-
// NEVER enables wallet signing/exec. Loopback by default.
|
|
4
|
-
//
|
|
5
|
-
// MAD_DESK_PORT=8787 node bin/desk-server.mjs
|
|
6
|
-
|
|
7
|
-
import { createServer } from "node:http";
|
|
8
|
-
import { readFileSync } from "node:fs";
|
|
9
|
-
import { randomBytes } from "node:crypto";
|
|
10
|
-
import { verifyMessage } from "ethers";
|
|
11
|
-
import { data, dataCall, dataHealth, dataCatalog, isExecutionProvider } from "../src/data/desk-data.mjs";
|
|
12
|
-
import { getProvider } from "../src/data/catalog.mjs";
|
|
13
|
-
import { csvEnv, env, envFlag } from "../src/oracle-env.mjs";
|
|
14
|
-
import {
|
|
15
|
-
listTiers,
|
|
16
|
-
onboardUser,
|
|
17
|
-
onboardAuthenticate,
|
|
18
|
-
onboardListKeys,
|
|
19
|
-
onboardRevoke,
|
|
20
|
-
} from "../src/onboarding/index.mjs";
|
|
21
|
-
|
|
22
|
-
const HOST = env("ORACLE_DATA_HOST", "MAD_DESK_HOST", "127.0.0.1");
|
|
23
|
-
const PORT = Number(env("ORACLE_DATA_PORT", "MAD_DESK_PORT", 8787));
|
|
24
|
-
const ONBOARD_ENABLED = envFlag("ORACLE_ONBOARD_HTTP", "MAD_ONBOARD_HTTP", false);
|
|
25
|
-
const PUBLIC_API_MODE = envFlag("ORACLE_PUBLIC_API_MODE", "MAD_PUBLIC_API_MODE", false);
|
|
26
|
-
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
27
|
-
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1", "[::1]"]);
|
|
28
|
-
const MAX_BODY_BYTES = 64 * 1024;
|
|
29
|
-
const CHALLENGE_TTL_SECONDS = 300;
|
|
30
|
-
const MAX_CHALLENGES = 10_000;
|
|
31
|
-
const walletChallenges = new Map();
|
|
32
|
-
|
|
33
|
-
if (!LOOPBACK_HOSTS.has(String(HOST).toLowerCase())) {
|
|
34
|
-
throw new Error("oracle data server only binds loopback; use 127.0.0.1 and do not expose it through a reverse proxy");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function csvSet(value) {
|
|
38
|
-
return new Set(String(value || "").split(",").map((s) => s.trim()).filter(Boolean));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function publicAllowsServerKeyProvider(provider) {
|
|
42
|
-
return csvSet(csvEnv("ORACLE_PUBLIC_ALLOW_SERVER_KEY_PROVIDERS", "MAD_PUBLIC_ALLOW_SERVER_KEY_PROVIDERS")).has(provider);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function providerNeedsServerKey(meta) {
|
|
46
|
-
return meta && meta.auth && meta.auth !== "none";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function publicCallableProviders() {
|
|
50
|
-
return dataCatalog()
|
|
51
|
-
.filter((p) => !providerNeedsServerKey(p) || publicAllowsServerKeyProvider(p.id))
|
|
52
|
-
.map((p) => p.id);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class HttpError extends Error {
|
|
56
|
-
constructor(status, code, message) {
|
|
57
|
-
super(message || code);
|
|
58
|
-
this.status = status;
|
|
59
|
-
this.code = code;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function normalizedOwner(owner) {
|
|
64
|
-
const value = String(owner || "").trim().toLowerCase();
|
|
65
|
-
if (!/^0x[0-9a-f]{40}$/.test(value)) throw new HttpError(400, "invalid-owner", "owner must be a 0x-prefixed address");
|
|
66
|
-
return value;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function parseProofMessage(message) {
|
|
70
|
-
const out = {};
|
|
71
|
-
const lines = String(message || "").split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
72
|
-
if (lines[0] !== "Oracle onboarding") throw new HttpError(401, "invalid-proof", "wallet proof must be an Oracle onboarding challenge");
|
|
73
|
-
for (const line of lines.slice(1)) {
|
|
74
|
-
const idx = line.indexOf(":");
|
|
75
|
-
if (idx <= 0) continue;
|
|
76
|
-
out[line.slice(0, idx).trim()] = line.slice(idx + 1).trim();
|
|
77
|
-
}
|
|
78
|
-
return out;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function pruneWalletChallenges(now = Math.floor(Date.now() / 1000)) {
|
|
82
|
-
for (const [nonce, challenge] of walletChallenges) {
|
|
83
|
-
if (challenge.expiresAt <= now) walletChallenges.delete(nonce);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function issueWalletChallenge({ owner, action, tier, id } = {}) {
|
|
88
|
-
const expectedOwner = normalizedOwner(owner);
|
|
89
|
-
const expectedAction = String(action || "");
|
|
90
|
-
if (!new Set(["onboard", "list", "revoke"]).has(expectedAction)) {
|
|
91
|
-
throw new HttpError(400, "invalid-action", "action must be onboard, list, or revoke");
|
|
92
|
-
}
|
|
93
|
-
const expectedTier = tier == null ? null : String(tier);
|
|
94
|
-
if (expectedAction === "onboard" && !expectedTier) {
|
|
95
|
-
throw new HttpError(400, "tier-required", "onboard challenge requires tier");
|
|
96
|
-
}
|
|
97
|
-
const expectedId = id == null ? null : String(id).trim();
|
|
98
|
-
if (expectedAction === "revoke" && !expectedId) {
|
|
99
|
-
throw new HttpError(400, "id-required", "revoke challenge requires key id");
|
|
100
|
-
}
|
|
101
|
-
if (expectedId && expectedId.length > 256) {
|
|
102
|
-
throw new HttpError(400, "invalid-id", "key id is too long");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const issuedAt = Math.floor(Date.now() / 1000);
|
|
106
|
-
pruneWalletChallenges(issuedAt);
|
|
107
|
-
if (walletChallenges.size >= MAX_CHALLENGES) {
|
|
108
|
-
throw new HttpError(429, "challenge-capacity", "too many pending wallet challenges");
|
|
109
|
-
}
|
|
110
|
-
const expiresAt = issuedAt + CHALLENGE_TTL_SECONDS;
|
|
111
|
-
const nonce = randomBytes(32).toString("hex");
|
|
112
|
-
const lines = [
|
|
113
|
-
"Oracle onboarding",
|
|
114
|
-
`owner: ${expectedOwner}`,
|
|
115
|
-
`action: ${expectedAction}`,
|
|
116
|
-
];
|
|
117
|
-
if (expectedTier != null) lines.push(`tier: ${expectedTier}`);
|
|
118
|
-
if (expectedId != null) lines.push(`id: ${expectedId}`);
|
|
119
|
-
lines.push(`nonce: ${nonce}`, `issuedAt: ${issuedAt}`, `expiresAt: ${expiresAt}`);
|
|
120
|
-
const message = lines.join("\n");
|
|
121
|
-
walletChallenges.set(nonce, {
|
|
122
|
-
owner: expectedOwner,
|
|
123
|
-
action: expectedAction,
|
|
124
|
-
tier: expectedTier,
|
|
125
|
-
id: expectedId,
|
|
126
|
-
issuedAt,
|
|
127
|
-
expiresAt,
|
|
128
|
-
message,
|
|
129
|
-
used: false,
|
|
130
|
-
});
|
|
131
|
-
return { message, issuedAt, expiresAt };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function requireWalletProof(body = {}, { owner, action, tier, id } = {}) {
|
|
135
|
-
const expectedOwner = normalizedOwner(owner);
|
|
136
|
-
const proof = body.proof || body.walletProof || {};
|
|
137
|
-
const message = proof.message || body.message;
|
|
138
|
-
const signature = proof.signature || body.signature;
|
|
139
|
-
if (!message || !signature) throw new HttpError(401, "wallet-proof-required", "wallet signature proof required");
|
|
140
|
-
let recovered;
|
|
141
|
-
try {
|
|
142
|
-
recovered = verifyMessage(String(message), String(signature)).toLowerCase();
|
|
143
|
-
} catch {
|
|
144
|
-
throw new HttpError(401, "invalid-proof", "wallet proof signature is invalid");
|
|
145
|
-
}
|
|
146
|
-
if (recovered !== expectedOwner) throw new HttpError(401, "owner-signature-mismatch", "wallet proof signer does not match owner");
|
|
147
|
-
const fields = parseProofMessage(message);
|
|
148
|
-
if (normalizedOwner(fields.owner) !== expectedOwner) throw new HttpError(401, "owner-proof-mismatch", "wallet proof owner mismatch");
|
|
149
|
-
const nonce = String(fields.nonce || "");
|
|
150
|
-
if (!/^[0-9a-f]{64}$/.test(nonce)) {
|
|
151
|
-
throw new HttpError(401, "challenge-required", "wallet proof must use a server-issued challenge");
|
|
152
|
-
}
|
|
153
|
-
const challenge = walletChallenges.get(nonce);
|
|
154
|
-
if (!challenge) throw new HttpError(401, "challenge-required", "wallet challenge is unknown or expired");
|
|
155
|
-
if (challenge.used) throw new HttpError(401, "proof-replayed", "wallet challenge was already used");
|
|
156
|
-
if (String(message) !== challenge.message) {
|
|
157
|
-
throw new HttpError(401, "challenge-mismatch", "wallet proof does not match the issued challenge");
|
|
158
|
-
}
|
|
159
|
-
challenge.used = true;
|
|
160
|
-
|
|
161
|
-
if (challenge.owner !== expectedOwner) throw new HttpError(401, "owner-proof-mismatch", "wallet proof owner mismatch");
|
|
162
|
-
if (challenge.action !== action || String(fields.action || "") !== action) {
|
|
163
|
-
throw new HttpError(401, "action-proof-mismatch", "wallet proof action mismatch");
|
|
164
|
-
}
|
|
165
|
-
if (tier != null && (challenge.tier !== String(tier) || String(fields.tier || "") !== String(tier))) {
|
|
166
|
-
throw new HttpError(401, "tier-proof-mismatch", "wallet proof tier mismatch");
|
|
167
|
-
}
|
|
168
|
-
if (id != null && (challenge.id !== String(id) || String(fields.id || "") !== String(id))) {
|
|
169
|
-
throw new HttpError(401, "id-proof-mismatch", "wallet proof key id mismatch");
|
|
170
|
-
}
|
|
171
|
-
const now = Math.floor(Date.now() / 1000);
|
|
172
|
-
const issuedAt = Number(fields.issuedAt || 0);
|
|
173
|
-
const expiresAt = Number(fields.expiresAt || 0);
|
|
174
|
-
if (issuedAt !== challenge.issuedAt || expiresAt !== challenge.expiresAt) {
|
|
175
|
-
throw new HttpError(401, "proof-expiry-mismatch", "wallet proof timestamps do not match the issued challenge");
|
|
176
|
-
}
|
|
177
|
-
if (issuedAt > now + 60) throw new HttpError(401, "proof-from-future", "wallet proof issuedAt is in the future");
|
|
178
|
-
if (expiresAt <= now) throw new HttpError(401, "proof-expired", "wallet proof expired");
|
|
179
|
-
if (expiresAt - issuedAt > 600) throw new HttpError(401, "proof-window-too-long", "wallet proof window must be <= 10 minutes");
|
|
180
|
-
return { owner: expectedOwner, recovered, action, expiresAt };
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function send(res, status, body) {
|
|
184
|
-
const json = JSON.stringify(body);
|
|
185
|
-
res.writeHead(status, {
|
|
186
|
-
"content-type": "application/json; charset=utf-8",
|
|
187
|
-
"cache-control": "no-store",
|
|
188
|
-
"x-oracle-plane": "data+onboard",
|
|
189
|
-
"x-oracle-exec": "false",
|
|
190
|
-
});
|
|
191
|
-
res.end(json);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function readBody(req) {
|
|
195
|
-
return new Promise((resolve, reject) => {
|
|
196
|
-
const declared = Number(req.headers["content-length"] || 0);
|
|
197
|
-
if (Number.isFinite(declared) && declared > MAX_BODY_BYTES) {
|
|
198
|
-
reject(new HttpError(413, "body-too-large", `request body exceeds ${MAX_BODY_BYTES} bytes`));
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const chunks = [];
|
|
202
|
-
let size = 0;
|
|
203
|
-
let rejected = false;
|
|
204
|
-
req.on("data", (c) => {
|
|
205
|
-
if (rejected) return;
|
|
206
|
-
size += c.length;
|
|
207
|
-
if (size > MAX_BODY_BYTES) {
|
|
208
|
-
rejected = true;
|
|
209
|
-
chunks.length = 0;
|
|
210
|
-
reject(new HttpError(413, "body-too-large", `request body exceeds ${MAX_BODY_BYTES} bytes`));
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
chunks.push(c);
|
|
214
|
-
});
|
|
215
|
-
req.on("end", () => {
|
|
216
|
-
if (rejected) return;
|
|
217
|
-
const raw = Buffer.concat(chunks).toString("utf8");
|
|
218
|
-
if (!raw) return resolve({});
|
|
219
|
-
try {
|
|
220
|
-
resolve(JSON.parse(raw));
|
|
221
|
-
} catch (e) {
|
|
222
|
-
reject(e);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
req.on("error", reject);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Local-only origin guard.
|
|
231
|
-
*
|
|
232
|
-
* This server binds loopback and is documented as "safe because it's local",
|
|
233
|
-
* but loopback is NOT a security boundary against a browser. Any page the
|
|
234
|
-
* operator visits can issue requests to http://127.0.0.1:8787, and a
|
|
235
|
-
* DNS-rebinding host can resolve an attacker domain to 127.0.0.1 and reach it
|
|
236
|
-
* under that name. Either way the request arrives with the server's own API
|
|
237
|
-
* keys attached, able to call every prepare op.
|
|
238
|
-
*
|
|
239
|
-
* Two cheap checks close both: the Host header must actually be loopback
|
|
240
|
-
* (defeats rebinding, which needs its own hostname), and a cross-origin
|
|
241
|
-
* browser request must be rejected (defeats the visited-page case; real CLI
|
|
242
|
-
* and server-side callers send no Origin at all).
|
|
243
|
-
*/
|
|
244
|
-
function assertLocalCaller(req) {
|
|
245
|
-
// The SOCKET is the boundary, not the Host header. Host is caller-controlled,
|
|
246
|
-
// and `0.0.0.0` was on the accept list — so binding ORACLE_DATA_HOST=0.0.0.0
|
|
247
|
-
// and sending `Host: 0.0.0.0` from another machine returned 200. Check the
|
|
248
|
-
// actual peer address first; nothing a remote client can type changes it.
|
|
249
|
-
const peer = String(req.socket?.remoteAddress || "");
|
|
250
|
-
const normalisedPeer = peer.replace(/^::ffff:/, "");
|
|
251
|
-
const PEER_LOOPBACK = new Set(["127.0.0.1", "::1"]);
|
|
252
|
-
const peerIsLoopback =
|
|
253
|
-
PEER_LOOPBACK.has(normalisedPeer) || normalisedPeer.startsWith("127.");
|
|
254
|
-
if (!peerIsLoopback) {
|
|
255
|
-
return `remote address ${peer || "(unknown)"} is not loopback — this server only answers local callers`;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const host = String(req.headers.host || "").toLowerCase();
|
|
259
|
-
const hostname = host.replace(/:\d+$/, "").replace(/^\[|\]$/g, "");
|
|
260
|
-
// 0.0.0.0 is deliberately NOT here: it is a bind wildcard, never a legitimate
|
|
261
|
-
// Host for a loopback-only service, and accepting it defeated the check.
|
|
262
|
-
const LOOPBACK = new Set(["127.0.0.1", "localhost", "::1"]);
|
|
263
|
-
if (!LOOPBACK.has(hostname)) {
|
|
264
|
-
return `unexpected Host header ${host || "(none)"} — this server only answers to loopback names`;
|
|
265
|
-
}
|
|
266
|
-
const origin = req.headers.origin;
|
|
267
|
-
if (origin && origin !== "null") {
|
|
268
|
-
try {
|
|
269
|
-
const oh = new URL(origin).hostname;
|
|
270
|
-
if (!LOOPBACK.has(oh)) return `cross-origin request from ${origin} refused`;
|
|
271
|
-
} catch {
|
|
272
|
-
return `malformed Origin ${origin} refused`;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return null;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const server = createServer(async (req, res) => {
|
|
279
|
-
try {
|
|
280
|
-
const localOnly = assertLocalCaller(req);
|
|
281
|
-
if (localOnly) return send(res, 403, { error: localOnly });
|
|
282
|
-
|
|
283
|
-
const url = new URL(req.url || "/", `http://${HOST}:${PORT}`);
|
|
284
|
-
const path = url.pathname;
|
|
285
|
-
|
|
286
|
-
if (req.method === "GET" && path === "/health") {
|
|
287
|
-
return send(res, 200, {
|
|
288
|
-
ok: true,
|
|
289
|
-
service: "oracle",
|
|
290
|
-
plane: "data+onboard",
|
|
291
|
-
exec: false,
|
|
292
|
-
version: pkg.version,
|
|
293
|
-
onboardHttp: ONBOARD_ENABLED,
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (req.method === "GET" && path === "/data/catalog") {
|
|
298
|
-
return send(res, 200, { catalog: dataCatalog() });
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (req.method === "GET" && path === "/data/health") {
|
|
302
|
-
const report = await dataHealth({
|
|
303
|
-
timeoutMs: 10_000,
|
|
304
|
-
providers: PUBLIC_API_MODE ? publicCallableProviders() : undefined,
|
|
305
|
-
});
|
|
306
|
-
return send(res, 200, report);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (path === "/data/call") {
|
|
310
|
-
let provider, op, args;
|
|
311
|
-
if (req.method === "GET") {
|
|
312
|
-
provider = url.searchParams.get("provider");
|
|
313
|
-
op = url.searchParams.get("op");
|
|
314
|
-
const argsRaw = url.searchParams.get("args");
|
|
315
|
-
args = argsRaw ? JSON.parse(argsRaw) : {};
|
|
316
|
-
} else if (req.method === "POST") {
|
|
317
|
-
const body = await readBody(req);
|
|
318
|
-
provider = body.provider;
|
|
319
|
-
op = body.op;
|
|
320
|
-
args = body.args || {};
|
|
321
|
-
} else {
|
|
322
|
-
return send(res, 405, { error: "method not allowed" });
|
|
323
|
-
}
|
|
324
|
-
if (!provider || !op) return send(res, 400, { error: "provider and op required" });
|
|
325
|
-
// Provider-level boundary. A name-based verb filter is NOT a boundary:
|
|
326
|
-
// `op:"trade"` matches none of these words, so the live signing lane was
|
|
327
|
-
// reachable through a server whose /health advertises exec:false. Reject
|
|
328
|
-
// the execution provider outright, before any op-name heuristic.
|
|
329
|
-
if (isExecutionProvider(provider)) {
|
|
330
|
-
return send(res, 403, {
|
|
331
|
-
error: `${provider} is an execution provider and is not served by the data plane; run the execution binary instead`,
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
if (/sign|execute|broadcast|approve|submit|place|send|write|trade|order|swap/i.test(op)) {
|
|
335
|
-
return send(res, 403, { error: "sign/exec ops forbidden on data server" });
|
|
336
|
-
}
|
|
337
|
-
const meta = getProvider(provider);
|
|
338
|
-
if (PUBLIC_API_MODE && providerNeedsServerKey(meta) && !publicAllowsServerKeyProvider(provider)) {
|
|
339
|
-
return send(res, 403, {
|
|
340
|
-
error: `public mode blocks ${provider}.${op}: server API key providers are disabled unless explicitly allowlisted`,
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
const result = await dataCall(provider, op, args, { timeoutMs: 15_000 });
|
|
344
|
-
return send(res, 200, { provider, op, result });
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (path.startsWith("/onboard")) {
|
|
348
|
-
if (!ONBOARD_ENABLED) return send(res, 403, { error: "onboard HTTP disabled" });
|
|
349
|
-
|
|
350
|
-
if (req.method === "GET" && path === "/onboard/tiers") {
|
|
351
|
-
return send(res, 200, { tiers: listTiers() });
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
if (req.method === "POST" && path === "/onboard/challenge") {
|
|
355
|
-
const body = await readBody(req);
|
|
356
|
-
return send(res, 200, issueWalletChallenge(body));
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (req.method === "POST" && path === "/onboard") {
|
|
360
|
-
const body = await readBody(req);
|
|
361
|
-
if (body.privateKey || body.secretKey) {
|
|
362
|
-
return send(res, 400, { error: "do not send wallet private keys — owner address only" });
|
|
363
|
-
}
|
|
364
|
-
const tier = body.tier || "observer";
|
|
365
|
-
requireWalletProof(body, { owner: body.owner, action: "onboard", tier });
|
|
366
|
-
const controllers = csvEnv("ORACLE_EXECUTOR_CONTROLLERS", "MAD_EXECUTOR_CONTROLLERS")
|
|
367
|
-
.split(",")
|
|
368
|
-
.map((s) => s.trim())
|
|
369
|
-
.filter(Boolean);
|
|
370
|
-
const result = onboardUser({
|
|
371
|
-
owner: body.owner,
|
|
372
|
-
tier,
|
|
373
|
-
name: body.name,
|
|
374
|
-
controllerAllowlist: controllers,
|
|
375
|
-
});
|
|
376
|
-
return send(res, 201, result);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (req.method === "POST" && path === "/onboard/auth") {
|
|
380
|
-
const body = await readBody(req);
|
|
381
|
-
const auth = onboardAuthenticate(body.key || body.apiKey);
|
|
382
|
-
return send(res, 200, auth);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (req.method === "GET" && path === "/onboard/keys") {
|
|
386
|
-
const owner = url.searchParams.get("owner");
|
|
387
|
-
if (!owner) return send(res, 400, { error: "owner query required" });
|
|
388
|
-
return send(res, 405, { error: "method not allowed", message: "use POST /onboard/keys with wallet proof" });
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
if (req.method === "POST" && path === "/onboard/keys") {
|
|
392
|
-
const body = await readBody(req);
|
|
393
|
-
requireWalletProof(body, { owner: body.owner, action: "list" });
|
|
394
|
-
return send(res, 200, { keys: onboardListKeys(body.owner) });
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (req.method === "POST" && path === "/onboard/revoke") {
|
|
398
|
-
const body = await readBody(req);
|
|
399
|
-
requireWalletProof(body, { owner: body.owner, action: "revoke", id: body.id });
|
|
400
|
-
const rec = onboardRevoke({ owner: body.owner, id: body.id });
|
|
401
|
-
return send(res, 200, { revoked: rec });
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
return send(res, 404, {
|
|
406
|
-
error: "not found",
|
|
407
|
-
routes: [
|
|
408
|
-
"/health",
|
|
409
|
-
"/data/catalog",
|
|
410
|
-
"/data/health",
|
|
411
|
-
"/data/call",
|
|
412
|
-
"/onboard/tiers",
|
|
413
|
-
"POST /onboard/challenge",
|
|
414
|
-
"POST /onboard",
|
|
415
|
-
"POST /onboard/auth",
|
|
416
|
-
"POST /onboard/keys",
|
|
417
|
-
"POST /onboard/revoke",
|
|
418
|
-
],
|
|
419
|
-
});
|
|
420
|
-
} catch (e) {
|
|
421
|
-
if (e instanceof HttpError) {
|
|
422
|
-
return send(res, e.status, { error: e.code, message: e.message });
|
|
423
|
-
}
|
|
424
|
-
// Never echo raw Error objects or stacks to the client.
|
|
425
|
-
console.error("desk-server internal error:", e && e.stack ? e.stack : e);
|
|
426
|
-
return send(res, 500, { error: "internal-error" });
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
server.listen(PORT, HOST, () => {
|
|
431
|
-
console.log(
|
|
432
|
-
JSON.stringify({
|
|
433
|
-
listening: `http://${HOST}:${PORT}`,
|
|
434
|
-
plane: "data+onboard",
|
|
435
|
-
exec: false,
|
|
436
|
-
catalog: data.catalog().map((p) => p.id),
|
|
437
|
-
tiers: listTiers().map((t) => t.id),
|
|
438
|
-
})
|
|
439
|
-
);
|
|
440
|
-
});
|