import { C as FeedAttemptOutcome, K as SessionVelocitySignal, O as KeySetOutcome, S as EngineWasmSource, W as RuleBundleRejectionCode, b as EngineConfig, h as DelegationVerifyInput, i as AdoptedVendorKeys, it as VerifyResult, o as AgentRequest, p as ContextSpec, q as SignalsEnvelope, tt as VendorKeyMiss, u as ClientIntegrityInput, v as DirectedVerifyResult, w as FeedDemandReason, y as EnforcementMode } from "./types-BVx5XvPN.js"; import { G as ClockAdapter, L as ResolutionHost, S as ResolutionWarmerEngine, Z as ReputationOracleAdapter } from "./index-DGY90512.js"; import { n as StatusListVerifier } from "./status-list-cache-C-fmbUlJ.js"; import "./edge-COZ8dP4b.js"; import { HeaderEntry } from "@kya-os/checkpoint-shared"; import { ChallengeWireInput as ChallengeWireInput$1 } from "@kya-os/checkpoint-shared/host-adapter"; //#region src/vendor-keys/feed.d.ts type VendorKeyFeedFailureCode = RuleBundleRejectionCode | 'fetch-failed' | 'http-error' | 'too-large' | 'apply-failed'; type VendorKeyFeedEvent = { kind: 'demand'; reason: FeedDemandReason; } | { kind: 'applied'; version: number; keyOutcomes: KeySetOutcome[]; durationMs: number; } | { kind: 'current'; version: number; } | { kind: 'failed'; code: VendorKeyFeedFailureCode; message: string; durationMs?: number; } | { kind: 'finished'; outcome: FeedAttemptOutcome; }; interface VendorKeyEdgeOptions { waitUntil?: (promise: Promise) => void; } declare function configureVendorKeyFeed(config: { url?: string; onEvent?: (event: VendorKeyFeedEvent) => void; }): void; //#endregion //#region src/engine/orchestrator/types.d.ts /** * Framework-agnostic HTTP request shape. * * Next.js / Express / Cloudflare Workers / Hono adapters marshal * their native request type into this shape before calling * `verifyRequest`. The shape is intentionally minimal — only what * the engine needs to make a verdict. */ interface IncomingHttpLike { method: string; /** Path + query string (no scheme + host). */ url: string; headers: Record; /** * Parsed body if the framework has already parsed it (Next.js * with `await req.json()`, Express with `body-parser`). Falsy if * the caller hasn't materialised the body — the orchestrator * treats that as "no KYA-OS envelope present" and routes to * PlainHttp. */ body?: Uint8Array | string | object | null; /** * The request body bytes exactly as received, before any parsing. Hosts * set this when they hold the wire bytes: a cloned Fetch `Request`, an * Express `express.raw()` body, or a body-parser `verify` hook that saved * `req.rawBody`. A KYA HTTP Binding (kya-http/2) signature covers these * bytes through `Content-Digest`, so they must be byte-identical to what * the client signed. Set it only after reading the body to its end: an * empty value says the body was empty, which makes a chunked body count * as delivered. A body the host has no stream for is not empty; omit it. When omitted, the orchestrator derives the bytes from * `body`: exact for binary or a string, re-serialised JSON for a parsed * object (which verifies only when the client sent compact JSON). */ rawBody?: Uint8Array | string | null; /** Client IP if the framework surfaces one (Express `req.ip`). */ remoteAddress?: string; /** * Transport/client/behavioural entropy signals, when the host * collected any (e.g. the gateway's TLS fingerprint, or the pixel * beacon's client-collected attributes). Threaded through to * `PlainHttpRequest.signals` or `HttpSignedRequest.signals` untouched; * see `types.ts`. */ signals?: SignalsEnvelope | null; /** * Edge-computed request-velocity heuristic for this client (e.g. the * gateway's in-isolate `SessionVelocityTracker` — see * `apps/web/workers/gateway/src/detection/session-velocity.ts`). * Threaded through to `PlainHttpRequest.sessionVelocity` or * `HttpSignedRequest.sessionVelocity` untouched. * Deliberately separate from `signals` above — see * `SessionVelocitySignal`'s doc comment in `../types.ts`. */ sessionVelocity?: SessionVelocitySignal | null; /** * Host-verified client-integrity facts (the pixel and beacon ingest's nonce * check and interaction-integrity verdict). Threaded through to * `PlainHttpRequest.clientIntegrity` untouched; never sent on a signed * request. See `ClientIntegrityInput` in `../types.ts`. */ clientIntegrity?: ClientIntegrityInput | null; } /** * Options the host wrapper passes per-`verifyRequest`-construction. * The five adapters + clock + tenant identifier + enforcement mode. */ interface VerifyRequestOpts { /** * Answers the DID documents and status lists the engine names in * engine-directed mode. Defaults to one inline host per process * (`makeResolutionHost({ mode: 'inline' })`); a persistent host passes its * warmer's cache-only host so the request path never fetches. */ resolutionHost?: ResolutionHost; reputationOracle: ReputationOracleAdapter; clock: ClockAdapter; /** * @deprecated No longer used; will be removed. Nothing reads it: the engine * makes the tenant decision. */ tenantHost?: string; enforcementMode: EnforcementMode; /** * **Envelope-1 (#2537) coordination flag.** Pre-Envelope-1 the TS * bouncer ships KYA-OS proofs as `{protected,payload,signature}` JSON * in a `KYA-Delegation` header. Post-Envelope-1 they ship compact * JWS in `_meta.proof.jws` of the body. When this flag is true the * orchestrator also accepts the legacy header form. **Default off.** */ legacyEnvelopeFallback?: boolean; /** * Argus URL — passed only so the orchestrator can detect "Argus * not configured" at construction time and log the one-shot * warning. The actual reputation fetch goes through `reputationOracle`. */ argusUrl?: string; /** Injectable for the once-only Argus configuration warning. */ logger?: (msg: string) => void; /** * Override the engine WASM-bridge function used during the sync * `verify()` call. Defaults to the wasm-bindgen `--target bundler` * variant imported by `./verify-request.ts` from `'../index'`. * * The `./orchestrator/node` subpath (SDK-Next.js-Integration-Audit-1 * / #2618 safety net) injects the `--target nodejs` variant here so * Webpack-without-asyncWebAssembly consumers don't transitively pull * the bundler artifact through the orchestrator's verify call. */ engineVerifyFn?: (input: AgentRequest, ctx: ContextSpec) => DirectedVerifyResult; /** * Override for the standalone Layer-2 bearer delegation verifier. Hosts rarely * set this; tests use it to assert the bearer path reaches the correct engine * export instead of demoting to PlainHttp. */ engineVerifyDelegationFn?: (input: DelegationVerifyInput, ctx: ContextSpec) => DirectedVerifyResult | Promise; /** * Override for the engine's status-list verifier (`verifyStatusList`). * Defaults to the export of the engine build this orchestrator entry binds; * tests use it to observe the request the status-list cache sends. */ engineVerifyStatusListFn?: StatusListVerifier; /** * Engine-default behaviour knobs forwarded onto every composed * `ContextSpec`. Defaults to `{ tier3Action: 'monitor' }` so a host * installing `@kya-os/checkpoint-*` with minimal config preserves * 1.3.0 behaviour — tenant policy is the arbiter, the engine does * not short-circuit known-agent UAs with an engine-default Block. * * Host wrappers that want the calibrated engine-default block opt * into `{ tier3Action: 'block' }`. The bench harness is the * canonical opt-in consumer. See the wasm-runtime 1.4.0 CHANGELOG. */ engineConfig?: EngineConfig; /** * Host-injected allow-list of trusted Layer-2 delegation root DIDs, * forwarded verbatim onto every composed `ContextSpec.trustedDelegationRoots`. * Omit (or pass `[]`) and the engine rejects every presented delegation * (fail closed). The host resolves this from its own org context (e.g. * `resolveTrustedDelegationRoots({ slug })`); the stateless runtime never * derives it. */ trustedDelegationRoots?: string[]; /** * Resource server org DID for `Authorization: Bearer `. * The standalone verifier checks the credential's `aud` against this value. */ resourceOrgDid?: string; httpDelegation?: ContextSpec['httpDelegation']; /** * Scopes required by this request for standalone bearer delegation checks. * Omit to verify identity/audience/revocation only. */ requiredScopes?: string[]; } /** * Transport-agnostic response shape `renderDecisionAsResponse` * produces. Host wrappers adapt this to their framework's response * type (NextResponse / Express `res` / Cloudflare Response). * * `status === null` means "pass through" — the request continues to * the next handler. Happens in two cases: * 1. `Decision::Permit` (no block in Enforce mode). * 2. **Any verdict in Observe mode** — Observe never blocks, but * the response headers still carry the would-have-been verdict. */ interface RenderedResponse { status: number | null; headers: Record; /** * Ordered repeatable HTTP fields. Host adapters append these after applying * `headers`; unlike a record, this preserves two `WWW-Authenticate` fields. */ headerEntries?: readonly HeaderEntry[]; body?: string | object; } //#endregion //#region src/engine/orchestrator/build-agent-request.d.ts interface BuildAgentRequestOpts { /** See `VerifyRequestOpts.legacyEnvelopeFallback`. */ legacyEnvelopeFallback?: boolean; } interface CredentialStatusRef { /** URL the host should fetch from the StatusList cache. */ fetchUrl: string; /** Exact key the engine will query in `ContextSpec.revoked`. */ mapUrl: string; /** * The issuer of the credential carrying the status entry: the list must be * signed by it. Null when the credential names none (the list then fails * closed). */ issuer: string | null; /** * The credential's `statusListIndex`, or null when it is not a * non-negative integer. An index outside the list fails closed. */ index: number | null; } /** * The `iss` a presented DelegationCredential names, read before any signature * check. Null when the credential has no string `iss`. */ interface DelegationIssuerRef { issuer: string | null; } interface BearerDelegationCredentialRef extends DelegationIssuerRef { /** The compact VC-JWT presented as a standalone bearer delegation. */ credential: string; /** Decoded JWT payload claims. Signature verification happens in the engine. */ claims: Record; agentDid: string | null; credentialStatus: CredentialStatusRef | null; } /** * Translate an HTTP-like request into the engine's `AgentRequest`. * * Detection order (conservative — never escalate ambiguous input): * 1. KYA-OS L2 detached proof in `_meta.proof.jws` (spec form). * 2. (Legacy, opt-in) KYA-OS in `KYA-Delegation` header * (Envelope-1 #2537 transition window only). * 3. RFC 9421 HTTP Message Signatures (`Signature-Input` header). * 4. PlainHttp (default — anonymous traffic). */ declare function buildAgentRequest(req: IncomingHttpLike, opts?: BuildAgentRequestOpts): AgentRequest; /** * Preflight check — does the request body carry a `_meta.proof.jws` * string that `parseJwsPayloadStruct` cannot project into a typed * `McpIPayload`? * * The caller declared intent (an KYA-OS envelope) by including the * JWS field; structural failure to extract the payload means the * envelope is malformed, not absent. Without this preflight, the * orchestrator would silently fall through to PlainHttp — pre-#2560 * that happened to also Block (engine returned `Block(ParseError)` * for every PlainHttp), so the regression was invisible; post-#2560 * the engine's Stage 1 + stub policy returns `Permit` for anonymous * PlainHttp and tampered envelopes would be silently accepted. * * Returns `true` when the orchestrator should synthesize * `Block(ParseError)` BEFORE calling `buildAgentRequest`. */ declare function hasMalformedJwsBody(req: IncomingHttpLike): boolean; /** * Issuer DID — Stage 1 (identity resolution) targets this. `null` * for PlainHttp (anonymous → no DID to resolve) and for an McpI envelope, * which the engine refuses without resolving anything. * * For `HttpSigned`, this is the KYA HTTP Binding `kya=` signature's base * DID (see [[extractKyaHttpDid]]) — the #3362 gap this closes: without a * pre-fetched `did_doc`, the engine cannot resolve the `keyid` and blocks * a validly-signed request with `kyaos/did-unresolvable`. * A generic RFC 9421 signature (e.g. ChatGPT's `sig1=` profile) has no * `kya` label and stays `null` here, unaffected. */ declare function extractIssuer(request: AgentRequest): string | null; /** * Agent DID — used by ReputationOracle. For `HttpSigned`, the KYA signer IS * the subject (no separate `sub` claim on a bare L1 signature), so this * returns the same DID as [[extractIssuer]]. `null` otherwise. */ declare function extractAgentDid(request: AgentRequest): string | null; /** * Standalone draft-kya-http bearer delegation (`Authorization: Bearer `) * plus its explicit fallback header (`KYA-Delegation`). This intentionally does * NOT consume `KYA-OS-Delegation-Credential` when the request is RFC-9421 signed; * that path must stay on `HttpSigned` so holder binding is verified. */ declare function extractBearerDelegationCredential(req: IncomingHttpLike): BearerDelegationCredentialRef | null; //#endregion //#region src/engine/orchestrator/render-decision.d.ts /** Options for {@link renderDecisionAsResponse}. */ interface RenderDecisionOptions { /** * Serve the body-readable HTTP 200 fetcher envelope for the agent-facing * step-up verdicts (Challenge / Instruct) instead of the spec 401 / 422. * The caller decides this via the shared `serveBodyReadable200` predicate * (`@kya-os/checkpoint-shared`) when its challenge-emission mode is * `negotiated`. Same body, no `WWW-Authenticate`; a cooperative-UX bridge * for fetchers that drop 4xx/5xx bodies, NOT an access control. */ bodyReadable200?: boolean; /** * Complete registered context for a canonical Delegation challenge. Hosts * resolve this asynchronously before calling the synchronous renderer. */ delegationChallenge?: ChallengeWireInput$1; /** The host attempted registered context resolution but none was available. */ challengeContextRequested?: boolean; } declare function renderDecisionAsResponse(result: VerifyResult, options?: RenderDecisionOptions): RenderedResponse; //#endregion //#region src/engine/orchestrator/verify-request-edge.d.ts type VerifyRequestEdgeOpts = VerifyRequestOpts & VendorKeyEdgeOptions; declare function vendorKeysEdge(options?: VendorKeyEdgeOptions): Promise; declare function reportVendorKeyMissEdge(miss: VendorKeyMiss, options?: VendorKeyEdgeOptions): Promise; /** * Factory — constructs a `verifyRequestEdge` closure that remembers the * one-shot Argus-not-configured warning state. Use this when the * host wrapper wants the startup log; call `verifyRequestEdge` directly * (the loose function below) if you don't. */ declare function makeVerifyRequestEdge(opts: VerifyRequestEdgeOpts): (req: IncomingHttpLike) => Promise; /** * Single-shot async entry. Use [`makeVerifyRequestEdge`] in long-lived * hosts (so the Argus warning is one-shot per process); use this * loose form in tests + one-off invocations. */ declare function verifyRequestEdge(req: IncomingHttpLike, opts: VerifyRequestEdgeOpts): Promise; /** * The engine calls a resolution warmer makes (`makeResolutionWarmer`), on the * edge engine `verifyRequestEdge` uses. */ declare const resolutionEngine: ResolutionWarmerEngine; /** * Load the engine from the module the host imported. The edge engine has no * URL fallback, so the first call passes `wasmModule` on every runtime; see * `initEngineEdge` for which module a retry uses. */ declare function initEngine(wasmModule?: EngineWasmSource): Promise; //#endregion export { RenderedResponse as _, resolutionEngine as a, VendorKeyFeedEvent as b, renderDecisionAsResponse as c, buildAgentRequest as d, extractAgentDid as f, IncomingHttpLike as g, hasMalformedJwsBody as h, reportVendorKeyMissEdge as i, BearerDelegationCredentialRef as l, extractIssuer as m, initEngine as n, vendorKeysEdge as o, extractBearerDelegationCredential as p, makeVerifyRequestEdge as r, verifyRequestEdge as s, VerifyRequestEdgeOpts as t, BuildAgentRequestOpts as u, VerifyRequestOpts as v, configureVendorKeyFeed as x, VendorKeyEdgeOptions as y }; //# sourceMappingURL=verify-request-edge-BKuVDe0j.d.ts.map