import { X25519KeyPair } from "./keypair"; import { Env } from "../types"; export declare class UserEncryption { private encPrivateKey; private encPrivateKeyBackup; private storage; private userId; private sessionKeyPath; private encryptedPasswordKeyPath; constructor(config?: { encPrivateKey?: string; encPrivateKeyBackup?: string; storage?: Storage; env?: Env; }); setEncryptedPrivateKey(encPrivateKey: string): void; setEncryptedPrivateKeyBackup(encPrivateKeyBackup: string): void; setupPassword(password: string, keystore?: boolean): Promise<{ keypair: X25519KeyPair; encPrivateKey: string; }>; changePassword(oldPassword: string, newPassword: string, keystore?: boolean): Promise<{ encPrivateKey: string; }>; backupPassword(password: string): Promise<{ backupPhrase: string; encPrivateKeyBackup: string; }>; resetPassword(backupPhrase: string, newPassword: string, keystore?: boolean): Promise<{ encPrivateKey: string; }>; importFromKeystore(): Promise<{ keypair: X25519KeyPair; }>; importFromPassword(password: string, keystore?: boolean): Promise<{ keypair: X25519KeyPair; }>; importFromBackupPhrase(backupPhrase: string): Promise<{ keypair: X25519KeyPair; }>; /** * Encryption with key derived from password * - generate random salt * - derive the encryption key from password and salt * - encrypt plaintext with the derived key * @param {string} password * @param {string} plaintext plaintext array * @returns {Promise.} Promise of string represents stringified payload */ private encryptWithPassword; /** * Decryption with key derived from password * - parse the payload * - derive the decryption key from password and salt * - decrypt the ciphertext with the derived key * @param {string} password * @param {string} encryptedPayload stringified payload * @returns {Promise.} Promise of string represents utf-8 plaintext */ private decryptWithPassword; /** * Encryption with key derived from backup phrase * - derive the encryption key from backup phrase * - encrypt plaintext with the derived key * @param {string} backupPhrase * @param {string} plaintext plaintext array * @returns {Promise.} Promise of string represents stringified payload */ private encryptWithBackupPhrase; /** * Decryption with key derived from backup phrase * - derive the decryption key from backup phrase * - decrypt the ciphertext with the derived key * @param {string} backupPhrase * @param {string} encryptedPayload stringified payload * @returns {Promise.} Promise of string represents utf-8 plaintext */ private decryptWithBackupPhrase; hasEncryptionSession(): Promise; clear(): Promise; private saveSessionInKeystore; }