/**
 * OAuth Token Refresh Service
 *
 * Handles automatic token refresh for OAuth providers:
 * - Detects expired or expiring tokens
 * - Refreshes tokens using provider refresh token endpoints
 * - Updates encrypted tokens in database
 * - Handles refresh failures gracefully
 *
 * Can be triggered:
 * 1. On-demand before API calls
 * 2. Via cron job for proactive refresh
 * 3. Via Next.js middleware for automatic background refresh
 */
import { OAuthProvider, TokenRefreshResult } from './types';
/**
 * Token Refresh Service
 */
export declare class TokenRefreshService {
    /**
     * Check if a token needs refresh based on expiration
     *
     * @param expiresAt - Token expiration date
     * @returns true if token needs refresh
     */
    static needsRefresh(expiresAt: Date | null | undefined): boolean;
    /**
     * Refresh an OAuth token
     *
     * @param provider - OAuth provider
     * @param refreshToken - Current refresh token
     * @param clientId - OAuth client ID
     * @param clientSecret - OAuth client secret
     * @returns Refresh result with new tokens
     */
    static refreshToken(provider: OAuthProvider, refreshToken: string, clientId: string, clientSecret: string): Promise<TokenRefreshResult>;
    /**
     * Build provider-specific refresh parameters
     */
    private static buildRefreshParams;
    /**
     * Refresh expired tokens for a specific account
     *
     * @param accountId - Account ID from Better Auth account table
     * @returns true if refresh succeeded
     */
    static refreshAccountTokens(accountId: string): Promise<boolean>;
    /**
     * Refresh expired tokens for all accounts of a user
     *
     * @param userId - User ID
     * @returns Number of accounts successfully refreshed
     */
    static refreshUserTokens(userId: string): Promise<number>;
    /**
     * Refresh all expired tokens in the system (for cron job)
     *
     * @returns Number of accounts successfully refreshed
     */
    static refreshAllExpiredTokens(): Promise<number>;
    /**
     * Mark account connection status
     */
    private static markAccountStatus;
    /**
     * Get OAuth client ID from environment
     */
    private static getClientId;
    /**
     * Get OAuth client secret from environment
     */
    private static getClientSecret;
    /**
     * Get decrypted access token for an account (refreshes if needed)
     *
     * @param accountId - Account ID
     * @returns Decrypted access token
     */
    static getAccessToken(accountId: string): Promise<string>;
    /**
     * Check if account needs refresh and refresh if necessary
     */
    private static checkAndRefreshIfNeeded;
}
//# sourceMappingURL=token-refresh.d.ts.map