Enhance market DM decryption process with improved authentication checks
- Introduced checks for both injected auth service and global auth composable to retrieve user private and public keys. - Enhanced logging to provide clearer feedback on authentication status during DM decryption attempts. - Improved error handling for cases where user keys are unavailable, ensuring better user guidance. These changes strengthen the authentication flow and improve the reliability of market-related direct messages.
This commit is contained in:
parent
d3ee19f56f
commit
c7e11a7c01
1 changed files with 19 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ import { config } from '@/lib/config'
|
|||
import { nostrmarketService } from '../services/nostrmarketService'
|
||||
import { nip04 } from 'nostr-tools'
|
||||
import { useAsyncOperation } from '@/core/composables/useAsyncOperation'
|
||||
import { auth } from '@/composables/useAuth'
|
||||
|
||||
// Nostr event kinds for market functionality
|
||||
const MARKET_EVENT_KINDS = {
|
||||
|
|
@ -384,15 +385,30 @@ export function useMarket() {
|
|||
try {
|
||||
console.log('🔔 Received order-related DM:', event.id, 'from:', event.pubkey.slice(0, 8))
|
||||
|
||||
const userPrivkey = authService.user.value?.prvkey
|
||||
// Check both injected auth service AND global auth composable
|
||||
const hasAuthService = authService.user.value?.prvkey
|
||||
const hasGlobalAuth = auth.currentUser.value?.prvkey
|
||||
|
||||
if (!userPrivkey) {
|
||||
const userPrivkey = hasAuthService ? authService.user.value.prvkey : auth.currentUser.value?.prvkey
|
||||
const userPubkey = hasAuthService ? authService.user.value.pubkey : auth.currentUser.value?.pubkey
|
||||
|
||||
if (!userPrivkey || !userPubkey) {
|
||||
console.warn('Cannot decrypt DM: no user private key available', {
|
||||
authServicePrivkey: !!authService.user.value?.prvkey
|
||||
hasAuthService: !!hasAuthService,
|
||||
hasGlobalAuth: !!hasGlobalAuth,
|
||||
authServicePrivkey: !!authService.user.value?.prvkey,
|
||||
globalAuthPrivkey: !!auth.currentUser.value?.prvkey
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
console.log('🔐 Market DM decryption auth check:', {
|
||||
hasAuthService: !!hasAuthService,
|
||||
hasGlobalAuth: !!hasGlobalAuth,
|
||||
usingAuthService: !!hasAuthService,
|
||||
userPubkey: userPubkey.substring(0, 10) + '...'
|
||||
})
|
||||
|
||||
console.log('🔓 Attempting to decrypt DM with private key available')
|
||||
|
||||
// Decrypt the DM content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue