diff --git a/src/pages/birthday-setup/birthday-setup.ts b/src/pages/birthday-setup/birthday-setup.ts index f328615..8cd99f4 100644 --- a/src/pages/birthday-setup/birthday-setup.ts +++ b/src/pages/birthday-setup/birthday-setup.ts @@ -36,16 +36,9 @@ document.addEventListener('DOMContentLoaded', async () => { updateStatus('🔍 VĂ©rification des prĂ©requis...', 'loading'); updateProgress(20); - // VĂ©rifier que le wallet existe en base - const wallet = await services.getDeviceFromDatabase(); - if (!wallet) { - throw new Error('Wallet not found in database. Please complete wallet setup first.'); - } - console.log('✅ Wallet found in database'); - - // VĂ©rifier que le PBKDF2 key existe - const { default: SecureCredentialsService } = await import('../../services/secure-credentials.service'); - const secureCredentials = new SecureCredentialsService(); + // VĂ©rifier que le PBKDF2 key existe d'abord (prĂ©requis le plus basique) + const { SecureCredentialsService } = await import('../../services/secure-credentials.service'); + const secureCredentials = SecureCredentialsService.getInstance(); let pbkdf2KeyFound = false; const securityModes = ['none', 'password', 'os', 'proton-pass']; @@ -63,8 +56,25 @@ document.addEventListener('DOMContentLoaded', async () => { } if (!pbkdf2KeyFound) { - throw new Error('PBKDF2 key not found. Please complete security setup first.'); + console.log('⚠ PBKDF2 key not found, redirecting to security-setup...'); + updateStatus('⚠ Redirection vers la configuration de sĂ©curitĂ©...', 'loading'); + setTimeout(() => { + window.location.href = '/src/pages/security-setup/security-setup.html'; + }, 1000); + return; } + + // VĂ©rifier que le wallet existe en base + const wallet = await services.getDeviceFromDatabase(); + if (!wallet) { + console.log('⚠ Wallet not found, redirecting to wallet-setup...'); + updateStatus('⚠ Redirection vers la configuration du wallet...', 'loading'); + setTimeout(() => { + window.location.href = '/src/pages/wallet-setup/wallet-setup.html'; + }, 1000); + return; + } + console.log('✅ Wallet found in database'); console.log('✅ All prerequisites verified'); // Connexion aux relais diff --git a/src/pages/wallet-setup/wallet-setup.ts b/src/pages/wallet-setup/wallet-setup.ts index 2f16082..a2267bf 100644 --- a/src/pages/wallet-setup/wallet-setup.ts +++ b/src/pages/wallet-setup/wallet-setup.ts @@ -173,12 +173,14 @@ document.addEventListener('DOMContentLoaded', async () => { } } - // CRITICAL: Si aucune clĂ© PBKDF2 n'est disponible, arrĂȘter immĂ©diatement + // CRITICAL: Si aucune clĂ© PBKDF2 n'est disponible, rediriger vers security-setup if (!currentMode) { - console.error('❌ CRITICAL: No PBKDF2 key found for any security mode.'); - console.error('❌ Cannot proceed with wallet creation without encryption key.'); - updateStatus('❌ Erreur: Aucune clĂ© de chiffrement trouvĂ©e. Veuillez configurer la sĂ©curitĂ©.', 'error'); - throw new Error('CRITICAL: No PBKDF2 key found. Cannot create wallet without encryption key.'); + console.log('⚠ No PBKDF2 key found, redirecting to security-setup...'); + updateStatus('⚠ Redirection vers la configuration de sĂ©curitĂ©...', 'loading'); + setTimeout(() => { + window.location.href = '/src/pages/security-setup/security-setup.html'; + }, 1000); + return; } console.log('🔐 Using security mode for wallet encryption:', currentMode);