mirror of
https://github.com/dergigi/boris.git
synced 2025-12-28 03:54:51 +01:00
debug: wrap nip04/nip44 methods with [bunker] logging
- Log when decrypt/encrypt methods are called - Log when they complete or fail - Show pubkey and ciphertext/plaintext lengths - This will tell us if decrypt is hanging in the signer or never returning
This commit is contained in:
@@ -78,18 +78,60 @@ export async function reconnectBunkerSigner(
|
||||
account.signer.isConnected = true
|
||||
console.log('[bunker] Signer marked as connected, ready for signing/decryption')
|
||||
|
||||
// Expose nip04/nip44 at account level for compatibility
|
||||
// Expose nip04/nip44 at account level for compatibility with logging
|
||||
// This allows bookmark decryption to work without accessing account.signer
|
||||
if (!('nip04' in account)) {
|
||||
Object.defineProperty(account, 'nip04', {
|
||||
get() { return this.signer.nip04 },
|
||||
get() {
|
||||
const original = this.signer.nip04
|
||||
return {
|
||||
encrypt: async (pubkey: string, plaintext: string) => {
|
||||
console.log('[bunker] 🔐 nip04.encrypt called', { pubkey: pubkey.slice(0, 8) })
|
||||
const result = await original.encrypt(pubkey, plaintext)
|
||||
console.log('[bunker] ✅ nip04.encrypt completed')
|
||||
return result
|
||||
},
|
||||
decrypt: async (pubkey: string, ciphertext: string) => {
|
||||
console.log('[bunker] 🔓 nip04.decrypt called', { pubkey: pubkey.slice(0, 8), ciphertextLength: ciphertext.length })
|
||||
try {
|
||||
const result = await original.decrypt(pubkey, ciphertext)
|
||||
console.log('[bunker] ✅ nip04.decrypt completed')
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error('[bunker] ❌ nip04.decrypt failed:', err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
if (!('nip44' in account)) {
|
||||
Object.defineProperty(account, 'nip44', {
|
||||
get() { return this.signer.nip44 },
|
||||
get() {
|
||||
const original = this.signer.nip44
|
||||
return {
|
||||
encrypt: async (pubkey: string, plaintext: string) => {
|
||||
console.log('[bunker] 🔐 nip44.encrypt called', { pubkey: pubkey.slice(0, 8) })
|
||||
const result = await original.encrypt(pubkey, plaintext)
|
||||
console.log('[bunker] ✅ nip44.encrypt completed')
|
||||
return result
|
||||
},
|
||||
decrypt: async (pubkey: string, ciphertext: string) => {
|
||||
console.log('[bunker] 🔓 nip44.decrypt called', { pubkey: pubkey.slice(0, 8), ciphertextLength: ciphertext.length })
|
||||
try {
|
||||
const result = await original.decrypt(pubkey, ciphertext)
|
||||
console.log('[bunker] ✅ nip44.decrypt completed', { plaintextLength: result.length })
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error('[bunker] ❌ nip44.decrypt failed:', err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user