import { B as RootNeedsResult, M as Need, R as ResourceFailureDetail, _ as DidDocument, a as AgentCard, b as EngineConfig, m as Decision, y as EnforcementMode, z as ResourceOutcome } from "./types-BVx5XvPN.js"; import { n as StatusListVerifier } from "./status-list-cache-C-fmbUlJ.js"; import * as NodeDns from "node:dns"; import { LookupAddress, LookupOptions } from "node:dns"; //#region src/engine/adapters/agent-card-resolver.d.ts declare class AgentCardNotFound extends Error { readonly kind = "AgentCardNotFound"; } declare class AgentCardResolverTimeout extends Error { readonly kind = "AgentCardResolverTimeout"; } declare class AgentCardResolverError extends Error { readonly kind = "AgentCardResolverError"; } interface AgentCardResolverAdapter { resolve(origin: string): Promise; } type CacheEntry$1 = { kind: 'card'; card: AgentCard; fetchedAt: number; } | { kind: 'failure'; error: Error; fetchedAt: number; }; interface AgentCardResolverOpts { /** AbortController timeout shared by the card AND (if the scheme needs it) the JWKS fetch. Default 3000ms — docs/architecture/a2a-verification.md. */ fetchTimeoutMs?: number; /** TTL for a resolved card. Default 10 minutes — docs/architecture/a2a-verification.md. */ ttlMs?: number; /** Injectable fetch — defaults to global `fetch` (Node 18+). */ fetch?: typeof fetch; /** Injectable cache — defaults to a fresh `Map` per adapter instance. */ cache?: Map; /** Injectable wall-clock — defaults to `Date.now()`. Tests use a stub. */ now?: () => number; } declare function makeAgentCardResolver(opts?: AgentCardResolverOpts): AgentCardResolverAdapter; //#endregion //#region src/engine/adapters/legacy-resolvers.d.ts /** * @deprecated `verifyRequest` ignores `didResolver`; it answers the engine's * needs with a resolution host (`makeResolutionHost`). */ interface DidResolverAdapter { resolve(did: string): Promise; } /** * @deprecated `verifyRequest` ignores `statusListCache`; it answers the * engine's needs with a resolution host (`makeResolutionHost`). */ interface StatusListCacheAdapter { fetch(url: string, issuer: string, verify: StatusListVerifier): Promise; } /** * @deprecated Returns an adapter whose `resolve` rejects. `verifyRequest` * ignores `didResolver`; use `makeResolutionHost`. */ declare function makeDidResolver(_options?: unknown): DidResolverAdapter; /** * @deprecated Returns an adapter whose `fetch` rejects. `verifyRequest` * ignores `statusListCache`; use `makeResolutionHost`. */ declare function makeStatusListCache(_options?: unknown): StatusListCacheAdapter; //#endregion //#region src/engine/adapters/reputation-oracle.d.ts /** * ReputationOracle adapter — sub-phase B.3. * * Resolves a per-DID reputation score in `[0.0, 1.0]`. Phase 1 wires * an optional HTTP endpoint (Argus). Unavailable / misconfigured / * out-of-range responses degrade to a baseline score so infrastructure * blips can't silently DOS Adobe-class traffic. The orchestrators hand the * engine each agent DID's score; a tenant rule over reputation is Cedar. * * **Degrade-to-trust** (Phase B § 4.5). Reputation is best-effort; * Argus outages do not block traffic. The adapter returns the * configured baseline (default 1.0 = "no signal, treat as trusted") * and logs loudly, so no traffic is rejected just because Argus went down. */ interface ReputationOracleAdapter { /** * Return the agent's reputation in `[0.0, 1.0]`. Higher is better. * * **Does not throw.** Network / parse / range failures degrade to * the baseline + log; the engine should never see a thrown error * from this adapter. */ score(agentDid: string): Promise; } interface CacheEntry { value: number; fetchedAt: number; } interface ReputationOracleOpts { /** * Base URL for the reputation service (Argus). When unset, the * adapter returns the baseline without fetching. */ argusUrl?: string; /** Fetch budget. Default 1500ms — reputation is best-effort, tighter than DID resolution. */ fetchTimeoutMs?: number; /** Cache TTL. Default 10s — reputation churns faster than DIDs. */ ttlMs?: number; /** Injectable fetch. Defaults to global `fetch`. */ fetch?: typeof fetch; /** Returned when Argus is unset / unreachable / malformed. Default 1.0. */ baselineWhenUnreachable?: number; /** Injectable cache for tests. */ cache?: Map; /** Injectable wall-clock. */ now?: () => number; /** Hook for diagnostics. Phase 1 keeps log volume manageable by sampling. */ logger?: (msg: string) => void; } declare function makeReputationOracle(opts?: ReputationOracleOpts): ReputationOracleAdapter; //#endregion //#region src/engine/adapters/policy-evaluator.d.ts /** * @deprecated `verifyRequest` ignores `policyEvaluator`; the engine decides, * and a tenant's rules are Cedar. */ interface PolicyEvalInput { tenantHost: string; reputation: number; } /** * @deprecated `verifyRequest` ignores `policyEvaluator`; the engine decides, * and a tenant's rules are Cedar. */ interface PolicyEvaluatorAdapter { evaluate(input: PolicyEvalInput): Promise; } /** * @deprecated Returns an adapter that permits every request and reads no * remote policy. `verifyRequest` ignores `policyEvaluator`; a tenant's rules * are Cedar. */ declare function makePolicyEvaluator(_options?: unknown): PolicyEvaluatorAdapter; //#endregion //#region src/engine/adapters/clock.d.ts /** * Clock adapter — sub-phase B.5. * * Provides the Unix-seconds timestamp the engine's `Clock` trait needs * for Stage 4 expiration checks. Trivial; the trait shape exists so * tests can inject a frozen clock (and so the engine's sync-trait * surface is satisfied without a JS callback crossing the WASM * boundary — `ContextSpec.nowUnix` carries the value). */ interface ClockAdapter { nowUnix(): number; } declare function makeSystemClock(): ClockAdapter; declare function makeFixedClock(unixSeconds: number): ClockAdapter; //#endregion //#region src/engine/adapters/resolution-host.d.ts /** One fetch's deadline: connect, headers and body. */ declare const RESOLUTION_FETCH_TIMEOUT_MS = 3000; /** The window the per-role fetch budget counts in. */ declare const RESOLUTION_BUDGET_WINDOW_MS = 10000; /** Fetches per window for each request-chosen role. Roots are not budgeted. */ declare const RESOLUTION_FETCH_BUDGET: Readonly>; /** Largest number of entries kept for each request-chosen role. */ declare const RESOLUTION_MAX_ENTRIES: Readonly>; /** A non-root entry is refreshed in the background while it was named this recently. */ declare const RESOLUTION_ACTIVE_MS = 900000; /** After a failed fetch, an entry is tried again after this long. */ declare const RESOLUTION_RETRY_MS = 30000; /** The background refresh fetches an entry this far ahead of its maximum age. */ declare const RESOLUTION_REFRESH_LEAD_MS = 35000; /** A non-root entry no request named for this long is dropped. */ declare const RESOLUTION_INACTIVE_EVICT_MS = 86400000; /** Background fetches in flight at once. */ declare const RESOLUTION_MAX_CONCURRENT_FETCHES = 4; /** * Milliseconds after its fetch at which the background refresh fetches an * entry again: half its maximum age, or `RESOLUTION_REFRESH_LEAD_MS` before * it, whichever is sooner, and never under a second. */ declare function refreshAfterMs(maxAgeSeconds: number): number; /** The engine call a host needs to answer a status-list need. */ interface ResolutionEngine { verifyStatusList: StatusListVerifier; } type ResolutionMode = 'inline' | 'cache-only'; /** A fetched resource as a store keeps it: the raw body and when it was fetched. */ interface StoredResource { /** The response body: a DID document's JSON, or a status list's envelope. */ body: string; /** Epoch seconds of the fetch that produced `body`. */ fetchedAtUnix: number; } /** * Persistent storage for fetched resources, keyed by need key, for a host * that keeps no memory between requests. A `get` that throws counts as a * miss and a `put` that throws is logged; neither fails a request. */ interface ResolutionStore { get(key: string): Promise; put(key: string, value: StoredResource): Promise; } interface ResolutionHostOptions { mode: ResolutionMode; /** * Replaces `safeGet`'s transport. It must connect only to a vetted public * address, refuse redirects, cap the body and enforce a deadline; the * connect-time address check is then the caller's job. */ fetch?: typeof fetch; /** Epoch milliseconds. Defaults to `Date.now`. */ now?: () => number; fetchTimeoutMs?: number; logger?: (msg: string) => void; /** Where fetched resources are kept between requests. See {@link ResolutionStore}. */ store?: ResolutionStore; } /** * The verification a host answers for. The engine judges every answer with the * verify call's clock (`opts.clock`), which need not be the host's: a replay or * a conformance run pins it to an instant of its own. So what the host hands * the engine is in that clock: a resource's fetch time is the call's `nowUnix` * less the resource's real age, and a status list fetched for the call is * verified, and its expiry judged, at the call's `nowUnix`. The host's own * timing (retry delays, budgets, refresh points) stays on its clock. */ interface ResolutionCall { /** The `nowUnix` the engine is called with for this request. */ nowUnix: number; /** * Keeps the call's background work alive after the response (Cloudflare * Workers' `ctx.waitUntil`). Without it, background fetches run detached. */ waitUntil?: (promise: Promise) => void; } interface ResolutionHost { readonly mode: ResolutionMode; /** * The answers already held for configured roots that an engine would * accept, to send with a request's first call so a request that needs only * roots is decided in one call. Without `call`, in the host's clock. */ rootAnswers(call?: ResolutionCall): Record; /** * One outcome per need, from the cache, a fetch, or `pending`. Never throws. * Without `call`, in the host's clock. */ answer(needs: readonly Need[], engine: ResolutionEngine, call?: ResolutionCall): Promise>; /** Track needs without answering them (the configured roots at startup). */ register(needs: readonly Need[]): void; /** Keep only these root needs pinned; a root no longer configured is dropped. */ setRoots(needs: readonly Need[]): void; /** * Fetch every tracked need that is due, DID documents before status lists, * within the budgets, reading the store first when there is one. Never * throws. */ refresh(engine: ResolutionEngine): Promise; } declare function makeResolutionHost(options: ResolutionHostOptions): ResolutionHost; /** A fetch that produced no usable resource, with the reason the engine is told. */ declare class ResourceFetchError extends Error { readonly detail: ResourceFailureDetail; readonly kind = "ResourceFetchError"; constructor(detail: ResourceFailureDetail, message: string); } //#endregion //#region src/engine/adapters/resolution-warmer.d.ts /** How often the background refresh runs. */ declare const RESOLUTION_REFRESH_INTERVAL_MS = 30000; /** The engine calls a warmer makes: the roots' needs, and status-list verification. */ interface ResolutionWarmerEngine extends ResolutionEngine { rootNeeds(contextJson: string): RootNeedsResult | Promise; } interface ResolutionWarmerOptions { /** Reads the current trusted-delegation roots (the per-project policy roots). */ rootsSource: () => Promise; /** The orchestrator entry's `resolutionEngine`. */ engine: ResolutionWarmerEngine; /** * Replaces the default transport (`safeGet`). It must connect only to a * vetted public address, refuse redirects, cap the body and enforce a * deadline. */ fetch?: typeof fetch; /** Epoch milliseconds. Defaults to `Date.now`. */ now?: () => number; logger?: (msg: string) => void; } /** The persistent-host control surface over the warmer's host. */ interface RunnableResolutionWarmer { /** The cache-only host to pass as `VerifyRequestOpts.resolutionHost`. */ readonly host: ResolutionHost; /** True once the first {@link prime} has completed. */ readonly primed: boolean; /** Register and fetch the configured roots once, then mark {@link primed}. Never throws. */ prime(): Promise; /** Re-read the roots and refresh every entry that is due. Never throws. */ refreshTick(): Promise; /** prime(), then refreshTick every `intervalMs`. Returns a stop handle. Idempotent. */ start(intervalMs?: number): () => void; /** Clear the refresh timer (if any). */ stop(): void; } declare function makeResolutionWarmer(options: ResolutionWarmerOptions): RunnableResolutionWarmer; //#endregion //#region src/engine/adapters/safe-get.d.ts /** Why `safeGet` refused a fetch. */ type SafeGetRefusal = 'redirect' | 'too-large' | 'blocked-address' | 'no-address' | 'content-encoding' | 'no-address-check'; /** A redirect, an oversized body, or a blocked address. */ declare class SafeGetRefused extends Error { readonly reason: SafeGetRefusal; readonly kind = "SafeGetRefused"; constructor(message: string, reason: SafeGetRefusal); } interface SafeGetResponse { status: number; /** The body for a 2xx; empty for any other status (never read). */ body: Uint8Array; } interface SafeGetOpts { /** Bounds the whole exchange: connect, headers and body. */ signal: AbortSignal; maxBytes: number; /** * A caller-supplied `fetch` is used as-is (with `redirect: 'manual'`, the * size cap and `SAFE_GET_HEADERS`); connect-time address checks are then * the caller's job. */ fetch?: typeof fetch; } declare const SAFE_GET_HEADERS: Readonly>; declare function safeGet(url: string, opts: SafeGetOpts): Promise; type LookupCallback = (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family?: number) => void; /** * Wraps `dns.lookup` so the socket can only connect to checked addresses. * One blocked answer refuses the whole host (as the .NET SDK's * `SsrfSafeDidFetcher` does), so a mixed public/private record set cannot * win a Happy Eyeballs race to the private one. */ declare function makeSafeLookup(lookup: typeof NodeDns.lookup): (hostname: string, options: LookupOptions, callback: LookupCallback) => void; //#endregion //#region src/engine/adapters/outbound-url-policy.d.ts /** * Shared egress guard for verifier-owned outbound fetches. * * KYA-OS payloads are attacker controlled until the signature verifies. Any * host-side fetch derived from that payload must reject obvious local/private * targets before invoking `fetch`. */ declare class UnsafeOutboundUrl extends Error { readonly kind = "UnsafeOutboundUrl"; } declare function assertSafeHttpsUrl(rawUrl: string, label?: string): string; /** * True when a resolved socket address must not be dialed. The Node transport * in `safe-get.ts` calls this at connect time on every address a hostname * resolves to. Anything that is not a parseable IP address fails closed. */ declare function isBlockedIpAddress(address: string): boolean; //#endregion //#region src/engine/adapters/rdns-verifier.d.ts /** * ReverseDnsVerifier adapter — P36. * * Forward-confirmed reverse DNS: the mechanism vendors document for * proving a request genuinely came from their infrastructure (Google via * `crawler.googlebot.com` reverse DNS + a published range file, Bing via * `search.msn.com`). Three steps, in order: * * 1. Reverse-resolve the client address to a hostname (PTR). * 2. Forward-resolve that hostname back to addresses (A/AAAA). * 3. Confirm the original address is among them, AND that the hostname * falls within the vendor's expected domain. * * Step 2 is not optional and not a belt-and-braces extra. A PTR record is * controlled by whoever holds the address block, so anyone can point their * own address at `crawler.googlebot.com` — reverse-only "verification" is * trivially forgeable, and worse than no verification at all, because it * produces a *confident* wrong answer. Only the forward step, which * resolves through the domain owner's own authoritative DNS, actually * proves anything. * * **Degrade-to-unverified.** DNS is unreliable. A resolver timeout or * error must never become a thrown error (which would fail the caller) * or a `verified: true` (which would forge trust from a resolver hiccup). * Every failure mode returns `{ verified: false, reason }`; this adapter * never throws. * * SCOPE: this is the verification mechanism only. Wiring a verdict into * an attribution / confidence tier (consuming `agent-types.yaml`'s vendor * list, exposing it to the classification engine) is a separate ticket * (P37) — this module intentionally takes the expected hostname suffixes * as a plain argument rather than owning a vendor registry. * * **No default resolver, deliberately.** This file lives in the * `adapters` barrel (`./index.ts`), which tsup builds as a single * runtime-agnostic entry consumed by both Node hosts and the Cloudflare * Worker gateway (`apps/web/workers/gateway`, `nodejs_compat`). A static * top-level `import ... from 'node:dns/promises'` would tie the whole * bundled entry — every other adapter in it, not just this one — to * whatever DNS support that Worker runtime happens to have, for a * capability (raw resolver I/O) that Workers are not guaranteed to * implement. The entry also reaches the Edge runtime, which has no Node * built-ins at all. `resolver` is therefore a * required argument: a Node caller passes `node:dns/promises`'s * `reverse`/`resolve4`/`resolve6` in directly (three lines), the same * way `apps/web/workers/gateway/src/detection/resolution-host.ts` gives * the Worker its own KV-backed resolution host instead of this package's * Node `resolution-warmer.ts`: the split lives at the call site, not * inside this module. */ type RdnsVerdictReason = 'confirmed' | 'no-ptr' | 'forward-mismatch' | 'suffix-mismatch' | 'timeout' | 'lookup-error'; interface RdnsVerdict { /** True only when PTR → forward resolution → suffix all agree. */ verified: boolean; /** The PTR hostname that was checked, present whenever one was found. */ hostname?: string; reason: RdnsVerdictReason; } /** * The subset of `node:dns/promises` this adapter depends on. Exposed as * an injectable parameter (mirroring `DnsLookupFn` in * `apps/web/lib/security/ssrf-dns.ts`) so tests supply a deterministic * resolver instead of monkey-patching the `dns` module. */ interface RdnsResolverFns { reverse: (address: string) => Promise; resolve4: (hostname: string) => Promise; resolve6: (hostname: string) => Promise; } interface RdnsVerifierOptions { /** DNS budget per individual lookup call. Default 2000ms. */ timeoutMs?: number; /** * TTL for a confirmed hostname. Default 6h — PTR/A/AAAA records for * stable crawler infrastructure change rarely, and a long success TTL * is what keeps a verified vendor address from re-paying two DNS round * trips on every request. */ successTtlMs?: number; /** * TTL for a negative result (no PTR, forged/mismatched PTR, or a * lookup failure). Deliberately shorter than `successTtlMs`: without a * negative cache at all, every request from an ordinary non-crawler * address would cost two uncached DNS lookups, which is both a latency * cost and query volume aimed at resolvers — a cheap amplification for * an attacker to trigger. Short enough that a newly-published PTR * record or a transient resolver blip recovers quickly. Default 5min. */ failureTtlMs?: number; /** Injectable wall-clock, so TTL behaviour is testable without real time. */ now?: () => number; /** Injectable cache, keyed by the client address. */ cache?: Map; /** * DNS resolver functions. Required — see the module docblock for why * this adapter does not default to `node:dns/promises` itself. On * Node, pass `{ reverse, resolve4, resolve6 }` imported directly from * `node:dns/promises`. */ resolver: RdnsResolverFns; /** Diagnostics hook. Never allowed to throw back into the adapter. */ logger?: (msg: string) => void; } interface RdnsVerifier { /** * Verify that `address` genuinely belongs to a host within * `expectedSuffixes` (e.g. `['googlebot.com', 'google.com']`), via * forward-confirmed reverse DNS. Never throws. * * The PTR → forward-confirm result is cached per address regardless of * which suffixes are asked for — the underlying DNS fact ("does this * address forward-confirm to hostname X") doesn't depend on the * caller's allowlist, so checking the same address against several * vendors' suffix lists costs one DNS round trip, not one per vendor. */ verify(address: string, expectedSuffixes: string[]): Promise; } type HostnameConfirmation = { ok: true; hostname: string; } | { ok: false; reason: 'no-ptr' | 'forward-mismatch' | 'timeout' | 'lookup-error'; }; interface ConfirmCacheEntry { confirmation: HostnameConfirmation; expiresAt: number; } declare function makeRdnsVerifier(opts: RdnsVerifierOptions): RdnsVerifier; //#endregion //#region src/engine/adapters/engine-defaults.d.ts /** Host-supplied adapters that replace the defaults (advanced use and tests). */ type EngineAdapterOverrides = Partial<{ /** * The `fetch` DID documents and status lists are fetched with, instead of * the default `safeGet` transport. It must connect only to a vetted public * address (check every resolved address, including after DNS, and never * re-resolve), refuse redirects, cap the body and enforce a deadline: the * connect-time address check is then the caller's job. `safeGet`, * `makeSafeLookup` and `isBlockedIpAddress` (`./adapters`) are the pieces * the default uses. Edge and Workers runtimes have no connect hook, so there * the platform's egress rules keep a fetch off private addresses. */ fetch: typeof fetch; reputationOracle: ReputationOracleAdapter; }>; interface EngineDefaultsOptions { /** @deprecated No longer used; will be removed. */ tenantHost?: string; /** Defaults to `'enforce'`. */ enforcementMode?: EnforcementMode; adapters?: EngineAdapterOverrides; /** Reputation service base URL, for the default reputation oracle and the engine. */ argusUrl?: string; resourceOrgDid?: string; trustedDelegationRoots?: string[]; /** Defaults to `false`. */ legacyEnvelopeFallback?: boolean; engineConfig?: EngineConfig; } /** * The options `makeEngineDefaults` sets: the part of `VerifyRequestOpts` that * does not change per request. Declared here rather than taken from the * orchestrator's types, which import this directory. */ interface EngineDefaults { /** An inline resolution host; a persistent host swaps in its warmer's cache-only host. */ resolutionHost: ResolutionHost; reputationOracle: ReputationOracleAdapter; clock: ClockAdapter; /** @deprecated No longer used; will be removed. */ tenantHost?: string; enforcementMode: EnforcementMode; legacyEnvelopeFallback: boolean; resourceOrgDid?: string; trustedDelegationRoots?: string[]; argusUrl?: string; engineConfig?: EngineConfig; } declare function makeEngineDefaults(options: EngineDefaultsOptions): EngineDefaults; //#endregion export { makeReputationOracle as $, RESOLUTION_INACTIVE_EVICT_MS as A, ResolutionStore as B, ResolutionWarmerOptions as C, RESOLUTION_BUDGET_WINDOW_MS as D, RESOLUTION_ACTIVE_MS as E, ResolutionCall as F, ClockAdapter as G, StoredResource as H, ResolutionEngine as I, PolicyEvalInput as J, makeFixedClock as K, ResolutionHost as L, RESOLUTION_MAX_ENTRIES as M, RESOLUTION_REFRESH_LEAD_MS as N, RESOLUTION_FETCH_BUDGET as O, RESOLUTION_RETRY_MS as P, ReputationOracleOpts as Q, ResolutionHostOptions as R, ResolutionWarmerEngine as S, makeResolutionWarmer as T, makeResolutionHost as U, ResourceFetchError as V, refreshAfterMs as W, makePolicyEvaluator as X, PolicyEvaluatorAdapter as Y, ReputationOracleAdapter as Z, SafeGetRefused as _, RdnsResolverFns as a, AgentCardResolverAdapter as at, safeGet as b, RdnsVerifier as c, AgentCardResolverTimeout as ct, UnsafeOutboundUrl as d, DidResolverAdapter as et, assertSafeHttpsUrl as f, SafeGetRefusal as g, SafeGetOpts as h, makeEngineDefaults as i, AgentCardNotFound as it, RESOLUTION_MAX_CONCURRENT_FETCHES as j, RESOLUTION_FETCH_TIMEOUT_MS as k, RdnsVerifierOptions as l, makeAgentCardResolver as lt, SAFE_GET_HEADERS as m, EngineDefaults as n, makeDidResolver as nt, RdnsVerdict as o, AgentCardResolverError as ot, isBlockedIpAddress as p, makeSystemClock as q, EngineDefaultsOptions as r, makeStatusListCache as rt, RdnsVerdictReason as s, AgentCardResolverOpts as st, EngineAdapterOverrides as t, StatusListCacheAdapter as tt, makeRdnsVerifier as u, SafeGetResponse as v, RunnableResolutionWarmer as w, RESOLUTION_REFRESH_INTERVAL_MS as x, makeSafeLookup as y, ResolutionMode as z }; //# sourceMappingURL=index-DGY90512.d.ts.map