/** A symbol use to store the encrypted content of an event in memory */ export declare const EncryptedContentSymbol: unique symbol; export interface EncryptedContentSigner { nip04?: { encrypt: (pubkey: string, plaintext: string) => Promise | string; decrypt: (pubkey: string, ciphertext: string) => Promise | string; }; nip44?: { encrypt: (pubkey: string, plaintext: string) => Promise | string; decrypt: (pubkey: string, ciphertext: string) => Promise | string; }; } /** Encryption method types */ export type EncryptionMethod = "nip04" | "nip44"; /** Type for an event who's encrypted content is unlocked */ export type UnlockedEncryptedContent = { [EncryptedContentSymbol]: string; }; /** A pair of encryption methods for encrypting and decrypting event content */ export interface EncryptionMethods { encrypt: (pubkey: string, plaintext: string) => Promise | string; decrypt: (pubkey: string, ciphertext: string) => Promise | string; } /** Various event kinds that can have encrypted content and which encryption method they use */ export declare const EventContentEncryptionMethod: Record; /** Sets the encryption method that is used for the contents of a specific event kind */ export declare function setEncryptedContentEncryptionMethod(kind: number, method: EncryptionMethod): number; /** * Returns either nip04 or nip44 encryption methods depending on event kind * @param kind The event kind to get the encryption method for * @param signer The signer to use to get the encryption methods * @param override The encryption method to use instead of the default * @throws If the event kind does not support encrypted content * @throws If the signer does not support the encryption method * @returns The encryption methods for the event kind */ export declare function getEncryptedContentEncryptionMethods(kind: number, signer: EncryptedContentSigner, override?: EncryptionMethod): EncryptionMethods; /** Checks if an event can have encrypted content */ export declare function canHaveEncryptedContent(kind: number): boolean; /** Checks if an event has encrypted content */ export declare function hasEncryptedContent(event: T): boolean; /** Returns the encrypted content for an event if it is unlocked */ export declare function getEncryptedContent(event: T): string; export declare function getEncryptedContent(event: T): string | undefined; /** Checks if the encrypted content is unlocked and casts it to the {@link UnlockedEncryptedContent} type */ export declare function isEncryptedContentUnlocked(event: T): event is T & UnlockedEncryptedContent; /** * Unlocks the encrypted content in an event and caches it * @param event The event with content to decrypt * @param pubkey The other pubkey that encrypted the content * @param signer A signer to use to decrypt the content * @throws If the event kind does not support encrypted content */ export declare function unlockEncryptedContent(event: T, pubkey: string, signer: EncryptedContentSigner): Promise; /** Sets the encrypted content on an event and updates it if its part of an event store */ export declare function setEncryptedContentCache(event: T, plaintext: string): void; /** Removes the encrypted content cache on an event */ export declare function lockEncryptedContent(event: T): void;