/** * @file Content-addressed blob fetching for socketusercontent.com (or a * compatible host). Lives outside the generated SocketSdk class because the * blob CDN is not part of the api.socket.dev OpenAPI surface — it is a * separate content store keyed by hash. Handles single-blob (`Q`-prefixed) * and chunked (`S`-prefixed) hashes: a chunked blob is reconstructed from the * manifest stored at its `Q`-swapped hash. Returns decoded text when the * bytes are valid UTF-8 without NULs, otherwise flags the result as binary so * callers can refuse to forward it to a model. */ export interface BlobResult { binary: boolean; bytes: number; contentType: string | undefined; text: string; truncated: boolean; } export interface ChunkedFetchResult { bytes: Uint8Array; totalSize: number; } export interface FetchBlobOptions { baseUrl: string; extraHeaders?: Record | undefined; maxBytes?: number | undefined; maxResponseBytes?: number | undefined; onRequest?: ((url: string) => void) | undefined; userAgent?: string | undefined; verifyHash?: boolean | undefined; } export interface RawFetchResult { bytes: Uint8Array; contentType: string | undefined; } export interface ChunkedManifest { _version?: string | undefined; chunks?: unknown | undefined; offset?: unknown | undefined; size?: number | undefined; } /** * Compute the content-address of `bytes` under Socket's blob hash scheme: `Q` + * base64url(sha256(bytes)). */ export declare function blobHashOf(bytes: Uint8Array): string; /** * Fetch a content-addressed blob by hash. Single-blob (`Q`) hashes resolve to * one GET; chunked (`S`) hashes are reconstructed from their manifest. Bytes * beyond `maxBytes` (default 1 MB) are dropped and `truncated` is set. */ export declare function fetchBlob(hash: string, options: FetchBlobOptions): Promise; /** * Resolve an `S`-prefixed chunked blob: fetch the manifest at the `Q`-swapped * hash, then fetch the listed chunks and concatenate them. Honors `maxBytes` by * stopping at the first chunk past the cap (using the manifest's `offset` array * when present, otherwise running totals). */ export declare function fetchChunkedBytes(sHash: string, options: FetchBlobOptions, maxBytes: number): Promise; /** * Single GET against `/blob/`. No prefix logic — callers pass an * already-resolved hash (manifest hash, chunk hash, or single blob). */ export declare function fetchRawBytes(hash: string, options: FetchBlobOptions): Promise; /** * Decode bytes as UTF-8 in fatal mode to detect binary content. Returns * undefined when the bytes are not valid UTF-8 or contain a NUL byte (a typical * binary marker). */ export declare function tryDecodeText(bytes: Uint8Array): string | undefined; /** * Throw if `bytes` does not content-address to `hash`. `S`-prefixed (file- * stream) hashes share the digest body with their `Q` form, so both verify * against the same sha256; any other prefix is treated as a `Q`-style hash. */ export declare function verifyBlobHash(hash: string, bytes: Uint8Array): void;