nip4decrypt

This commit is contained in:
Martti Malmi 2023-12-07 11:26:52 +02:00
parent 728d104f91
commit fbd6285b47

View File

@ -139,7 +139,12 @@ export class Nip46Signer implements EventSigner {
}
async nip4Decrypt(content: string, otherKey: string) {
return await this.#rpc<string>("nip04_decrypt", [otherKey, content]);
const payload = await this.#rpc<string>("nip04_decrypt", [otherKey, content]);
try {
return JSON.parse(payload)[0];
} catch {
return "<error>";
}
}
nip44Encrypt(content: string, key: string): Promise<string> {