import type { AgentProposal, JsonObject, JsonValue } from "@decionis/agent-safe-pipeline"; import type { ConsequentialMethod } from "./GatewayConfig.js"; /** One request as the listener hands it over: read in full, bounded, and not yet interpreted. */ export interface InterceptedRequest { readonly method: string; /** The path alone; the query is carried separately. */ readonly path: string; readonly search: string; /** Header names in lower case, values joined the way Node joins them. */ readonly headers: Readonly>; readonly body: Buffer; readonly remoteAddress: string | null; readonly encrypted: boolean; } /** The held HTTP request and operator policy selectors, bound together for the authority. */ export interface HttpActionParameters extends JsonObject { method: ConsequentialMethod; path: string; query: { [key: string]: string | string[]; }; body?: JsonValue; policy_id?: string; policy_version?: string; } /** * A facts-only HTTP action's parameters: the profile operation and its path * template, never the path, query or body the request carried. The handler * forwards the held request, bound by the keyed digest in the context. */ export interface HttpFactsParameters extends JsonObject { method: ConsequentialMethod; operation: string; path_template: string; } /** What the intent's context carries about the body: its digest, size and kind, never its bytes. */ export interface HttpActionContext extends JsonObject { readonly request_sha256: string; readonly body_sha256: string; readonly body_bytes: number; readonly content_type: string | null; readonly body_embedded: boolean; } export interface NormalizedAction { readonly proposal: AgentProposal; readonly context: HttpActionContext & JsonObject; readonly idempotencyKey: string | null; readonly correlationId: string | null; readonly principal: string | null; } /** SHA-256 over the bytes, in the contract's `sha256:` form. */ export declare function bodyDigest(body: Uint8Array): `sha256:${string}`; /** * Binds the complete held request, including raw query spelling and header * values, without disclosing those headers to the authority. Framed metadata * precedes the bytes; sorting header names makes object insertion order immaterial. */ export declare function requestDigest(request: InterceptedRequest): `sha256:${string}`; /** * The same binding as `requestDigest`, keyed: an HMAC-SHA-256 under a key * that never leaves the gateway process. Facts-only privacy sends this in * place of the plain digests, which a reader holding a guess of a small body * or a path could confirm; the keyed one confirms nothing to anyone without * the key, and still binds the held request to the grant byte for byte. */ export declare function keyedRequestDigest(request: InterceptedRequest, key: Uint8Array): `hmac-sha256:${string}`; /** * What a client's idempotency key promises: one operation, named by its * method, path, query, content type and body bytes. Unlike `requestDigest` * it leaves out the other headers and the caller's address, which a retry * from another egress, or with a new trace id, changes without changing * the operation. Kept only by the gateway, never sent to the authority. */ export declare function retryDigest(request: InterceptedRequest): `sha256:${string}`; /** The client's `Idempotency-Key` as the intent would state it, or null when absent, empty or over the bound. */ export declare function idempotencyKeyOf(request: InterceptedRequest): string | null; /** * Turns an intercepted request into the agent's part of an intent. The * proposal is method, path, query and, when the body is JSON within the * embedding limit, the body itself, so policy can see the fields it decides * on. The context binds the raw bytes by digest whether or not they were * embedded, which is what the forwarding handler checks before dispatch. * Raw request headers never reach the authority. Their digest binds their * meaning along with the exact query and bytes for the final dispatch check. * Policy selectors come only from the matched operator route, never from * the caller's body, query or headers. They are bound before intent hashing * and do not change the request forwarded to the upstream. */ export declare function normalizeRequest(request: InterceptedRequest, action: string, options: { readonly maxEmbeddedBodyBytes: number; readonly principalHeader: string | null; readonly policyId?: string; readonly policyVersion?: string; }): NormalizedAction; /** * The agent's part of an intent in facts-only privacy: the profile operation * that names the call, its path template, and nothing the request carried. * The context binds the held request by its keyed digest. The client's * idempotency key is a header value, so it is keyed too: a retry through the * same gateway process states the same key, and the value never leaves. A * correlation id and a principal header are not carried at all. */ export declare function normalizeFacts(request: InterceptedRequest, action: string, operation: { readonly id: string; readonly path: string; }, key: Uint8Array): NormalizedFacts; export interface NormalizedFacts { readonly proposal: AgentProposal; readonly context: { readonly request_hmac_sha256: string; }; readonly idempotencyKey: string | null; } //# sourceMappingURL=InterceptedRequest.d.ts.map