import { type ErrorHook, type ErrorHookInput, type Store, type SigningKeyOptions } from './core/index.js'; import { type WorkOSSeedConfig } from './workos/index.js'; export interface ErrorHookSeedConfig { method: string; path: string; status: number; body?: { message?: string; code?: string; errors?: Array<{ field: string; code: string; message?: string; }>; }; count?: number; } export interface EmulatorSeedConfig { apiKeys?: WorkOSSeedConfig['apiKeys']; organizations?: WorkOSSeedConfig['organizations']; users?: WorkOSSeedConfig['users']; connections?: WorkOSSeedConfig['connections']; connectedAccounts?: WorkOSSeedConfig['connectedAccounts']; invitations?: WorkOSSeedConfig['invitations']; roles?: WorkOSSeedConfig['roles']; permissions?: WorkOSSeedConfig['permissions']; webhookEndpoints?: WorkOSSeedConfig['webhookEndpoints']; connectApplications?: WorkOSSeedConfig['connectApplications']; resourceIndicators?: WorkOSSeedConfig['resourceIndicators']; jwtTemplate?: WorkOSSeedConfig['jwtTemplate']; sessionSettings?: WorkOSSeedConfig['sessionSettings']; featureFlags?: WorkOSSeedConfig['featureFlags']; directories?: WorkOSSeedConfig['directories']; agentBlueprints?: WorkOSSeedConfig['agentBlueprints']; errorHooks?: ErrorHookSeedConfig[]; } export interface EmulatorOptions { port?: number; /** Maximum requests per API key in each 60-second window; defaults to 1,000. */ requestsPerMinute?: number; /** * Network interface to bind to. Defaults to `localhost`, which keeps the * emulator's unauthenticated endpoints reachable only from the local * machine. Set to `0.0.0.0` (or a specific interface) to intentionally * expose the emulator to other hosts on the network. */ hostname?: string; seed?: EmulatorSeedConfig; /** * Base the `iss` claim is built from, and the base of the OIDC issuer discovery advertises. * Defaults to the emulator's own URL, which changes with the port. Pin it to the URL your real * WorkOS environment issues from so a verifier comparing `iss` against a constant needs no * test-only branch. The verifier must still fetch JWKS from the emulator. * * Not the whole claim: an AuthKit access token carries `{issuer}/user_management/{client_id}`, * as production does. Only the M2M, SSO, widget and OAuth-server (`/oauth2/token`) tokens carry * the bare value, and the latter's discovery documents advertise it as `issuer`. */ issuer?: string; /** * Pinned RSA signing key. By default the emulator generates one at startup, so its JWKS * — and every token signed against it — is invalidated by a restart. Pin the key to keep * the JWKS stable across restarts, to share one key between several emulator instances, * or to pre-sign tokens offline with the same key the emulator verifies. */ signingKey?: SigningKeyOptions; /** * Extra hosts a `redirect_uri` (or a session logout `return_to`) may point at. The emulator * refuses to redirect anywhere else so it cannot be used as an open redirect; `localhost`, * `127.0.0.1` and `[::1]` are always allowed. Add the production-like hostnames your test * environment fakes — `['app.example.test']` — or a subdomain wildcard * (`['*.example.test']`). `['*']` allows any host, which turns the check off entirely. */ allowedRedirectHosts?: string[]; /** * Serve login pages from the authorize endpoints instead of redirecting straight back with a * code, for browser-driven tests. `true` serves the email-only page; `{ password: true }` also * asks a user who has a password for it, as hosted AuthKit does. See `InteractiveAuthOptions`. */ interactiveAuth?: boolean | InteractiveAuthOptions; webhookRetryConfig?: { maxRetries?: number; initialDelayMs?: number; maxDelayMs?: number; backoffMultiplier?: number; }; webhookDebugMode?: boolean; } export interface InteractiveAuthOptions { /** * Ask a user who has a password for it after the email step, on its own page, before any * organization selection. A user without a password is not asked. Off by default, because the * one-step email page is what existing browser suites were written against. */ password?: boolean; } export interface Emulator { url: string; port: number; apiKey: string; store: Store; close(): Promise; reset(): void; addErrorHook(hook: ErrorHookInput): ErrorHook; removeErrorHook(id: string): boolean; listErrorHooks(): ErrorHook[]; } export declare function createEmulator(options?: EmulatorOptions): Promise;