import { ApiProfile } from "@decionis/agent-safe-pipeline"; import { type ConsequentialMethod, type GatewayConfig, type PrivacyMode, type RouteConfig, type UnmatchedPolicy } from "./GatewayConfig.js"; /** * What the gateway does with a read. `PASSTHROUGH` is today's: never * evaluated. `CHECK` checks a read a profile operation names against the * session's subject and passes the rest. `REFUSE_UNKNOWN` also refuses a * read no profile operation names. */ export type ReadPolicy = "PASSTHROUGH" | "CHECK" | "REFUSE_UNKNOWN"; /** What the gateway decided about one request before reading its body. */ export type RoutePlan = { readonly kind: "PASSTHROUGH"; readonly reason: "SAFE_METHOD" | "UNMATCHED" | "DISABLED"; } | { readonly kind: "REFUSE"; readonly code: "HTTP_METHOD_UNSUPPORTED" | "HTTP_PATH_AMBIGUOUS" | "PROFILE_OPERATION_UNMATCHED" | "READ_OPERATION_UNMATCHED"; } | { /** A read a profile operation names: checked against the session's subject, never decided. */ readonly kind: "CHECK"; readonly action: string; readonly operation: string; } | { readonly kind: "GOVERN"; readonly action: string; readonly route: RouteConfig | null; /** The API profile operation that named the action, when a profile did. */ readonly operation?: string; }; /** * One row of what the table does with a consequential request, as it tries * them: the methods and path pattern (`/**` for the rest), and the action it * governs under (`GOVERN`), or that it passes the request (`PASSTHROUGH`) or * refuses it (`REFUSE`) without asking anyone. */ export interface RouteRow { readonly methods: readonly ConsequentialMethod[]; readonly path: string; readonly action: string | null; readonly disposition: "GOVERN" | "PASSTHROUGH" | "REFUSE"; } /** A request's query, as the gateway reads it for planning: each name to one value or a list. */ export type PlanQuery = { readonly [key: string]: string | readonly string[]; }; /** The derived action for an unsafe request no route names. */ export declare function derivedAction(method: ConsequentialMethod): string; /** * The route table: which requests are consequential, and what each is * called. A safe method is never consequential. An explicit route is tried * first, then the API profile's operations, when the gateway governs by one * (`agent-safe.profile.api/1`). An unsafe request neither names is governed * under a derived name unless the configuration chose passthrough, so * narrowing what is governed is an explicit act. In facts-only privacy the * profile alone names a call: what it does not name is refused, because * governing it would send the authority its raw path. */ export declare class RouteTable { private readonly unmatched; private readonly enabled; /** The API profile the table governs by, after any explicit route; null for routes alone. */ readonly profile: ApiProfile | null; private readonly privacy; readonly reads: ReadPolicy; private readonly routes; constructor(routes: readonly RouteConfig[], unmatched: UnmatchedPolicy, enabled?: boolean, /** The API profile the table governs by, after any explicit route; null for routes alone. */ profile?: ApiProfile | null, privacy?: PrivacyMode, reads?: ReadPolicy); /** * The table a gateway with this configuration plans by. Reads are checked * only when the gateway pins subjects, and unknown ones refused only when * the configuration says so. */ static of(config: GatewayConfig): RouteTable; /** Every action name this table can produce, for the registry to be sealed over. */ actions(): readonly string[]; /** * What the table governs, in the order `plan` tries it: the explicit routes * (none in facts-only privacy, which never reads them), the profile's * writes, then what becomes of every other consequential request. A read * is never governed, so it is not a row. */ rows(): readonly RouteRow[]; /** * A read, when reads are checked. A `GET` a profile operation names is * checked. One that only resembles an operation (another letter case, an * encoded literal) is refused as ambiguous, since the upstream may serve * it as that operation. A path beneath a checked read (`/$count`, a * navigation, a media stream) answers what the read's subject rule does * not check, and a `HEAD` or `OPTIONS` on a checked read's path has no * answer to check while its status says whether a record exists: both are * refused. Anything else passes, or is refused when unknown reads are. */ private planRead; plan(method: string, pathname: string, query?: PlanQuery): RoutePlan; } //# sourceMappingURL=RouteTable.d.ts.map