import { AuthCallbacks, AuthConfig, AuthState, AuthTokens, AuthUser, ExtendedSessionInfo, LoginCredentials, RegisterData } from '../types'; type StateChangeListener = (state: AuthState) => void; /** * Refactored AuthSDK with improved modularity and session management */ export declare class AuthSDK { private config; private state; private callbacks; private storageManager; private refreshManager; private sessionValidator; private axiosInterceptorManager; private tabSyncManager; private authDebugger; private expirationTimer; private stateChangeListeners; private isInitialized; readonly ready: Promise; private logger; /** Follower instance: never refreshes nor clears the shared storage on its own. */ private readonly isSecondary; private sessionRequest; constructor(config: AuthConfig, callbacks?: AuthCallbacks); /** * Build complete configuration with defaults */ private buildConfig; /** * Enhanced login with automatic session establishment */ login(credentials: LoginCredentials): Promise; /** * Enhanced register with automatic session establishment when tokens are provided */ register(userData: RegisterData): Promise; /** * Enhanced logout with complete session cleanup */ logout(): Promise; /** * Tear down all listeners and timers without clearing auth state. * Call this when the SDK instance is being discarded (e.g. React hot-reload) * to prevent duplicate event listeners on the next instantiation. */ destroy(): void; /** * Clear local session without calling backend * Useful when the server has already invalidated the session (401/422) */ clearLocalSession(): Promise; /** * Enhanced token refresh with session renewal */ refreshTokens(): Promise; /** * Subscribe to authentication state changes */ onAuthStateChanged(listener: StateChangeListener): () => void; /** * Get current authentication state */ getState(): AuthState; /** * Get current authenticated user */ getCurrentUser(): AuthUser | null; /** * Get current access token */ getAccessToken(): string | null; /** * Get current refresh token */ getRefreshToken(): string | null; /** * Check if user is currently authenticated */ isAuthenticated(): Promise; /** * Validate current session with the server using refresh token * This is called automatically when the app regains focus/visibility */ validateSession(): Promise; /** * Get a valid access token, refreshing if necessary */ getValidAccessToken(): Promise; /** * Get authorization headers for API requests */ getAuthHeaders(): Promise>; /** * Debug token information */ debugToken(token?: string): void; /** * Debug API response structure */ debugResponse(response: any): void; /** * Force refresh tokens regardless of expiration */ forceRefreshTokens(): Promise; /** * Get comprehensive session information */ getExtendedSessionInfo(): Promise; /** * Get detailed session information (legacy method) */ getSessionInfo(): Promise<{ isValid: boolean; user: AuthUser | null; tokenType: string | null; expiresIn: number | null; refreshAvailable: boolean; sessionId: string | null; }>; /** * Test extraction with mock response (debugging) */ testExtraction(response: any): void; /** * Apply a session received from another tab via TabSyncManager. * Storage is shared (localStorage / IndexedDB), so we only update in-memory state. */ private applyRemoteSession; /** * Apply a token refresh received from another tab via TabSyncManager. */ private applyRemoteTokenRefresh; /** * Primary side of the session hand-over: answers an instance that has no * valid token (a secondary window, typically) with a current session, * renewing it first if needed. */ private shareSession; /** * Secondary side: asks a primary for the session and applies it. Concurrent * callers share one request. Resolves `false` if no primary answered. */ private requestSessionFromPrimary; /** Access token for a secondary instance, which never refreshes by itself. */ private getSecondaryAccessToken; /** * Detect token format */ private detectTokenFormat; /** * Initialize from stored authentication data */ private initializeFromStorage; /** Sets an existing session (from storage) as the current one. */ private restoreSession; /** * The access token expired while the app was closed or the machine slept, * but the refresh token may still be valid: renew before giving up. This * used to clear the storage straight away and send the user to the login. */ private restoreExpiredSession; /** * Establish new session with tokens and user */ private establishSession; /** * Clear current session completely */ private clearSession; /** * Handle token refresh completion */ private handleTokenRefresh; /** * Schedule automatic token expiration handling */ private scheduleTokenExpiration; /** * Handle automatic token expiration */ private handleTokenExpiration; /** * Clear expiration timer */ private clearExpirationTimer; /** * Validate token based on its type */ private isTokenValid; /** * Validate stored token using metadata */ private validateStoredToken; /** * Create default HTTP client using fetch */ private createDefaultHttpClient; /** * Set loading state */ private setLoading; /** * Set error state */ private setError; /** * Notify all state change listeners */ private notifyStateChange; /** * Debug current session with comprehensive info */ debugSession(): void; } export {}; //# sourceMappingURL=AuthSDK.d.ts.map