import { GetTokenParams, ApprovalParams, Strategy } from 'nominee'; interface PostgresQueryResult = Record> { rows: Row[]; } interface PostgresClient { query = Record>(text: string, values?: unknown[]): Promise>; } interface PostgresDatabase { transaction(operation: (client: PostgresClient) => Promise): Promise; } /** TTL of the built-in mock token (ms). Also the demo's compressed-expiry window. */ declare const MOCK_TTL_MS = 3000; interface Auth0CibaOptions { /** * Map a nominee user id to an Auth0 `login_hint` (typically the user's `sub`). * Defaults to the user id verbatim. */ loginHint?: (user: string) => string | Promise; /** * Short message shown to the user on their device when approving. Auth0 * limits this to ~64 chars. Defaults to `Approve: `. */ bindingMessage?: (params: ApprovalParams) => string | Promise; /** Scope requested for the approval. Default `"openid"`. */ scope?: string; /** API audience for the approval token, if your tenant requires one. */ audience?: string; /** Override the server-provided poll interval (ms). */ pollIntervalMs?: number; /** Durable request state used to resume polling after restart. */ store?: CibaStore; /** Per-request fetch deadline. Default 15 seconds. */ requestTimeoutMs?: number; /** * Override ID-token verification. The callback MUST verify signature, * issuer, audience, expiry, and return a trusted `sub`. */ verifyIdToken?: (idToken: string) => Promise>; } interface Auth0Options { /** Your Auth0 tenant domain, e.g. `your-tenant.us.auth0.com`. */ domain: string; clientId: string; clientSecret: string; /** * Resolve the user's Auth0 token used as the token-exchange subject — read it * from your session store. Return the user's **refresh token** (recommended, * durable) or access token (set {@link subjectTokenType} to `"access_token"`). */ subjectToken: (params: GetTokenParams) => string | Promise; /** Type of the subject token. Default `"refresh_token"`. */ subjectTokenType?: 'refresh_token' | 'access_token'; /** * Enable human-in-the-loop approval via CIBA (push/SMS to the user's device). * Omit to disable native approval — nominee then falls back to its built-in * approval engine. */ ciba?: Auth0CibaOptions; /** Custom fetch implementation (defaults to global `fetch`). Useful for tests. */ fetch?: typeof fetch; } interface CibaState { id: string; user: string; action: string; expectedApprover: string; inputHash?: string; policyVersion?: string; resource?: string; tenant?: string; intervalMs: number; nextPollAt: number; expiresAt: number; } interface CibaStore { readonly durable: boolean; get(id: string): Promise; put(state: CibaState): Promise; /** * Atomically claim a due poll and move `nextPollAt` forward. Returns null * when another worker already claimed it or the request does not exist. */ claimPoll(id: string, now: number): Promise; update(id: string, patch: Partial): Promise; delete(id: string): Promise; } declare class MemoryCibaStore implements CibaStore { readonly durable = false; private readonly states; get(id: string): Promise; put(state: CibaState): Promise; claimPoll(id: string, now: number): Promise; update(id: string, patch: Partial): Promise; delete(id: string): Promise; } /** Idempotent PostgreSQL schema for {@link PostgresCibaStore}. */ declare const POSTGRES_CIBA_SCHEMA = "\nCREATE TABLE IF NOT EXISTS nominee_ciba_requests (\n id text PRIMARY KEY,\n state jsonb NOT NULL,\n next_poll_at bigint NOT NULL,\n expires_at bigint NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS nominee_ciba_requests_expiry_idx\n ON nominee_ciba_requests (expires_at);\n"; /** Durable Auth0 CIBA request state using nominee-postgres' transaction adapter. */ declare class PostgresCibaStore implements CibaStore { private readonly database; readonly durable = true; constructor(database: PostgresDatabase); get(id: string): Promise; put(state: CibaState): Promise; claimPoll(id: string, now: number): Promise; update(id: string, patch: Partial): Promise; delete(id: string): Promise; } /** * Auth0 strategy for nominee — the flagship, most complete strategy. * * - `getToken` brokers a fresh third-party token via **Auth0 Token Vault** * (federated-connection token exchange), so your agent acts on the user's * GitHub / Slack / Google / … without you ever touching those credentials. * - `requestApproval` runs **CIBA** human-in-the-loop: the user approves on * their phone, then the agent resumes. * * Works with any nominee adapter (`nominee-ai`, `nominee-eve`) or standalone. * * ```ts * import { Nominee } from 'nominee' * import { Auth0 } from 'nominee-auth0' * * const nominee = new Nominee({ * strategy: Auth0({ * domain: process.env.AUTH0_DOMAIN!, * clientId: process.env.AUTH0_CLIENT_ID!, * clientSecret: process.env.AUTH0_CLIENT_SECRET!, * subjectToken: ({ user }) => store.getRefreshToken(user), // your session store * ciba: { loginHint: (user) => store.getAuth0Sub(user) }, * }), * }) * * const token = await nominee.token({ user, connection: 'github' }) // always fresh * ``` */ declare function Auth0(options: Auth0Options): Strategy; interface Auth0AutoOptions extends Partial { /** Force mock mode regardless of env (used by tests/demos). Default: auto-detect. */ mock?: boolean; /** Env source. Default: `process.env`. */ env?: Record; } /** * Zero-config Auth0 strategy. Reads `AUTH0_DOMAIN`, `AUTH0_CLIENT_ID`, * `AUTH0_CLIENT_SECRET`, `AUTH0_REFRESH_TOKEN`, and `AUTH0_USER_SUB` from the * environment. When the core creds are absent it transparently falls back to a * built-in mock (short-TTL token + auto-approve) so an example runs with zero * setup. Configure the env (e.g. via `pnpm setup`) and the *same call* becomes * real Token Vault + CIBA — no code change. * * ```ts * const nominee = new Nominee({ strategy: auth0() }) * ``` */ declare function auth0(options?: Auth0AutoOptions): Strategy; export { Auth0, type Auth0AutoOptions, type Auth0CibaOptions, type Auth0Options, type CibaState, type CibaStore, MOCK_TTL_MS, MemoryCibaStore, POSTGRES_CIBA_SCHEMA, PostgresCibaStore, auth0 };