tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

otpcredential-iframe.html (794B)


      1 <!doctype html>
      2 <script type="module">
      3 import {Status, expectOTPRequest} from './otpcredential-helper.js';
      4 
      5 // Loading otpcredential-iframe.html in the test will make an OTPCredentials
      6 // call on load, and trigger a postMessage upon completion.
      7 //
      8 // message {
      9 //   string result: "Pass" | "Fail"
     10 //   string code: credentials.code
     11 //   string errorType: error.name
     12 // }
     13 
     14 window.onload = async () => {
     15  try {
     16    await expectOTPRequest().andReturn(
     17        () => ({status: Status.SUCCESS, otp: "ABC123"}));
     18    const credentials =
     19        await navigator.credentials.get({otp: {transport: ["sms"]}});
     20    window.parent.postMessage({result: "Pass", code: credentials.code}, '*');
     21  } catch (error) {
     22    window.parent.postMessage({result: "Fail", errorType: error.name}, '*');
     23  }
     24 }
     25 
     26 </script>