/** * Encryption Strategy Interface (Strategy Pattern - GoF Design Pattern) * * SOLID Principles: * - Interface Segregation: Focused interface for encryption strategies * - Open/Closed: Open for extension, closed for modification * - Liskov Substitution: Any strategy can substitute another */ export interface EncryptionResult { encryptedBlob: Blob; iv: string; salt: string; } export interface DecryptionParams { encryptedBlob: Blob; password: string; iv: string; salt: string; } /** * Base Encryption Strategy Interface * Each encryption algorithm implements this interface */ export interface IEncryptionStrategy { readonly algorithmName: string; readonly isSupported: boolean; readonly requiresExternalLibrary: boolean; /** * Encrypt data using this strategy */ encrypt(data: ArrayBuffer, password: string, salt: string, iv: string): Promise; /** * Decrypt data using this strategy */ decrypt(params: DecryptionParams): Promise; /** * Get recommended IV size for this algorithm */ getIvSize(): number; /** * Get recommended salt size for this algorithm */ getSaltSize(): number; } /** * Base class for Web Crypto API-based strategies * Template Method Pattern for common functionality */ export declare abstract class WebCryptoStrategy implements IEncryptionStrategy { abstract readonly algorithmName: string; readonly isSupported = true; readonly requiresExternalLibrary = false; protected readonly PBKDF2_ITERATIONS = 100000; protected readonly KEY_LENGTH = 256; abstract encrypt(data: ArrayBuffer, password: string, salt: string, iv: string): Promise; abstract decrypt(params: DecryptionParams): Promise; abstract getIvSize(): number; getSaltSize(): number; /** * Derive encryption key from password using PBKDF2 * Template Method Pattern: Common key derivation logic */ protected deriveKey(password: string, saltHex: string, algorithm: 'AES-GCM' | 'AES-CBC' | 'AES-CTR'): Promise; /** * Utility: Convert hex string to Uint8Array * IMPORTANT: Creates a new ArrayBuffer to ensure Chrome compatibility. * Chrome's Web Crypto API requires the ArrayBuffer to exactly match the * Uint8Array's content, not reference a larger underlying buffer. */ protected hexToUint8Array(hex: string): Uint8Array; /** * Utility: Convert ArrayBuffer to hex string */ protected arrayBufferToHex(buffer: ArrayBuffer | Uint8Array): string; } //# sourceMappingURL=encryption-strategy.interface.d.ts.map