import { type JSONWebKeySet, type JWTPayload } from "jose"; import type { FetchLike } from "../handlers/HandlerRegistration.js"; import type { SecurityEvents } from "../incident/SecurityEvents.js"; export type JwtCode = "JWT_SIGNATURE_INVALID" | "JWT_AUDIENCE_MISMATCH" | "JWT_ISSUER_UNKNOWN" | "JWT_EXPIRED" | "JWT_ALGORITHM_REFUSED" | "JWT_SUBJECT_UNKNOWN" | "JWT_CLAIM_MISMATCH" | "JWKS_UNAVAILABLE"; export declare class JwtError extends Error { readonly code: JwtCode; constructor(code: JwtCode); } export interface VerifiedJwt { readonly issuer: string; readonly subject: string; readonly audiences: readonly string[]; readonly claims: JWTPayload; } export interface JwksRefresh { readonly url: string; /** The guarded fetch: the JWKS address is a sealed destination like any other. */ readonly fetch: FetchLike; readonly intervalSeconds: number; readonly events: SecurityEvents; } export interface WorkloadJwtVerifierOptions { /** Every audience a token may carry: the executor's own, and any a principal names. */ readonly audiences: readonly string[]; readonly keys: JSONWebKeySet; readonly clockToleranceSeconds: number; readonly maxTokenAgeSeconds?: number; readonly refresh?: JwksRefresh; /** Milliseconds since the epoch; `Date.now` when absent. */ readonly clock?: () => number; } /** Asymmetric only: a workload's token is signed by its platform, never by a shared secret. */ export declare const JWT_ALGORITHMS: readonly ["RS256", "ES256", "EdDSA"]; /** * The least time between two refreshes a token with an unknown key id asks * for. A key the issuer just rotated in is fetched at once rather than at the * next interval; a stream of tokens naming keys that do not exist cannot turn * this process into a client that fetches the key set on every request. */ export declare const UNKNOWN_KEY_REFRESH_MS = 30000; /** * Verifies a workload's token against a JWKS the platform team placed on * disk, optionally refreshed from a URL through the guarded fetch with the * last good set kept on any failure. Signature, algorithm, audience, age * and the four required claims are checked here; who the issuer and subject * are is the registry's question. There is no `jti` cache by design: a * projected token is a bearer for its lifetime, replay of a request is * defeated by the idempotency key, the intent hash and the single-use * grant, and a signed request exists for per-request proof. */ export declare class WorkloadJwtVerifier { private readonly options; private keys; private timer; private lastUnknownKeyRefresh; constructor(options: WorkloadJwtVerifierOptions); /** A JWKS document: an object with a `keys` array of objects that each name a key type. */ static parseJwks(text: string): JSONWebKeySet; verify(token: string): Promise; private payloadOf; /** One refresh for a token's unknown key id, when there is an address and the last was long enough ago. */ private refreshForUnknownKey; /** Begins refreshing from the URL on the interval; a failure keeps the last good set. */ start(): void; stop(): void; /** One refresh; true when a new set became current. */ refreshNow(): Promise; private static code; } //# sourceMappingURL=WorkloadJwtVerifier.d.ts.map