UNPKG

@provablehq/sdk

Version:

A Software Development Kit (SDK) for Zero-Knowledge Transactions

45 lines (44 loc) 2.44 kB
export declare function isNode(): boolean; export declare function environment(): "chrome" | "firefox" | "safari" | "edge" | "opera" | "browser" | "node" | "unknown"; export declare function logAndThrow(message: string): never; /** * A function matching the global `fetch` signature. Consumers can provide * their own implementation to inject custom HTTP agents, mTLS certificates, * timeouts, or logging. */ export type TransportFunction = typeof fetch; /** Default transport — wraps global fetch to avoid illegal-invocation errors in browsers. */ export declare const defaultTransport: TransportFunction; /** * Opt-in transport that layers a per-origin cookie jar on top of `fetch`. * * Not wired in by default — pass it explicitly as the `transport` option to * `AleoNetworkClient`, `RecordScanner`, `AleoKeyProvider`, etc. (or to the * `get`/`post` helpers) when talking to a backend that uses cookie-based * session affinity. Browsers and iOS NSURLSession persist cookies on their own, * so this is targeted at Node and bare React Native consumers. * * Wraps the global `fetch` (avoiding illegal-invocation errors in browsers when * `fetch` is passed around as a bare reference) and layers a per-origin cookie * jar on top. Responses' `Set-Cookie` headers are captured (filtered by * `AFFINITY_COOKIE_NAMES`) and replayed as a `Cookie` header on subsequent * same-origin requests, which is required for backends that use cookie-based * session affinity (see `cookieJar` above). * * A caller-supplied `Cookie` header is never overwritten — `network-client.ts` * forwards the pubkey-response cookie manually onto delegated-prove requests * for Node compatibility, and that path takes precedence over the jar. */ export declare const cookieAffinityTransport: TransportFunction; export declare function parseJSON(json: string): any; export declare function get(url: URL | string, options?: RequestInit, transport?: TransportFunction): Promise<Response>; export declare function post(url: URL | string, options: RequestInit, transport?: TransportFunction): Promise<Response>; type RetryOptions = { maxAttempts?: number; baseDelay?: number; jitter?: number; retryOnStatus?: number[]; shouldRetry?: (err: any) => boolean; }; export declare function retryWithBackoff<T>(fn: () => Promise<T>, { maxAttempts, baseDelay, jitter, retryOnStatus, shouldRetry, }?: RetryOptions): Promise<T>; export {};