Skip to content

fix(mfa): wire real WebOTP auto-fill into AuthorizerVerifyOtp#67

Merged
lakhansamani merged 1 commit into
mainfrom
fix/webotp-sms-autofill
Jul 23, 2026
Merged

fix(mfa): wire real WebOTP auto-fill into AuthorizerVerifyOtp#67
lakhansamani merged 1 commit into
mainfrom
fix/webotp-sms-autofill

Conversation

@lakhansamani

Copy link
Copy Markdown
Contributor

Summary

  • add a hasSmsOtp prop to AuthorizerVerifyOtp, threaded from every caller (AuthorizerRoot, AuthorizerPasskeyLogin, AuthorizerBasicAuthLogin, AuthorizerSignup, AuthorizerMFASetup) from the real signal each already has (mfaMethods.includes('sms_otp'), mfaStep.mobile, step.mobile, otpMethodPending === 'sms_otp') - not a phone_number-truthiness guess
  • when a real SMS-OTP factor is pending (not TOTP, not email-OTP), call navigator.credentials.get({ otp: { transport: ['sms'] }, signal }), feature-detected via window.OTPCredential - the explicit call the existing autoComplete="one-time-code" hint always implied but nothing backed
  • populate the OTP field when it resolves; abort via AbortController on unmount, on manual submit, and whenever the screen switches away from the code form (TOTP recovery scanner, passkey lockout) - a late resolution can never clobber a value already submitted

Also checked

authorizer-js#50 (pending breaking change to .webhooks()/.emailTemplates()/.verificationRequests() pagination shape) - confirmed via a repo-wide search that this package never imports AuthorizerAdmin or calls any of the three affected methods. No adjustment needed here regardless of when that PR merges/releases.

Test plan

  • tsc --noEmit passes
  • npm run build passes
  • manual verification on an Android Chrome + real backend SMS-OTP challenge (no device/backend available in this environment)

Closes #66

autoComplete="one-time-code" was a declarative hint with nothing behind
it - no call site anywhere called navigator.credentials.get(), so
platforms that need the explicit WebOTP call (e.g. Android Chrome) got
no auto-fill benefit at all.

Add a feature-detected (window.OTPCredential) navigator.credentials.get()
call, scoped to an actual SMS-OTP factor (not TOTP/email-OTP, which never
arrive by SMS) via a new hasSmsOtp prop threaded from every caller that
knows which factor is pending. Aborted via AbortController on unmount,
on manual submit, and whenever the screen switches away from the code
form, so a late resolution can never clobber a value the user already
submitted.

Closes #66
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
dist/index.cjs 60.36 KB (+0.15% 🔺)
dist/index.mjs 59.99 KB (+0.27% 🔺)

@lakhansamani
lakhansamani merged commit 28dd5d3 into main Jul 23, 2026
5 checks passed
@lakhansamani
lakhansamani deleted the fix/webotp-sms-autofill branch July 23, 2026 23:02
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.

No real WebOTP (navigator.credentials.get) wiring in AuthorizerVerifyOtp

1 participant