From 5def07797ed360342f992c471aafae3db09ab5cd Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Thu, 23 Oct 2025 21:53:45 +0200 Subject: [PATCH] fix: remove manual WebAuthn button and restore automatic authentication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **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 --- src/pages/home/home.ts | 4 ++-- src/utils/sp-address.utils.ts | 41 +++++++++++------------------------ 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index dde82cb..9d9be1f 100755 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -528,7 +528,7 @@ export function setupIframePairingButtons() { export function setupMainPairing(): void { const container = getCorrectDOM('login-4nk-component') as HTMLElement; const mainStatus = container.querySelector('#main-status') as HTMLElement; - + if (mainStatus) { mainStatus.innerHTML = `
@@ -538,7 +538,7 @@ export function setupMainPairing(): void {
`; } - + console.log('πŸ” Main pairing setup - authentication will be automatic'); } diff --git a/src/utils/sp-address.utils.ts b/src/utils/sp-address.utils.ts index 8406fe0..86870b4 100755 --- a/src/utils/sp-address.utils.ts +++ b/src/utils/sp-address.utils.ts @@ -2542,35 +2542,20 @@ async function onCreateButtonClick() { console.log('πŸ” DEBUG: protocol:', window.location.protocol); const { secureCredentialsService } = await import('../services/secure-credentials.service'); - updateCreatorStatus('πŸ” Click to authenticate with browser...'); + updateCreatorStatus('πŸ” Authenticating with browser...'); - // Force user interaction before WebAuthn - console.log('πŸ” DEBUG: Waiting for user interaction...'); - - // 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((resolve) => { - authButton.onclick = async () => { - document.body.removeChild(authButton); - try { - // This should trigger the browser popup immediately after user click - await secureCredentialsService.generateSecureCredentials('4nk-pairing-password'); - console.log('βœ… WebAuthn credentials obtained'); - updateCreatorStatus('βœ… Browser authentication successful'); - resolve(); - } catch (error) { - console.error('❌ WebAuthn failed:', error); - updateCreatorStatus('❌ Browser authentication failed'); - resolve(); - } - }; - }); + // Auto-trigger WebAuthn authentication + console.log('πŸ” DEBUG: Auto-triggering WebAuthn authentication...'); + + try { + // This should trigger the browser popup automatically + await secureCredentialsService.generateSecureCredentials('4nk-pairing-password'); + console.log('βœ… WebAuthn credentials obtained'); + updateCreatorStatus('βœ… Browser authentication successful'); + } catch (error) { + console.error('❌ WebAuthn failed:', error); + updateCreatorStatus('❌ Browser authentication failed'); + } } catch (error) { console.warn('⚠️ WebAuthn failed, continuing with fallback:', error); updateCreatorStatus('⚠️ Using fallback authentication');