mirror of
https://github.com/dergigi/boris.git
synced 2026-01-31 12:44:37 +01:00
feat: add manual decryption for unrecognized event kinds
- Add fallback decryption for events with encrypted content but unrecognized kinds - Temporarily change event kind to 10003 to use applesauce's standard decryption - Enables decryption of legacy bookmark events (kind 30001) that contain private bookmarks - Maintains compatibility with standard NIP-51 bookmark events
This commit is contained in:
@@ -225,6 +225,7 @@ export const fetchBookmarks = async (
|
||||
console.log('🔒 Signer candidate type:', typeof signerCandidate)
|
||||
console.log('🔒 Event kind supports hidden tags:', Helpers.canHaveHiddenTags(evt.kind))
|
||||
|
||||
// Try to unlock hidden content using applesauce's standard approach first
|
||||
if (Helpers.hasHiddenTags(evt) && Helpers.isHiddenTagsLocked(evt) && signerCandidate) {
|
||||
try {
|
||||
console.log('🔓 Attempting to unlock hidden tags with signer...')
|
||||
@@ -241,6 +242,26 @@ export const fetchBookmarks = async (
|
||||
}
|
||||
}
|
||||
}
|
||||
// For events that have content but aren't recognized as supporting hidden tags (like kind 30001)
|
||||
else if (evt.content && evt.content.length > 0 && signerCandidate) {
|
||||
try {
|
||||
console.log('🔓 Attempting manual decryption for event with unrecognized kind...')
|
||||
// Try to manually decrypt using applesauce's unlockHiddenContent function
|
||||
// We'll temporarily mark the event as supporting hidden content
|
||||
const originalKind = evt.kind
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(evt as any).kind = 10003 // Temporarily change to recognized kind
|
||||
try {
|
||||
await Helpers.unlockHiddenContent(evt, signerCandidate as any)
|
||||
console.log('✅ Successfully decrypted unrecognized event')
|
||||
} finally {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(evt as any).kind = originalKind // Restore original kind
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('❌ Failed manual decryption:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const priv = Helpers.getHiddenBookmarks(evt)
|
||||
console.log('🔍 Hidden bookmarks found:', priv ? Object.keys(priv).map(k => `${k}: ${priv[k as keyof typeof priv]?.length || 0}`).join(', ') : 'none')
|
||||
|
||||
Reference in New Issue
Block a user