tor-browser

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

permissions-policy-payment-extension.html (1684B)


      1 <script src="/resources/testdriver.js"></script>
      2 <script src="/resources/testdriver-vendor.js"></script>
      3 <script src="/webauthn/helpers.js"></script>
      4 <script>
      5 'use strict';
      6 
      7 const textEncoder = new TextEncoder();
      8 let authenticatorArgs = {
      9  protocol: 'ctap2_1',
     10  transport: 'internal',
     11  hasResidentKey: true,
     12  hasUserVerification: true,
     13  isUserVerified: true,
     14 };
     15 
     16 window.onload = async function() {
     17  test_driver.set_test_context(parent);
     18  const authenticator = await window.test_driver.add_virtual_authenticator(authenticatorArgs);
     19  let enabled = true;
     20  let name = `OK`;
     21  try {
     22    const publicKey = {
     23      rp: {
     24        id: window.location.hostname,
     25        name: 'Joe',
     26      },
     27      user: {
     28        name: 'user@domain',
     29        id: Uint8Array.from('id', c => c.charCodeAt(0)),
     30        displayName: 'User',
     31      },
     32      challenge: textEncoder.encode('Enrollment challenge'),
     33      pubKeyCredParams: [{
     34        type: 'public-key',
     35        alg: -7, // ECDSA, not supported on Windows.
     36      }, {
     37        type: 'public-key',
     38        alg: -257, // RSA, supported on Windows.
     39      }],
     40      authenticatorSelection: {
     41        userVerification: 'required',
     42        residentKey: 'required',
     43        authenticatorAttachment: 'platform',
     44      },
     45      extensions: {
     46        payment: {
     47          isPayment: true,
     48        },
     49      }
     50    };
     51    await window.test_driver.bless('user activation');
     52    await navigator.credentials.create({
     53      publicKey
     54    });
     55  } catch (e) {
     56    enabled = false;
     57    name = e.name;
     58  }
     59  await window.test_driver.remove_virtual_authenticator(authenticator);
     60  parent.postMessage({ type: 'availability-result', enabled, name }, '*');
     61 }
     62 </script>