/**
 * MCP OAuth Auto-Discovery
 *
 * Automatically detects OAuth requirements from MCP server responses
 * and extracts authentication endpoints.
 */
import type { FetchImpl } from "@pk-nerdsaver-ai/pi-ai/types";
export interface OAuthEndpoints {
    authorizationUrl: string;
    tokenUrl: string;
    clientId?: string;
    scopes?: string;
    resource?: string;
}
export interface AuthDetectionResult {
    requiresAuth: boolean;
    authType?: "oauth" | "apikey" | "unknown";
    oauth?: OAuthEndpoints;
    authServerUrl?: string;
    resourceMetadataUrl?: string;
    message?: string;
}
export declare function extractMcpAuthServerUrl(error: Error, serverUrl?: string): string | undefined;
/**
 * Detect if an error indicates authentication is required.
 * Checks for common auth error patterns.
 */
export declare function detectAuthError(error: Error): boolean;
/**
 * Extract OAuth endpoints from error response.
 * Looks for WWW-Authenticate header format or JSON error bodies.
 */
export declare function extractOAuthEndpoints(error: Error): OAuthEndpoints | null;
/**
 * Analyze an error to determine authentication requirements.
 * Returns structured info about what auth is needed.
 */
export declare function analyzeAuthError(error: Error, serverUrl?: string): AuthDetectionResult;
/**
 * Try to discover OAuth endpoints by querying the server's well-known endpoints.
 * This is a fallback when error responses don't include OAuth metadata.
 */
export declare function discoverOAuthEndpoints(serverUrl: string, authServerUrl?: string, resourceMetadataUrl?: string, opts?: {
    fetch?: FetchImpl;
    protectedResource?: string;
}): Promise<OAuthEndpoints | null>;
