fix(otp): support WebOTP sms pattern with {0} and {1} and robust code extraction
This commit is contained in:
1 parent
1fd9a92dd0
commit
c57f775cb4
15 files changed
+8628
-8534
No files matched your search
@@ -216,9 +216,9 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
signal: ac.signal,
|
||||
}).then((otp) => {
|
||||
if (!isMounted || !otp) return;
|
||||
// OTPCredential.code is the extracted code, not the full SMS text.
|
||||
// Still run toEnglishDigits in case it contains Persian numerals.
|
||||
const digits = toEnglishDigits(otp.code ?? "").replace(/[^0-9]/g, "").slice(0, 5);
|
||||
// OTPCredential.code is the extracted code, but fallback to any string property
|
||||
const rawCode = (otp as { code?: string })?.code || (otp as { id?: string })?.id || "";
|
||||
const digits = extractOtpFromText(rawCode);
|
||||
if (digits.length === 5) {
|
||||
setOtpCode(digits);
|
||||
// 400 ms delay so the user can see the filled boxes before verification
|
||||
|
||||
Reference in new issue
Block a user