feat(otp): add web otp auto-fill using sms credential API

This commit is contained in:
2026-06-13 11:27:17 +03:30
parent 96e19fc736
commit 50b16b5fe0

View File

@@ -174,6 +174,33 @@ export function OtpVerifyForm({
const otpMessage = otpMessageFn();
useEffect(() => {
let cancelled = false;
const run = async () => {
if (!('OTPCredential' in window)) return;
try {
const ac = new AbortController();
const otp = await (navigator as any).credentials.get({
otp: { transport: ['sms'] },
signal: ac.signal,
});
if (!cancelled && otp?.code) {
setOtpCode(otp.code);
}
} catch { }
};
run();
return () => {
cancelled = true;
};
}, []);
return (
<Stack alignItems="center">
<AuthenticationCard>