/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { OAuthToken, AuthStatus, TokenStore } from './types.js';
import { LoadedSettings } from '../config/settings.js';
/**
 * Interface for OAuth provider abstraction
 * Each provider (e.g., Google, Qwen) implements this interface
 */
export interface OAuthProvider {
    /** Provider name (e.g., 'gemini', 'qwen') */
    name: string;
    /**
     * Initiate OAuth authentication flow
     * This starts the device flow or opens browser for auth
     */
    initiateAuth(): Promise<void>;
    /**
     * Get current OAuth token for this provider
     * @returns OAuth token if available, null otherwise
     */
    getToken(): Promise<OAuthToken | null>;
    /**
     * Refresh token if it's expired or about to expire
     * @returns Refreshed token or null if refresh failed
     */
    refreshIfNeeded(): Promise<OAuthToken | null>;
}
/**
 * OAuth Manager coordinates multiple OAuth providers
 * Provides unified interface for authentication across providers
 */
export declare class OAuthManager {
    private providers;
    private tokenStore;
    private settings?;
    private inMemoryOAuthState;
    constructor(tokenStore: TokenStore, settings?: LoadedSettings);
    /**
     * Register an OAuth provider with the manager
     * @param provider - The OAuth provider to register
     */
    registerProvider(provider: OAuthProvider): void;
    /**
     * Get a registered OAuth provider
     * @param name - Provider name
     * @returns OAuth provider or undefined if not registered
     */
    getProvider(name: string): OAuthProvider | undefined;
    /**
     * Authenticate with a specific provider
     * @param providerName - Name of the provider to authenticate with
     */
    authenticate(providerName: string): Promise<void>;
    /**
     * Get authentication status for all registered providers
     * @returns Array of authentication status for each provider
     */
    getAuthStatus(): Promise<AuthStatus[]>;
    /**
     * @plan PLAN-20250823-AUTHFIXES.P14
     * @requirement REQ-002
     * @pseudocode lines 51-68
     * Check if authenticated with a specific provider (required by precedence resolver)
     * @param providerName - Name of the provider
     * @returns True if authenticated, false otherwise
     */
    isAuthenticated(providerName: string): Promise<boolean>;
    /**
     * @plan PLAN-20250823-AUTHFIXES.P14
     * @requirement REQ-002.1
     * @pseudocode lines 4-37
     * Logout from a specific provider by clearing stored tokens
     * @param providerName - Name of the provider to logout from
     */
    logout(providerName: string): Promise<void>;
    /**
     * @plan PLAN-20250823-AUTHFIXES.P14
     * @requirement REQ-002
     * @pseudocode lines 39-49
     * Logout from all providers by clearing all stored tokens
     */
    logoutAll(): Promise<void>;
    /**
     * Get OAuth token for a specific provider
     * Compatible with precedence resolver - returns access token string
     * @param providerName - Name of the provider
     * @returns Access token string if available, null otherwise
     */
    getToken(providerName: string): Promise<string | null>;
    /**
     * Get OAuth token object for a specific provider
     * @param providerName - Name of the provider
     * @returns OAuth token if available, null otherwise
     */
    getOAuthToken(providerName: string): Promise<OAuthToken | null>;
    /**
     * Get list of all registered provider names
     * @returns Array of provider names
     */
    getSupportedProviders(): string[];
    /**
     * Toggle OAuth enablement for a provider
     * @param providerName - Name of the provider
     * @returns New enablement state (true if enabled, false if disabled)
     */
    toggleOAuthEnabled(providerName: string): Promise<boolean>;
    /**
     * Check if OAuth is enabled for a provider
     * @param providerName - Name of the provider
     * @returns True if OAuth is enabled, false otherwise
     */
    isOAuthEnabled(providerName: string): boolean;
    /**
     * Check for higher priority authentication methods
     * @param providerName - Name of the provider to check
     * @returns String describing higher priority auth method, null if none
     */
    getHigherPriorityAuth(providerName: string): Promise<string | null>;
    /**
     * Check if a URL is compatible with Qwen OAuth
     * @param url - The base URL to check
     * @returns True if compatible, false otherwise
     */
    private isQwenCompatibleUrl;
    /**
     * CRITICAL FIX: Clear all auth caches for a provider after logout
     * This method finds and clears auth caches from both BaseProvider and provider-specific implementations
     * @param providerName - Name of the provider to clear caches for
     */
    private clearProviderAuthCaches;
}
