import type { Configuration } from '../..'; import { BaseAPI } from '../../api/generated/default'; import type { AudiusWalletClient } from '../AudiusWalletClient'; import type { EncryptedEmailsResult, SharedSymmetricKey } from './types'; export declare class EmailEncryptionService extends BaseAPI { private readonly audiusWalletClient; private readonly symmetricKeyCache; private readonly sharedSecretCache; private readonly cacheSize; /** * Constructs a new EmailEncryptionService instance * @param config - SDK configuration object * @param audiusWalletClient - Configured AudiusWalletClient instance for cryptographic operations */ constructor(config: Configuration, audiusWalletClient: AudiusWalletClient); /** * Creates a new symmetric key for email encryption * @returns The symmetric key as Uint8Array */ createSymmetricKey(): Uint8Array; /** * Encrypts a symmetric key for a user using their public key and shared secret * @param userId - The ID of the user to encrypt for * @param symmetricKey - The symmetric key to encrypt * @returns The encrypted key as a base64 string */ encryptSymmetricKey(userId: string, symmetricKey: Uint8Array): Promise; /** * Decrypts a symmetric key using cached shared secrets * @param encryptedKey - The encrypted symmetric key as a base64 string * @param userId - The ID of the user who encrypted the key * @param pubkeyBase64 - Optional pre-provided public key to avoid API calls * @returns The decrypted symmetric key from cache or new decryption * @remarks Uses LRU caching for symmetric keys and shared secrets to improve performance */ decryptSymmetricKey(encryptedKey: string, userId: string, pubkeyBase64?: string): Promise; /** * Encrypts an email using a symmetric key * @param email - The email to encrypt * @param symmetricKey - The symmetric key to use * @returns The encrypted email as a base64 string */ encryptEmail(email: string, symmetricKey: Uint8Array): Promise; /** * Decrypts an email using a symmetric key * @param encryptedEmail - The encrypted email as a base64 string * @param symmetricKey - The symmetric key to use * @returns The decrypted email */ decryptEmail(encryptedEmail: string, symmetricKey: Uint8Array): Promise; /** * Creates and distributes a symmetric key between an email owner and recipients * @param emailOwnerId - The ID of the email owner * @param receivingIds - List of user IDs who will receive access * @param grantorId - The ID of the user granting access * @returns The encrypted symmetric keys for storage * @remarks Includes the email owner in the recipient list automatically */ createSharedKey(emailOwnerId: string, receivingIds: string[], grantorId: string): Promise; /** * Encrypts emails for multiple recipients using a shared symmetric key * @param emailOwnerId - The ID of the email owner * @param receivingIds - List of user IDs who will receive access * @param grantorId - The ID of the user granting access * @param emails - List of emails to encrypt * @returns Object containing encrypted emails and encrypted symmetric keys */ encryptEmails(emailOwnerId: string, receivingIds: string[], grantorId: string, emails: string[]): Promise; /** * Removes oldest entries from a cache map when size limit is reached * @param map - The cache map to prune * @remarks Implements LRU-like cache eviction by removing oldest 1/3 of entries * @private Internal cache maintenance utility */ private removeOldestEntries; /** * Direct decryption path using user ID to fetch public key * @param encryptedKey - Base64 encoded encrypted symmetric key * @param userId - ID of user who encrypted the key * @returns Decrypted symmetric key bytes * @private Internal decryption implementation */ private decryptSymmetricKeyDirect; /** * Optimized decryption path using pre-provided public key * @param encryptedKey - Base64 encoded encrypted symmetric key * @param pubkeyBase64 - Base64 encoded public key of encrypting user * @returns Decrypted symmetric key bytes * @private Internal decryption implementation * @remarks Bypasses public key API call when key is already known */ private decryptSymmetricKeyWithPublicKey; /** * Gets the public key for a user from the comms API * @param userId - The ID of the user to get the public key for * @returns The user's public key as a Uint8Array * @private Internal API call wrapper */ private getPublicKey; /** * Retrieves shared secret with caching mechanism * @param publicKey - Public key to derive shared secret from * @returns Cached shared secret promise * @private Manages LRU cache for shared secrets */ private getSharedSecretWithCache; }