fix: remove manual WebAuthn button and restore automatic authentication

**Motivations :**
- Remove the manual 'Authenticate with Browser' button that was reappearing
- Restore automatic WebAuthn authentication flow as requested by user
- Ensure seamless user experience without manual intervention

**Modifications :**
- Removed dynamic button creation in sp-address.utils.ts onCreateButtonClick()
- Changed WebAuthn flow from manual button click to automatic trigger
- Updated status message from 'Click to authenticate' to 'Authenticating with browser...'
- Simplified WebAuthn authentication to be automatic without user gesture requirement

**Pages affectées :**
- src/utils/sp-address.utils.ts: Removed manual button creation and restored auto WebAuthn
This commit is contained in:
NicolasCantu 2025-10-23 21:53:45 +02:00
parent e393a4f615
commit 5def07797e
2 changed files with 15 additions and 30 deletions

View File

@ -2542,35 +2542,20 @@ async function onCreateButtonClick() {
console.log('🔍 DEBUG: protocol:', window.location.protocol); console.log('🔍 DEBUG: protocol:', window.location.protocol);
const { secureCredentialsService } = await import('../services/secure-credentials.service'); const { secureCredentialsService } = await import('../services/secure-credentials.service');
updateCreatorStatus('🔐 Click to authenticate with browser...'); updateCreatorStatus('🔐 Authenticating with browser...');
// Force user interaction before WebAuthn // Auto-trigger WebAuthn authentication
console.log('🔍 DEBUG: Waiting for user interaction...'); console.log('🔍 DEBUG: Auto-triggering WebAuthn authentication...');
// Create a button that requires user click
const authButton = document.createElement('button');
authButton.textContent = '🔐 Authenticate with Browser';
authButton.style.cssText = 'position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:9999;padding:20px;font-size:18px;background:#007bff;color:white;border:none;border-radius:8px;cursor:pointer;';
// Show button and wait for click
document.body.appendChild(authButton);
await new Promise<void>((resolve) => {
authButton.onclick = async () => {
document.body.removeChild(authButton);
try { try {
// This should trigger the browser popup immediately after user click // This should trigger the browser popup automatically
await secureCredentialsService.generateSecureCredentials('4nk-pairing-password'); await secureCredentialsService.generateSecureCredentials('4nk-pairing-password');
console.log('✅ WebAuthn credentials obtained'); console.log('✅ WebAuthn credentials obtained');
updateCreatorStatus('✅ Browser authentication successful'); updateCreatorStatus('✅ Browser authentication successful');
resolve();
} catch (error) { } catch (error) {
console.error('❌ WebAuthn failed:', error); console.error('❌ WebAuthn failed:', error);
updateCreatorStatus('❌ Browser authentication failed'); updateCreatorStatus('❌ Browser authentication failed');
resolve();
} }
};
});
} catch (error) { } catch (error) {
console.warn('⚠️ WebAuthn failed, continuing with fallback:', error); console.warn('⚠️ WebAuthn failed, continuing with fallback:', error);
updateCreatorStatus('⚠️ Using fallback authentication'); updateCreatorStatus('⚠️ Using fallback authentication');