import type { NostrService, EncryptionVersion } from '../types/nostr'; import type { Settings } from '../types/settings'; /** * Options for SettingsManager construction. */ export interface SettingsManagerOptions { /** The NostrService implementation for sending/querying DMs */ nostrService: NostrService; /** The user's hex-encoded public key */ userPubkey: string; /** * The user's hex-encoded private key. * Required when encryptionVersion is 'nip44' for deriving conversation keys. * When using 'nip04', the consuming application handles encryption in sendDirectMessage. */ privateKey?: string; /** * Encryption version to use for settings DMs. * - 'nip04': Legacy NIP-04 encryption (default). Encryption is handled by the * consuming application's NostrService.sendDirectMessage implementation. * - 'nip44': Modern NIP-44 encryption. SettingsManager encrypts/decrypts content * directly using the provided privateKey before passing to NostrService. */ encryptionVersion?: EncryptionVersion; } export declare class SettingsManager { private nostrService; private userPubkey; private privateKey; private encryptionVersion; private cachedSettings; constructor(options: SettingsManagerOptions); /** * @deprecated Use the options object constructor instead. * Retained for backward compatibility. */ constructor(nostrService: NostrService, userPubkey: string); /** * Get default settings */ private getDefaultSettings; /** * Encrypt content using NIP-44. * @param plaintext - The plaintext content to encrypt * @returns Base64-encoded NIP-44 encrypted payload */ private encryptNip44; /** * Decrypt content using NIP-44. * @param payload - Base64-encoded NIP-44 encrypted payload * @returns Decrypted plaintext string */ private decryptNip44; /** * Attempt to decrypt event content, trying NIP-44 first if configured, * then falling back to treating content as plaintext JSON (for NIP-04, * where the NostrService handles decryption before returning events). */ private decryptContent; /** * Get settings from Nostr DMs */ private getSettingsFromDMs; /** * Load settings */ loadSettings(): Promise; /** * Save settings to DM. * When using NIP-44, content is encrypted before passing to NostrService. * When using NIP-04, content is passed as plaintext JSON and the * NostrService.sendDirectMessage implementation handles encryption. */ saveSettings(settings: Settings): Promise; /** * Update specific settings */ updateSettings(updates: Partial): Promise; /** * Get the current encryption version */ getEncryptionVersion(): EncryptionVersion; }