export interface ClientOptions { /** Base URL of the CRM gateway, e.g. `https://api.example.com`. */ gatewayUrl: string; /** Ecosystem client id; sent as the `client-id` header on every call. */ clientId: string; /** Ecosystem bearer token, or a function resolving one per request. */ authToken: string | (() => string | Promise); /** * Value for the `origin` header. Browsers set this themselves and ignore any * override, so it is only needed on Node — where the gateway rejects the call * without it. Defaults to the page origin when running in a browser. */ origin?: string; /** Custom fetch implementation; defaults to the global one. */ fetch?: typeof fetch; /** Request timeout in milliseconds. Defaults to 30s. */ timeoutMs?: number; } export interface RequestInitOptions { /** Serialised as JSON unless `raw` is set. */ body?: unknown; query?: Record; /** * Request body sent verbatim, for the endpoints that take file bytes rather * than JSON. Takes precedence over `body`. */ raw?: BodyInit; /** Overrides `content-type`; required alongside `raw`. */ contentType?: string; } export declare class HttpClient { private readonly options; private readonly gatewayUrl; constructor(options: ClientOptions); /** * The fetch this client was built with, bound to the global object. * * Exposed for the one call that must not go through `request`: a presigned * upload goes straight to object storage, and sending our bearer token or an * extra header with it would both leak the credential to a third party and * break a signature that covers exactly the headers it was issued for. * * Bound, and that is not tidiness. A browser's `fetch` is a method of `Window` * and refuses any other receiver -- so reading it off this getter and calling it * as `client.fetchImpl(url)` invokes it with the `HttpClient` as `this` and * fails with `Illegal invocation`. Binding here makes the property safe to call * however it is reached, rather than leaving every call site to remember. */ get fetchImpl(): typeof fetch; /** Resolves the bearer token, failing here rather than sending an unauthenticated call. */ private token; request(method: string, path: string, init?: RequestInitOptions): Promise; }