import { it as VerifyResult, m as Decision } from "./types-BVx5XvPN.mjs"; import { t as AuthorizeInput } from "./policy-evaluator-Cn476P-M.mjs"; import { ChallengeWireInput } from "@kya-os/checkpoint-shared/host-adapter"; import { BrowserPosture, BrowserPostureConfig, BrowserPostureOutcome, PostureRequest, PostureVerification } from "@kya-os/checkpoint-shared/browser-posture"; import { PolicyFetcher } from "@kya-os/checkpoint-shared/policy/fetcher"; import { ChallengeWireInput as ChallengeWireInput$1 } from "@kya-os/checkpoint-shared"; //#region src/browser-posture.d.ts declare function verifiedBrowserPosture(result: VerifyResult): BrowserPosture | undefined; type PostureHandlerView = BrowserPostureOutcome & { posture?: BrowserPosture; }; declare function postureHandlerView(result: VerifyResult): PostureHandlerView | undefined; declare function postureOutcomeView(outcome: PostureVerification): PostureHandlerView; /** * Verify risk locally before projecting facts into Cedar. Never supplies * identity. `request` is the request's `KYA-Posture` headers and cookies * (`postureRequestFromHeaders`), or a bare `Cookie` header value. */ declare function applyBrowserPosture(result: VerifyResult, request: PostureRequest | string | undefined | null, config: BrowserPostureConfig | undefined, projectId: string | undefined): Promise; /** Restrictive default after tenant policy: existing denials/challenges survive. * Only a verified signed delegation covering the designated scopes satisfies consent. * The consent mint is attested-bearer; a tenant may require a higher floor. * Missing/invalid risk evidence never creates a Permit decision. */ declare function applyBrowserIntegrityStepUp(result: VerifyResult, config: BrowserPostureConfig | undefined, path: string): void; declare function browserIntegrityChallengeScopes(result: VerifyResult): readonly string[] | undefined; /** Registration must demand the same scopes; never fabricate a consent URL * or mutate a signed challenge after registration. Absent context renders 503. */ declare function validateBrowserIntegrityChallenge(result: VerifyResult, context: ChallengeWireInput$1 | undefined): ChallengeWireInput$1 | undefined; //#endregion //#region src/engine/orchestrator/consent-remediable.d.ts declare function isConsentRemediableBlock(result: VerifyResult): boolean; //#endregion //#region src/request-claim.d.ts interface RequestClaim { /** The engine's `kya_request_claim_scope`. */ scope: string; keyId: string; nonce: string; /** Unix seconds: the end of the request's signature window. */ expiresUnix: number; /** The client address, when the host resolved one. */ sourceIp?: string; } /** `claimed` lets the request through; the others refuse it. */ type RequestClaimOutcome = 'claimed' | 'replay' | 'capacity' | 'unavailable'; interface RequestClaimStore { claim(claim: RequestClaim): Promise; } /** Live claims the local store holds, the platform's per-project limit. */ declare const LOCAL_REQUEST_CLAIM_CAPACITY = 10000; /** * Seconds a claim is kept past its signature's expiry, the platform ledger's * retention, so a verifier's allowed clock skew cannot reopen a used claim. */ declare const REQUEST_CLAIM_RETENTION_SECONDS = 31; interface LocalRequestClaimStoreOptions { /** Live claims held at most. Default {@link LOCAL_REQUEST_CLAIM_CAPACITY}. */ capacity?: number; /** Epoch milliseconds. Default `Date.now`. */ now?: () => number; } /** * Claims kept in this process. A claim lives until its signature expires plus * {@link REQUEST_CLAIM_RETENTION_SECONDS}; expired claims are swept in expiry * order. When it holds `capacity` live claims it answers `capacity` and never * evicts one, since evicting a live claim would let its request through again. */ declare function createLocalRequestClaimStore(options?: LocalRequestClaimStoreOptions): RequestClaimStore; interface PlatformRequestClaimStoreOptions { /** Dashboard origin, e.g. `https://kya.vouched.id`. */ baseUrl: string; /** The project API key; the dashboard takes the project from it. */ apiKey: string; fetch?: typeof fetch; /** Default 2000 ms. A claim that cannot be answered in time is `unavailable`. */ timeoutMs?: number; } /** * Claims made in the dashboard's shared ledger, so every instance of a * resource refuses a request any of them already accepted. Any answer other * than claimed, replay or capacity, and any transport failure, is * `unavailable`. */ declare function createPlatformRequestClaimStore(options: PlatformRequestClaimStoreOptions): RequestClaimStore; /** * The claim the engine named on `result`: the four keys, none of them (no * claim needed), or `incomplete` when a nonce arrived without the rest. */ declare function requestClaimOf(result: VerifyResult): Omit | 'incomplete' | null; /** * Make the claim on a final Permit, before the request reaches its handler. * Like the other post-verify steps it changes `result` in place, and returns * it. A result that is not a Permit lets nothing through and is left as is; a * Permit that needs no claim is left as is. A refused claim turns the Permit * into a Block carrying the registry code, which renders as 401 * `kyaos/replay`, 429 `kyaos/replay-capacity` or 503 * `kyaos/replay-state-unavailable`; its granted scopes are cleared. */ declare function applyRequestClaim(result: VerifyResult, store: RequestClaimStore, options?: { sourceIp?: string; }): Promise; //#endregion //#region src/browser-integrity-challenge.d.ts interface BrowserIntegrityChallengeOptions { /** Trusted registration API origin, usually the Checkpoint dashboard. */ registrationOrigin: string; /** Trusted origin serving this project's consent and credential pickup. */ authorizationOrigin: string; resourceOrigin: string; resourceOrgDid: string; projectId: string; apiKey: string; timeoutMs?: number; } /** Register the default browser step-up through the existing consent/mint lane. * No organization signing key belongs in the customer middleware. Unknown * principals stay explicitly anonymous until the consent flow establishes them. * Other policy challenges remain the responsibility of the caller's resolver. */ declare function createBrowserIntegrityChallengeResolver(options: BrowserIntegrityChallengeOptions): ({ result }: { result: VerifyResult; }) => Promise; //#endregion //#region src/composed-policy.d.ts /** * Structural shape of a compiled policy bundle — `{ authorize, free }`. The * cache + compile contract reference THIS, not the nominal * `PolicyEvaluatorRuntime` class, so a compiler returning either the Node * (`./policy`) or edge (`./policy-edge`) `PolicyEvaluatorRuntime` — whose * `private` member makes the two class declarations nominally distinct ACROSS * subpaths — type-checks uniformly. Both runtimes' evaluators (and a test * fake) satisfy this public surface. */ interface CompiledPolicy { authorize(input: AuthorizeInput): Decision; free(): void; } /** * Credential/protocol verification failures are a fail-closed floor. Tenant * Cedar may further restrict verified traffic, but it must never turn a failed * signature, revoked credential, missing auth, expired credential, scope miss, * or parse failure back into Permit. */ declare function isCredentialVerificationBlock(decision: Decision): decision is Extract; interface AuthorizeInputContext { /** * Trusted host configuration for the native HTTP agent lane. Never set from * request headers. The host must complete status/revision/replay admission * before projecting a Permit result. Existing TS hosts do not enable this * until they implement that native boundary; .NET owns the qualified path. */ nativeHttp?: boolean; /** Tenant identifier — the project id whose composed policy is evaluated. */ tenantId: string; /** Request path → `resource` + `resource.path`. Defaults to `'/'`. */ path?: string; /** * Cryptographically-verified agent DID, when the host resolved one. Used * SOLELY to mark `delegation: 'verified'` — it is deliberately NOT written to * `AuthorizeInput.agentDid` (the Cedar principal id). Only some hosts resolve a * DID (the edge worker / Fly MCP PEP do; the SDK middlewares may not), so * binding the principal id to it would make the SAME composed bundle decide * differently per host — and generated `/policy-compose` Cedar matches on * principal ATTRIBUTES (name/category/delegation), never the principal id, so * the id is decision-inert. Leaving it unset keeps the projection * host-independent. Omit when none. */ agentDid?: string; } /** * Project a verified request's detection facts into the engine's * `AuthorizeInput`. Facts a request cannot supply are left unset → the engine * defaults them (`''`) so an attribute clause evaluates `false` rather than * erroring. */ declare function verifyResultToAuthorizeInput(result: VerifyResult, ctx: AuthorizeInputContext): AuthorizeInput; /** * Compile a `(language, source)` bundle into a reusable evaluator. Injected so * each runtime supplies its target's compiler — Node `createPolicyEvaluator` * (sync) wrapped, or edge `evaluatePolicy` (async). Throws on invalid source / * unsupported language (surfaced by {@link evaluateComposedPolicy} as an * `error` outcome). */ type ComposedPolicyCompile = (language: string, source: string) => CompiledPolicy | Promise; interface ComposedPolicyCacheLogger { warn(message: string, fields: Record): void; } interface ComposedPolicyCacheOptions { compile: ComposedPolicyCompile; /** Max distinct compiled bundles held (LRU). Default 50. */ cacheMax?: number; logger?: ComposedPolicyCacheLogger; } interface ComposedPolicyCache { getOrCompile(projectId: string, language: string, source: string): Promise; } declare function compileWithNoEvidenceExclusion(source: string, compile: (source: string) => CompiledPolicy | Promise, onFallback?: (error: unknown) => void): Promise; /** * Build a bounded, single-flight compile cache keyed by `projectId:hash(source)` * — a policy edit yields a new key (the stale evaluator ages out). Stores the * in-flight PROMISE (not the resolved evaluator) so concurrent callers for the * same key join ONE compile rather than each compiling a ~2 MB WASM evaluator * and orphaning all but the last (a WASM-memory leak). A rejected compile is * evicted so a later request retries. Eviction DROPS THE REFERENCE; it does NOT * call `free()` — the evaluator can be shared with an in-flight `authorize()`, * so freeing on eviction risks a use-after-free against freed WASM; the * wasm-bindgen FinalizationRegistry reclaims it once unreferenced. */ declare function makeComposedPolicyCache(opts: ComposedPolicyCacheOptions): ComposedPolicyCache; /** The composed-policy fields the host reads off the project's `PolicyConfig`. */ interface ComposedPolicyFlags { policyLanguage: string | null | undefined; policySourceText: string | null | undefined; engineEnforcementEnabled: boolean | null | undefined; /** Master enable toggle — enforcement off (`false`) ⇒ OBSERVE, never act. */ enabled: boolean | null | undefined; } type ComposedPolicyOutcome = /** No composed policy (null/unsupported language or blank source). */ { status: 'no-policy'; } | /** Compile/authorize fault — shadow keeps the baseline; an enforcing host fails closed. */ { status: 'error'; error: unknown; } | /** Computed but NOT acting (flag off / master off). Use for telemetry. */ { status: 'shadow'; engineDecision: Decision; diverged: boolean; } | /** Acting — replace the baseline with `engineDecision`. */ { status: 'acting'; engineDecision: Decision; diverged: boolean; }; interface EvaluateComposedPolicyArgs { cache: ComposedPolicyCache; projectId: string; flags: ComposedPolicyFlags; authorizeInput: AuthorizeInput; /** Baseline (structured/bespoke) decision kind — for divergence telemetry. */ baselineDecisionKind: Decision['kind']; } /** * Evaluate a project's composed policy for one request. Pure orchestration: the * caller owns fetching the policy, building the `authorizeInput` (typically via * {@link verifyResultToAuthorizeInput}), computing the baseline decision, and * mapping/logging the outcome. Never throws — a compile/authorize fault returns * `{ status: 'error' }`; an enforcing host (`isEngineEnforcing`) must fail closed. */ declare function evaluateComposedPolicy(args: EvaluateComposedPolicyArgs): Promise; //#endregion //#region src/composed-policy-context.d.ts /** Dashboard the policy fetch defaults to when no base URL is set. */ declare const DEFAULT_DASHBOARD_URL = "https://kya.vouched.id"; /** * Telemetry sink. The shadow-divergence signal is the go/no-go instrument for * flipping a project to ENFORCE. */ interface ComposedPolicyLogger { shadowDivergence(info: ShadowDivergenceInfo): void; evaluationError(projectId: string, error: unknown): void; compileFallback?(projectId: string, error: string): void; } interface ShadowDivergenceInfo { projectId: string; path?: string; /** The engine's composed-policy decision kind. */ engineDecision: Decision['kind']; /** The structured decision kind it diverged from. */ structuredDecision: Decision['kind']; detectionClass: string; verificationMethod?: string; confidence: number; agentName?: string; } /** One composed-policy evaluation: the decision to enforce, and whether it replaced the structured one. */ interface ComposedPolicyApplyResult { decision: Decision; acted: boolean; composedBlobHash?: string; } interface ComposedPolicyContext { /** * Evaluate the project's composed policy for one request. Reads * `result.decision` as the structured baseline for the divergence comparison; * the caller applies `acted ? decision` afterwards (see * {@link applyComposedPolicy}). Throws when an ENFORCING project's bundle * cannot be evaluated, or when the policy cannot be read (origin * unavailable, or the API key refused); the middleware answers 503 in * enforce mode. */ apply(result: VerifyResult, path: string | undefined): Promise; /** * Resolve the org's trusted Layer-2 delegation root DIDs from the project's * policy payload. The middleware forwards these into the engine's * `ContextSpec.trustedDelegationRoots` on requests presenting a credential. * Optional so an injected context (advanced use and tests) need not implement * it: absence means no roots, and the engine rejects delegation. A policy * origin outage propagates `PolicyUnavailableError`, and a refused API key * `PolicyAuthError`; the middleware answers 503 in enforce mode. */ trustedDelegationRoots?(): Promise; } interface MakeComposedPolicyContextOptions { projectId: string; /** Fetches the project's `PolicyConfig` (carries the composed-policy fields). */ fetcher: PolicyFetcher; /** The runtime's Cedar compiler (see the module comment). */ compile: ComposedPolicyCompile; logger?: ComposedPolicyLogger; /** Max distinct compiled bundles cached (LRU); the core's default when unset. */ cacheMax?: number; } declare function makeComposedPolicyContext(opts: MakeComposedPolicyContextOptions): ComposedPolicyContext; /** * Evaluate the composed policy and swap `result.decision` in place when the * engine acts. The middleware calls it before the detection reporter and * before render, so the reporter records, and the response renders, the * enforced decision. A fault on an enforcing project propagates so the * middleware answers 503 instead of allowing. */ declare function applyComposedPolicy(context: ComposedPolicyContext | null, result: VerifyResult, path: string | undefined): Promise; /** * Resolves the org's trusted delegation roots (empty when none), from whatever * source the middleware has: the composed context's accessor, or a * `projectId`-only policy fetch when no context exists. */ type TrustedDelegationRootsResolver = () => Promise; /** * The org trusted-delegation roots to pass to the engine for this request. * `undefined` (leaving the verify options unchanged) unless a resolver is * configured and the request presents a KYA credential (a kya-http signature, * a delegation-proof header, or a VC-JWT bearer), so the human and * no-credential path never pays the policy fetch. */ declare function resolveTrustedDelegationRootsForRequest(resolver: TrustedDelegationRootsResolver | null, headers: Headers | Record): Promise; /** * Debug logger mirroring the gateway worker's evaluation telemetry. The * middleware wires it only when `config.debug` is set, so the default stays * silent. */ declare const consoleComposedPolicyLogger: ComposedPolicyLogger; //#endregion export { RequestClaim as A, applyBrowserPosture as B, isCredentialVerificationBlock as C, createBrowserIntegrityChallengeResolver as D, BrowserIntegrityChallengeOptions as E, createPlatformRequestClaimStore as F, verifiedBrowserPosture as G, postureHandlerView as H, requestClaimOf as I, isConsentRemediableBlock as L, RequestClaimStore as M, applyRequestClaim as N, LOCAL_REQUEST_CLAIM_CAPACITY as O, createLocalRequestClaimStore as P, PostureHandlerView as R, evaluateComposedPolicy as S, verifyResultToAuthorizeInput as T, postureOutcomeView as U, browserIntegrityChallengeScopes as V, validateBrowserIntegrityChallenge as W, ComposedPolicyCompile as _, MakeComposedPolicyContextOptions as a, EvaluateComposedPolicyArgs as b, applyComposedPolicy as c, resolveTrustedDelegationRootsForRequest as d, AuthorizeInputContext as f, ComposedPolicyCacheOptions as g, ComposedPolicyCacheLogger as h, DEFAULT_DASHBOARD_URL as i, RequestClaimOutcome as j, REQUEST_CLAIM_RETENTION_SECONDS as k, consoleComposedPolicyLogger as l, ComposedPolicyCache as m, ComposedPolicyContext as n, ShadowDivergenceInfo as o, CompiledPolicy as p, ComposedPolicyLogger as r, TrustedDelegationRootsResolver as s, ComposedPolicyApplyResult as t, makeComposedPolicyContext as u, ComposedPolicyFlags as v, makeComposedPolicyCache as w, compileWithNoEvidenceExclusion as x, ComposedPolicyOutcome as y, applyBrowserIntegrityStepUp as z }; //# sourceMappingURL=composed-policy-context-B7ziFk3g.d.mts.map