refactor: remove artificial timeouts from bookmark decryption

Removed all withTimeout wrappers - now matches debug page behavior:
- Direct decrypt calls with no artificial timeouts
- Let operations fail naturally and quickly
- Bunker responds instantly (success or rejection)

No timeouts needed because:
1. Account queue is disabled (requests sent immediately)
2. Only decrypting truly encrypted content (no wasted attempts)
3. Bunker either succeeds quickly or fails quickly

This makes bookmark decryption instant, just like the debug page
encryption/decryption tests.
This commit is contained in:
Gigi
2025-10-17 20:54:45 +02:00
parent f6cc49c07a
commit 3a752a761a

View File

@@ -5,7 +5,6 @@ import {
} from '../types/bookmarks'
import { BookmarkHiddenSymbol, hasNip04Decrypt, hasNip44Decrypt, processApplesauceBookmarks } from './bookmarkHelpers'
import type { NostrEvent } from './bookmarkHelpers'
import { withTimeout } from '../utils/async'
type DecryptFn = (pubkey: string, content: string) => Promise<string>
type UnlockHiddenTagsFn = typeof Helpers.unlockHiddenTags
@@ -42,13 +41,10 @@ async function decryptEvent(
// NIP-44 starts with version byte (currently 0x02), NIP-04 is base64
const looksLikeNip44 = evt.content.length > 0 && !evt.content.includes('?iv=')
// Try the likely method first, with a 5s timeout
// Try the likely method first (no timeout - let it fail naturally like debug page)
if (looksLikeNip44 && hasNip44Decrypt(signerCandidate)) {
try {
decryptedContent = await withTimeout(
(signerCandidate as { nip44: { decrypt: DecryptFn } }).nip44.decrypt(evt.pubkey, evt.content),
5000
)
decryptedContent = await (signerCandidate as { nip44: { decrypt: DecryptFn } }).nip44.decrypt(evt.pubkey, evt.content)
} catch (err) {
console.log("[bunker] ❌ nip44.decrypt failed:", err instanceof Error ? err.message : String(err))
}
@@ -57,10 +53,7 @@ async function decryptEvent(
// Fallback to nip04 if nip44 failed or content looks like nip04
if (!decryptedContent && hasNip04Decrypt(signerCandidate)) {
try {
decryptedContent = await withTimeout(
(signerCandidate as { nip04: { decrypt: DecryptFn } }).nip04.decrypt(evt.pubkey, evt.content),
5000
)
decryptedContent = await (signerCandidate as { nip04: { decrypt: DecryptFn } }).nip04.decrypt(evt.pubkey, evt.content)
} catch (err) {
console.log("[bunker] ❌ nip04.decrypt failed:", err instanceof Error ? err.message : String(err))
}