import { type OperatorScope, type PrincipalEntry } from "./PrincipalsFile.js"; import { type RateLimitRule } from "./RateLimiter.js"; export type Role = "PROPOSER" | "OPERATOR"; export type ClaimValue = string | number | boolean; export interface PrincipalActor { readonly id: string; readonly type: string; readonly runtime?: string; } export type PrincipalCredential = { readonly kind: "BEARER"; readonly digest: () => Uint8Array; } | { readonly kind: "MTLS"; readonly sanUri: string; readonly fingerprint: string | null; } | { readonly kind: "WORKLOAD_JWT"; readonly issuer: string; readonly subject: string; readonly audience: string | null; readonly requiredClaims: Readonly>; }; export interface Principal { readonly id: string; readonly role: Role; /** A proposer's tenant and actor: what its intents carry. Null for an operator. */ readonly tenantId: string | null; readonly actor: PrincipalActor | null; readonly allowedActions: ReadonlySet; readonly scopes: ReadonlySet; readonly credential: PrincipalCredential; readonly rateLimit: RateLimitRule | null; } /** The one caller a configuration without a principals file has. */ export declare const LEGACY_CALLER_ID = "legacy-caller"; /** One credential kind's own shape, for a lookup that narrowed to it. */ type CredentialOf = Extract; export type Comparator = (a: Uint8Array, b: Uint8Array) => boolean; export interface RegistryContext { readonly registeredActions: Iterable; readonly jwtConfigured: boolean; readonly mutualTls: boolean; } export interface LegacyContext { readonly tenantId: string; readonly actor: PrincipalActor; readonly registeredActions: Iterable; /** The caller token's current digest; read at each comparison so rotation is followed. */ readonly callerToken: () => Uint8Array; } /** * Who may call this process and as what. Built once, from the principals * file or from the legacy caller the configuration names, and never changed * while running. A bearer lookup hashes what was presented and compares it * with every bearer digest in constant time, without stopping at a match, * so timing says nothing about which principal, if any, it was. */ export declare class PrincipalRegistry { private readonly principals; readonly legacy: boolean; private readonly compare; private readonly byId; constructor(principals: readonly Principal[], legacy: boolean, compare?: Comparator); /** The principals a file names, checked against what this process can run and verify. */ static fromEntries(entries: readonly PrincipalEntry[], context: RegistryContext, compare?: Comparator): PrincipalRegistry; /** The legacy caller: one proposer, every registered action, the caller token as its credential. */ static legacy(context: LegacyContext, compare?: Comparator): PrincipalRegistry; get size(): number; get all(): readonly Principal[]; get proposers(): readonly Principal[]; get operators(): readonly Principal[]; principal(id: string): Principal | null; /** * The principals holding one kind of credential, narrowed once here rather * than by a kind check inside every lookup. A lookup then reads only the * fields its own kind has, and there is one place where the narrowing * could be wrong. */ private ofKind; /** Every bearer digest is compared, in constant time, whether or not an earlier one matched. */ byBearerDigest(presented: string): Principal | null; /** The principal a client certificate names by SAN URI, and pins by fingerprint when the file says so. */ byCertificate(sanUris: readonly string[], fingerprint: string): Principal | null; issuerKnown(issuer: string): boolean; /** * The principal a workload token names, with its own credential, so the * caller reads the issuer, audience and required claims without narrowing * a second time. */ byJwt(issuer: string, subject: string): { readonly principal: Principal; readonly credential: CredentialOf<"WORKLOAD_JWT">; } | null; /** The audiences named per principal, so the verifier accepts each; the global one is the default. */ audiences(): readonly string[]; private static credential; } export {}; //# sourceMappingURL=PrincipalRegistry.d.ts.map