aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/nostr.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/nostr.ts b/src/lib/nostr.ts
index a5b2d990..bfaa14c1 100644
--- a/src/lib/nostr.ts
+++ b/src/lib/nostr.ts
@@ -17,6 +17,7 @@ import {
nip04,
nip19,
} from "nostr-tools";
+import { decrypt as nip44decrypt, getConversationKey } from "nostr-tools/nip44";
import { Relay } from "nostr-tools/relay";
import { get } from "svelte/store";
@@ -168,9 +169,13 @@ const signingMethods = {
async onevent(event) {
pk = event.pubkey;
try {
- const response = JSON.parse(
- await nip04.decrypt(sk, pk, event.content),
- );
+ let response;
+ try {
+ response = JSON.parse(await nip04.decrypt(sk, pk, event.content));
+ } catch (e) {
+ const ck = await getConversationKey(sk, pk);
+ response = JSON.parse(await nip44decrypt(event.content, ck));
+ }
if (response.id === id) resolve(JSON.parse(response.result));
} catch (e) {