import { type EnvironmentConfig } from "../../config/environment-config.js"; import { type EnvReader } from "../providers/base.js"; import type { OAuthServiceConfig, OAuthTokens, TokenStore } from "../types.js"; /** Options accepted by oauth callback handler. */ export interface OAuthCallbackHandlerOptions { /** Shared token store. Optional only in explicit development/test environments. */ tokenStore?: TokenStore; /** Base URL for redirects (defaults to APP_URL or localhost) */ baseUrl?: string; /** Success redirect path */ successRedirect?: string; /** Error redirect path */ errorRedirect?: string; /** * Post-commit success notification. Failures are logged without changing the * completed OAuth result. Receives a detached token snapshot. */ onSuccess?: (serviceId: string, tokens: OAuthTokens, userId: string) => void | Promise; /** Custom error callback */ onError?: (serviceId: string, error: string) => void | Promise; /** @deprecated State validation cannot be disabled; `true` is rejected. */ skipStateValidation?: boolean; /** * @deprecated Callback identity is always recovered from the one-shot state * row. This option is retained only for source compatibility and is ignored. */ getUserId?: (request: Request) => string | null | Promise; /** EnvironmentConfig for test isolation (defaults to getEnvironmentConfig()) */ env?: EnvironmentConfig; /** EnvReader for dynamic env vars (defaults to getEnv) */ envReader?: EnvReader; } /** Options accepted by a shared OAuth callback dispatcher. */ export interface OAuthCallbackDispatcherOptions extends OAuthCallbackHandlerOptions { /** * Physical callback route shared by every allowlisted service. * * Init handlers for these services must receive the same `callbackRouteId`. */ callbackRouteId: string; } /** Create a callback handler for one logical OAuth service. */ export declare function createOAuthCallbackHandler(config: OAuthServiceConfig, options?: OAuthCallbackHandlerOptions): (request: Request) => Promise; /** * Create one callback handler shared by a fixed allowlist of logical services. * * The consumed state selects a service only after generic state validation. * Configuration is snapshotted at construction and duplicate service IDs are * rejected so dispatch cannot depend on mutable array order. */ export declare function createOAuthCallbackDispatcher(configs: readonly OAuthServiceConfig[], options: OAuthCallbackDispatcherOptions): (request: Request) => Promise; //# sourceMappingURL=callback-handler.d.ts.map