This package created to read otp-sms in web.
- your website must have ssl (or must be on https protocol)
- your website must be PWA
you just need to implement function and then wait for otp-sms. this function will automatically abort after 2 minute, so if you want to wait more change the parameter.
import { readOtpSms } from "read-otp"
// wait for 3 minute to get OTP-SMS
readOtpSms(3).then((code: string) => {
// set the code anywhere you want.
}).catch((e: Error) => {
// hanle error.
})
Potentially in web we can not access the sms or connect to OS, so browsers are our mediators. also this code use browser apis ,So some of them may not support this feature. here you can read about Compatibility.
in the end of sms must be like this:
your website: website.org
code: 1111
this is the OTP from my website , blah blah.
@website.org #1111