import type { JsonValue } from "@decionis/agent-safe-pipeline"; /** * The Verifying Provider Profile (`docs/authority/verifying-provider.md`), as * a provider runs it: the reference for VP-1 and VP-2. Everything the profile * numbers is a step here, in the profile's order, and the first failing step * names the refusal. The signature half is `SignedRequestCredential.verify`, * unchanged; this adds what a provider does around it: the freshness window, * the key registry, the attestation, the canonical body digest, the single * presentation of a grant, and the target's state version the grant was * decided against. It is held to the same mutation gate, * because a mutant that accepts what it should refuse is a provider that * effects what the authority never claimed. */ export type ProviderRefusalCode = "SIGNATURE_INVALID_OR_INCOMPLETE" | "ATTESTATION_INVALID" | "ATTESTATION_DOES_NOT_DESCRIBE_THIS_REQUEST" | "GRANT_REPLAYED" | "TARGET_STATE_CHANGED"; export declare const ATTESTATION_TYPE = "decionis-claim-attestation+jwt"; export declare const JCS_PROFILE = "RFC8785/JCS"; /** A key the provider issued to, or registered for, the executor, by the `keyid` a signature names. */ export type ExecutorKey = { readonly keyId: string; readonly algorithm: "ed25519"; readonly publicKeyPem: string; } | { readonly keyId: string; readonly algorithm: "hmac-sha256"; readonly secret: Uint8Array; }; /** * The claims of an attestation, as far as the provider reads them; the * authority's schema has more. The dossier, the claim-token digest and the * attestation's own id are what a receipt (VP-3) is built from, so a * provider that effects has them in hand. */ export interface ClaimAttestationClaims { readonly iss: string; readonly sub: string; readonly decision_id: string; readonly dossier_id: string; readonly binding: { readonly intent_hash: string; readonly execution_payload_digest: string; readonly execution_payload_canonicalization_profile: string; /** * The target's version the grant was decided against, when it names one: * the precondition of the write, compared as a strong `If-Match` is. */ readonly expected_state_version?: string; }; readonly claim_token_digest: string; readonly jti: string; readonly exp: number; } /** * The target a request would change, as the provider reads it under the lock * its effect takes: its version now, or null when it no longer exists. A * provider that cannot read it before effecting passes none, and applies the * attestation's `expected_state_version` as its write's own precondition. */ export interface ProviderTarget { readonly version: string | null; } /** * Where a provider keeps the grants it accepted, until their attestation * expires. `record` answers true when the grant was not there and is now, * false when it was: the second presentation. Shared by every instance that * can effect; the profile's step 8. */ export interface ReplayStore { record(grantId: string, expiresAtMs: number): boolean; } export interface VerifyingProviderOptions { /** Whether this endpoint effects anything. An effecting provider requires all eight components. */ readonly effects: boolean; /** Unique by `keyId`; the first match is the key. */ readonly executorKeys: readonly ExecutorKey[]; /** The authority's execution-grant JWKS, as its well-known path serves it. */ readonly authorityJwks: { readonly keys: readonly Readonly>[]; }; /** The `iss` the provider trusts: `https://decionis.com` for Decionis. */ readonly authorityIssuer: string; /** How far `created` may lie from `now`, each way. */ readonly clockWindowSeconds: number; readonly replay: ReplayStore; readonly now?: () => number; } export interface ReceivedRequest { readonly method: string; /** The request path, without its query. */ readonly path: string; readonly body: string | null; /** Header names in lower case. A covered header received more than once is a refusal; do not collapse it here. */ readonly headers: Readonly>; } export type ProviderVerdict = { readonly accepted: true; readonly reasonCode: null; readonly attestation: ClaimAttestationClaims | null; } | { readonly accepted: false; readonly reasonCode: Exclude; readonly attestation: null; } | { /** * The provider's own refusal of a genuine, now spent, attestation: the * target moved on. The claims are handed back, since a provider at VP-3 * signs its refusal as a receipt built from them. */ readonly accepted: false; readonly reasonCode: "TARGET_STATE_CHANGED"; readonly attestation: ClaimAttestationClaims; }; /** The body as I-JSON, or null: not JSON, or a name repeated within one object. Lone surrogates are the canonicaliser's to refuse. */ export declare function parseIJson(body: string): JsonValue | null; /** * The whole procedure for one received request. An accepted verdict carries * the attestation's claims for the provider's own record, or null for a read * a non-effecting provider verified at VP-1 alone; a refusal carries the code * the response body names. `target` is the provider's own read of what the * request would change, for step 9; without it the step is the provider's, * at its write, with the accepted claims' `expected_state_version`. */ export declare function verifyProviderRequest(received: ReceivedRequest, options: VerifyingProviderOptions, target?: ProviderTarget): ProviderVerdict; /** The refusal body the profile names; the status is the provider's, 409 in the references. */ export declare function refusalBody(reasonCode: ProviderRefusalCode): string; /** * A replay store for one process: enough for a single instance, and for the * vectors. A provider with more than one instance that can effect shares one * instead, keyed the same way. Expired grants are forgotten on the next * record, which is why the store needs no life beyond the lease. */ export declare class MemoryReplayStore implements ReplayStore { private readonly clock; private readonly seen; constructor(clock?: () => number); record(grantId: string, expiresAtMs: number): boolean; get size(): number; } //# sourceMappingURL=VerifyingProvider.d.ts.map