/** * CESR-over-HTTP request helpers. * * Mailbox and exchange interop depends on getting this boundary right. * * KERIpy correspondence: * - default behavior is one CESR message per HTTP request with the message body * in the request body and attachments in `CESR-ATTACHMENT` * * Current `keri-ts` difference: * - `keri-ts` supports an optional `"body"` mode for mailbox operations where the * full CESR payload is sent in the body instead of splitting attachments into * the header */ import { SerderKERI } from "../../../cesr/mod.js"; /** Mailbox HTTP framing modes supported by `keri-ts`. */ export type CesrBodyMode = "header" | "body"; /** Default interop mode matching KERIpy mailbox behavior. */ export declare const DEFAULT_CESR_BODY_MODE: CesrBodyMode; /** CESR HTTP content type used by mailbox and exchange endpoints. */ export declare const CESR_CONTENT_TYPE = "application/cesr"; /** KERIpy's legacy-but-authoritative CESR HTTP media type. */ export declare const KERIPY_CESR_JSON_CONTENT_TYPE = "application/cesr+json"; /** Multipart form content type retained for mailbox-admin compatibility. */ export declare const MULTIPART_CONTENT_TYPE = "multipart/form-data"; /** Header that carries detached CESR attachments in header mode. */ export declare const CESR_ATTACHMENT_HEADER = "CESR-ATTACHMENT"; /** Header naming the intended recipient endpoint AID when needed. */ export declare const CESR_DESTINATION_HEADER = "CESR-DESTINATION"; /** Return true when one HTTP content type names CESR payload framing. */ export declare function isCesrContentType(value: string | null | undefined): boolean; /** Return true when one HTTP content type names multipart form media. */ export declare function isMultipartFormContentType(value: string | null | undefined): boolean; /** Normalized mailbox-admin request after content-type-specific parsing. */ export interface MailboxAdminRequest { readonly bytes: Uint8Array; readonly inspection: CesrStreamInspection; } /** Parsed CESR stream plus its terminal message for callers that need both. */ export interface CesrStreamInspection { readonly messages: readonly SerderKERI[]; readonly terminal: SerderKERI | null; } /** Normalize CLI or config input into one supported CESR body mode. */ export declare function normalizeCesrBodyMode(value: unknown, fallback?: CesrBodyMode): CesrBodyMode; /** Normalize a global config string into one supported CESR body mode. */ export declare function cesrBodyModeFromGlobal(value: string | null | undefined): CesrBodyMode; /** * Build one HTTP request payload for a CESR message. * * Header mode: * - HTTP body carries the message body only * - `CESR-ATTACHMENT` carries the detached attachments * * Body mode: * - the full payload is sent in the HTTP body */ export declare function buildCesrRequest(message: Uint8Array, { bodyMode, contentType, destination, }?: { bodyMode?: CesrBodyMode; contentType?: string; destination?: string; }): { headers: Record; body: ArrayBuffer; }; /** * Build one raw CESR-body HTTP request. * * This is the right helper for endpoints that accept an already assembled CESR * payload or a multi-message CESR stream in the body. */ export declare function buildCesrStreamRequest(bytes: Uint8Array, { destination, }?: { destination?: string; }): { headers: Record; body: ArrayBuffer; }; /** * Split one CESR JSON message stream into individual request-ready messages. * * KERIpy correspondence: * - mirrors `streamCESRRequests(...)`, which posts one message body plus its * attachments per HTTP request instead of shoving a whole multi-message * stream behind one `CESR-ATTACHMENT` header */ export declare function splitCesrStream(message: Uint8Array): Uint8Array[]; /** * Reconstruct one logical CESR payload from an incoming HTTP request. * * In header mode this reattaches `CESR-ATTACHMENT` bytes to the parsed message * body so downstream parsing always sees the canonical CESR byte stream. */ export declare function readCesrRequestBytes(req: Request): Promise; /** * Read one direct signed-KERI ingress request. * * Endpoints that accept existing signed KERI material should use this helper * instead of hand-rolling JSON or form-data wrappers around CESR bytes. * * Returns `null` when the request is not CESR-framed at all. */ export declare function readRequiredCesrRequestBytes(req: Request): Promise; /** * Read one mailbox-admin request from either raw CESR or multipart fields. * * Multipart compatibility contract: * - `kel`: required controller replay * - `delkel`: optional delegation replay * - `rpy`: required mailbox authorization reply */ export declare function readMailboxAdminRequest(req: Request): Promise; /** Parse and return the first CESR message in one request body. */ export declare function inspectCesrRequest(bytes: Uint8Array): SerderKERI | null; /** Parse and return the final CESR message in one request body. */ export declare function inspectCesrTerminalMessage(bytes: Uint8Array): SerderKERI | null; /** Parse one entire CESR request body and return every message plus the last. */ export declare function inspectCesrStream(bytes: Uint8Array): CesrStreamInspection; //# sourceMappingURL=cesr-http.d.ts.map