Auto verify OTP on the web using javasacript

Send an SMS from a different device that includes
@www.jyotishman.github.io/webOTPAPI/ #1234
to this phone.
Here @www.jyotishman.github.io/webOTPAPI/ is the domain from otp verification is to be done and  #1234 is the OTP
to this phone.
Enter OTP here:

<input type="text" autocomplete="one-time-code" inputmode="numeric" />
<script>
if ('OTPCredential' in window) {
  window.addEventListener('DOMContentLoaded', e => {
    const input = document.querySelector('input[autocomplete="one-time-code"]');
    if (!input) return;
    const ac = new AbortController();
    const form = input.closest('form');
    if (form) {
      form.addEventListener('submit', e => {
        ac.abort();
      });
    }
    navigator.credentials.get({
      otp: { transport:['sms'] },
      signal: ac.signal
    }).then(otp => {
      input.value = otp.code;
      if (form) form.submit();
    }).catch(err => {
      console.log(err);
    });
  });
}
</script>