@oracle-agent/oracle 0.14.1 → 0.15.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 +2 -2
- package/SETUP.md +4 -4
- 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 +59 -0
- package/dist/bin/oracle-data-mcp.mjs +8 -0
- package/dist/bin/oracle-equities.mjs +20 -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 +61 -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 +45 -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/equities.mjs +15 -0
- package/dist/cli/commands/farm.mjs +59 -0
- package/dist/cli/commands/fees.mjs +10 -0
- package/dist/cli/commands/follow.mjs +28 -0
- package/dist/cli/commands/harness.mjs +15 -0
- package/dist/cli/commands/help.mjs +1 -0
- package/dist/cli/commands/init.mjs +3 -0
- package/dist/cli/commands/mcp.mjs +36 -0
- package/dist/cli/commands/model.mjs +54 -0
- package/dist/cli/commands/plugins.mjs +43 -0
- package/dist/cli/commands/prepare.mjs +2 -0
- package/dist/cli/commands/public.mjs +3 -0
- package/dist/cli/commands/resolve.mjs +23 -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/swap.mjs +36 -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 +55 -0
- package/dist/data/names.mjs +2 -0
- package/dist/data/providers/farming.mjs +2 -0
- package/dist/equities/index.mjs +1 -0
- package/dist/index.mjs +60 -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-api/agent-grants.mjs +3 -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 +32 -78
- package/public/oracle-splash/_variants/ice.html +5 -18
- package/public/oracle-splash/_variants/ivory.html +5 -18
- package/public/oracle-splash/index.html +114 -34
- package/CONTRIBUTING.md +0 -99
- package/bin/desk-server.mjs +0 -473
- package/bin/oracle-data-mcp.mjs +0 -1252
- package/bin/oracle-equities.mjs +0 -168
- package/bin/oracle-init.mjs +0 -525
- 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 -34
- package/docs/adding-a-chain.md +0 -229
- package/docs/architecture.md +0 -139
- package/docs/buzz-integration.md +0 -115
- package/docs/cli.md +0 -143
- package/docs/connectors.md +0 -13
- package/docs/hyperliquid-builder-code.md +0 -50
- package/docs/locals-only-fee-waiver.md +0 -34
- package/docs/oracle-pack-standard.md +0 -29
- package/docs/profiles.md +0 -151
- package/docs/public-surface.md +0 -206
- 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 -288
- package/plugins/oracle-owner-gate/plugin.yaml +0 -9
- 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-dist.mjs +0 -119
- package/scripts/build-inscription.py +0 -230
- package/scripts/check-doc-drift.mjs +0 -123
- 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/guard-publish.mjs +0 -22
- package/scripts/protocol-template-gate.mjs +0 -15
- package/scripts/public-api-scan.mjs +0 -23
- package/scripts/publish-dist.mjs +0 -67
- package/scripts/record-hero-cli.sh +0 -80
- package/scripts/secret-scan.mjs +0 -169
- package/scripts/smoke-dist-bins.mjs +0 -89
- package/scripts/verify-dist.mjs +0 -29
- package/scripts/verify-v3-venues.mjs +0 -233
- package/skins/oracle.yaml +0 -56
- package/src/action-receipts.mjs +0 -265
- 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 -94
- 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/cards.mjs +0 -422
- 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 -465
- package/src/cli/commands/credential.mjs +0 -9
- package/src/cli/commands/data-mcp.mjs +0 -18
- package/src/cli/commands/data.mjs +0 -75
- package/src/cli/commands/doctor.mjs +0 -136
- package/src/cli/commands/equities.mjs +0 -41
- package/src/cli/commands/farm.mjs +0 -129
- package/src/cli/commands/fees.mjs +0 -109
- package/src/cli/commands/follow.mjs +0 -130
- package/src/cli/commands/harness.mjs +0 -63
- package/src/cli/commands/help.mjs +0 -7
- package/src/cli/commands/init.mjs +0 -27
- package/src/cli/commands/mcp.mjs +0 -154
- package/src/cli/commands/model.mjs +0 -106
- package/src/cli/commands/plugins.mjs +0 -275
- package/src/cli/commands/prepare.mjs +0 -12
- package/src/cli/commands/public.mjs +0 -20
- package/src/cli/commands/resolve.mjs +0 -64
- 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 -294
- package/src/cli/commands/sign.mjs +0 -21
- package/src/cli/commands/signer.mjs +0 -9
- package/src/cli/commands/swap.mjs +0 -102
- 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 -262
- 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/cursor.mjs +0 -32
- package/src/cli/mcp-targets/shared.mjs +0 -71
- package/src/cli/mcp-targets/vscode.mjs +0 -39
- package/src/cli/messaging-platforms.mjs +0 -217
- package/src/cli/model-config.mjs +0 -78
- package/src/cli/operator-dispatch.mjs +0 -194
- package/src/cli/oracle-harness.py +0 -415
- package/src/cli/paths.mjs +0 -107
- 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 -858
- package/src/data/desk-data.mjs +0 -877
- package/src/data/http.mjs +0 -253
- package/src/data/names.mjs +0 -188
- package/src/data/provider-endpoint.mjs +0 -94
- package/src/data/providers/aave-v3.mjs +0 -139
- package/src/data/providers/across-bridge.mjs +0 -41
- package/src/data/providers/aerodrome.mjs +0 -245
- package/src/data/providers/aevo.mjs +0 -33
- package/src/data/providers/approval-indexer.mjs +0 -133
- package/src/data/providers/approvals.mjs +0 -594
- package/src/data/providers/babylon-staking.mjs +0 -149
- package/src/data/providers/balancer.mjs +0 -209
- package/src/data/providers/beefy-yields.mjs +0 -45
- package/src/data/providers/birdeye-tokens.mjs +0 -33
- package/src/data/providers/bisq-markets.mjs +0 -145
- 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/bob-rootstock.mjs +0 -198
- package/src/data/providers/braiins-insights.mjs +0 -103
- package/src/data/providers/bridge-aggregator.mjs +0 -259
- package/src/data/providers/bridges.mjs +0 -242
- package/src/data/providers/bungee.mjs +0 -29
- package/src/data/providers/celestia-da.mjs +0 -38
- package/src/data/providers/changenow.mjs +0 -135
- package/src/data/providers/compound.mjs +0 -32
- package/src/data/providers/connext.mjs +0 -28
- package/src/data/providers/convex.mjs +0 -30
- package/src/data/providers/cow-protocol.mjs +0 -110
- package/src/data/providers/cowswap.mjs +0 -415
- package/src/data/providers/curve.mjs +0 -201
- package/src/data/providers/das-assets.mjs +0 -59
- package/src/data/providers/debridge.mjs +0 -109
- package/src/data/providers/defillama.mjs +0 -88
- package/src/data/providers/dexscreener.mjs +0 -43
- package/src/data/providers/drift.mjs +0 -32
- package/src/data/providers/dydx.mjs +0 -41
- package/src/data/providers/evm-rpc.mjs +0 -225
- package/src/data/providers/farming.mjs +0 -291
- package/src/data/providers/geckoterminal.mjs +0 -34
- package/src/data/providers/gmx.mjs +0 -496
- package/src/data/providers/hiro-stacks.mjs +0 -150
- 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 -419
- 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/jito-mev.mjs +0 -117
- package/src/data/providers/jupiter-venues.mjs +0 -119
- package/src/data/providers/jupiter.mjs +0 -315
- package/src/data/providers/kamino-strategies.mjs +0 -143
- package/src/data/providers/l2beat-tvl.mjs +0 -42
- package/src/data/providers/lifi.mjs +0 -166
- package/src/data/providers/liquid-esplora.mjs +0 -152
- package/src/data/providers/magiceden-ordinals.mjs +0 -141
- package/src/data/providers/magiceden-sol.mjs +0 -406
- package/src/data/providers/mempool-lightning.mjs +0 -144
- package/src/data/providers/mempool-mining.mjs +0 -142
- package/src/data/providers/meteora-dlmm.mjs +0 -168
- package/src/data/providers/morpho.mjs +0 -177
- 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/ondo.mjs +0 -31
- 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/orca.mjs +0 -29
- package/src/data/providers/ordinals-runes.mjs +0 -180
- package/src/data/providers/pancakeswap.mjs +0 -28
- package/src/data/providers/paraswap.mjs +0 -125
- package/src/data/providers/pendle.mjs +0 -188
- 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/polygon-staking.mjs +0 -227
- package/src/data/providers/portfolio-history.mjs +0 -394
- package/src/data/providers/portfolio.mjs +0 -600
- package/src/data/providers/pyth-price-feeds.mjs +0 -172
- package/src/data/providers/raydium.mjs +0 -35
- package/src/data/providers/relayscan-mev.mjs +0 -72
- package/src/data/providers/rfq.mjs +0 -15
- package/src/data/providers/rh-agent.mjs +0 -59
- package/src/data/providers/sanctum-lst.mjs +0 -180
- package/src/data/providers/satflow.mjs +0 -341
- package/src/data/providers/signed-material-guard.mjs +0 -108
- package/src/data/providers/solana-rpc.mjs +0 -197
- package/src/data/providers/solend-lending.mjs +0 -166
- package/src/data/providers/spark-lend.mjs +0 -42
- package/src/data/providers/squid-router.mjs +0 -29
- package/src/data/providers/stargate.mjs +0 -29
- package/src/data/providers/sushiswap.mjs +0 -30
- package/src/data/providers/symbiotic-restaking.mjs +0 -41
- package/src/data/providers/thorchain.mjs +0 -36
- package/src/data/providers/traderjoe.mjs +0 -28
- package/src/data/providers/twap.mjs +0 -152
- package/src/data/providers/uniswap-v3.mjs +0 -457
- package/src/data/providers/uniswap-v4.mjs +0 -414
- package/src/data/providers/vertex.mjs +0 -41
- package/src/data/providers/wallet-watch.mjs +0 -264
- package/src/data/providers/wormhole.mjs +0 -28
- package/src/data/providers/yearn.mjs +0 -31
- 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/desk/swap-prepare.mjs +0 -194
- package/src/equities/bridge.mjs +0 -388
- package/src/equities/fixtures/bridge_routes.json +0 -159
- package/src/equities/fixtures/dst_transitions.json +0 -29
- package/src/equities/fixtures/equity_dex_pools.json +0 -154
- package/src/equities/fixtures/hip3_l2books.json +0 -2711
- package/src/equities/fixtures/nyse_holidays.json +0 -1
- package/src/equities/fixtures/oracles.json +0 -100
- package/src/equities/fixtures/rh_pool_state.json +0 -244
- package/src/equities/fixtures/solana_xstocks.json +0 -704
- package/src/equities/fixtures/ton_xstocks.json +0 -35
- package/src/equities/fixtures/universe.json +0 -411
- package/src/equities/fixtures/venues.json +0 -3542
- package/src/equities/fixtures.mjs +0 -405
- package/src/equities/funding.mjs +0 -142
- package/src/equities/index.mjs +0 -166
- package/src/equities/liveness.mjs +0 -148
- package/src/equities/marketHours.mjs +0 -249
- package/src/equities/normalize.mjs +0 -295
- package/src/equities/num.mjs +0 -146
- package/src/equities/prepare.mjs +0 -95
- package/src/equities/rank.mjs +0 -260
- package/src/equities/sourceNum.mjs +0 -69
- package/src/equities/types.mjs +0 -220
- package/src/equities/venues/arcus-perp.mjs +0 -84
- package/src/equities/venues/arcus-spot.mjs +0 -105
- package/src/equities/venues/hyperliquid-hip3.mjs +0 -224
- package/src/equities/venues/rh-uniswap.mjs +0 -216
- package/src/equities/venues/solana-xstocks.mjs +0 -139
- package/src/equities/venues/ton-stonfi.mjs +0 -139
- package/src/exact-integer.mjs +0 -72
- package/src/exec-policy.mjs +0 -419
- 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 -107
- package/src/licensing/locals-only.mjs +0 -25
- 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 -55
- package/src/package-manifest.mjs +0 -42
- package/src/plugins/agent-plugin-loader.mjs +0 -225
- package/src/portfolio-risk.mjs +0 -170
- package/src/prepare-envelope.mjs +0 -204
- 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/agent-grants.mjs +0 -57
- package/src/public-api/buzz-integration.mjs +0 -267
- package/src/public-api/connect-agent.mjs +0 -424
- package/src/public-api/grants.mjs +0 -142
- package/src/public-api/http.mjs +0 -707
- package/src/public-api/metering.mjs +0 -111
- 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 -322
- package/src/public-control/runtime-config.mjs +0 -275
- package/src/public-control/session-key-model.mjs +0 -379
- package/src/public-control/session-orchestrator.mjs +0 -418
- 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 -250
- package/src/router/integrator-fee.mjs +0 -135
- package/src/router/prepare-bridge.mjs +0 -293
- package/src/router/prepare-route.mjs +0 -398
- package/src/router/proposal.mjs +0 -311
- package/src/router/risk-classifier.mjs +0 -119
- package/src/router/route-sources.mjs +0 -364
- package/src/scanner/chains.config.mjs +0 -543
- 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 -351
- package/src/scanner/v3-venue.mjs +0 -308
- 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 -215
- 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/memory.mjs +0 -105
- package/src/tui/meta-learn.mjs +0 -85
- package/src/tui/renderer.mjs +0 -443
- package/src/tui/scheduler.mjs +0 -205
- package/src/tui/skills-loader.mjs +0 -140
- package/src/tui/standalone-client.mjs +0 -752
- 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/{profiles → dist/assets/profiles}/_template/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/_template/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/bitcoin-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/bitcoin-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/hyperliquid-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/hyperliquid-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/oracle/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/oracle/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/polymarket-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/polymarket-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/profile.schema.json +0 -0
- /package/{profiles → dist/assets/profiles}/protocol-builder/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/protocol-builder/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/robinhood-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/robinhood-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/solana-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/solana-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/stable-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/stable-agent/profile.json +0 -0
- /package/{skills → dist/assets/skills}/balance/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/bitcoin-l1.md +0 -0
- /package/{skills → dist/assets/skills}/chain-defi-ecosystem-profiling.md +0 -0
- /package/{skills → dist/assets/skills}/evm-contract-research.md +0 -0
- /package/{skills → dist/assets/skills}/hyperliquid.md +0 -0
- /package/{skills → dist/assets/skills}/multichain-exec-desk.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-action-semantics/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-best-execution/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-best-execution.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-bitcoin/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chain-graphs-telegram-cards/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/chain.SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/setup.SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-circuit-breaker/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-contract-research/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-desk/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-desk.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-dex-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-equities/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-grants/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-hypercore-staking/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-hyperliquid/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-meme-token-sniper/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-multichain-nft-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-multichain-token-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-nft-gacha-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-nft-mint-gas-war/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-polymarket/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-protocol-builder/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-protocol-security/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-public-product/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-receipts/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-receipts.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-rfq-tokenized-assets/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-smart-wallet-scanner/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-solana/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-solana-nft/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-token-research/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/solana.md +0 -0
package/src/public-api/http.mjs
DELETED
|
@@ -1,707 +0,0 @@
|
|
|
1
|
-
// Oracle Public HTTP surface (Slice G) — secret-free BFF over the public
|
|
2
|
-
// read/assemble contract.
|
|
3
|
-
//
|
|
4
|
-
// Hard boundaries for this file:
|
|
5
|
-
// - Imports ONLY the public API/peer modules (connect-agent, grants,
|
|
6
|
-
// policy-schema, oracle-env). NEVER the private executor stack
|
|
7
|
-
// (get-signer, keystore, exec-policy, local-signer/*, adapters/*,
|
|
8
|
-
// exec-server, mint-capability).
|
|
9
|
-
// - NEVER signs anything and NEVER holds key material. Every payload this
|
|
10
|
-
// server emits is unsigned public data; the user signs client-side.
|
|
11
|
-
// - Fail-closed no-secret invariant: EVERY response body is recursively
|
|
12
|
-
// scanned with assertNoSecretMaterial() before it is written to the
|
|
13
|
-
// socket. If the scan throws, the body is dropped and the client gets
|
|
14
|
-
// 500 { error: "secret-leak-blocked" } instead. The model proposes,
|
|
15
|
-
// the owner authorizes.
|
|
16
|
-
// - No auth secrets in code: this plane serves public reads/assembly only,
|
|
17
|
-
// binds to loopback by default, and carries no bearer/token logic.
|
|
18
|
-
|
|
19
|
-
import { createServer } from "node:http";
|
|
20
|
-
import { readFileSync, existsSync } from "node:fs";
|
|
21
|
-
import { dirname, join, normalize, sep } from "node:path";
|
|
22
|
-
import { fileURLToPath } from "node:url";
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
buildConnectRequest,
|
|
26
|
-
assembleUnsignedGrant,
|
|
27
|
-
assertNoSecretMaterial,
|
|
28
|
-
assertSerializedNoSecrets,
|
|
29
|
-
SecretLeakError,
|
|
30
|
-
} from "./connect-agent.mjs";
|
|
31
|
-
import { listActiveGrants, getGrant } from "./grants.mjs";
|
|
32
|
-
import { GrantValidationError } from "../public-control/policy-schema.mjs";
|
|
33
|
-
import { approvalsScan } from "../data/providers/approvals.mjs";
|
|
34
|
-
import { portfolioBalance } from "../data/providers/portfolio.mjs";
|
|
35
|
-
import { nftInventory } from "../data/providers/nft-portfolio.mjs";
|
|
36
|
-
import { env } from "../oracle-env.mjs";
|
|
37
|
-
|
|
38
|
-
const pkg = JSON.parse(
|
|
39
|
-
readFileSync(new URL("../../package.json", import.meta.url), "utf8")
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
export const PUBLIC_PLANE = "public";
|
|
43
|
-
export const DEFAULT_HOST = "127.0.0.1";
|
|
44
|
-
export const DEFAULT_PORT = 8799;
|
|
45
|
-
export const VERSION = pkg.version;
|
|
46
|
-
|
|
47
|
-
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1"]);
|
|
48
|
-
|
|
49
|
-
const ROOT_DIR = join(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
50
|
-
const CONSOLE_DIR = join(ROOT_DIR, "public", "oracle-console");
|
|
51
|
-
|
|
52
|
-
/** Allowlisted console static files only — no directory listing / traversal. */
|
|
53
|
-
const STATIC_FILES = Object.freeze({
|
|
54
|
-
"/": { file: "index.html", type: "text/html; charset=utf-8" },
|
|
55
|
-
"/index.html": { file: "index.html", type: "text/html; charset=utf-8" },
|
|
56
|
-
"/app.js": { file: "app.js", type: "application/javascript; charset=utf-8" },
|
|
57
|
-
"/styles.css": { file: "styles.css", type: "text/css; charset=utf-8" },
|
|
58
|
-
"/oracle-console": { file: "index.html", type: "text/html; charset=utf-8" },
|
|
59
|
-
"/oracle-console/": { file: "index.html", type: "text/html; charset=utf-8" },
|
|
60
|
-
"/oracle-console/index.html": { file: "index.html", type: "text/html; charset=utf-8" },
|
|
61
|
-
"/oracle-console/app.js": { file: "app.js", type: "application/javascript; charset=utf-8" },
|
|
62
|
-
"/oracle-console/styles.css": { file: "styles.css", type: "text/css; charset=utf-8" },
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
/** Refuse absurd bodies before parsing (fail closed, cheap DoS guard). */
|
|
66
|
-
const MAX_BODY_BYTES = 1_000_000;
|
|
67
|
-
|
|
68
|
-
class HttpError extends Error {
|
|
69
|
-
constructor(status, code, message) {
|
|
70
|
-
super(message || code);
|
|
71
|
-
this.status = status;
|
|
72
|
-
this.code = code;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Write a JSON response. The no-secret invariant runs HERE, on every body,
|
|
78
|
-
* immediately before the bytes hit the socket.
|
|
79
|
-
*
|
|
80
|
-
* Two layers, in order:
|
|
81
|
-
* 1. assertNoSecretMaterial() walks the object graph (precise path in the
|
|
82
|
-
* error, catches forbidden key names on real properties).
|
|
83
|
-
* 2. assertSerializedNoSecrets() scans the ACTUAL JSON bytes we are about to
|
|
84
|
-
* write. This is the authoritative check: toJSON(), getters, symbol keys
|
|
85
|
-
* and non-enumerable properties can all put a value on the wire that the
|
|
86
|
-
* graph walk never visited.
|
|
87
|
-
*
|
|
88
|
-
* If either throws, the original body is never serialized to the client; a
|
|
89
|
-
* fixed 500 secret-leak-blocked envelope is sent instead.
|
|
90
|
-
*/
|
|
91
|
-
function send(res, status, body) {
|
|
92
|
-
let payloadStatus = status;
|
|
93
|
-
let json;
|
|
94
|
-
try {
|
|
95
|
-
assertNoSecretMaterial(body);
|
|
96
|
-
json = assertSerializedNoSecrets(body);
|
|
97
|
-
} catch {
|
|
98
|
-
payloadStatus = 500;
|
|
99
|
-
json = JSON.stringify({ error: "secret-leak-blocked" });
|
|
100
|
-
}
|
|
101
|
-
res.writeHead(payloadStatus, {
|
|
102
|
-
"content-type": "application/json; charset=utf-8",
|
|
103
|
-
"cache-control": "no-store",
|
|
104
|
-
"x-oracle-plane": PUBLIC_PLANE,
|
|
105
|
-
"x-oracle-unsigned": "true",
|
|
106
|
-
});
|
|
107
|
-
res.end(json);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function readJsonBody(req) {
|
|
111
|
-
return new Promise((resolve, reject) => {
|
|
112
|
-
const chunks = [];
|
|
113
|
-
let size = 0;
|
|
114
|
-
req.on("data", (chunk) => {
|
|
115
|
-
size += chunk.length;
|
|
116
|
-
if (size > MAX_BODY_BYTES) {
|
|
117
|
-
reject(new HttpError(413, "payload-too-large", "request body too large"));
|
|
118
|
-
req.destroy();
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
chunks.push(chunk);
|
|
122
|
-
});
|
|
123
|
-
req.on("end", () => {
|
|
124
|
-
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
125
|
-
if (raw === "") return resolve({});
|
|
126
|
-
try {
|
|
127
|
-
resolve(JSON.parse(raw));
|
|
128
|
-
} catch {
|
|
129
|
-
reject(new HttpError(400, "invalid-json", "request body must be valid JSON"));
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
req.on("error", () => reject(new HttpError(400, "bad-request", "request stream error")));
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function asPlainObject(v, code) {
|
|
137
|
-
if (v == null) return {};
|
|
138
|
-
if (typeof v !== "object" || Array.isArray(v)) {
|
|
139
|
-
throw new HttpError(400, code, `${code} must be a JSON object`);
|
|
140
|
-
}
|
|
141
|
-
return v;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function normalizeHost(host) {
|
|
145
|
-
return String(host || "").trim().toLowerCase().replace(/^\[|\]$/g, "");
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function assertLoopbackBindHost(host) {
|
|
149
|
-
const normalized = normalizeHost(host);
|
|
150
|
-
if (!LOOPBACK_HOSTS.has(normalized)) {
|
|
151
|
-
throw new TypeError(`oracle-public only binds loopback hosts; got ${String(host)}`);
|
|
152
|
-
}
|
|
153
|
-
return normalized === "::1" ? "::1" : String(host).trim();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// ---------------------------------------------------------------------------
|
|
157
|
-
// Route handlers — each returns { status, body }; errors are thrown.
|
|
158
|
-
// ---------------------------------------------------------------------------
|
|
159
|
-
|
|
160
|
-
function handleHealth() {
|
|
161
|
-
return { status: 200, body: { ok: true, plane: PUBLIC_PLANE, version: VERSION } };
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function serverTimeOptions(clientOpts) {
|
|
165
|
-
return {
|
|
166
|
-
...clientOpts,
|
|
167
|
-
allowWildcardActions: false,
|
|
168
|
-
now: Math.floor(Date.now() / 1000),
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function handleConnectRequest(body) {
|
|
173
|
-
const b = asPlainObject(body, "body");
|
|
174
|
-
// Accept either { input, opts } or the raw grant fields as the body itself.
|
|
175
|
-
// Caller opts.now is deliberately overwritten by serverTimeOptions().
|
|
176
|
-
const input = b.input !== undefined ? asPlainObject(b.input, "input") : b;
|
|
177
|
-
const opts = serverTimeOptions(asPlainObject(b.opts, "opts"));
|
|
178
|
-
const rawInput = input === b ? (({ opts: _drop, ...rest }) => rest)(b) : input;
|
|
179
|
-
return { status: 200, body: buildConnectRequest(rawInput, opts) };
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function handleConnectAssemble(body) {
|
|
183
|
-
const b = asPlainObject(body, "body");
|
|
184
|
-
const input =
|
|
185
|
-
b.request !== undefined
|
|
186
|
-
? asPlainObject(b.request, "request")
|
|
187
|
-
: b.input !== undefined
|
|
188
|
-
? asPlainObject(b.input, "input")
|
|
189
|
-
: b;
|
|
190
|
-
const opts = serverTimeOptions(asPlainObject(b.opts, "opts"));
|
|
191
|
-
const rawInput = input === b ? (({ opts: _drop, ...rest }) => rest)(b) : input;
|
|
192
|
-
return { status: 200, body: assembleUnsignedGrant(rawInput, opts) };
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function handleGrantsActive(body) {
|
|
196
|
-
const b = asPlainObject(body, "body");
|
|
197
|
-
const opts = serverTimeOptions(asPlainObject(b.opts, "opts"));
|
|
198
|
-
const grants = listActiveGrants(b.store ?? [], opts);
|
|
199
|
-
return { status: 200, body: { ok: true, count: grants.length, grants } };
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function handleGrantsGet(body) {
|
|
203
|
-
const b = asPlainObject(body, "body");
|
|
204
|
-
const opts = serverTimeOptions(asPlainObject(b.opts, "opts"));
|
|
205
|
-
const found = getGrant(b.store ?? [], b.id, opts);
|
|
206
|
-
if (found == null) {
|
|
207
|
-
return { status: 404, body: { error: "grant-not-found" } };
|
|
208
|
-
}
|
|
209
|
-
return { status: 200, body: found };
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Public runtime config for the browser console.
|
|
214
|
-
*
|
|
215
|
-
* Advertises which wallet-connection modes this deployment supports so the frontend
|
|
216
|
-
* does not have to guess or hardcode. Two modes, both self-custodial:
|
|
217
|
-
*
|
|
218
|
-
* injected EIP-1193 / EIP-6963 browser wallet (MetaMask, Rabby, ...)
|
|
219
|
-
* privy embedded/social login, still user-held keys
|
|
220
|
-
*
|
|
221
|
-
* A Privy APP ID is a PUBLIC client identifier -- it is designed to ship in
|
|
222
|
-
* frontend bundles. The app SECRET is server-side and must never appear here, which
|
|
223
|
-
* is why only the id is read and the send() path runs a secret scan over every
|
|
224
|
-
* response body regardless.
|
|
225
|
-
*
|
|
226
|
-
* Absent env means the mode is simply unavailable. Reporting it as disabled is
|
|
227
|
-
* honest; inventing a default app id would produce a broken login flow.
|
|
228
|
-
*/
|
|
229
|
-
function handleConfig() {
|
|
230
|
-
const privyAppId = (process.env.ORACLE_PRIVY_APP_ID || process.env.PRIVY_APP_ID || "").trim();
|
|
231
|
-
const privyEnabled = privyAppId.length > 0;
|
|
232
|
-
// Injected wallets need no server config, so this deployment can always offer it.
|
|
233
|
-
const injectedEnabled = true;
|
|
234
|
-
|
|
235
|
-
const modes = [];
|
|
236
|
-
if (privyEnabled) modes.push("privy");
|
|
237
|
-
if (injectedEnabled) modes.push("injected");
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
status: 200,
|
|
241
|
-
body: {
|
|
242
|
-
ok: true,
|
|
243
|
-
plane: PUBLIC_PLANE,
|
|
244
|
-
version: VERSION,
|
|
245
|
-
custody: {
|
|
246
|
-
// Stated explicitly: no deployment of the public plane ever holds keys.
|
|
247
|
-
selfCustodial: true,
|
|
248
|
-
signer: "user-wallet",
|
|
249
|
-
privyEnabled,
|
|
250
|
-
injectedEnabled,
|
|
251
|
-
modes,
|
|
252
|
-
},
|
|
253
|
-
privy: {
|
|
254
|
-
// Public client id only. Never the app secret.
|
|
255
|
-
appId: privyAppId || null,
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Read-only ERC-20 approval review.
|
|
263
|
-
*
|
|
264
|
-
* Log-derived and range-scoped by construction, so the response carries its
|
|
265
|
-
* own scan range and never implies completeness. Revoking is a separate
|
|
266
|
-
* prepare-only surface whose output the user's wallet signs.
|
|
267
|
-
*/
|
|
268
|
-
/**
|
|
269
|
-
* Read-only approval review.
|
|
270
|
-
*
|
|
271
|
-
* Amplification-aware: a single request fans out to many upstream RPC calls, so
|
|
272
|
-
* the chain list is capped here as well as rate-limited at the dispatcher. An
|
|
273
|
-
* uncapped `chainIds` array would let one request cost as much as many.
|
|
274
|
-
*/
|
|
275
|
-
const MAX_CHAINS_PER_REQUEST = 12;
|
|
276
|
-
|
|
277
|
-
async function handleApprovals(body) {
|
|
278
|
-
const b = asPlainObject(body, "body");
|
|
279
|
-
const owner = typeof b.owner === "string" ? b.owner : null;
|
|
280
|
-
if (!owner) throw new HttpError(400, "owner-required", "owner must be an EVM address");
|
|
281
|
-
const requested = Array.isArray(b.chainIds) ? b.chainIds.map(Number).filter(Number.isFinite) : undefined;
|
|
282
|
-
if (requested && requested.length > MAX_CHAINS_PER_REQUEST) {
|
|
283
|
-
throw new HttpError(
|
|
284
|
-
400,
|
|
285
|
-
"too-many-chains",
|
|
286
|
-
`at most ${MAX_CHAINS_PER_REQUEST} chainIds per request`,
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
const chainIds = requested;
|
|
290
|
-
|
|
291
|
-
const result = await approvalsScan({ owner, chainIds }, {});
|
|
292
|
-
return {
|
|
293
|
-
status: 200,
|
|
294
|
-
body: {
|
|
295
|
-
ok: true,
|
|
296
|
-
owner: result.owner,
|
|
297
|
-
scannedRange: result.scannedRange,
|
|
298
|
-
approvals: result.approvals,
|
|
299
|
-
scans: result.scans,
|
|
300
|
-
warnings: result.warnings,
|
|
301
|
-
},
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Accept either a bare EVM address string or the multi-family object the app
|
|
307
|
-
* sends ({ evm, solana, bitcoin, hyperliquid }). Returns null when no usable
|
|
308
|
-
* EVM address is present; callers reject rather than fall back to the env.
|
|
309
|
-
*/
|
|
310
|
-
const PUBLIC_SOL_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
311
|
-
const PUBLIC_BTC_RE = /^([13][1-9A-HJ-NP-Za-km-z]{25,34}|bc1[ac-hj-np-z02-9]{11,71})$/i;
|
|
312
|
-
|
|
313
|
-
// Optional side-addresses. Invalid input returns null rather than throwing:
|
|
314
|
-
// a malformed BTC address must not deny someone their EVM balances.
|
|
315
|
-
function optionalSolanaAddress(value) {
|
|
316
|
-
if (typeof value !== "string") return null;
|
|
317
|
-
const v = value.trim();
|
|
318
|
-
return PUBLIC_SOL_RE.test(v) ? v : null;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function optionalBitcoinAddress(value) {
|
|
322
|
-
if (typeof value !== "string") return null;
|
|
323
|
-
const v = value.trim();
|
|
324
|
-
return PUBLIC_BTC_RE.test(v) ? v : null;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function ownerEvmAddress(value) {
|
|
328
|
-
if (typeof value === "string") return value.trim() === "" ? null : value;
|
|
329
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
330
|
-
const evm = value.evm;
|
|
331
|
-
if (typeof evm === "string" && evm.trim() !== "") return evm;
|
|
332
|
-
}
|
|
333
|
-
return null;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Portfolio balances for a caller-supplied owner.
|
|
338
|
-
*
|
|
339
|
-
* The owner is REQUIRED and never falls back to the environment. The provider
|
|
340
|
-
* resolves ORACLE_EVM_ADDRESS and friends when no address is passed, which on
|
|
341
|
-
* an anonymous public plane would answer a stranger's request with the
|
|
342
|
-
* operator's own wallet. Reject instead.
|
|
343
|
-
*
|
|
344
|
-
* EVM JSON-RPC cannot enumerate wallet tokens without an address indexer, so
|
|
345
|
-
* this returns native balances and reports token/NFT discovery as unavailable
|
|
346
|
-
* per chain rather than presenting an empty list as a complete portfolio.
|
|
347
|
-
*/
|
|
348
|
-
async function handlePortfolio(body) {
|
|
349
|
-
const b = asPlainObject(body, "body");
|
|
350
|
-
const owner = ownerEvmAddress(b.owner);
|
|
351
|
-
// The provider has supported Solana and Bitcoin all along, but this handler
|
|
352
|
-
// hardcoded { evm: owner }, so a SOL/BTC wallet could never return a balance
|
|
353
|
-
// no matter what the caller sent.
|
|
354
|
-
const solana = optionalSolanaAddress(b.solana);
|
|
355
|
-
const bitcoin = optionalBitcoinAddress(b.bitcoin);
|
|
356
|
-
if (!owner && !solana && !bitcoin) {
|
|
357
|
-
throw new HttpError(400, "owner-required", "owner must be an EVM address (or pass solana/bitcoin)");
|
|
358
|
-
}
|
|
359
|
-
const requested = Array.isArray(b.chainIds) ? b.chainIds.map(Number).filter(Number.isFinite) : undefined;
|
|
360
|
-
if (requested && requested.length > MAX_CHAINS_PER_REQUEST) {
|
|
361
|
-
throw new HttpError(400, "too-many-chains", `at most ${MAX_CHAINS_PER_REQUEST} chainIds per request`);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
const result = await portfolioBalance(
|
|
365
|
-
{
|
|
366
|
-
addresses: { evm: owner, solana, bitcoin },
|
|
367
|
-
evmChainIds: requested,
|
|
368
|
-
includePrices: true,
|
|
369
|
-
includeTokens: true,
|
|
370
|
-
includeCollectibles: false,
|
|
371
|
-
},
|
|
372
|
-
// Empty env: the provider must not read operator addresses from process.env
|
|
373
|
-
// on a public request.
|
|
374
|
-
{ env: {} },
|
|
375
|
-
);
|
|
376
|
-
|
|
377
|
-
const rows = [];
|
|
378
|
-
const chains = [];
|
|
379
|
-
for (const chain of result.chains || []) {
|
|
380
|
-
// Non-EVM families carry the same native/status shape; skipping them here
|
|
381
|
-
// is what made SOL/BTC invisible even when the provider resolved them.
|
|
382
|
-
if (!["evm", "solana", "bitcoin"].includes(chain.family)) continue;
|
|
383
|
-
chains.push({
|
|
384
|
-
chainId: chain.chainId,
|
|
385
|
-
// Without family the app cannot tell a Solana row from an EVM row: both
|
|
386
|
-
// carry a chainId and a symbol.
|
|
387
|
-
family: chain.family,
|
|
388
|
-
name: chain.name,
|
|
389
|
-
status: chain.status,
|
|
390
|
-
error: chain.error ?? null,
|
|
391
|
-
tokenDiscovery: chain.fungibleTokens?.status ?? "unavailable",
|
|
392
|
-
tokenDiscoveryReason: chain.fungibleTokens?.reason ?? null,
|
|
393
|
-
});
|
|
394
|
-
const native = chain.native;
|
|
395
|
-
if (chain.status !== "ok" || !native || native.status !== "ok") continue;
|
|
396
|
-
if (!native.amountRaw || native.amountRaw === "0" || native.amountRaw === "0x0") continue;
|
|
397
|
-
rows.push({
|
|
398
|
-
chainId: chain.chainId,
|
|
399
|
-
family: chain.family,
|
|
400
|
-
chain: chain.name,
|
|
401
|
-
symbol: native.symbol,
|
|
402
|
-
decimals: native.decimals,
|
|
403
|
-
// `amount` MUST be the raw integer. The app's pricing path runs
|
|
404
|
-
// decimalAmount(row.amount, row.decimals), which requires /^\d+$/ and
|
|
405
|
-
// returns null for a human-readable "6.632...". A null there silently
|
|
406
|
-
// drops the row from every USD total.
|
|
407
|
-
amount: String(native.amountRaw),
|
|
408
|
-
amountRaw: String(native.amountRaw),
|
|
409
|
-
amountFormatted: native.amount,
|
|
410
|
-
kind: "native",
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
return {
|
|
415
|
-
status: 200,
|
|
416
|
-
body: {
|
|
417
|
-
ok: true,
|
|
418
|
-
owner: result.addresses?.evm ?? owner,
|
|
419
|
-
queriedAt: result.queriedAt,
|
|
420
|
-
// Nested under `portfolio` because that is the shape the app's data-plane
|
|
421
|
-
// client already parses (rawRows reads value.portfolio.rows).
|
|
422
|
-
portfolio: {
|
|
423
|
-
rows,
|
|
424
|
-
chains,
|
|
425
|
-
coverage: result.coverage,
|
|
426
|
-
// Native-only discovery is a real gap, not a complete picture. Surfaced
|
|
427
|
-
// so the client renders it instead of implying the wallet is empty.
|
|
428
|
-
complete: false,
|
|
429
|
-
incompleteReason:
|
|
430
|
-
"EVM JSON-RPC returns native balances only; token enumeration requires an address indexer",
|
|
431
|
-
},
|
|
432
|
-
warnings: result.warnings,
|
|
433
|
-
},
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* NFT inventory for a caller-supplied owner. Same owner rule as portfolio.
|
|
439
|
-
*/
|
|
440
|
-
async function handleNfts(body) {
|
|
441
|
-
const b = asPlainObject(body, "body");
|
|
442
|
-
const owner = ownerEvmAddress(b.owner);
|
|
443
|
-
if (!owner) throw new HttpError(400, "owner-required", "owner must be an EVM address");
|
|
444
|
-
|
|
445
|
-
const result = await nftInventory({ addresses: { evm: owner } }, { env: {} });
|
|
446
|
-
return {
|
|
447
|
-
status: 200,
|
|
448
|
-
body: {
|
|
449
|
-
ok: true,
|
|
450
|
-
owner,
|
|
451
|
-
queriedAt: result.queriedAt ?? new Date().toISOString(),
|
|
452
|
-
// Nested to match the shape the app's client parses: value.nfts.items
|
|
453
|
-
// plus value.nfts.coverage.
|
|
454
|
-
nfts: {
|
|
455
|
-
items: Array.isArray(result.items) ? result.items : [],
|
|
456
|
-
chains: result.chains ?? [],
|
|
457
|
-
coverage: {
|
|
458
|
-
operational: result.ok !== false,
|
|
459
|
-
complete: result.complete === true,
|
|
460
|
-
hasGaps: result.complete !== true,
|
|
461
|
-
},
|
|
462
|
-
},
|
|
463
|
-
warnings: result.warnings,
|
|
464
|
-
},
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
/** Direct handler access for tests. Not routed; no auth implications. */
|
|
469
|
-
export const handlePortfolioForTest = handlePortfolio;
|
|
470
|
-
export const handleNftsForTest = handleNfts;
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Per-IP rate limiting for the unauthenticated public plane.
|
|
474
|
-
*
|
|
475
|
-
* `/public/approvals` fans a single request out to many upstream RPC calls, so
|
|
476
|
-
* an unthrottled loop against it burns the shared public-RPC quota and the
|
|
477
|
-
* service's own capacity. Cheap reads (health, config) get a loose ceiling;
|
|
478
|
-
* anything that amplifies into upstream work gets a strict one.
|
|
479
|
-
*
|
|
480
|
-
* Fixed-window counters in memory: no dependency, no shared state, and a
|
|
481
|
-
* restart simply forgives. Sufficient for accidental hammering and casual
|
|
482
|
-
* abuse; a real edge/WAF is still the answer for a distributed flood.
|
|
483
|
-
*/
|
|
484
|
-
const RATE_WINDOW_MS = 60_000;
|
|
485
|
-
const RATE_LIMIT_DEFAULT = 120;
|
|
486
|
-
/** Routes whose cost is measured in upstream RPC calls, not CPU. */
|
|
487
|
-
const RATE_LIMIT_AMPLIFYING = 10;
|
|
488
|
-
const AMPLIFYING_ROUTES = Object.freeze(
|
|
489
|
-
new Set(["/public/approvals", "/public/portfolio", "/public/nfts"]),
|
|
490
|
-
);
|
|
491
|
-
const MAX_RATE_ENTRIES = 4096;
|
|
492
|
-
|
|
493
|
-
const rateBuckets = new Map();
|
|
494
|
-
|
|
495
|
-
/** Drop all rate-limit state. Exported for tests. */
|
|
496
|
-
export function clearRateLimits() {
|
|
497
|
-
rateBuckets.clear();
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Identify the caller.
|
|
502
|
-
*
|
|
503
|
-
* Proxy headers are honoured ONLY when the operator opts in via
|
|
504
|
-
* ORACLE_TRUST_PROXY, because a spoofable X-Forwarded-For would otherwise let
|
|
505
|
-
* any client mint a fresh identity per request and bypass the limit entirely.
|
|
506
|
-
*/
|
|
507
|
-
function clientKey(req) {
|
|
508
|
-
if (process.env.ORACLE_TRUST_PROXY === "1") {
|
|
509
|
-
const forwarded = req.headers["x-forwarded-for"];
|
|
510
|
-
if (typeof forwarded === "string" && forwarded.length > 0) {
|
|
511
|
-
const first = forwarded.split(",")[0].trim();
|
|
512
|
-
if (first) return first.slice(0, 64);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
return req.socket?.remoteAddress || "unknown";
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
function rateLimit(req, routePath) {
|
|
519
|
-
const limit = AMPLIFYING_ROUTES.has(routePath) ? RATE_LIMIT_AMPLIFYING : RATE_LIMIT_DEFAULT;
|
|
520
|
-
const now = Date.now();
|
|
521
|
-
const key = `${clientKey(req)}:${AMPLIFYING_ROUTES.has(routePath) ? "amp" : "std"}`;
|
|
522
|
-
|
|
523
|
-
const entry = rateBuckets.get(key);
|
|
524
|
-
if (!entry || now >= entry.resetAt) {
|
|
525
|
-
rateBuckets.set(key, { count: 1, resetAt: now + RATE_WINDOW_MS });
|
|
526
|
-
while (rateBuckets.size > MAX_RATE_ENTRIES) {
|
|
527
|
-
const oldest = rateBuckets.keys().next();
|
|
528
|
-
if (oldest.done) break;
|
|
529
|
-
rateBuckets.delete(oldest.value);
|
|
530
|
-
}
|
|
531
|
-
return { allowed: true, limit, remaining: limit - 1, retryAfterSec: 0 };
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
entry.count += 1;
|
|
535
|
-
if (entry.count > limit) {
|
|
536
|
-
return {
|
|
537
|
-
allowed: false,
|
|
538
|
-
limit,
|
|
539
|
-
remaining: 0,
|
|
540
|
-
retryAfterSec: Math.max(1, Math.ceil((entry.resetAt - now) / 1000)),
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
return { allowed: true, limit, remaining: limit - entry.count, retryAfterSec: 0 };
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const ROUTES = Object.freeze({
|
|
547
|
-
"GET /public/health": handleHealth,
|
|
548
|
-
"GET /public/config": handleConfig,
|
|
549
|
-
"POST /public/connect/request": handleConnectRequest,
|
|
550
|
-
"POST /public/connect/assemble": handleConnectAssemble,
|
|
551
|
-
"POST /public/grants/active": handleGrantsActive,
|
|
552
|
-
"POST /public/grants/get": handleGrantsGet,
|
|
553
|
-
"POST /public/approvals": handleApprovals,
|
|
554
|
-
"POST /public/portfolio": handlePortfolio,
|
|
555
|
-
"POST /public/nfts": handleNfts,
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
function publicHeaders(extra = {}) {
|
|
559
|
-
return {
|
|
560
|
-
"cache-control": "no-store",
|
|
561
|
-
"x-oracle-plane": PUBLIC_PLANE,
|
|
562
|
-
"x-oracle-unsigned": "true",
|
|
563
|
-
...extra,
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
function sendStatic(res, status, contentType, body) {
|
|
568
|
-
res.writeHead(status, publicHeaders({ "content-type": contentType }));
|
|
569
|
-
res.end(body);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Serve allowlisted Oracle console assets only.
|
|
574
|
-
* Returns true if the request was handled (including 404 for missing file).
|
|
575
|
-
*/
|
|
576
|
-
function tryServeStatic(req, res, pathname) {
|
|
577
|
-
if (req.method !== "GET" && req.method !== "HEAD") return false;
|
|
578
|
-
// Keep trailing slash variants resolvable via STATIC_FILES keys.
|
|
579
|
-
const rawPath = pathname === "" ? "/" : pathname;
|
|
580
|
-
const meta = STATIC_FILES[rawPath] || STATIC_FILES[rawPath.replace(/\/+$/, "") || "/"];
|
|
581
|
-
if (!meta) return false;
|
|
582
|
-
|
|
583
|
-
const abs = normalize(join(CONSOLE_DIR, meta.file));
|
|
584
|
-
if (!abs.startsWith(CONSOLE_DIR + sep) && abs !== CONSOLE_DIR) {
|
|
585
|
-
send(res, 404, { error: "not-found", message: "unknown static path" });
|
|
586
|
-
return true;
|
|
587
|
-
}
|
|
588
|
-
if (!existsSync(abs)) {
|
|
589
|
-
send(res, 404, { error: "not-found", message: `missing static file ${meta.file}` });
|
|
590
|
-
return true;
|
|
591
|
-
}
|
|
592
|
-
const body = readFileSync(abs);
|
|
593
|
-
// Static HTML/JS/CSS are not JSON secret-scanned the same way as API bodies;
|
|
594
|
-
// content is repo-authored allowlisted files only.
|
|
595
|
-
if (req.method === "HEAD") {
|
|
596
|
-
res.writeHead(200, publicHeaders({
|
|
597
|
-
"content-type": meta.type,
|
|
598
|
-
"content-length": String(body.length),
|
|
599
|
-
}));
|
|
600
|
-
res.end();
|
|
601
|
-
return true;
|
|
602
|
-
}
|
|
603
|
-
sendStatic(res, 200, meta.type, body);
|
|
604
|
-
return true;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
async function handleRequest(req, res) {
|
|
608
|
-
const url = new URL(req.url, "http://localhost");
|
|
609
|
-
// Preserve a single trailing slash only for static console aliases.
|
|
610
|
-
let pathname = url.pathname || "/";
|
|
611
|
-
if (pathname.length > 1 && pathname.endsWith("/") && pathname !== "/oracle-console/") {
|
|
612
|
-
pathname = pathname.replace(/\/+$/, "");
|
|
613
|
-
}
|
|
614
|
-
if (pathname === "") pathname = "/";
|
|
615
|
-
const routePath = pathname.replace(/\/+$/, "") || "/";
|
|
616
|
-
const key = `${req.method} ${routePath}`;
|
|
617
|
-
const handler = ROUTES[key];
|
|
618
|
-
|
|
619
|
-
try {
|
|
620
|
-
if (!handler) {
|
|
621
|
-
if (tryServeStatic(req, res, pathname)) return;
|
|
622
|
-
const pathKnown = Object.keys(ROUTES).some((k) => k.endsWith(` ${routePath}`));
|
|
623
|
-
if (pathKnown) throw new HttpError(405, "method-not-allowed", `unsupported method for ${routePath}`);
|
|
624
|
-
throw new HttpError(404, "not-found", `unknown route ${routePath}`);
|
|
625
|
-
}
|
|
626
|
-
const gate = rateLimit(req, routePath);
|
|
627
|
-
if (!gate.allowed) {
|
|
628
|
-
res.writeHead(429, publicHeaders({
|
|
629
|
-
"content-type": "application/json",
|
|
630
|
-
"retry-after": String(gate.retryAfterSec),
|
|
631
|
-
"x-ratelimit-limit": String(gate.limit),
|
|
632
|
-
"x-ratelimit-remaining": "0",
|
|
633
|
-
}));
|
|
634
|
-
res.end(JSON.stringify({
|
|
635
|
-
error: "rate-limited",
|
|
636
|
-
message: `too many requests for ${routePath}; retry in ${gate.retryAfterSec}s`,
|
|
637
|
-
}));
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
const body = req.method === "GET" || req.method === "HEAD" ? undefined : await readJsonBody(req);
|
|
642
|
-
// Handlers may be sync or async; await normalizes both so a rejected
|
|
643
|
-
// promise lands in this try/catch instead of escaping as an unhandled
|
|
644
|
-
// rejection with the socket left open.
|
|
645
|
-
const out = await handler(body);
|
|
646
|
-
send(res, out.status, out.body);
|
|
647
|
-
} catch (err) {
|
|
648
|
-
if (err instanceof SecretLeakError) {
|
|
649
|
-
// Never echo the leak path/rule detail either — fixed envelope only.
|
|
650
|
-
send(res, 500, { error: "secret-leak-blocked" });
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
if (err instanceof GrantValidationError) {
|
|
654
|
-
send(res, 400, {
|
|
655
|
-
error: "invalid-grant",
|
|
656
|
-
errors: err.errors.map((e) => ({ field: e.field, message: e.message })),
|
|
657
|
-
});
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
if (err instanceof HttpError) {
|
|
661
|
-
send(res, err.status, { error: err.code, message: err.message });
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
if (err instanceof TypeError) {
|
|
665
|
-
send(res, 400, { error: "bad-request", message: err.message });
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
// Unknown failure: fixed envelope, no internal detail leaves the server.
|
|
669
|
-
send(res, 500, { error: "internal-error" });
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
/** Build (but do not bind) the public HTTP server. */
|
|
674
|
-
export function createPublicServer() {
|
|
675
|
-
return createServer((req, res) => {
|
|
676
|
-
handleRequest(req, res).catch(() => {
|
|
677
|
-
try {
|
|
678
|
-
send(res, 500, { error: "internal-error" });
|
|
679
|
-
} catch {
|
|
680
|
-
/* socket already gone */
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* Resolve host/port: explicit args > ORACLE_PUBLIC_HOST/PORT env (via
|
|
688
|
-
* oracle-env's env() helper) > loopback 127.0.0.1:8799 default.
|
|
689
|
-
* Non-loopback binds fail closed; this plane has no remote peer/origin guard.
|
|
690
|
-
*/
|
|
691
|
-
export function resolvePublicBind({ host, port } = {}) {
|
|
692
|
-
const h = assertLoopbackBindHost(host ?? env("ORACLE_PUBLIC_HOST", "MAD_PUBLIC_HOST", DEFAULT_HOST));
|
|
693
|
-
const rawPort = port ?? env("ORACLE_PUBLIC_PORT", "MAD_PUBLIC_PORT", String(DEFAULT_PORT));
|
|
694
|
-
const p = Number(rawPort);
|
|
695
|
-
if (!Number.isInteger(p) || p < 0 || p > 65535) {
|
|
696
|
-
throw new TypeError(`invalid public port: ${String(rawPort)}`);
|
|
697
|
-
}
|
|
698
|
-
return { host: h, port: p };
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/** Create + bind the public server. Returns the node:http server instance. */
|
|
702
|
-
export function startPublicServer(bind = {}) {
|
|
703
|
-
const { host, port } = resolvePublicBind(bind);
|
|
704
|
-
const server = createPublicServer();
|
|
705
|
-
server.listen(port, host);
|
|
706
|
-
return server;
|
|
707
|
-
}
|