/**
 * OAuth Manager
 *
 * Manages OAuth authentication flows for AI providers.
 * Supports PKCE, token refresh, and secure storage.
 */
import { EventEmitter } from 'events';
import type { OAuthProviderId, OAuthProviderConfig, OAuthToken, StoredCredential, OAuthConfig } from './types.js';
/**
 * OAuth Manager
 *
 * Handles OAuth 2.0 flows for AI provider authentication.
 */
export declare class OAuthManager extends EventEmitter {
    private config;
    private providerConfigs;
    private credentials;
    private pendingStates;
    private refreshTimers;
    private localServer;
    constructor(config?: Partial<OAuthConfig>);
    /**
     * Configure an OAuth provider
     */
    configureProvider(providerId: OAuthProviderId, clientId: string, clientSecret?: string, redirectUri?: string): void;
    /**
     * Get provider configuration
     */
    getProviderConfig(providerId: OAuthProviderId): OAuthProviderConfig | undefined;
    /**
     * List configured providers
     */
    getConfiguredProviders(): OAuthProviderId[];
    /**
     * Get authorization URL for a provider
     */
    getAuthorizationUrl(providerId: OAuthProviderId): Promise<string>;
    /**
     * Exchange authorization code for tokens
     */
    exchangeCode(providerId: OAuthProviderId, code: string, state: string): Promise<StoredCredential>;
    /**
     * Refresh an access token
     */
    refreshToken(credentialId: string): Promise<OAuthToken>;
    /**
     * Get credential by ID
     */
    getCredential(credentialId: string): StoredCredential | undefined;
    /**
     * Get default credential for a provider
     */
    getCredentialForProvider(providerId: OAuthProviderId): StoredCredential | undefined;
    /**
     * Get all credentials
     */
    getAllCredentials(): Map<string, StoredCredential>;
    /**
     * Remove a credential
     */
    removeCredential(credentialId: string): boolean;
    /**
     * Check if token is expired or about to expire
     */
    isTokenExpired(credential: StoredCredential): boolean;
    /**
     * Get valid access token, refreshing if needed
     */
    getAccessToken(credentialId: string): Promise<string>;
    /**
     * Start local server for OAuth callback
     */
    startLocalServer(): Promise<void>;
    /**
     * Stop local server
     */
    stopLocalServer(): Promise<void>;
    /**
     * Handle OAuth callback
     */
    private handleCallback;
    /**
     * Generate PKCE challenge
     */
    private generatePKCE;
    /**
     * Parse token response
     */
    private parseTokenResponse;
    /**
     * Fetch user info from provider
     */
    private fetchUserInfo;
    /**
     * Generate credential ID
     */
    private generateCredentialId;
    /**
     * Schedule token refresh
     */
    private scheduleRefresh;
    /**
     * Shutdown manager
     */
    shutdown(): Promise<void>;
    /**
     * Get statistics
     */
    getStats(): {
        configuredProviders: number;
        storedCredentials: number;
        pendingAuthorizations: number;
    };
}
/**
 * Get OAuth manager instance
 */
export declare function getOAuthManager(config?: Partial<OAuthConfig>): OAuthManager;
/**
 * Reset OAuth manager instance
 */
export declare function resetOAuthManager(): Promise<void>;
export default OAuthManager;
