UNPKG

autotrader-connect-api

Version:

Production-ready TypeScript wrapper for Auto Trader UK Connect APIs

89 lines 2.21 kB
/** * Authentication module for AutoTrader API * Handles OAuth2 client credentials flow with token caching and refresh */ import { AuthCredentials, AuthState, TokenValidation } from './types/auth'; /** * Authentication manager class */ export declare class AuthManager { private credentials; private tokenEndpoint; private state; private refreshPromise; constructor(credentials: AuthCredentials, baseURL?: string); /** * Get a valid access token, refreshing if necessary * Ensures concurrency safety by queuing multiple calls */ getToken(): Promise<string>; /** * Force refresh the access token */ refreshToken(): Promise<string>; /** * Validate the current token */ validateToken(): TokenValidation; /** * Get the current authentication state */ getAuthState(): AuthState; /** * Clear the stored token (logout) */ clearToken(): void; /** * Check if currently authenticated */ isAuthenticated(): boolean; /** * Request a new token from the API */ private requestToken; /** * Store the token and update authentication state */ private storeToken; /** * Handle authentication errors */ private handleAuthError; /** * Create a standardized auth error */ private createAuthError; /** * Determine error type from axios error */ private getErrorType; /** * Get error message from axios error */ private getErrorMessage; /** * Extract retry-after header value */ private getRetryAfter; /** * Check if error indicates invalid credentials */ private isAuthenticationError; /** * Check if error should trigger a retry */ private shouldRetry; /** * Sleep for specified milliseconds */ private sleep; } /** * Get or create the default auth manager */ export declare function getAuthManager(credentials?: AuthCredentials, baseURL?: string): AuthManager; /** * Get a valid token using the default auth manager */ export declare function getToken(): Promise<string>; //# sourceMappingURL=auth.d.ts.map