Skip to content

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

Merged
tofikwest merged 3 commits into
mainfrom
fix/browser-automation-passkey-2fa
Jul 28, 2026
Merged

fix: make the 2FA take-over universal — tailor guidance to what the page asks for#3520
tofikwest merged 3 commits into
mainfrom
fix/browser-automation-passkey-2fa

Conversation

@tofikwest

@tofikwest tofikwest commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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).

Vendors like GitHub default the 2FA step to a passkey / security-key prompt
(github.com/sessions/two-factor/webauthn) — which we can't use and which has no
6-digit field, so the panel said 'enter the code' while the page showed no place
to type it. After sign-in, best-effort switch to the authenticator-app option
(More options -> Use authenticator app / Enter a code) so the code field is
actually shown — for us to fill a stored code, or for the user to type one during
take-over. +test.
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jul 28, 2026 5:35pm
comp-framework-editor Ready Ready Preview, Comment Jul 28, 2026 5:35pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
portal Skipped Skipped Jul 28, 2026 5:35pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/api/src/browserbase/browser-credential-login.ts Outdated
Make the two-factor take-over universal instead of assuming an authenticator
code:

- Classify the verification page into how it wants the user to verify (a code,
  a passkey that can be switched away from, a passkey-only login, or another
  challenge) and return it from the sign-in result.
- When Comp AI has a stored code, auto-switch off a passkey so the code field
  appears, then fill it. When a human is taking over, don't pick a method for
  them — just reveal the vendor's other options so they choose the one they can
  complete.
- Show exact guidance in the take-over panel from that classification: enter the
  code, switch off the passkey, or a plain notice that a passkey-only login
  can't be automated (with the confirm button hidden, since there's nothing to
  complete). No vendor names are hard-coded.

Adds unit coverage for the classifier, the take-over vs stored-code login
behavior, and the panel copy for each method state.
@tofikwest tofikwest changed the title fix(api): switch a passkey 2FA prompt to the authenticator-code method fix: make the 2FA take-over universal — tailor guidance to what the page asks for Jul 28, 2026
@vercel
vercel Bot temporarily deployed to Preview – portal July 28, 2026 17:01 Inactive

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/api/src/browserbase/browser-credential-login.ts Outdated
- Split the passkey→code switch into two single-action steps (reveal the other
  options, then choose the authenticator/code method). act() performs one action
  per call, so a combined 'click More options, then Use authenticator app' could
  stop after the first click and never reach the code field.
- Trust an explicit method classification when routing the take-over panel: an
  'other' verification (device approval, CAPTCHA, link) now uses the generic
  finish panel instead of code-entry guidance, even when the outcome is
  needs_2fa. Falls back to the failure code only when no method was detected.
- Extract the page classifiers (classifyLoginOutcome, classifyTwoFactorMethod,
  safeOriginAndPath) into a focused browser-login-classifier module, bringing the
  login file back under the 300-line limit.

Tests moved/updated alongside; 186 browserbase tests green, typecheck clean.
@vercel
vercel Bot temporarily deployed to Preview – portal July 28, 2026 17:31 Inactive
@tofikwest
tofikwest merged commit b12f3fe into main Jul 28, 2026
11 checks passed
@tofikwest
tofikwest deleted the fix/browser-automation-passkey-2fa branch July 28, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant