import type { IncomingHttpHeaders, IncomingMessage } from "node:http"; /** Trusted principal header injected by the switching proxy after auth. */ export declare const ROUTEKIT_PRINCIPAL_HEADER = "x-routekit-principal"; export type GatewayPrincipal = { id: string; label: string; role: "owner" | "admin" | "eval"; routing?: { repositoryRoot: string; profileName: string; }; evalSession?: { sessionId: string; allowedModels: readonly string[]; expiresAt: string; perCallOutputTokens?: number; admit?: (model: string, inputTokenUpperBound: number, requestedOutputTokens: number) => EvalSessionAdmission; }; }; export type EvalSessionAdmission = { readonly admitted: true; } | { readonly admitted: false; readonly reason: "closed" | "expired" | "call_limit" | "input_limit" | "output_limit"; }; export type WorkloadJwtPrincipalPolicy = { /** Exact AWS workload identity subject accepted by the broker. */ subject: string; /** Immutable isolation boundary carried in the signed credential. */ trustDomain: string; /** RouteKit principal carried in the signed credential. */ principal: string; role?: "owner" | "admin"; }; export type WorkloadJwtVerifierOptions = { issuer: string; audience: string; /** ES256 public keys keyed by the JWT `kid`. */ publicKeys: Readonly>; principals: readonly WorkloadJwtPrincipalPolicy[]; /** Maximum permitted credential lifetime. Defaults to ten minutes. */ maxLifetimeSeconds?: number; /** Clock tolerance for distributed hosts. Defaults to 30 seconds. */ clockSkewSeconds?: number; /** Test seam. Production callers should leave this unset. */ now?: () => number; }; /** * Build a synchronous ES256 verifier for short-lived RouteKit workload JWTs. * * Public keys and authorization mappings are immutable configuration. The * bearer credential remains memory-only at callers and is never registered in * RouteKit's durable token store. */ export declare function createWorkloadJwtVerifier(options: WorkloadJwtVerifierOptions): (presented: string) => GatewayPrincipal | undefined; /** Constant-time string equality (length-independent; no timing leaks). */ export declare function timingSafeStringEqual(a: string, b: string): boolean; /** Verify an `Authorization: Bearer ` header value. */ export declare function verifyBearerToken(header: string | undefined, expected: string): boolean; /** * Extract the presented credential from either `Authorization: Bearer` or * `x-api-key`. Returns undefined when neither is present. */ export declare function presentedCredential(req: IncomingMessage): string | undefined; /** * The gateway's request-authorization rule: a matching bearer token or a * matching `x-api-key` header. */ export declare function authorizedRequest(req: IncomingMessage, token: string): boolean; export declare function authorizedHeaders(headers: IncomingHttpHeaders, token: string): boolean; /** Resolve a principal from the request using the configured token registry. */ export declare function resolvePrincipal(req: IncomingMessage, resolve: (presented: string) => GatewayPrincipal | undefined): GatewayPrincipal | undefined; /** Parse a trusted principal header value injected by the switching proxy. */ export declare function parsePrincipalHeader(value: string | undefined): GatewayPrincipal | undefined;