diff --git a/src/functions/Login.ts b/src/functions/Login.ts index 9bbfec1..9f59453 100644 --- a/src/functions/Login.ts +++ b/src/functions/Login.ts @@ -262,12 +262,13 @@ export class Login { this.bot.log(this.bot.isMobile, 'LOGIN', 'Login complete') this.totpHandler.setTotpSecret(undefined) - // Stop Escape watcher after successful login - this.passkeyHandler.stopEscapeWatcher() + // CRITICAL: Keep Escape watcher running for 10 more seconds + // Bluetooth/Windows Hello dialogs appear AFTER login completion + this.bot.log(this.bot.isMobile, 'LOGIN-ESCAPE', 'Keeping Escape watcher active for 10s (dialogs may appear after login)', 'log', 'cyan') + setTimeout(() => { + this.passkeyHandler.stopEscapeWatcher() + }, 10000) } catch (e) { - // Stop Escape watcher on error - this.passkeyHandler.stopEscapeWatcher() - const errorMessage = e instanceof Error ? e.message : String(e) const stackTrace = e instanceof Error ? e.stack : undefined this.bot.log(this.bot.isMobile, 'LOGIN', `Failed login: ${errorMessage}${stackTrace ? '\nStack: ' + stackTrace.split('\n').slice(0, 3).join(' | ') : ''}`, 'error') diff --git a/src/functions/login/PasskeyHandler.ts b/src/functions/login/PasskeyHandler.ts index 3db5614..8848b93 100644 --- a/src/functions/login/PasskeyHandler.ts +++ b/src/functions/login/PasskeyHandler.ts @@ -70,6 +70,16 @@ export class PasskeyHandler { public async handlePasskeyPrompts(page: Page, context: 'main' | 'oauth') { let did = false + // CRITICAL: Send Escape key FIRST to dismiss any native OS dialogs (Bluetooth, Windows Hello) + // These dialogs appear AFTER password/TOTP and cannot be dismissed via DOM clicks + try { + await page.keyboard.press('Escape') + await page.waitForTimeout(100) // Brief wait for dialog to close + this.bot.log(this.bot.isMobile, 'PASSKEY-ESCAPE', 'Sent Escape key to dismiss native dialogs', 'log', 'green') + } catch { + // Silent failure - page might not be ready + } + // Early exit for passkey creation flows (common on mobile): hit cancel/skip if present const currentUrl = page.url() if (/fido\/create|passkey/i.test(currentUrl)) {