From f3d2029a61138d69437c1815a41fa6db3fd6198a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 1 Mar 2026 14:30:39 -0800 Subject: dm test --- src/lib/nip17.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/lib/nip17.ts') diff --git a/src/lib/nip17.ts b/src/lib/nip17.ts index 97191a18..29a14549 100644 --- a/src/lib/nip17.ts +++ b/src/lib/nip17.ts @@ -3,12 +3,10 @@ import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js"; import { finalizeEvent, getEventHash, generateSecretKey, getPublicKey } from "nostr-tools/pure"; import { SimplePool } from "nostr-tools/pool"; import { Relay } from "nostr-tools/relay"; -import { unwrapEvent } from "nostr-tools/nip17"; - import { ensureSigner } from "$lib/nip07"; import { relaysSupporting } from "$lib/nip11"; import { expired, expiration } from "$lib/nip40"; -import { encrypt, u } from "$lib/nip44"; +import { encrypt, decrypt as nip44Decrypt, u } from "$lib/nip44"; const TWO_DAYS = 2 * 24 * 60 * 60; const randomTimestamp = () => Math.floor(Date.now() / 1000 - Math.random() * TWO_DAYS); @@ -156,7 +154,11 @@ export const decrypt = async (wrapped: any, user: any): Promise => { if (sk === null) { return decryptNIP17MessageNIP07(wrapped); } else { - return unwrapEvent(wrapped, sk); + const skHex = bytesToHex(sk); + const sealedText = nip44Decrypt(wrapped.content, u.getConversationKey(skHex, wrapped.pubkey)); + const sealed = JSON.parse(sealedText); + const rumourText = nip44Decrypt(sealed.content, u.getConversationKey(skHex, sealed.pubkey)); + return JSON.parse(rumourText); } }; -- cgit v1.2.3