import { type RedisStateProvider } from '../distributed-state.js';
import type { WebAuthnCredential, ChallengeEntry } from './types.js';
/**
 * Storage interface for WebAuthn credentials
 */
export interface IWebAuthnStore {
    /**
     * Create a new credential
     */
    createCredential(credential: WebAuthnCredential): Promise<WebAuthnCredential>;
    /**
     * Get a credential by its internal ID
     */
    getCredentialById(id: string): Promise<WebAuthnCredential | null>;
    /**
     * Get a credential by its WebAuthn credential ID
     */
    getCredentialByCredentialId(credentialId: string): Promise<WebAuthnCredential | null>;
    /**
     * Get all credentials for a user
     */
    getCredentialsByUserId(userId: string): Promise<WebAuthnCredential[]>;
    /**
     * Update a credential
     */
    updateCredential(id: string, updates: Partial<WebAuthnCredential>): Promise<WebAuthnCredential | null>;
    /**
     * Delete a credential
     */
    deleteCredential(id: string): Promise<boolean>;
    /**
     * Delete all credentials for a user
     */
    deleteCredentialsByUserId(userId: string): Promise<number>;
    /**
     * Count credentials for a user
     */
    countCredentialsByUserId(userId: string): Promise<number>;
    /**
     * Store a challenge
     */
    setChallenge(key: string, entry: ChallengeEntry): Promise<void>;
    /**
     * Get and delete a challenge (one-time use)
     */
    getChallenge(key: string): Promise<ChallengeEntry | null>;
    /**
     * Delete a challenge
     */
    deleteChallenge(key: string): Promise<boolean>;
    /**
     * Reset the store (for testing)
     */
    reset(): void;
}
/**
 * In-memory implementation of WebAuthn credential store.
 *
 * NOTE: This is suitable for development and testing only.
 * Production deployments should use a database.
 */
export declare class InMemoryWebAuthnStore implements IWebAuthnStore {
    /** Credentials indexed by internal ID */
    private credentialsById;
    /** Credentials indexed by WebAuthn credential ID */
    private credentialsByCredentialId;
    /** Credentials indexed by user ID (one user can have multiple credentials) */
    private credentialsByUserId;
    /** Challenge storage with TTL */
    private challenges;
    /** Cleanup interval handle */
    private cleanupInterval;
    constructor();
    /**
     * Create a new credential
     */
    createCredential(credential: WebAuthnCredential): Promise<WebAuthnCredential>;
    /**
     * Get a credential by its internal ID
     */
    getCredentialById(id: string): Promise<WebAuthnCredential | null>;
    /**
     * Get a credential by its WebAuthn credential ID
     */
    getCredentialByCredentialId(credentialId: string): Promise<WebAuthnCredential | null>;
    /**
     * Get all credentials for a user
     */
    getCredentialsByUserId(userId: string): Promise<WebAuthnCredential[]>;
    /**
     * Update a credential
     */
    updateCredential(id: string, updates: Partial<WebAuthnCredential>): Promise<WebAuthnCredential | null>;
    /**
     * Delete a credential
     */
    deleteCredential(id: string): Promise<boolean>;
    /**
     * Delete all credentials for a user
     */
    deleteCredentialsByUserId(userId: string): Promise<number>;
    /**
     * Count credentials for a user
     */
    countCredentialsByUserId(userId: string): Promise<number>;
    /**
     * Store a challenge
     */
    setChallenge(key: string, entry: ChallengeEntry): Promise<void>;
    /**
     * Get and delete a challenge (one-time use)
     */
    getChallenge(key: string): Promise<ChallengeEntry | null>;
    /**
     * Delete a challenge
     */
    deleteChallenge(key: string): Promise<boolean>;
    /**
     * Start periodic cleanup of expired challenges
     */
    private startCleanup;
    /**
     * Stop the cleanup interval
     */
    stop(): void;
    /**
     * Reset the store (for testing)
     */
    reset(): void;
    /**
     * Get store statistics
     */
    getStats(): {
        totalCredentials: number;
        totalUsers: number;
        pendingChallenges: number;
        credentialsByUser: Record<string, number>;
    };
}
/**
 * WebAuthn store with Redis-backed challenge storage.
 *
 * Uses Redis for challenge storage to support multi-instance deployments.
 * Challenges are stored with proper TTL and automatically expire.
 * Falls back to in-memory storage if Redis is unavailable.
 *
 * Key format: `webauthn:challenge:{userId}:{type}`
 */
export declare class RedisWebAuthnStore implements IWebAuthnStore {
    private readonly stateProvider;
    private readonly fallback;
    private useRedis;
    constructor(stateProvider?: RedisStateProvider);
    private checkRedisHealth;
    createCredential(credential: WebAuthnCredential): Promise<WebAuthnCredential>;
    getCredentialById(id: string): Promise<WebAuthnCredential | null>;
    getCredentialByCredentialId(credentialId: string): Promise<WebAuthnCredential | null>;
    getCredentialsByUserId(userId: string): Promise<WebAuthnCredential[]>;
    updateCredential(id: string, updates: Partial<WebAuthnCredential>): Promise<WebAuthnCredential | null>;
    deleteCredential(id: string): Promise<boolean>;
    deleteCredentialsByUserId(userId: string): Promise<number>;
    countCredentialsByUserId(userId: string): Promise<number>;
    /**
     * Store a challenge in Redis with automatic TTL expiration
     *
     * Key format: `webauthn:challenge:{key}`
     */
    setChallenge(key: string, entry: ChallengeEntry): Promise<void>;
    /**
     * Get and delete a challenge from Redis (one-time use)
     *
     * Uses GET + DELETE to ensure the challenge is consumed atomically.
     * Redis TTL handles automatic expiration.
     */
    getChallenge(key: string): Promise<ChallengeEntry | null>;
    /**
     * Delete a challenge from Redis
     */
    deleteChallenge(key: string): Promise<boolean>;
    /**
     * Reset the store (for testing)
     */
    reset(): void;
    /**
     * Stop the store
     */
    stop(): void;
    /**
     * Get store statistics
     */
    getStats(): {
        totalCredentials: number;
        totalUsers: number;
        pendingChallenges: number;
        credentialsByUser: Record<string, number>;
        usingRedis: boolean;
    };
    /**
     * Check if Redis is being used for challenges
     */
    isUsingRedis(): boolean;
}
/**
 * Enable Redis-backed WebAuthn store
 * Call this before first getWebAuthnStore() call to use Redis for challenges
 */
export declare function enableRedisWebAuthnStore(): void;
/**
 * Get the WebAuthn store singleton
 */
export declare function getWebAuthnStore(): IWebAuthnStore;
/**
 * Create a new WebAuthn store instance (for testing)
 */
export declare function createWebAuthnStore(): InMemoryWebAuthnStore;
/**
 * Create a new Redis WebAuthn store instance
 */
export declare function createRedisWebAuthnStore(stateProvider?: RedisStateProvider): RedisWebAuthnStore;
/**
 * Reset the WebAuthn store singleton (for testing)
 */
export declare function resetWebAuthnStore(): void;
//# sourceMappingURL=store.d.ts.map