/** * Claims set on a signed token. Each one overrides this issuer's default; one set to `undefined` * is left out. */ export interface TokenClaims { readonly iss?: string | undefined; readonly sub?: string | undefined; readonly aud?: string | string[] | undefined; readonly iat?: number | undefined; /** Epoch seconds. Default: five minutes from now. */ readonly exp?: number | undefined; /** Space-separated, as the wire carries it. */ readonly scope?: string | undefined; readonly client_id?: string | undefined; /** Proof of possession, for checking that a sender-constrained token is refused. */ readonly cnf?: { readonly jkt: string; } | undefined; } export interface FakeIssuerOptions { /** The resource identifier tokens are minted for: an application's public origin root. */ readonly resource: string; /** The scopes a signed token, and a key minted without permissions, carry. */ readonly scopes: readonly string[]; /** Who every credential belongs to. Default `"owner"`. */ readonly subject?: string; } /** Resource identifier to the scopes a key has there, as the real issuer takes them. */ export type Permissions = Readonly>; export interface FakeIssuer { /** What a resource server is configured with: `http://127.0.0.1:/api/auth`. */ readonly issuer: string; /** Sign an access token this issuer's JWKS verifies. */ readonly sign: (claims?: TokenClaims, typ?: string) => Promise; /** * Mint an API key, listed in each granted resource's key list from its next read. * Default permissions: every configured scope on the configured resource. `expiresAt` * is when the key stops verifying; default never. Key IDs are `key-1`, `key-2`, …. */ readonly apiKey: (permissions?: Permissions, expiresAt?: Date) => string; /** Leave a minted key out of every key list from now on, as the real issuer does. */ readonly revoke: (key: string) => void; /** Answer both endpoints with this status instead of serving them; omit to restore. */ readonly fail: (status?: number) => void; /** Key lists served, so a test can see when a resource server reads its next one. */ readonly keyLists: () => number; readonly close: () => Promise; } export declare const startFakeIssuer: (options: FakeIssuerOptions) => Promise;