import type { SecretHandle } from "../secrets/SecretHandle.js"; import type { DownstreamCredential, DownstreamRequest } from "./DownstreamCredential.js"; export type SignedRequestAlgorithm = "ed25519" | "hmac-sha256"; export interface SignedRequestOptions { readonly algorithm: SignedRequestAlgorithm; readonly keyId: string; } /** Covered on every request: what was sent, to where, for which intent. */ export declare const BASE_COMPONENTS: readonly ["@method", "@path", "content-digest", "idempotency-key", "x-agent-safe-intent-hash"]; /** Covered on a dispatch: which grant, and which decision, this request executes under. */ export declare const GRANT_COMPONENTS: readonly ["x-agent-safe-grant-id", "x-agent-safe-decision-id"]; /** Covered when the authority attested the claim: its proof, bound to this request. */ export declare const ATTESTATION_COMPONENT: "x-agent-safe-claim-attestation"; /** Every component this credential can cover, in the order the base lists them. */ export declare const SIGNED_COMPONENTS: readonly ["@method", "@path", "content-digest", "idempotency-key", "x-agent-safe-intent-hash", "x-agent-safe-grant-id", "x-agent-safe-decision-id", "x-agent-safe-claim-attestation"]; export type SignedComponent = (typeof SIGNED_COMPONENTS)[number]; export declare const SIGNATURE_LABEL = "agentsafe"; /** What a verifier on the downstream side needs to rebuild the base. */ export interface SignedRequestMaterial { readonly method: string; readonly path: string; readonly body: string | null; readonly idempotencyKey: string; readonly intentHash: string; readonly grantId?: string; readonly decisionId?: string; readonly claimAttestation?: string; } /** What a downstream may insist the signature cover before it acts. */ export interface SignedRequestVerification { /** * Components that must be among the covered ones. A system of record that * effects anything requires the grant pair and the attestation; a read that * effects nothing may accept the base alone. The base is always required. */ readonly require?: readonly SignedComponent[]; } /** * RFC 9421 HTTP message signatures with an RFC 9530 content digest. The base * always covers the method, the path, the body's digest, the idempotency key * and the intent hash, so the downstream can prove that this process, * holding this key, sent this request for this intent. A dispatch also * covers the grant id and the decision id, and, when the authority attested * the claim, the attestation itself: then the downstream can prove that the * authority claimed this grant for this intent, which is the difference * between refusing an unsigned instruction and refusing an unauthorized one. * * `signature-input` names exactly what was covered, and the verifier rebuilds * from that rather than from a fixed list: a request that carries a grant * header the signature does not cover proves nothing about that grant. The * handler must send every covered header with the value it asked the * credential to sign; the reference handlers do. Ed25519 or HMAC-SHA256; * the key is a secret handle read at each request. */ export declare class SignedRequestCredential implements DownstreamCredential { private readonly options; private readonly key; private readonly clock; readonly kind: "SIGNED_REQUEST"; constructor(options: SignedRequestOptions, key: () => SecretHandle, clock?: () => number); /** The RFC 9530 digest of a body, the empty body included. */ static contentDigest(body: string | null): string; /** The components this material can cover, in base order. */ static componentsFor(material: SignedRequestMaterial): readonly SignedComponent[]; /** The signature parameters, as they appear in `signature-input` and at the base's end. */ static parameters(created: number, keyId: string, algorithm: SignedRequestAlgorithm, components?: readonly SignedComponent[]): string; /** The covered components a `signature-input` names, or null when it names one this credential does not know. */ static coveredComponents(parameters: string): readonly SignedComponent[] | null; /** One line of the base, or null when the material cannot supply the component. */ private static line; /** * The signature base, exactly as both sides must build it: one line per * covered component in the order `parameters` lists them, then the * parameters. Null when the parameters name a component the material does * not have, which on the signing side is a bug and on the verifying side * is a request that does not carry what its signature claims to cover. */ static base(material: SignedRequestMaterial, parameters: string): string | null; /** * What the downstream runs: read which components the signature covers, * refuse if any it requires is missing, rebuild the base from the request * it received, then check the signature with the public key (Ed25519) or * the shared secret (HMAC-SHA256). The base five are always required; a * system of record passes the grant pair and the attestation too. * * The base is built from `material`, which is what the downstream will act * on. A header that says something else is not checked separately: if the * two disagree, the base differs from the one that was signed and the * signature fails, which is the refusal that matters. */ static verify(material: SignedRequestMaterial, headers: Readonly>, verifier: { readonly publicKeyPem: string; } | { readonly secret: Uint8Array; }, verification?: SignedRequestVerification): boolean; /** * The material a downstream rebuilds from the request it received. The * grant fields come from the headers only when present, so a request that * carries none is verified against the base and refused by a downstream * that requires more. */ static materialFrom(received: { readonly method: string; readonly path: string; readonly body: string | null; readonly headers: Readonly>; }): SignedRequestMaterial; /** The headers a handler must send beside the signature, with the values the signature covers. */ static coveredHeaders(request: DownstreamRequest): Readonly>; headersFor(request: DownstreamRequest): Promise>>; } //# sourceMappingURL=SignedRequestCredential.d.ts.map