/** * @fileoverview RFC 9421 + RFC 9530 request-binding profile: sign and verify. * * ── PROOF BOX ────────────────────────────────────────────────────────────── * What a valid request-binding proof PROVES: * The signer, holding the private key for the named DID verification method, * authorized this exact HTTP request (method, authority, path, and, when * content-digest is covered, body bytes) at the signing time `created`. * * What it does NOT prove: * - It does NOT show the request reached its destination, was acted on, or * produced any effect. It binds intent at signing time, not delivery. * - It does NOT, by itself, show authority. Authority is established by the APS * delegation receipt linked via `receiptHash`. The HTTP signature shows * "this exact request was the one authorized"; the APS layer shows the * signer was authorized to make it. * - action_ref does NOT bind the HTTP request and is not used here. The link * between this request and a delegation receipt is the content hash carried * in `receiptHash`, plus the inner HTTP Message Signature (not action_ref). * - A covered content-digest binds the body ONLY if the verifier recomputes * the digest over received bytes and byte-compares. content-digest alone, * unsigned or unrecomputed, shows nothing about the body. * ─────────────────────────────────────────────────────────────────────────── * * This module composes the byte-exact serialization in signature-base.ts with * the existing Ed25519 sign/verify primitives. It does not reimplement crypto * and it does not touch the APS receipt-signing path, the action_ref preimage, * or canonical-jcs. * * Reference scope: this is a protocol primitive plus a reference verifier. The * nonce store is an in-memory reference implementation behind an interface; a * production replay cache is a deployment concern and is out of scope. */ import type { CoveredComponent, RequestBindingProfile, RequestContext, SignatureParams, SignerKey, VerifierKey, VerifyPolicy, VerifyResult } from './types.js'; import type { ScopeOfClaim } from '../../accountability/types/base.js'; /** Fixed profile tag for this version. Scopes signatures to this profile. */ export declare const APS_REQUEST_BINDING_TAG = "aps-rfc9421-request-binding-v1"; /** Fixed profile identifier. */ export declare const APS_REQUEST_BINDING_PROFILE: "aps:rfc9421-request-binding:v1"; /** Default covered components for request binding (RFC 9421 §7.2.1 minimum). */ export declare const DEFAULT_COVERED: CoveredComponent[]; /** * Default honest scope declaration for a request-binding profile. Callers * SHOULD override `does_not_assert` with delegation-specific context, but the * floor below is always true for this primitive. */ export declare function defaultScopeOfClaim(): ScopeOfClaim; export interface SignRequestInput { request: RequestContext; signer: SignerKey; /** created, nonce, and any overrides. keyid defaults to the signer VM. */ params: Omit & { keyid?: string; tag?: string; }; /** Covered components in signed order. Defaults to DEFAULT_COVERED. */ covered?: CoveredComponent[]; /** Structured-Fields label for this signature. Defaults to 'aps'. */ label?: string; /** Content hash of the linked APS delegation receipt (hex sha-256). */ receiptHash?: string; /** Override the scope-of-claim. Defaults to defaultScopeOfClaim(). */ scopeOfClaim?: ScopeOfClaim; } /** * Sign a request, producing a RequestBindingProfile whose inner proof is a * byte-exact RFC 9421 HTTP Message Signature. */ export declare function signRequest(input: SignRequestInput): RequestBindingProfile; /** * A pluggable replay store. The verifier records and checks nonces. This is the * interface; production stores (shared, persistent, cross-tenant) are out of * scope. A reference in-memory store is provided. */ export interface NonceStore { /** Returns true if the nonce was already seen (i.e. a replay). */ seen(nonce: string): boolean; /** Records the nonce as seen. */ record(nonce: string): void; } /** Reference in-memory nonce store. Not a service; for tests and local use. */ export declare class InMemoryNonceStore implements NonceStore { private readonly set; seen(nonce: string): boolean; record(nonce: string): void; } export interface VerifyRequestInput { /** The profile artifact carried with the request. */ profile: RequestBindingProfile; /** The request as received, for independent base reconstruction. */ request: RequestContext; /** Verifier key(s) keyed by verification method. */ keys: VerifierKey[]; /** Acceptance policy. */ policy: VerifyPolicy; /** Optional replay store. When provided, replayed nonces are rejected. */ nonceStore?: NonceStore; } /** * Verify a request against a profile. Performs, in order: covered-set safety, * required-component presence, tag match, freshness (created within skew), * key resolution, content-digest recomputation (when covered), independent base * reconstruction and byte-compare, Ed25519 signature check, and replay check. * * Verification is fail-closed: any check that does not pass returns valid:false * with a precise reason and does NOT consume the nonce. */ export declare function verifyRequest(input: VerifyRequestInput): VerifyResult; //# sourceMappingURL=profile.d.ts.map