tor-browser

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

authentication-accepted-bbk-per-passkey.https.html (3230B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Test for the 'secure-payment-confirmation' payment method authentication - browser bound key per passkey</title>
      4 <link rel="help" href="https://w3c.github.io/secure-payment-confirmation/#sctn-binding-a-keypair">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/resources/testdriver.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 <script src=../webauthn/resources/common-inputs.js></script>
     10 <script src=../webauthn/resources/utils.js></script>
     11 <script src="utils.sub.js"></script>
     12 <script src="utils-bbk.js"></script>
     13 <script>
     14 'use strict';
     15 
     16 async function payWithPasskey(passkey) {
     17  const challenge = 'server challenge';
     18  const payeeOrigin = 'https://merchant.com';
     19  const displayName = 'Troycard ***1234';
     20  const request = new PaymentRequest([{
     21    supportedMethods: 'secure-payment-confirmation',
     22    data: {
     23      credentialIds: [passkey.rawId],
     24      challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
     25      payeeOrigin,
     26      rpId: window.location.hostname,
     27      timeout: 60000,
     28      instrument: {
     29        displayName,
     30        icon: ICON_URL,
     31      },
     32    }
     33  }], PAYMENT_DETAILS);
     34  await test_driver.bless('user activation');
     35  const response = await request.show();
     36  return response;
     37 }
     38 
     39 promise_test(async t => {
     40  await window.test_driver.add_virtual_authenticator(
     41    AUTHENTICATOR_OPTS)
     42    .then(authenticator => {
     43      t.add_cleanup(() => {
     44        return window.test_driver.remove_virtual_authenticator(authenticator);
     45      });
     46    });
     47 
     48  await window.test_driver.set_spc_transaction_mode("autoAccept")
     49    .then(_ => {
     50      t.add_cleanup(() => {
     51        return window.test_driver.set_spc_transaction_mode("none");
     52      });
     53    });
     54 
     55  const enrollmentBrowserBoundPubKeyCredParams = [{
     56    type: "public-key",
     57    alg: 0 // "Reserved": User agent should not create a key at credential enrollment.
     58  }];
     59 
     60  const credential1 = await createCredential(/*set_payment_extension=*/true, {
     61    browserBoundPubKeyCredParams: enrollmentBrowserBoundPubKeyCredParams,
     62  });
     63  assertNoBrowserBoundPublicKeyInCredential(credential1);
     64  const instrumentResponse1 = await payWithPasskey(credential1);
     65  await instrumentResponse1.complete('success');
     66  const browserBoundPublicKey1 = getBrowserBoundPublicKeyFromCredential(instrumentResponse1.details);
     67 
     68  const credential2 = await createCredential(/*set_payment_extension=*/true, {
     69    browserBoundPubKeyCredParams: enrollmentBrowserBoundPubKeyCredParams,
     70  });
     71  assertNoBrowserBoundPublicKeyInCredential(credential2);
     72  const instrumentResponse2 = await payWithPasskey(credential2);
     73  await instrumentResponse2.complete('success');
     74  const browserBoundPublicKey2 = getBrowserBoundPublicKeyFromCredential(instrumentResponse2.details);
     75 
     76  if (browserBoundPublicKey1 === undefined && browserBoundPublicKey2 === undefined) {
     77    return;
     78  }
     79  assert_not_equals(browserBoundPublicKey1, browserBoundPublicKey2,
     80    'The browser bound key must be different for different passkeys.');
     81 }, 'If a browser bound keys are created on authentication then a different browser bound key is created for a different passkey');
     82 </script>