/** * The one place a LIT Action turns an RPC URL into an ethers connection. * * dRPC authenticates either with the key in the URL (`?dkey=`) or with a * `Drpc-Key` header on a keyless URL. ethers puts the request URL into every * provider error, and a LIT Action's errors travel back through Chipotle into * server logs and API responses — so a keyed URL is a key in every failed read. * The header form keeps the key out of the URL, and therefore out of the errors. * * The caller supplies the key as the `drpcKey` jsParam. It is a secret aimed at * one provider, so this module only ever attaches it to a dRPC host: the host * check sits in `evmRpcConnection`, where the header is built, so no code path * can send the key anywhere else, and only over https. A keyed `?dkey=` URL is * still accepted on its own (callers move over after the new CIDs are live), but * its key is moved into the header too; sending both is refused. */ /** dRPC's header for the API key. */ export declare const DRPC_KEY_HEADER = "Drpc-Key"; /** The ethers v5 `ConnectionInfo` subset the actions use. */ export interface EvmRpcConnection { url: string; headers?: Record; timeout?: number; } /** * Validate a caller-supplied `drpcKey` against the RPC URL it will authenticate. * * Returns `undefined` when no key was supplied. Throws when the key is malformed, * when `rpcUrl` is not an https dRPC URL, or when `rpcUrl` already carries * `?dkey=`. Call it right after the URL itself has been validated, so a bad key * fails the action before any read. */ export declare function resolveDrpcKey(rpcUrl: string, drpcKey: unknown): string | undefined; /** * The Lit node's own RPC endpoint for `chain` — the fallback when the caller * sent no `rpcUrl`. A `drpcKey` authenticates the caller's dRPC URL only, so it * is refused here rather than attached to an endpoint the caller did not choose * (which may itself be a dRPC host). */ export declare function litNodeRpcUrl(chain: string, drpcKey: unknown): Promise; /** * The ethers connection for `rpcUrl`: the dRPC key, if any, goes in the * `Drpc-Key` header. Re-validates the key here so the header can only ever be * attached to an https dRPC URL, whatever the call site did before. * * A legacy keyed dRPC URL (`?dkey=`) is still accepted, but its key is * moved out of the URL into the header, so a failed read's error carries a * keyless URL either way. A `dkey` on a non-dRPC host, or more than one `dkey`, * is refused rather than passed through. */ export declare function evmRpcConnection(rpcUrl: string, drpcKey?: string, timeout?: number): EvmRpcConnection; //# sourceMappingURL=evm-rpc.d.ts.map