Skip to content

Commit

Permalink
fix(autofillotp): added AutoFillOtp service
Browse files Browse the repository at this point in the history
  • Loading branch information
opensrc0 committed Mar 13, 2024
1 parent 9165831 commit 4c57954
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
24 changes: 24 additions & 0 deletions __app/component/AutoFillOtp/AutoFillOtp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const abortAutoFill = (abort, time) => {
setTimeout(() => {
// abort after two minutes
abort.abort();
}, time * 60 * 1000);
};

const AutoFillOtp = (successCb, failureCb) => {
if ('OTPCredential' in window) {
const abort = new AbortController();
abortAutoFill(abort, 1);
navigator.credentials.get({
otp: { transport: ['sms'] },
signal: abort.signal,
}).then((otp) => {
const { code } = otp;
successCb(code);
}).catch((error) => {
failureCb(error);
});
}
};

export default AutoFillOtp;
7 changes: 0 additions & 7 deletions __app/component/WIP-AutoFillOtp/AutoFillOtp.js

This file was deleted.

0 comments on commit 4c57954

Please sign in to comment.