/** * Cross-runtime HTTP server for handling OAuth callbacks. * * SPDX-FileCopyrightText: 2025-present Kriasoft * SPDX-License-Identifier: MIT */ /** * Result object returned from OAuth callback containing authorization code or error details. */ export interface CallbackResult { /** Authorization code returned by OAuth provider */ code?: string; /** State parameter for CSRF protection */ state?: string; /** OAuth error code (e.g., 'access_denied', 'invalid_request') */ error?: string; /** Human-readable error description */ error_description?: string; /** URI with additional error information */ error_uri?: string; /** Additional query parameters from OAuth provider */ [key: string]: string | undefined; } /** * Configuration options for the OAuth callback server. */ export interface ServerOptions { /** Port number to bind the server to */ port: number; /** Hostname to bind the server to (default: "localhost") */ hostname?: string; /** Custom HTML content for successful authorization */ successHtml?: string; /** Custom HTML template for error pages (supports {{error}}, {{error_description}}, {{error_uri}} placeholders) */ errorHtml?: string; /** AbortSignal for cancelling the server operation */ signal?: AbortSignal; /** Callback function called for each HTTP request (useful for logging/debugging) */ onRequest?: (req: Request) => void; } /** * Interface for OAuth callback server implementations across different runtimes. */ export interface CallbackServer { /** Start the HTTP server with the given options */ start(options: ServerOptions): Promise; /** Wait for OAuth callback on the specified path with timeout */ waitForCallback(path: string, timeout: number): Promise; /** Stop the server and cleanup resources */ stop(): Promise; } /** * Create a callback server for the current runtime (Bun, Deno, or Node.js). * Automatically detects the runtime and returns the appropriate server implementation. * @returns CallbackServer instance optimized for the current runtime. */ export declare function createCallbackServer(): CallbackServer; //# sourceMappingURL=server.d.ts.map