/** * Bitcoin provider auth (LIT Action side). * * The BitcoinProviderRegistry stores one encrypted blob per * `(chainId, providerId)`. Historically that blob was a bare Esplora base URL. * To support commercial providers that require credentials, the blob may now be * a JSON object: * * { "provider": "esplora", "url": "https://blockstream.info/api" } * { "provider": "maestro", "url": ".../v0/esplora", "apiKey": "..." } * { "provider": "blockstream-enterprise", "url": ".../api", * "clientId": "...", "clientSecret": "...", "tokenUrl"?: "..." } * * Secrets only ever materialize HERE, inside the running LIT Action (the blob is * decrypted in-TEE). They are never in jsParams, on-chain plaintext, or the * bundle. * * Backward compatibility: a legacy plaintext that is a bare URL (does not parse * as a JSON object with a string `url`) is treated as * `{ provider: "esplora", url }` — existing registry entries keep working * without re-encryption. */ export type ProviderAuth = { provider: "esplora"; } | { provider: "maestro"; apiKey: string; } | { provider: "blockstream-enterprise"; clientId: string; clientSecret: string; tokenUrl?: string; }; export interface ParsedProvider { /** Esplora base URL (no trailing slash; paths are concatenated onto it). */ url: string; /** Auth descriptor used to build request headers. */ auth: ProviderAuth; } /** Options for {@link parseProviderPlaintext}. */ export interface ParseProviderOptions { /** * Require `https://` for EVERY provider type, including credential-less * esplora and legacy bare URLs. Registry call sites set this whenever * `!policy.allowArbitraryBitcoinProvider` (sepolia/mainnet) — a plain-http * provider there hands an on-path attacker the balance feed the PKP signs * over (finding #3). Hardhat/regtest bypasses the registry entirely, so the * local `http://` daemon keeps working. */ requireHttps?: boolean; } /** * Parse a decrypted provider plaintext into `{ url, auth }`. * * Accepts either a JSON object (when the trimmed plaintext starts with `{` and * has a non-empty string `url`) or a legacy bare URL string. Throws on a JSON * object that is missing `url` or required credentials for its provider type. * Credentialed provider types (maestro / blockstream-enterprise) ALWAYS * require https; `opts.requireHttps` extends that to esplora/bare URLs. */ export declare function parseProviderPlaintext(plaintext: string, opts?: ParseProviderOptions): ParsedProvider; /** * Resolve the HTTP headers to attach to an Esplora request for the given auth. * * - `esplora` (or undefined) → no auth headers * - `maestro` → `{ "api-key": }` * - `blockstream-enterprise` → OAuth client-credentials exchange → `Authorization: Bearer ` */ export declare function authHeaders(auth: ProviderAuth | undefined, timeoutMs?: number): Promise>; /** * Auth-aware GET with an END-TO-END timeout budget. * * A request to an authenticated provider has two sequential network legs — the * OAuth token exchange (Blockstream Enterprise) and the data request itself. * Bounding each leg independently would let a single logical request run up to * `2 × timeoutMs`, which can collide with Lit's ~30s execution limit. Instead we * pin one deadline at the start: the token exchange is bounded by `timeoutMs`, * and the data fetch only gets the REMAINING time. Total wall-time ≤ `timeoutMs`. * * Maestro/esplora have no token leg, so the data fetch gets ~the full budget. * Returns the raw fetch Response; callers handle `.ok` / `.json()` as today. */ export declare function authedFetch(url: string, auth: ProviderAuth | undefined, timeoutMs: number): Promise; //# sourceMappingURL=bitcoin-provider-auth.d.ts.map