From c3a4e419682f89af8a8cccb8ead4d95a45d95c53 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 17 Oct 2025 21:31:21 +0200 Subject: [PATCH] fix: detect NIP-04 encrypted content in bookmark events Added explicit detection for NIP-04 encrypted content format: - NIP-04: base64 content with ?iv= suffix - NIP-44: detected by Helpers.hasHiddenContent() - Encrypted tags: detected by Helpers.hasHiddenTags() Created hasEncryptedContent() helper that checks all three cases. Now properly shows padlock emoji and decrypt button for events with NIP-04 encrypted content (like the example with ?iv=5KzDXv09...). --- src/components/Debug.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/Debug.tsx b/src/components/Debug.tsx index b5ccd8dc..b871b5b8 100644 --- a/src/components/Debug.tsx +++ b/src/components/Debug.tsx @@ -95,9 +95,22 @@ const Debug: React.FC = ({ relayPool }) => { return content.length + tags.length } + const hasEncryptedContent = (evt: NostrEvent): boolean => { + // Check for NIP-44 encrypted content (detected by Helpers) + if (Helpers.hasHiddenContent(evt)) return true + + // Check for NIP-04 encrypted content (base64 with ?iv= suffix) + if (evt.content && evt.content.includes('?iv=')) return true + + // Check for encrypted tags + if (Helpers.hasHiddenTags(evt) && !Helpers.isHiddenTagsUnlocked(evt)) return true + + return false + } + const getBookmarkCount = (evt: NostrEvent): { public: number; private: number } => { const publicTags = (evt.tags || []).filter((t: string[]) => t[0] === 'e' || t[0] === 'a') - const hasEncrypted = Helpers.hasHiddenContent(evt) || (Helpers.hasHiddenTags(evt) && !Helpers.isHiddenTagsUnlocked(evt)) + const hasEncrypted = hasEncryptedContent(evt) return { public: publicTags.length, private: hasEncrypted ? 1 : 0 // Can't know exact count until decrypted @@ -670,7 +683,7 @@ const Debug: React.FC = ({ relayPool }) => { const titleTag = evt.tags?.find((t: string[]) => t[0] === 'title')?.[1] const size = getEventSize(evt) const counts = getBookmarkCount(evt) - const hasEncrypted = Helpers.hasHiddenContent(evt) || (Helpers.hasHiddenTags(evt) && !Helpers.isHiddenTagsUnlocked(evt)) + const hasEncrypted = hasEncryptedContent(evt) const isDecrypting = decryptingEventIds.has(evt.id) const decryptResult = decryptedEvents.get(evt.id)