From db7f9ed10f11fb3c8108de56f84e4561c521894a Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Thu, 30 Oct 2025 08:10:21 +0100 Subject: [PATCH] Remove all emoji characters from service.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations:** • Fix compilation errors caused by emoji characters • Ensure all secureLogger calls compile correctly **Modifications:** • Removed all emoji characters from service.ts file **Pages affected:** • service.ts --- src/services/service.ts | 402 ++++++++++++++++++++-------------------- 1 file changed, 201 insertions(+), 201 deletions(-) diff --git a/src/services/service.ts b/src/services/service.ts index 6ed013e..be29b8f 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -130,7 +130,7 @@ export default class Services { } // Update user status during initialization (using helper function) - updateUserStatusHelper('🔄 Initializing services...'); + updateUserStatusHelper(' Initializing services...'); // Add WebAssembly memory optimization and error handling try { @@ -190,13 +190,13 @@ export default class Services { if ((performance as any).memory) { const memory = (performance as any).memory; const usedPercent = (memory.usedJSHeapSize / memory.jsHeapSizeLimit) * 100; - secureLogger.info('📊 Memory usage after cleanup: ${usedPercent.toFixed(1)}% (${(memory.usedJSHeapSize / 1024 / 1024).toFixed(1)}MB)', { component: 'Service' }); + secureLogger.info(' Memory usage after cleanup: ${usedPercent.toFixed(1)}% (${(memory.usedJSHeapSize / 1024 / 1024).toFixed(1)}MB)', { component: 'Service' }); if (usedPercent > 75) { - secureLogger.warn('⚠️ High memory usage detected, performing aggressive cleanup...', { component: 'Service' }); + secureLogger.warn(' High memory usage detected, performing aggressive cleanup...', { component: 'Service' }); // More aggressive cleanup - secureLogger.debug('🔍 Debugging memory usage...', { component: 'Service' }); + secureLogger.debug(' Debugging memory usage...', { component: 'Service' }); secureLogger.debug(`Document elements: ${document.querySelectorAll('*').length}`, { component: 'Service' }); // Multiple garbage collections @@ -221,7 +221,7 @@ export default class Services { } } } catch (error) { - secureLogger.error('❌ WebAssembly optimization error:', error, { component: 'Service' }); + secureLogger.error(' WebAssembly optimization error:', error, { component: 'Service' }); // Don't throw here, continue with initialization } @@ -233,12 +233,12 @@ export default class Services { const usedPercent = (memory.usedJSHeapSize / memory.jsHeapSizeLimit) * 100; const availableMB = (memory.jsHeapSizeLimit - memory.usedJSHeapSize) / 1024 / 1024; - secureLogger.info('📊 Memory check before WebAssembly: ${usedPercent.toFixed(1)}% used, ${availableMB.toFixed(1)}MB available', { component: 'Service' }); + secureLogger.info(' Memory check before WebAssembly: ${usedPercent.toFixed(1)}% used, ${availableMB.toFixed(1)}MB available', { component: 'Service' }); // WebAssembly nécessite généralement au moins 100-200MB de mémoire disponible // Si moins de 150MB disponibles ou plus de 85% utilisé, ne pas initialiser if (usedPercent > 85 || availableMB < 150) { - secureLogger.error('🚫 Memory insufficient for WebAssembly: ${usedPercent.toFixed(1)}% used, ${availableMB.toFixed(1)}MB available', { component: 'Service' }); + secureLogger.error(' Memory insufficient for WebAssembly: ${usedPercent.toFixed(1)}% used, ${availableMB.toFixed(1)}MB available', { component: 'Service' }); Services.initializing = null; throw new Error(`Insufficient memory for WebAssembly initialization. Current usage: ${usedPercent.toFixed(1)}%, Available: ${availableMB.toFixed(1)}MB. Please close other tabs and refresh.`); } @@ -247,17 +247,17 @@ export default class Services { // Memory is sufficient, load WebAssembly Services.instance = await Services.initializing; Services.initializing = null; - secureLogger.info('✅ Services initialized with WebAssembly', { component: 'Service' }); + secureLogger.info(' Services initialized with WebAssembly', { component: 'Service' }); } catch (error) { - secureLogger.error('❌ Service initialization failed:', error, { component: 'Service' }); + secureLogger.error(' Service initialization failed:', error, { component: 'Service' }); // Réinitialiser initializing pour permettre une nouvelle tentative après un délai Services.initializing = null; // Si c'est une erreur de mémoire, ne pas réessayer immédiatement const errorMessage = (error as Error).message || String(error); if (errorMessage.includes('Out of memory') || errorMessage.includes('memory')) { - secureLogger.error('🚫 Memory error detected - cannot retry immediately', { component: 'Service' }); + secureLogger.error(' Memory error detected - cannot retry immediately', { component: 'Service' }); throw new Error('WebAssembly initialization failed due to insufficient memory. Please refresh the page.'); } @@ -265,7 +265,7 @@ export default class Services { } // Update user status after successful initialization - updateUserStatusHelper('✅ Services initialized successfully'); + updateUserStatusHelper(' Services initialized successfully'); return Services.instance; } @@ -279,11 +279,11 @@ export default class Services { const usedPercent = (memory.usedJSHeapSize / memory.jsHeapSizeLimit) * 100; const availableMB = (memory.jsHeapSizeLimit - memory.usedJSHeapSize) / 1024 / 1024; - secureLogger.info('📊 Memory check before WebAssembly import: ${usedPercent.toFixed(1)}% used, ${availableMB.toFixed(1)}MB available', { component: 'Service' }); + secureLogger.info(' Memory check before WebAssembly import: ${usedPercent.toFixed(1)}% used, ${availableMB.toFixed(1)}MB available', { component: 'Service' }); // WebAssembly nécessite au moins 150MB de mémoire disponible if (usedPercent > 85 || availableMB < 150) { - secureLogger.error('🚫 Memory insufficient for WebAssembly import: ${usedPercent.toFixed(1)}% used, ${availableMB.toFixed(1)}MB available', { component: 'Service' }); + secureLogger.error(' Memory insufficient for WebAssembly import: ${usedPercent.toFixed(1)}% used, ${availableMB.toFixed(1)}MB available', { component: 'Service' }); throw new Error(`Insufficient memory for WebAssembly. Current usage: ${usedPercent.toFixed(1)}%, Available: ${availableMB.toFixed(1)}MB. Please close other tabs and refresh.`); } } @@ -455,7 +455,7 @@ export default class Services { */ public async connectAllRelays(): Promise { const relayUrls = Object.keys(this.relayAddresses); - secureLogger.info('🚀 Connecting to ${relayUrls.length} relays in parallel...', { component: 'Service' }); + secureLogger.info(' Connecting to ${relayUrls.length} relays in parallel...', { component: 'Service' }); // Create the relay ready promise immediately when starting connections this.getRelayReadyPromise(); @@ -463,12 +463,12 @@ export default class Services { // Connect to all relays in parallel const connectionPromises = relayUrls.map(async wsurl => { try { - secureLogger.info('🔗 Connecting to: ${wsurl}', { component: 'Service' }); + secureLogger.info(' Connecting to: ${wsurl}', { component: 'Service' }); await this.addWebsocketConnection(wsurl); - secureLogger.info('✅ Successfully connected to: ${wsurl}', { component: 'Service' }); + secureLogger.info(' Successfully connected to: ${wsurl}', { component: 'Service' }); return wsurl; } catch (error) { - secureLogger.error('❌ Failed to connect to ${wsurl}:', error, { component: 'Service' }); + secureLogger.error(' Failed to connect to ${wsurl}:', error, { component: 'Service' }); return null; } }); @@ -482,43 +482,43 @@ export default class Services { ) .map(result => result.value); - secureLogger.info('✅ Connected to ${connectedUrls.length}/${relayUrls.length} relays', { component: 'Service' }); + secureLogger.info(' Connected to ${connectedUrls.length}/${relayUrls.length} relays', { component: 'Service' }); // Wait for at least one handshake message if we have connections if (connectedUrls.length > 0) { try { await this.waitForHandshakeMessage(10000); // Augmenter le timeout à 10 secondes - secureLogger.info('✅ Handshake received from at least one relay', { component: 'Service' }); + secureLogger.info(' Handshake received from at least one relay', { component: 'Service' }); } catch (error) { - secureLogger.warn('⚠️ No handshake received within timeout, but continuing with ${connectedUrls.length} connections', { component: 'Service' }); + secureLogger.warn(' No handshake received within timeout, but continuing with ${connectedUrls.length} connections', { component: 'Service' }); // Continue anyway - we have connections even without handshake // Resolve the relay ready promise manually since we have connections this.resolveRelayReady(); } } else { - secureLogger.warn('⚠️ No relay connections established', { component: 'Service' }); + secureLogger.warn(' No relay connections established', { component: 'Service' }); } } private getRelayReadyPromise(): Promise { - secureLogger.debug('🔍 DEBUG: getRelayReadyPromise called, promise exists:', { component: 'Service', data: !!this.relayReadyPromise }); + secureLogger.debug(' DEBUG: getRelayReadyPromise called, promise exists:', { component: 'Service', data: !!this.relayReadyPromise }); // If we already have a relay with spAddress, return resolved promise const hasRelayWithAddress = Object.values(this.relayAddresses).some(address => address && address.trim() !== ''); if (hasRelayWithAddress) { - secureLogger.debug('🔍 DEBUG: Relay already ready with spAddress, returning resolved promise', { component: 'Service' }); + secureLogger.debug(' DEBUG: Relay already ready with spAddress, returning resolved promise', { component: 'Service' }); return Promise.resolve(); } if (!this.relayReadyPromise) { - secureLogger.debug('🔍 DEBUG: Creating new relay ready promise', { component: 'Service' }); + secureLogger.debug(' DEBUG: Creating new relay ready promise', { component: 'Service' }); this.relayReadyPromise = new Promise((resolve) => { this.relayReadyResolver = resolve; // Timeout après 10 secondes si aucun handshake n'arrive setTimeout(() => { if (this.relayReadyResolver) { - secureLogger.warn('⚠️ Relay ready timeout - resolving anyway', { component: 'Service' }); + secureLogger.warn(' Relay ready timeout - resolving anyway', { component: 'Service' }); this.relayReadyResolver(); this.relayReadyResolver = null; this.relayReadyPromise = null; @@ -526,20 +526,20 @@ export default class Services { }, 10000); }); } else { - secureLogger.debug('🔍 DEBUG: Returning existing relay ready promise', { component: 'Service' }); + secureLogger.debug(' DEBUG: Returning existing relay ready promise', { component: 'Service' }); } return this.relayReadyPromise; } private resolveRelayReady(): void { - secureLogger.debug('🔍 DEBUG: resolveRelayReady called, resolver exists:', { component: 'Service', data: !!this.relayReadyResolver }); + secureLogger.debug(' DEBUG: resolveRelayReady called, resolver exists:', { component: 'Service', data: !!this.relayReadyResolver }); if (this.relayReadyResolver) { - secureLogger.debug('✅ DEBUG: Resolving relay ready promise', { component: 'Service' }); + secureLogger.debug(' DEBUG: Resolving relay ready promise', { component: 'Service' }); this.relayReadyResolver(); this.relayReadyResolver = null; this.relayReadyPromise = null; } else { - secureLogger.warn('⚠️ DEBUG: No resolver to resolve - promise may have been resolved already or never created', { component: 'Service' }); + secureLogger.warn(' DEBUG: No resolver to resolve - promise may have been resolved already or never created', { component: 'Service' }); } } @@ -554,7 +554,7 @@ export default class Services { * @param spAddress - The SP Address (value). */ public updateRelay(url: string, spAddress: string) { - secureLogger.info('✅ Updating relay ${url} with spAddress ${spAddress}', { component: 'Service' }); + secureLogger.info(' Updating relay ${url} with spAddress ${spAddress}', { component: 'Service' }); this.relayAddresses[url] = spAddress; } @@ -742,21 +742,21 @@ export default class Services { const availableAmt = await this.getAmount(); const target: bigint = DEFAULTAMOUNT * 10n; - secureLogger.info('💰 Current amount: ${availableAmt}, target: ${target}', { component: 'Service' }); + secureLogger.info(' Current amount: ${availableAmt}, target: ${target}', { component: 'Service' }); if (availableAmt < target) { - secureLogger.info('🪙 Requesting tokens from faucet...', { component: 'Service' }); - this.updateUserStatus('🪙 Requesting test tokens from faucet...'); + secureLogger.info(' Requesting tokens from faucet...', { component: 'Service' }); + this.updateUserStatus(' Requesting test tokens from faucet...'); const faucetMsg = this.createFaucetMessage(); - secureLogger.info('🪙 Faucet message created:', { component: 'Service', data: faucetMsg }); + secureLogger.info(' Faucet message created:', { component: 'Service', data: faucetMsg }); this.sendFaucetMessage(faucetMsg); - secureLogger.info('🪙 Faucet message sent, waiting for tokens...', { component: 'Service' }); - this.updateUserStatus('⏳ Waiting for tokens to be sent...'); + secureLogger.info(' Faucet message sent, waiting for tokens...', { component: 'Service' }); + this.updateUserStatus(' Waiting for tokens to be sent...'); await this.waitForAmount(target); } else { - secureLogger.info('✅ Sufficient tokens already available', { component: 'Service' }); - this.updateUserStatus('✅ Sufficient tokens available'); + secureLogger.info(' Sufficient tokens already available', { component: 'Service' }); + this.updateUserStatus(' Sufficient tokens available'); } } @@ -765,17 +765,17 @@ export default class Services { private async safeScanBlocks(): Promise { if (this.isScanningBlocks) { - secureLogger.warn('⏳ Block scan already in progress, skipping...', { component: 'Service' }); + secureLogger.warn(' Block scan already in progress, skipping...', { component: 'Service' }); return; } this.isScanningBlocks = true; try { - secureLogger.info('🔄 Starting block scan...', { component: 'Service' }); + secureLogger.info(' Starting block scan...', { component: 'Service' }); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); - secureLogger.info('✅ Block scan completed', { component: 'Service' }); + secureLogger.info(' Block scan completed', { component: 'Service' }); } catch (error) { - secureLogger.error('❌ Block scan failed:', error, { component: 'Service' }); + secureLogger.error(' Block scan failed:', error, { component: 'Service' }); throw error; } finally { this.isScanningBlocks = false; @@ -801,45 +801,45 @@ export default class Services { while (attempts > 0) { const amount = await this.getAmount(); - secureLogger.info('🪙 Attempt ${21 - attempts}: current amount ${amount}, target ${target}', { component: 'Service' }); + secureLogger.info(' Attempt ${21 - attempts}: current amount ${amount}, target ${target}', { component: 'Service' }); if (amount >= target) { - secureLogger.info('✅ Sufficient tokens received!', { component: 'Service' }); - this.updateUserStatus('✅ Tokens received successfully!'); + secureLogger.info(' Sufficient tokens received!', { component: 'Service' }); + this.updateUserStatus(' Tokens received successfully!'); return amount; } // Only scan if we've received a transaction (NewTx message) if (this.hasReceivedTransaction && attempts < 20) { - secureLogger.info('🔄 Transaction received, scanning blocks to update wallet state...', { component: 'Service' }); - this.updateUserStatus('🔄 Processing received transaction...'); + secureLogger.info(' Transaction received, scanning blocks to update wallet state...', { component: 'Service' }); + this.updateUserStatus(' Processing received transaction...'); try { // Force a complete scan to catch the new transaction - secureLogger.info('🔄 Scanning blocks to catch new transaction...', { component: 'Service' }); + secureLogger.info(' Scanning blocks to catch new transaction...', { component: 'Service' }); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); - secureLogger.info('✅ Block scan completed after transaction', { component: 'Service' }); + secureLogger.info(' Block scan completed after transaction', { component: 'Service' }); // Check amount again after scanning const newAmount = await this.getAmount(); - secureLogger.info('💰 Amount after transaction scan: ${newAmount}', { component: 'Service' }); + secureLogger.info(' Amount after transaction scan: ${newAmount}', { component: 'Service' }); if (newAmount > 0n) { - this.updateUserStatus(`💰 Found ${newAmount} tokens in wallet!`); + this.updateUserStatus(` Found ${newAmount} tokens in wallet!`); } else { - this.updateUserStatus('⏳ Transaction processed, waiting for confirmation...'); + this.updateUserStatus(' Transaction processed, waiting for confirmation...'); } } catch (scanError) { - secureLogger.error('❌ Error during transaction scan:', scanError, { component: 'Service' }); - this.updateUserStatus('⚠️ Processing transaction...'); + secureLogger.error(' Error during transaction scan:', scanError, { component: 'Service' }); + this.updateUserStatus(' Processing transaction...'); } } else if (!this.hasReceivedTransaction) { - this.updateUserStatus('⏳ Waiting for faucet transaction...'); + this.updateUserStatus(' Waiting for faucet transaction...'); } attempts--; if (attempts > 0) { - secureLogger.info('⏳ Waiting 5 seconds before next attempt (${attempts} attempts left)...', { component: 'Service' }); - this.updateUserStatus(`⏳ Checking for tokens... (${attempts} attempts remaining)`); + secureLogger.info(' Waiting 5 seconds before next attempt (${attempts} attempts left)...', { component: 'Service' }); + this.updateUserStatus(` Checking for tokens... (${attempts} attempts remaining)`); await new Promise(resolve => setTimeout(resolve, 5000)); // Wait for 5 seconds } } @@ -919,10 +919,10 @@ export default class Services { await this.ensureWalletKeysAvailable(); // Attendre que le relai soit prêt avec son spAddress - secureLogger.info('⏳ Waiting for relays to be ready...', { component: 'Service' }); + secureLogger.info(' Waiting for relays to be ready...', { component: 'Service' }); // Update UI status const { updateCreatorStatus } = await import('../utils/sp-address.utils'); - updateCreatorStatus('⏳ Waiting for relays to be ready...'); + updateCreatorStatus(' Waiting for relays to be ready...'); await this.getRelayReadyPromise(); @@ -932,10 +932,10 @@ export default class Services { if (!relayAddress) { secureLogger.error('Available relays:', relays, { component: 'Service' }); - throw new Error('❌ No relay address available after waiting'); + throw new Error(' No relay address available after waiting'); } - secureLogger.info('✅ Relay address found:', { component: 'Service', data: relayAddress }); + secureLogger.info(' Relay address found:', { component: 'Service', data: relayAddress }); const feeRate = 1; @@ -960,7 +960,7 @@ export default class Services { // secureLogger.info('relayAddress:', { component: 'Service', data: relayAddress, 'feeRate:', feeRate }); // First, ensure we have a complete initial scan before requesting faucet tokens - secureLogger.info('🔄 Ensuring complete initial scan before faucet request...', { component: 'Service' }); + secureLogger.info(' Ensuring complete initial scan before faucet request...', { component: 'Service' }); await this.ensureCompleteInitialScan(); // Now request tokens from faucet @@ -1174,7 +1174,7 @@ export default class Services { const parsedMsg: NewTxMessage = typeof newTxMsg === 'string' ? JSON.parse(newTxMsg) : newTxMsg; if (parsedMsg.error !== null) { secureLogger.error('Received error in new tx message:', parsedMsg.error, { component: 'Service' }); - this.updateUserStatus('❌ Transaction error received'); + this.updateUserStatus(' Transaction error received'); return; } @@ -1224,12 +1224,12 @@ export default class Services { await this.saveDeviceInDatabase(newDevice); // Force SDK to scan blocks to update wallet state after receiving tokens - secureLogger.info('🔄 Forcing SDK to scan blocks to update wallet state...', { component: 'Service' }); + secureLogger.info(' Forcing SDK to scan blocks to update wallet state...', { component: 'Service' }); try { // Get current device to check birthday const device = await this.getDeviceFromDatabase(); if (device?.sp_wallet) { - secureLogger.debug('🔍 Device wallet state:', { component: 'Service', data: { + secureLogger.debug(' Device wallet state:', { component: 'Service', data: { birthday: device.sp_wallet.birthday, last_scan: device.sp_wallet.last_scan, current_block: this.currentBlockHeight @@ -1243,45 +1243,45 @@ export default class Services { ? Math.max(0, this.currentBlockHeight - 100) // Scan from 100 blocks earlier for new wallets : device.sp_wallet.birthday; - secureLogger.info('🔄 Forcing complete scan from block ${scanFromHeight} to current block ${this.currentBlockHeight}...', { component: 'Service' }); + secureLogger.info(' Forcing complete scan from block ${scanFromHeight} to current block ${this.currentBlockHeight}...', { component: 'Service' }); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); - secureLogger.info('✅ Complete block scan completed', { component: 'Service' }); + secureLogger.info(' Complete block scan completed', { component: 'Service' }); // Update last_scan to current block height device.sp_wallet.last_scan = this.currentBlockHeight; await this.saveDeviceInDatabase(device); - secureLogger.info('✅ Wallet last_scan updated to current block height', { component: 'Service' }); + secureLogger.info(' Wallet last_scan updated to current block height', { component: 'Service' }); } else { - secureLogger.info('🔄 Using safe scan blocks...', { component: 'Service' }); + secureLogger.info(' Using safe scan blocks...', { component: 'Service' }); await this.safeScanBlocks(); } } else { - secureLogger.info('🔄 Using safe scan blocks (no device found)...', { component: 'Service' }); + secureLogger.info(' Using safe scan blocks (no device found)...', { component: 'Service' }); await this.safeScanBlocks(); } } catch (scanError) { - secureLogger.error('❌ Error during forced block scan:', scanError, { component: 'Service' }); + secureLogger.error(' Error during forced block scan:', scanError, { component: 'Service' }); // Fallback to safe scan try { await this.safeScanBlocks(); } catch (fallbackError) { - secureLogger.error('❌ Fallback scan also failed:', fallbackError, { component: 'Service' }); + secureLogger.error(' Fallback scan also failed:', fallbackError, { component: 'Service' }); } } // Check amount after scanning const updatedAmount = await this.getAmount(); - secureLogger.info('💰 Amount after block scan: ${updatedAmount}', { component: 'Service' }); + secureLogger.info(' Amount after block scan: ${updatedAmount}', { component: 'Service' }); // Update user with scan results if (updatedAmount > 0n) { - this.updateUserStatus(`💰 Wallet updated! Found ${updatedAmount} tokens`); + this.updateUserStatus(` Wallet updated! Found ${updatedAmount} tokens`); } else { - this.updateUserStatus('⏳ Transaction processed, waiting for confirmation...'); + this.updateUserStatus(' Transaction processed, waiting for confirmation...'); } // Additional debugging: check if SDK is properly initialized - secureLogger.debug('🔍 SDK debugging info:', { component: 'Service' }); + secureLogger.debug(' SDK debugging info:', { component: 'Service' }); secureLogger.info('- Current block height:', { component: 'Service', data: this.currentBlockHeight }); secureLogger.info('- Blindbit URL:', { component: 'Service', data: BLINDBITURL }); secureLogger.info('- SDK client initialized:', { component: 'Service', data: !!this.sdkClient }); @@ -1290,16 +1290,16 @@ export default class Services { try { const device = await this.getDeviceFromDatabase(); if (device?.sp_wallet) { - secureLogger.debug('🔍 Wallet state:', { component: 'Service' }); + secureLogger.debug(' Wallet state:', { component: 'Service' }); secureLogger.info('- Last scan:', { component: 'Service', data: device.sp_wallet.last_scan }); secureLogger.info('- Current block:', { component: 'Service', data: this.currentBlockHeight }); secureLogger.info('- Scan needed:', { component: 'Service', data: device.sp_wallet.last_scan < this.currentBlockHeight }); } } catch (error) { - secureLogger.error('❌ Error checking wallet state:', error, { component: 'Service' }); + secureLogger.error(' Error checking wallet state:', error, { component: 'Service' }); } } catch (scanError) { - secureLogger.error('❌ Failed to scan blocks:', scanError, { component: 'Service' }); + secureLogger.error(' Failed to scan blocks:', scanError, { component: 'Service' }); } } } catch (e) { @@ -1429,50 +1429,50 @@ export default class Services { maxRetries: number = 30, retryDelay: number = 2000 ): Promise { - secureLogger.debug('🔍 DEBUG: waitForPairingCommitment called with processId: ${processId}', { component: 'Service' }); - secureLogger.info('⏳ Waiting for pairing process ${processId} to be committed and synchronized...', { component: 'Service' }); - secureLogger.info('🔄 This may take some time as we wait for SDK synchronization...', { component: 'Service' }); + secureLogger.debug(' DEBUG: waitForPairingCommitment called with processId: ${processId}', { component: 'Service' }); + secureLogger.info(' Waiting for pairing process ${processId} to be committed and synchronized...', { component: 'Service' }); + secureLogger.info(' This may take some time as we wait for SDK synchronization...', { component: 'Service' }); for (let i = 0; i < maxRetries; i++) { try { // Check device state directly without forcing updateDevice const device = this.dumpDeviceFromMemory(); - secureLogger.debug('🔍 Attempt ${i + 1}/${maxRetries}: pairing_process_commitment =', { component: 'Service', data: device.pairing_process_commitment + secureLogger.debug(' Attempt ${i + 1}/${maxRetries}: pairing_process_commitment =', { component: 'Service', data: device.pairing_process_commitment }); // Additional debugging: Check if we can get the pairing process ID let currentPairingId: string | null = null; try { currentPairingId = this.sdkClient.get_pairing_process_id(); - secureLogger.debug('🔍 Current pairing process ID from SDK: ${currentPairingId}', { component: 'Service' }); + secureLogger.debug(' Current pairing process ID from SDK: ${currentPairingId}', { component: 'Service' }); } catch (e) { - secureLogger.error('⚠️ SDK pairing process ID not available yet: ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' SDK pairing process ID not available yet: ${(e as Error).message}', { component: 'Service' }); } // Try to force synchronization by requesting the process from peers if (i % 3 === 0 && i > 0) { try { - secureLogger.info('🔄 Attempting to request process from peers...', { component: 'Service' }); + secureLogger.info(' Attempting to request process from peers...', { component: 'Service' }); await this.requestDataFromPeers(processId, [], []); - secureLogger.info('✅ Process request sent to peers', { component: 'Service' }); + secureLogger.info(' Process request sent to peers', { component: 'Service' }); } catch (e) { - secureLogger.error('⚠️ Failed to request process from peers: ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' Failed to request process from peers: ${(e as Error).message}', { component: 'Service' }); } } // For quorum=1, try to force process synchronization if (i === 2) { try { - secureLogger.info('🔄 Forcing process synchronization for quorum=1 test...', { component: 'Service' }); + secureLogger.info(' Forcing process synchronization for quorum=1 test...', { component: 'Service' }); // Force the SDK to recognize this as a pairing process const process = await this.getProcess(processId); if (process) { - secureLogger.info('🔄 Process found, attempting to sync with SDK...', { component: 'Service' }); + secureLogger.info(' Process found, attempting to sync with SDK...', { component: 'Service' }); // Try to trigger SDK synchronization await this.sdkClient.get_pairing_process_id(); } } catch (e) { - secureLogger.error('⚠️ Process synchronization attempt failed: ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' Process synchronization attempt failed: ${(e as Error).message}', { component: 'Service' }); } } @@ -1480,25 +1480,25 @@ export default class Services { try { const process = await this.getProcess(processId); if (process) { - secureLogger.debug('🔍 Process exists: ${processId}, states: ${process.states?.length || 0}', { component: 'Service' }); + secureLogger.debug(' Process exists: ${processId}, states: ${process.states?.length || 0}', { component: 'Service' }); const lastState = process.states?.[process.states.length - 1]; if (lastState) { - secureLogger.debug('🔍 Last state ID: ${lastState.state_id}', { component: 'Service' }); + secureLogger.debug(' Last state ID: ${lastState.state_id}', { component: 'Service' }); } } else { - secureLogger.warn('⚠️ Process not found in local processes: ${processId}', { component: 'Service' }); + secureLogger.warn(' Process not found in local processes: ${processId}', { component: 'Service' }); } } catch (e) { - secureLogger.error('⚠️ Error checking process: ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' Error checking process: ${(e as Error).message}', { component: 'Service' }); } // Check WebSocket connection and handshake data try { - secureLogger.debug('🔍 WebSocket connections: ${Object.keys(this.relayAddresses).length} relays', { component: 'Service' }); - secureLogger.debug('🔍 Current block height: ${this.currentBlockHeight}', { component: 'Service' }); - secureLogger.debug('🔍 Members list size: ${Object.keys(this.membersList).length}', { component: 'Service' }); + secureLogger.debug(' WebSocket connections: ${Object.keys(this.relayAddresses).length} relays', { component: 'Service' }); + secureLogger.debug(' Current block height: ${this.currentBlockHeight}', { component: 'Service' }); + secureLogger.debug(' Members list size: ${Object.keys(this.membersList).length}', { component: 'Service' }); } catch (e) { - secureLogger.error('⚠️ Error checking WebSocket state: ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' Error checking WebSocket state: ${(e as Error).message}', { component: 'Service' }); } // Check if the commitment is set and not null/empty @@ -1507,14 +1507,14 @@ export default class Services { device.pairing_process_commitment !== null && device.pairing_process_commitment !== '' ) { - secureLogger.info('✅ Pairing process commitment found:', { component: 'Service', data: device.pairing_process_commitment }); + secureLogger.info(' Pairing process commitment found:', { component: 'Service', data: device.pairing_process_commitment }); return; } // For quorum=1.0 processes, the creator must commit themselves // Check if the process is ready for the creator to commit if (currentPairingId && currentPairingId === processId) { - secureLogger.info('✅ Creator process is synchronized and ready for self-commitment (quorum=1.0)', { component: 'Service' }); + secureLogger.info(' Creator process is synchronized and ready for self-commitment (quorum=1.0)', { component: 'Service' }); return; } @@ -1523,55 +1523,55 @@ export default class Services { if (i < 5) { try { await this.updateDevice(); - secureLogger.info('🔄 Forced device update on attempt ${i + 1}', { component: 'Service' }); + secureLogger.info(' Forced device update on attempt ${i + 1}', { component: 'Service' }); } catch (e) { - secureLogger.error('⚠️ Forced device update failed: ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' Forced device update failed: ${(e as Error).message}', { component: 'Service' }); } } // If we have the process but SDK doesn't know about it yet, try to force SDK sync if (currentPairingId === null && i > 2) { try { - secureLogger.info('🔄 Attempting to force SDK synchronization for process ${processId}...', { component: 'Service' }); + secureLogger.info(' Attempting to force SDK synchronization for process ${processId}...', { component: 'Service' }); // Try to manually pair the device with the process const process = await this.getProcess(processId); if (process && process.states && process.states.length > 0) { const lastState = process.states[process.states.length - 1]; if (lastState.public_data && lastState.public_data['pairedAddresses']) { const pairedAddresses = this.decodeValue(lastState.public_data['pairedAddresses']); - secureLogger.info('🔄 Manually pairing device with addresses: ${JSON.stringify(pairedAddresses)}', { component: 'Service' }); + secureLogger.info(' Manually pairing device with addresses: ${JSON.stringify(pairedAddresses)}', { component: 'Service' }); this.sdkClient.pair_device(processId, pairedAddresses); - secureLogger.info('✅ Manual pairing completed', { component: 'Service' }); + secureLogger.info(' Manual pairing completed', { component: 'Service' }); } } } catch (e) { - secureLogger.error('⚠️ Manual pairing failed: ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' Manual pairing failed: ${(e as Error).message}', { component: 'Service' }); } } - secureLogger.info('⏳ Still waiting for SDK synchronization... (${i + 1}/${maxRetries})', { component: 'Service' }); + secureLogger.info(' Still waiting for SDK synchronization... (${i + 1}/${maxRetries})', { component: 'Service' }); // Only try updateDevice every 5 attempts to avoid spam if (i % 5 === 0 && i > 0) { try { await this.updateDevice(); - secureLogger.info('✅ Device update successful on attempt ${i + 1}', { component: 'Service' }); + secureLogger.info(' Device update successful on attempt ${i + 1}', { component: 'Service' }); } catch (e) { - secureLogger.error('⚠️ Device update failed on attempt ${i + 1} (process may not be committed yet): ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' Device update failed on attempt ${i + 1} (process may not be committed yet): ${(e as Error).message}', { component: 'Service' }); } } } catch (e) { - secureLogger.error('❌ Attempt ${i + 1}/${maxRetries}: Error during synchronization - ${(e as Error).message}', { component: 'Service' }); + secureLogger.error(' Attempt ${i + 1}/${maxRetries}: Error during synchronization - ${(e as Error).message}', { component: 'Service' }); } if (i < maxRetries - 1) { - secureLogger.info('⏳ Waiting ${retryDelay}ms before next attempt...', { component: 'Service' }); + secureLogger.info(' Waiting ${retryDelay}ms before next attempt...', { component: 'Service' }); await new Promise(resolve => setTimeout(resolve, retryDelay)); } } throw new Error( - `❌ Pairing process ${processId} was not synchronized after ${maxRetries} attempts (${(maxRetries * retryDelay) / 1000}s)` + ` Pairing process ${processId} was not synchronized after ${maxRetries} attempts (${(maxRetries * retryDelay) / 1000}s)` ); } @@ -1665,17 +1665,17 @@ export default class Services { try { const device = this.dumpDeviceFromMemory(); if (!device?.sp_wallet) { - throw new Error('❌ Wallet not initialized - WebAuthn decryption required'); + throw new Error(' Wallet not initialized - WebAuthn decryption required'); } // Vérifier si les clés sont déjà disponibles dans le device if (device.sp_wallet.spend_key && device.sp_wallet.scan_sk) { - secureLogger.info('✅ Wallet keys available for operation', { component: 'Service' }); + secureLogger.info(' Wallet keys available for operation', { component: 'Service' }); return; } // Si les clés ne sont pas disponibles, restaurer le device complet depuis la base de données - secureLogger.info('🔐 Wallet keys not in memory, restoring full device from database...', { component: 'Service' }); + secureLogger.info(' Wallet keys not in memory, restoring full device from database...', { component: 'Service' }); try { // Récupérer le device complet depuis la base de données (contient birthday, last_scan, etc.) @@ -1683,15 +1683,15 @@ export default class Services { try { deviceFromDb = await this.getDeviceFromDatabase(); } catch (dbError) { - secureLogger.error('❌ Failed to get device from database:', dbError, { component: 'Service' }); - throw new Error(`❌ Database error: ${dbError}`); + secureLogger.error(' Failed to get device from database:', dbError, { component: 'Service' }); + throw new Error(` Database error: ${dbError}`); } if (!deviceFromDb?.sp_wallet) { throw new Error('Device not found in database'); } - secureLogger.debug('🔍 Device from database - birthday: ${deviceFromDb.sp_wallet.birthday}, last_scan: ${deviceFromDb.sp_wallet.last_scan}', { component: 'Service' }); + secureLogger.debug(' Device from database - birthday: ${deviceFromDb.sp_wallet.birthday}, last_scan: ${deviceFromDb.sp_wallet.last_scan}', { component: 'Service' }); // Récupérer les credentials pour injecter les clés let credentials; @@ -1700,11 +1700,11 @@ export default class Services { const secureCredentialsService = SecureCredentialsService.getInstance(); credentials = await secureCredentialsService.retrieveCredentials(''); } catch (credentialError) { - secureLogger.error('❌ Failed to retrieve credentials:', credentialError, { component: 'Service' }); - throw new Error(`❌ Credential retrieval failed: ${credentialError}`); + secureLogger.error(' Failed to retrieve credentials:', credentialError, { component: 'Service' }); + throw new Error(` Credential retrieval failed: ${credentialError}`); } - secureLogger.debug('🔍 Credentials to inject:', { component: 'Service', data: { + secureLogger.debug(' Credentials to inject:', { component: 'Service', data: { spendKey_length: credentials.spendKey?.length || 0, scanKey_length: credentials.scanKey?.length || 0, spendKey_type: typeof credentials.spendKey, @@ -1719,7 +1719,7 @@ export default class Services { secureLogger.info('🔧 Injecting keys into device from database...', { component: 'Service' }); try { if (deviceFromDb?.sp_wallet) { - secureLogger.debug('🔍 Device from database before injection:', { component: 'Service', data: { + secureLogger.debug(' Device from database before injection:', { component: 'Service', data: { has_spend_key: !!deviceFromDb.sp_wallet.spend_key, has_scan_sk: !!deviceFromDb.sp_wallet.scan_sk, spend_key_type: typeof deviceFromDb.sp_wallet.spend_key, @@ -1730,7 +1730,7 @@ export default class Services { deviceFromDb.sp_wallet.spend_key = {Secret: credentials.spendKey}; deviceFromDb.sp_wallet.scan_sk = credentials.scanKey; - secureLogger.debug('🔍 Device from database after injection:', { component: 'Service', data: { + secureLogger.debug(' Device from database after injection:', { component: 'Service', data: { has_spend_key: !!deviceFromDb.sp_wallet.spend_key, has_scan_sk: !!deviceFromDb.sp_wallet.scan_sk, spend_key_type: typeof deviceFromDb.sp_wallet.spend_key, @@ -1742,18 +1742,18 @@ export default class Services { throw new Error('No sp_wallet found in device from database'); } } catch (injectError) { - secureLogger.error('❌ Failed to inject keys into device from database:', injectError, { component: 'Service' }); - throw new Error(`❌ Key injection failed: ${injectError}`); + secureLogger.error(' Failed to inject keys into device from database:', injectError, { component: 'Service' }); + throw new Error(` Key injection failed: ${injectError}`); } // Restaurer le device complet avec les clés injectées secureLogger.info('🔧 Restoring complete device with injected keys...', { component: 'Service' }); try { this.restoreDevice(deviceFromDb); - secureLogger.info('✅ Device restored successfully with keys', { component: 'Service' }); + secureLogger.info(' Device restored successfully with keys', { component: 'Service' }); } catch (restoreError) { - secureLogger.error('❌ Failed to restore device:', restoreError, { component: 'Service' }); - throw new Error(`❌ Device restore failed: ${restoreError}`); + secureLogger.error(' Failed to restore device:', restoreError, { component: 'Service' }); + throw new Error(` Device restore failed: ${restoreError}`); } // Le SDK a déjà les bonnes clés en mémoire après restoreDevice(deviceFromDb) @@ -1761,7 +1761,7 @@ export default class Services { secureLogger.info('🔧 Verifying keys in SDK after device restoration...', { component: 'Service' }); try { const currentDevice = this.dumpDeviceFromMemory(); - secureLogger.debug('🔍 Device state after restoration:', { component: 'Service', data: { + secureLogger.debug(' Device state after restoration:', { component: 'Service', data: { has_spend_key: !!currentDevice.sp_wallet?.spend_key, has_scan_sk: !!currentDevice.sp_wallet?.scan_sk, spend_key_type: typeof currentDevice.sp_wallet?.spend_key, @@ -1770,20 +1770,20 @@ export default class Services { // Si les clés ne sont pas présentes, c'est normal car le SDK les gère en interne // Le SDK utilise ses propres clés pour les opérations, pas celles du device JavaScript - secureLogger.info('✅ Device restored with SDK-managed keys', { component: 'Service' }); + secureLogger.info(' Device restored with SDK-managed keys', { component: 'Service' }); } catch (verifyError) { - secureLogger.error('❌ Failed to verify device state:', verifyError, { component: 'Service' }); - throw new Error(`❌ Device verification failed: ${verifyError}`); + secureLogger.error(' Failed to verify device state:', verifyError, { component: 'Service' }); + throw new Error(` Device verification failed: ${verifyError}`); } - secureLogger.info('✅ Device restored with updated keys from credentials', { component: 'Service' }); + secureLogger.info(' Device restored with updated keys from credentials', { component: 'Service' }); } catch (credentialError) { - secureLogger.error('❌ Failed to restore wallet keys from credentials:', credentialError, { component: 'Service' }); - throw new Error(`❌ Wallet keys not available: ${credentialError}`); + secureLogger.error(' Failed to restore wallet keys from credentials:', credentialError, { component: 'Service' }); + throw new Error(` Wallet keys not available: ${credentialError}`); } } catch (error) { - secureLogger.error('❌ Wallet keys not available:', error, { component: 'Service' }); - throw new Error('❌ Wallet keys not available - WebAuthn decryption required'); + secureLogger.error(' Wallet keys not available:', error, { component: 'Service' }); + throw new Error(' Wallet keys not available - WebAuthn decryption required'); } } @@ -1797,13 +1797,13 @@ export default class Services { try { const amount = this.sdkClient.get_available_amount(); - secureLogger.info('💰 SDK get_available_amount() returned: ${amount}', { component: 'Service' }); + secureLogger.info(' SDK get_available_amount() returned: ${amount}', { component: 'Service' }); // Additional debugging: check wallet state try { const device = this.dumpDeviceFromMemory(); if (device?.sp_wallet) { - secureLogger.debug('🔍 Wallet debugging info:', { component: 'Service', data: { + secureLogger.debug(' Wallet debugging info:', { component: 'Service', data: { birthday: device.sp_wallet.birthday, last_scan: device.sp_wallet.last_scan, current_block: this.currentBlockHeight, @@ -1812,12 +1812,12 @@ export default class Services { } }); } } catch (error) { - secureLogger.warn('⚠️ Error getting wallet debugging info:', { component: 'Service', data: error }); + secureLogger.warn(' Error getting wallet debugging info:', { component: 'Service', data: error }); } return amount; } catch (error) { - secureLogger.error('❌ Error calling get_available_amount():', error, { component: 'Service' }); + secureLogger.error(' Error calling get_available_amount():', error, { component: 'Service' }); throw error; } } @@ -1867,10 +1867,10 @@ export default class Services { } async saveDeviceInDatabase(device: Device): Promise { - secureLogger.info('🔐 saveDeviceInDatabase called - starting encryption process...', { component: 'Service' }); + secureLogger.info(' saveDeviceInDatabase called - starting encryption process...', { component: 'Service' }); try { // Récupérer la clé PBKDF2 pour chiffrer le device - secureLogger.info('🔐 Retrieving PBKDF2 key for device encryption...', { component: 'Service' }); + secureLogger.info(' Retrieving PBKDF2 key for device encryption...', { component: 'Service' }); const { SecureCredentialsService } = await import('./secure-credentials.service'); const secureCredentialsService = SecureCredentialsService.getInstance(); @@ -1887,13 +1887,13 @@ export default class Services { if (key) { pbkdf2Key = key; workingMode = mode; - secureLogger.info('✅ PBKDF2 key found for mode: ${mode}', { component: 'Service' }); + secureLogger.info(' PBKDF2 key found for mode: ${mode}', { component: 'Service' }); break; } } } catch (e) { // Continue to next mode - secureLogger.warn('⚠️ No PBKDF2 key for mode ${mode}', { component: 'Service' }); + secureLogger.warn(' No PBKDF2 key for mode ${mode}', { component: 'Service' }); } } @@ -1901,16 +1901,16 @@ export default class Services { throw new Error('Failed to retrieve PBKDF2 key - cannot encrypt device'); } - secureLogger.info('🔐 Encrypting device with PBKDF2 key...', { component: 'Service' }); + secureLogger.info(' Encrypting device with PBKDF2 key...', { component: 'Service' }); // Chiffrer le device const { EncryptionService } = await import('./encryption.service'); const encryptionService = EncryptionService.getInstance(); const deviceString = JSON.stringify(device); const encryptedDevice = await encryptionService.encrypt(deviceString, pbkdf2Key); - secureLogger.info('✅ Device encrypted successfully', { component: 'Service' }); + secureLogger.info(' Device encrypted successfully', { component: 'Service' }); // Récupérer le wallet existant pour préserver encrypted_wallet - secureLogger.debug('🔍 Retrieving existing wallet to preserve encrypted_wallet...', { component: 'Service' }); + secureLogger.debug(' Retrieving existing wallet to preserve encrypted_wallet...', { component: 'Service' }); let encryptedWallet: string | undefined = undefined; // Récupérer le wallet chiffré depuis la base de données directement @@ -1931,9 +1931,9 @@ export default class Services { if (walletData?.encrypted_wallet) { encryptedWallet = walletData.encrypted_wallet; - secureLogger.info('✅ encrypted_wallet preserved', { component: 'Service' }); + secureLogger.info(' encrypted_wallet preserved', { component: 'Service' }); } else { - secureLogger.warn('⚠️ No existing encrypted_wallet to preserve', { component: 'Service' }); + secureLogger.warn(' No existing encrypted_wallet to preserve', { component: 'Service' }); } // Sauvegarder avec le format chiffré @@ -1966,7 +1966,7 @@ export default class Services { // Définir les handlers de transaction avant le put transaction.oncomplete = async () => { - secureLogger.info('✅ Transaction completed for wallet save', { component: 'Service' }); + secureLogger.info(' Transaction completed for wallet save', { component: 'Service' }); // Vérifier que le wallet a bien été sauvegardé en le récupérant depuis la base try { @@ -1984,16 +1984,16 @@ export default class Services { verifyRequest.onsuccess = () => { const savedData = verifyRequest.result; if (savedData?.encrypted_device === encryptedDevice) { - secureLogger.info('✅ Verified: Device correctly saved in database', { component: 'Service' }); + secureLogger.info(' Verified: Device correctly saved in database', { component: 'Service' }); resolveVerify(); } else { - secureLogger.error('❌ Verification failed: Device not found or encrypted data mismatch', { component: 'Service' }); + secureLogger.error(' Verification failed: Device not found or encrypted data mismatch', { component: 'Service' }); rejectVerify(new Error('Device save verification failed')); } }; verifyRequest.onerror = () => { - secureLogger.error('❌ Verification failed: Could not retrieve saved device', verifyRequest.error, { component: 'Service' }); + secureLogger.error(' Verification failed: Could not retrieve saved device', verifyRequest.error, { component: 'Service' }); rejectVerify(verifyRequest.error); }; }); @@ -2005,22 +2005,22 @@ export default class Services { }; transaction.onerror = () => { - secureLogger.error('❌ Transaction failed:', transaction.error, { component: 'Service' }); + secureLogger.error(' Transaction failed:', transaction.error, { component: 'Service' }); reject(transaction.error); }; const putRequest = store.put(walletObject); putRequest.onsuccess = () => { - secureLogger.info('✅ Device saved to database with encryption', { component: 'Service' }); + secureLogger.info(' Device saved to database with encryption', { component: 'Service' }); // La vérification se fera dans transaction.oncomplete }; putRequest.onerror = () => { - secureLogger.error('❌ Failed to save wallet:', putRequest.error, { component: 'Service' }); + secureLogger.error(' Failed to save wallet:', putRequest.error, { component: 'Service' }); reject(putRequest.error); }; }); } catch (e) { - secureLogger.error('❌ Error saving device to database:', e, { component: 'Service' }); + secureLogger.error(' Error saving device to database:', e, { component: 'Service' }); throw e; } } @@ -2036,7 +2036,7 @@ export default class Services { }); const walletStore = DATABASE_CONFIG.stores.wallet.name; - secureLogger.debug('🔍 DEBUG: getDeviceFromDatabase - db opened directly, objectStoreNames:', { component: 'Service', data: Array.from(db.objectStoreNames })); + secureLogger.debug(' DEBUG: getDeviceFromDatabase - db opened directly, objectStoreNames:', { component: 'Service', data: Array.from(db.objectStoreNames })); try { const dbRes = await new Promise((resolve, reject) => { @@ -2047,7 +2047,7 @@ export default class Services { getRequest.onerror = () => reject(getRequest.error); }); - secureLogger.debug('🔍 DEBUG: getDeviceFromDatabase - db.getObject result:', { component: 'Service', data: dbRes }); + secureLogger.debug(' DEBUG: getDeviceFromDatabase - db.getObject result:', { component: 'Service', data: dbRes }); if (!dbRes) { secureLogger.debug('getDeviceFromDatabase - no data found for key "1"', { component: 'Service' }); return null; @@ -2056,7 +2056,7 @@ export default class Services { // Check if data is encrypted (new format) or plain (old format) if (dbRes['encrypted_device']) { // New encrypted format - need to decrypt - secureLogger.info('🔐 Wallet found in encrypted format, decrypting...', { component: 'Service' }); + secureLogger.info(' Wallet found in encrypted format, decrypting...', { component: 'Service' }); // Get the PBKDF2 key based on security mode const { SecureCredentialsService } = await import('./secure-credentials.service'); @@ -2100,11 +2100,11 @@ export default class Services { ); const decryptedDevice = JSON.parse(decryptedDeviceString); - secureLogger.info('✅ Wallet decrypted successfully', { component: 'Service' }); + secureLogger.info(' Wallet decrypted successfully', { component: 'Service' }); return decryptedDevice; } else if (dbRes['device']) { // Old plain format (backward compatibility) - secureLogger.warn('⚠️ Wallet found in old format (not encrypted)', { component: 'Service' }); + secureLogger.warn(' Wallet found in old format (not encrypted)', { component: 'Service' }); return dbRes['device']; } else { return null; @@ -2133,9 +2133,9 @@ export default class Services { // Clear IndexedDB completely await this.clearAllIndexedDB(); - secureLogger.info('✅ Account completely deleted', { component: 'Service' }); + secureLogger.info(' Account completely deleted', { component: 'Service' }); } catch (e) { - secureLogger.error('❌ Error deleting account:', e, { component: 'Service' }); + secureLogger.error(' Error deleting account:', e, { component: 'Service' }); throw new Error(`Failed to delete account: ${e}`); } } @@ -2144,11 +2144,11 @@ export default class Services { return new Promise((resolve, reject) => { const deleteReq = indexedDB.deleteDatabase('4nk'); deleteReq.onsuccess = () => { - secureLogger.info('✅ IndexedDB database deleted', { component: 'Service' }); + secureLogger.info(' IndexedDB database deleted', { component: 'Service' }); resolve(); }; deleteReq.onerror = () => { - secureLogger.error('❌ Error deleting IndexedDB database', { component: 'Service' }); + secureLogger.error(' Error deleting IndexedDB database', { component: 'Service' }); reject(deleteReq.error); }; }); @@ -2219,19 +2219,19 @@ export default class Services { // We set birthday later when we have the chain tip from relay secureLogger.info('🔧 Creating new device with birthday 0...', { component: 'Service' }); spAddress = await this.sdkClient.create_new_device(0, 'signet'); - secureLogger.info('✅ Device created with address:', { component: 'Service', data: spAddress }); + secureLogger.info(' Device created with address:', { component: 'Service', data: spAddress }); // Force wallet generation to ensure keys are created secureLogger.info('🔧 Forcing wallet generation...', { component: 'Service' }); try { const wallet = await this.sdkClient.dump_wallet(); - secureLogger.info('✅ Wallet generated:', { component: 'Service', data: wallet }); + secureLogger.info(' Wallet generated:', { component: 'Service', data: wallet }); } catch (walletError) { - secureLogger.warn('⚠️ Wallet generation failed:', { component: 'Service', data: walletError }); + secureLogger.warn(' Wallet generation failed:', { component: 'Service', data: walletError }); } const device = this.dumpDeviceFromMemory(); - secureLogger.debug('🔍 Device details after creation:', { component: 'Service', data: { + secureLogger.debug(' Device details after creation:', { component: 'Service', data: { has_spend_key: !!device.sp_wallet?.spend_key, has_scan_key: !!device.sp_wallet?.scan_sk, birthday: device.sp_wallet?.birthday, @@ -2239,7 +2239,7 @@ export default class Services { } }); await this.saveDeviceInDatabase(device); - secureLogger.info('✅ Device saved to database', { component: 'Service' }); + secureLogger.info(' Device saved to database', { component: 'Service' }); } catch (e) { secureLogger.error('Services ~ Error:', e, { component: 'Service' }); } @@ -2250,14 +2250,14 @@ export default class Services { public restoreDevice(device: Device) { try { this.sdkClient.restore_device(device); - secureLogger.info('✅ Device restored successfully', { component: 'Service' }); + secureLogger.info(' Device restored successfully', { component: 'Service' }); } catch (e) { - secureLogger.error('❌ Error restoring device:', e, { component: 'Service' }); + secureLogger.error(' Error restoring device:', e, { component: 'Service' }); } } public async waitForBlockHeight(): Promise { - secureLogger.info('⏳ Waiting for block height to be set...', { component: 'Service' }); + secureLogger.info(' Waiting for block height to be set...', { component: 'Service' }); // Wait up to 10 seconds for block height to be set let attempts = 0; @@ -2265,7 +2265,7 @@ export default class Services { while (this.currentBlockHeight === -1 && attempts < maxAttempts) { attempts++; - secureLogger.info('⏳ Waiting for block height... (attempt ${attempts}/${maxAttempts})', { component: 'Service' }); + secureLogger.info(' Waiting for block height... (attempt ${attempts}/${maxAttempts})', { component: 'Service' }); await new Promise(resolve => setTimeout(resolve, 500)); } @@ -2273,7 +2273,7 @@ export default class Services { throw new Error('Timeout waiting for block height from relay'); } - secureLogger.info('✅ Block height received: ${this.currentBlockHeight}', { component: 'Service' }); + secureLogger.info(' Block height received: ${this.currentBlockHeight}', { component: 'Service' }); } /** @@ -2282,7 +2282,7 @@ export default class Services { * Only performs scan if wallet is not already synchronized */ public async ensureCompleteInitialScan(): Promise { - secureLogger.info('🔄 Ensuring complete initial scan...', { component: 'Service' }); + secureLogger.info(' Ensuring complete initial scan...', { component: 'Service' }); try { const device = await this.getDeviceFromDatabase(); @@ -2295,24 +2295,24 @@ export default class Services { const isSynchronized = lastScan >= this.currentBlockHeight; if (isSynchronized) { - secureLogger.info('✅ Wallet already synchronized (last_scan: ${lastScan}, current: ${this.currentBlockHeight})', { component: 'Service' }); + secureLogger.info(' Wallet already synchronized (last_scan: ${lastScan}, current: ${this.currentBlockHeight})', { component: 'Service' }); return; } // Only scan if wallet is not synchronized - secureLogger.info('🔄 Wallet needs synchronization (last_scan: ${lastScan}, current: ${this.currentBlockHeight})', { component: 'Service' }); - secureLogger.info('🔄 Performing scan from block ${lastScan} to ${this.currentBlockHeight}...', { component: 'Service' }); + secureLogger.info(' Wallet needs synchronization (last_scan: ${lastScan}, current: ${this.currentBlockHeight})', { component: 'Service' }); + secureLogger.info(' Performing scan from block ${lastScan} to ${this.currentBlockHeight}...', { component: 'Service' }); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); - secureLogger.info('✅ Complete initial scan completed', { component: 'Service' }); + secureLogger.info(' Complete initial scan completed', { component: 'Service' }); // Update last_scan to current block height device.sp_wallet.last_scan = this.currentBlockHeight; await this.saveDeviceInDatabase(device); - secureLogger.info('✅ Wallet scan state updated', { component: 'Service' }); + secureLogger.info(' Wallet scan state updated', { component: 'Service' }); } catch (error) { - secureLogger.error('❌ Error during complete initial scan:', error, { component: 'Service' }); + secureLogger.error(' Error during complete initial scan:', error, { component: 'Service' }); throw error; } } @@ -2323,7 +2323,7 @@ export default class Services { } // Update user status - this.updateUserStatus('🔄 Synchronizing wallet with blockchain...'); + this.updateUserStatus(' Synchronizing wallet with blockchain...'); let device: Device | null = null; try { @@ -2360,7 +2360,7 @@ export default class Services { // Vérifier que le device a été restauré en mémoire const restoredDevice = this.dumpDeviceFromMemory(); if (restoredDevice?.sp_wallet?.birthday === device.sp_wallet.birthday) { - secureLogger.info('✅ Device restored in memory with updated birthday:', { component: 'Service', data: device.sp_wallet.birthday }); + secureLogger.info(' Device restored in memory with updated birthday:', { component: 'Service', data: device.sp_wallet.birthday }); } else { throw new Error(`Device restoration failed: expected birthday ${device.sp_wallet.birthday}, got ${restoredDevice?.sp_wallet?.birthday}`); } @@ -2371,21 +2371,21 @@ export default class Services { // Vérifier que le device a été sauvegardé en base de données const savedDevice = await this.getDeviceFromDatabase(); if (savedDevice?.sp_wallet?.birthday === device.sp_wallet.birthday) { - secureLogger.info('✅ Device saved to database with updated birthday:', { component: 'Service', data: device.sp_wallet.birthday }); + secureLogger.info(' Device saved to database with updated birthday:', { component: 'Service', data: device.sp_wallet.birthday }); } else { throw new Error(`Device save verification failed: expected birthday ${device.sp_wallet.birthday}, got ${savedDevice?.sp_wallet?.birthday}`); } // For new wallets, perform initial scan to catch any existing transactions - secureLogger.info('🔄 Performing initial scan for new wallet from block ${device.sp_wallet.birthday} to ${this.currentBlockHeight}...', { component: 'Service' }); + secureLogger.info(' Performing initial scan for new wallet from block ${device.sp_wallet.birthday} to ${this.currentBlockHeight}...', { component: 'Service' }); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); // Vérifier que le scan est terminé en vérifiant last_scan const deviceAfterScan = this.dumpDeviceFromMemory(); if (deviceAfterScan?.sp_wallet?.last_scan === this.currentBlockHeight) { - secureLogger.info('✅ Initial scan completed for new wallet', { component: 'Service' }); + secureLogger.info(' Initial scan completed for new wallet', { component: 'Service' }); } else { - secureLogger.warn('⚠️ Initial scan may not be complete: expected last_scan ${this.currentBlockHeight}, got ${deviceAfterScan?.sp_wallet?.last_scan}', { component: 'Service' }); + secureLogger.warn(' Initial scan may not be complete: expected last_scan ${this.currentBlockHeight}, got ${deviceAfterScan?.sp_wallet?.last_scan}', { component: 'Service' }); } // Update last_scan to current block height @@ -2395,16 +2395,16 @@ export default class Services { // Vérifier que le device a été sauvegardé avec last_scan mis à jour const finalDevice = await this.getDeviceFromDatabase(); if (finalDevice?.sp_wallet?.last_scan === this.currentBlockHeight) { - secureLogger.info('✅ New wallet initial scan completed and saved', { component: 'Service' }); + secureLogger.info(' New wallet initial scan completed and saved', { component: 'Service' }); } else { throw new Error(`Final save verification failed: expected last_scan ${this.currentBlockHeight}, got ${finalDevice?.sp_wallet?.last_scan}`); } // Note: Faucet tokens will be requested later in the pairing process // when credentials are available - secureLogger.info('🪙 Faucet tokens will be requested during pairing process', { component: 'Service' }); + secureLogger.info(' Faucet tokens will be requested during pairing process', { component: 'Service' }); - secureLogger.info('✅ updateDeviceBlockHeight completed successfully for new device', { component: 'Service' }); + secureLogger.info(' updateDeviceBlockHeight completed successfully for new device', { component: 'Service' }); return; } catch (e) { throw new Error(`Failed to save updated device: ${e}`); @@ -2413,10 +2413,10 @@ export default class Services { // This is existing device, we need to catch up if last_scan is lagging behind chain_tip if (device.sp_wallet.last_scan < this.currentBlockHeight) { // We need to catch up - this is the initial synchronization, not a duplicate scan - secureLogger.info('🔄 Initial wallet synchronization with blockchain...', { component: 'Service' }); + secureLogger.info(' Initial wallet synchronization with blockchain...', { component: 'Service' }); try { await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); - secureLogger.info('✅ Initial wallet synchronization completed', { component: 'Service' }); + secureLogger.info(' Initial wallet synchronization completed', { component: 'Service' }); } catch (e) { secureLogger.error('Failed to scan blocks: ${e}', { component: 'Service' }); return; @@ -2426,14 +2426,14 @@ export default class Services { try { const device = this.dumpDeviceFromMemory(); await this.saveDeviceInDatabase(device); - this.updateUserStatus('✅ Wallet synchronized with blockchain'); + this.updateUserStatus(' Wallet synchronized with blockchain'); } catch (e) { secureLogger.error('Failed to save updated device: ${e}', { component: 'Service' }); - this.updateUserStatus('⚠️ Wallet synchronization completed with warnings'); + this.updateUserStatus(' Wallet synchronization completed with warnings'); } } else { // Up to date, just returns - this.updateUserStatus('✅ Wallet already synchronized'); + this.updateUserStatus(' Wallet already synchronized'); return; } } @@ -2839,7 +2839,7 @@ export default class Services { try { // parsedMsg is already parsed by the validator, no need to JSON.parse again const handshakeMsg: HandshakeMessage = parsedMsg; - secureLogger.debug('🔍 DEBUG: Handshake message received:', { component: 'Service', data: { + secureLogger.debug(' DEBUG: Handshake message received:', { component: 'Service', data: { url, hasSpAddress: !!handshakeMsg.sp_address, spAddress: handshakeMsg.sp_address, @@ -2852,7 +2852,7 @@ export default class Services { this.relayAddresses[url] = handshakeMsg.sp_address; this.resolveRelayReady(); } else { - secureLogger.warn('⚠️ Handshake received but sp_address is empty or undefined', { component: 'Service' }); + secureLogger.warn(' Handshake received but sp_address is empty or undefined', { component: 'Service' }); } secureLogger.info('handshakeMsg:', { component: 'Service', data: handshakeMsg });