import type { AuthUser, AuthSession, SessionConfig } from "../types/authTypes.js";
/**
 * Session storage interface for SessionManager
 *
 * Defines the contract for session storage backends (memory, Redis, custom).
 * Note: This is a SessionManager-specific interface that uses `set()`/`getUserSessions()`/
 * `deleteUserSessions()`/`isHealthy()` method names, which differ from the canonical
 * `SessionStorage` type in `../types/authTypes.js` (which uses `save()`/`getForUser()`/
 * `deleteAllForUser()`/`exists()`/`touch()`). Both interfaces coexist because
 * SessionManager and BaseAuthProvider have separate storage patterns.
 */
export interface SessionManagerStorage {
    /** Get a session by ID */
    get(sessionId: string): Promise<AuthSession | null>;
    /** Store a session */
    set(session: AuthSession): Promise<void>;
    /** Delete a session */
    delete(sessionId: string): Promise<void>;
    /** Get all sessions for a user */
    getUserSessions(userId: string): Promise<AuthSession[]>;
    /** Delete all sessions for a user */
    deleteUserSessions(userId: string): Promise<void>;
    /** Clear all sessions (for cleanup) */
    clear(): Promise<void>;
    /** Health check */
    isHealthy(): Promise<boolean>;
}
/**
 * In-memory session storage
 *
 * Simple session storage using Map. Suitable for single-instance deployments
 * or development. Sessions are lost on restart.
 */
export declare class MemorySessionStorage implements SessionManagerStorage {
    private sessions;
    private userSessions;
    get(sessionId: string): Promise<AuthSession | null>;
    set(session: AuthSession): Promise<void>;
    delete(sessionId: string): Promise<void>;
    getUserSessions(userId: string): Promise<AuthSession[]>;
    deleteUserSessions(userId: string): Promise<void>;
    clear(): Promise<void>;
    isHealthy(): Promise<boolean>;
}
/**
 * Redis session storage
 *
 * Distributed session storage using Redis. Suitable for multi-instance
 * deployments. Requires the "redis" (node-redis) package.
 *
 * Note: Redis client must be provided or configured via environment.
 */
export declare class RedisSessionStorage implements SessionManagerStorage {
    private prefix;
    private ttl;
    private redisUrl;
    private client;
    private initPromise;
    constructor(config: {
        url: string;
        prefix?: string;
        ttl?: number;
    });
    private getClient;
    private createClient;
    private sessionKey;
    private userSessionsKey;
    get(sessionId: string): Promise<AuthSession | null>;
    set(session: AuthSession): Promise<void>;
    delete(sessionId: string): Promise<void>;
    getUserSessions(userId: string): Promise<AuthSession[]>;
    deleteUserSessions(userId: string): Promise<void>;
    clear(): Promise<void>;
    isHealthy(): Promise<boolean>;
    disconnect(): Promise<void>;
}
/**
 * Session Manager
 *
 * High-level session management that handles session lifecycle,
 * automatic refresh, and storage abstraction.
 */
export declare class SessionManager {
    private storage;
    private config;
    constructor(config?: SessionConfig);
    private createStorage;
    /**
     * Create a new session
     */
    createSession(user: AuthUser, metadata?: {
        ipAddress?: string;
        userAgent?: string;
        deviceId?: string;
    }): Promise<AuthSession>;
    /**
     * Get a session by ID
     *
     * Optionally auto-refreshes if close to expiration.
     */
    getSession(sessionId: string, autoRefresh?: boolean | undefined): Promise<AuthSession | null>;
    /**
     * Check if session should be refreshed
     */
    private shouldRefresh;
    /**
     * Refresh a session
     */
    refreshSession(sessionId: string): Promise<AuthSession | null>;
    /**
     * Destroy a session
     */
    destroySession(sessionId: string): Promise<void>;
    /**
     * Get all sessions for a user
     */
    getUserSessions(userId: string): Promise<AuthSession[]>;
    /**
     * Destroy all sessions for a user (global logout)
     */
    destroyAllUserSessions(userId: string): Promise<void>;
    /**
     * Validate a session is still active
     */
    validateSession(sessionId: string): Promise<boolean>;
    /**
     * Update session metadata
     */
    updateSessionMetadata(sessionId: string, metadata: Record<string, unknown>): Promise<AuthSession | null>;
    /**
     * Health check
     */
    isHealthy(): Promise<boolean>;
    /**
     * Clear all sessions (for testing/cleanup)
     */
    clear(): Promise<void>;
}
/**
 * Create session storage based on configuration
 */
export declare function createSessionStorage(config: SessionConfig): SessionManagerStorage;
