/** * @fileoverview Chainweb HTTP client - allowlisted fetch + header-encoding * * Thin layer over `createAllowlistedFetch` from mcp-shared. Every chainweb * HTTP endpoint MUST be accessed through this module so that: * 1. origin validation happens exactly once at construction, * 2. the binary-vs-JSON header-encoding trap for `/chain/:id/header` is * enforced by routing through {@link getBlockHeader}, * 3. non-2xx responses surface as McpToolError (not generic exceptions). */ export interface ChainwebClientConfig { /** e.g. `http://localhost:8081` — already validated against the allowlist. */ baseUrl: string; /** Network id (e.g. `development`). */ networkId: string; /** Primary allowlisted origins (production set). */ allowedOrigins: string[]; /** * Programmatic test-only override that adds extra allowed origins (used to * point the client at a 127.0.0.1:{ephemeral} mock server during unit * tests). NEVER honored from env variables in production callers. */ additionalAllowedOrigins?: string[]; } export interface ChainwebClient { /** Raw GET — returns parsed JSON on 2xx, throws McpToolError on non-2xx. */ getJson(pathAndQuery: string, init?: RequestInit): Promise; /** Raw POST (JSON body) — returns parsed JSON on 2xx, throws on non-2xx. */ postJson(pathAndQuery: string, body: unknown, init?: RequestInit): Promise; /** * Fetch a block header with the CORRECT Accept header. The default * `application/json` returns base64 binary — documented devnet bug. */ getBlockHeader(chainId: string, blockHash: string): Promise; /** For diagnostics/tests only: inspect the base URL. */ readonly baseUrl: string; readonly networkId: string; } /** * Construct a chainweb HTTP client with an allowlisted fetch. * * The base URL origin MUST be present in `allowedOrigins` (or in * `additionalAllowedOrigins` when provided by test harness). We re-validate * here — defence in depth vs. a caller that forgot to cross-check. */ export declare function createChainwebClient(cfg: ChainwebClientConfig): ChainwebClient; //# sourceMappingURL=fetch.d.ts.map