import { AxiosInstance } from 'axios'; import { StoredToken, AuthorizationCodeFlowConfig } from '../types'; import { TokenManager } from './token-manager'; /** * AuthorizationCodeFlowAuth handles the OAuth2 authorization code flow. * This is the preferred flow for distributed applications and public clients. * * State management is handled by the application layer - the application is responsible * for creating the state parameter and verifying it before calling handleCallback. * * See: https://oauth.iracing.com/oauth2/book/authorization_code_flow.html */ export declare class AuthorizationCodeFlowAuth { private config; private tokenManager; private httpClient; private tokenKey; constructor(config: AuthorizationCodeFlowConfig, tokenManager: TokenManager, httpClient?: AxiosInstance); /** * Generate an authorization URL for redirecting the user to iRacing login * @param state - State parameter for CSRF protection (caller must generate and verify) * @returns Object containing authorizationUrl and codeVerifier (if PKCE enabled) */ generateAuthorizationUrl(state: string): { authorizationUrl: string; codeVerifier?: string; }; /** * Handle the callback from the authorization server * @param code - Authorization code from redirect_uri * @param codeVerifier - PKCE code verifier (if PKCE was used) * @returns Access token string * @throws AuthError if exchange fails */ handleCallback(code: string, codeVerifier?: string): Promise; /** * Exchange authorization code for access token */ private exchangeCodeForToken; /** * Get a valid access token * @returns Access token string or null if not available */ getAccessToken(): Promise; /** * Refresh an access token using a refresh token * @param refreshToken - The refresh token to use * @returns New access token string * @throws AuthError if refresh fails */ refreshToken(refreshToken: string): Promise; /** * Get the current stored token * @returns StoredToken or undefined */ getStoredToken(): StoredToken | undefined; /** * Manually clear the stored token */ clearToken(): void; /** * Handle token response and store it */ private handleTokenResponse; /** * Handle errors from authentication requests */ private handleError; } //# sourceMappingURL=authorization-code-flow.d.ts.map