/** * @file Storage Utilities * @description Enterprise-grade storage utilities with TTL, encryption, * quota management, and cross-tab synchronization */ /** * Storage item with metadata */ export interface StorageItem { value: T; timestamp: number; ttl?: number; version?: number; encrypted?: boolean; } /** * Storage configuration */ export interface StorageConfig { /** Storage prefix for namespacing */ prefix?: string; /** Default TTL in milliseconds */ defaultTTL?: number; /** Enable encryption for sensitive data */ enableEncryption?: boolean; /** Encryption key (required if encryption enabled) */ encryptionKey?: string; /** Storage version for migrations */ version?: number; /** Maximum storage quota in bytes */ maxQuota?: number; /** Enable cross-tab synchronization */ syncAcrossTabs?: boolean; } /** * Storage statistics */ export interface StorageStats { itemCount: number; usedBytes: number; availableBytes: number; expiredCount: number; } /** * Migration function type */ export type MigrationFn = (oldValue: unknown, oldVersion: number) => T; /** * Secure encryption using Web Crypto API */ export declare class CryptoStorage { private passphrase; private key; private keyPromise; constructor(passphrase: string); encrypt(data: string): Promise; decrypt(data: string): Promise; private getKey; private deriveKey; } /** * Enterprise storage manager with TTL, encryption, and quota management */ export declare class StorageManager { private storage; private config; private readonly crypto; private migrations; private broadcastChannel; constructor(storage: Storage, config?: StorageConfig); /** * Set item in storage */ set(key: string, value: T, options?: { ttl?: number; encrypt?: boolean; }): Promise; /** * Get item from storage */ get(key: string, defaultValue?: T): Promise; /** * Get item synchronously (no encryption support) */ getSync(key: string, defaultValue?: T): T | undefined; /** * Remove item from storage */ remove(key: string): void; /** * Check if key exists and is not expired */ has(key: string): Promise; /** * Clear all items with prefix */ clear(): void; /** * Get all keys with prefix */ keys(): string[]; /** * Cleanup expired items */ cleanup(): number; /** * Get storage statistics */ getStats(): StorageStats; /** * Register a migration function for a key */ registerMigration(key: string, migration: MigrationFn): void; /** * Dispose resources */ dispose(): void; /** * Get prefixed key */ private getKey; /** * Setup cross-tab synchronization */ private setupCrossTabSync; /** * Broadcast storage change to other tabs */ private broadcast; /** * Schedule periodic cleanup of expired items */ private scheduleCleanup; } /** * Error thrown when storage quota is exceeded */ export declare class StorageQuotaError extends Error { constructor(message: string); } /** * Session-scoped storage with automatic cleanup */ export declare class SessionStorageManager extends StorageManager { constructor(config?: Omit); } /** * In-memory storage implementation for SSR */ export declare function createMemoryStorage(): Storage; /** * Default localStorage manager */ export declare const localStorageManager: StorageManager; /** * Default sessionStorage manager */ export declare const sessionStorageManager: SessionStorageManager; /** * Set item in local storage */ export declare function setLocal(key: string, value: T, options?: { ttl?: number; encrypt?: boolean; }): Promise; /** * Get item from local storage */ export declare function getLocal(key: string, defaultValue?: T): Promise; /** * Remove item from local storage */ export declare function removeLocal(key: string): void; /** * Set item in session storage */ export declare function setSession(key: string, value: T, options?: { ttl?: number; encrypt?: boolean; }): Promise; /** * Get item from session storage */ export declare function getSession(key: string, defaultValue?: T): Promise; /** * Remove item from session storage */ export declare function removeSession(key: string): void;