fix: make the 2FA take-over universal — tailor guidance to what the page asks for

Merged
TO
3mo ago
+477-125

What

Makes the two-factor take-over work for any vendor instead of assuming an authenticator code. Three parts:

  1. Classify how the page wants the user to verify. After a blocked sign-in, we read the verification page into one of: code (a code can be entered), passkey (a passkey/security key is shown, but another method can be chosen), passkey_only (passkey is the only option), or other (device approval / CAPTCHA / link). Returned on the sign-in result. No vendor names are hard-coded — the model recognizes the prompt and the "use another method" control itself.

  2. Right agent behavior per situation.

    • When Comp AI has a stored code: if the page defaults to a passkey, auto-switch to the authenticator-app method so the code field appears, then fill it.
    • When a human is taking over (no stored code): don't pick a method for them — just reveal the vendor's other options ("More options" / "Try another way") so they choose the one they can actually complete.
  3. Exact take-over guidance in the panel, driven by the classification:

    • code → "Enter the code in the page."
    • passkey → "Switch to a code method" (click More options → authenticator / SMS / email).
    • passkey_only → plain notice that it can't be automated, confirm button hidden (nothing to complete), with what to do instead.

Why

Follows the two live-view fixes merged in #3516 (live view follows to the 2FA tab; session stays alive during take-over). Those got the user to the right page; this makes the panel stop telling everyone to "enter the code" when the page is really showing a passkey — and says so honestly when a login can't be automated at all.

Scope

  • API: browser-credential-login.ts (per-situation passkey handling + classifyTwoFactorMethod), browser-credential-signin.service.ts (return twoFactorMethod on take-over).
  • App: ConnectLiveSignin.tsx (method-tailored copy), ConnectVendorLoginFlow.tsx (thread the method through).

Tests

  • API: classifier (valid values, non-conforming → other, throw → other); stored-code login switches off a passkey; take-over reveals options without picking one; service returns the classified method. 186 browserbase tests green, typecheck clean on the touched files.
  • App: panel renders the right heading/body and shows/hides the confirm button per method state.

Note

The passkey→code switch and "reveal options" are best-effort model steps, and during take-over the live view is interactive — if the model misses the control, the user can click it themselves. Needs one live check on stage against a vendor that defaults 2FA to a passkey (can't be reproduced locally).