tor-browser

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

idlharness-manual.https.window.js (1339B)


      1 // META: timeout=long
      2 // META: script=/resources/WebIDLParser.js
      3 // META: script=/resources/idlharness.js
      4 // META: script=helpers.js
      5 
      6 // https://w3c.github.io/webauthn/
      7 
      8 'use strict';
      9 
     10 idl_test(
     11  ['webauthn'],
     12  ['credential-management'],
     13  async idlArray => {
     14    idlArray.add_untested_idls("[Exposed=(Window,Worker)] interface ArrayBuffer {};");
     15 
     16    idlArray.add_objects({
     17      PublicKeyCredential: ['cred', 'assertion'],
     18      AuthenticatorAttestationResponse: ['cred.response'],
     19      AuthenticatorAssertionResponse: ['assertion.response']
     20    });
     21 
     22    const challengeBytes = new Uint8Array(16);
     23    window.crypto.getRandomValues(challengeBytes);
     24 
     25    self.cred = await Promise.race([
     26      new Promise((_, reject) => window.setTimeout(() => {
     27        reject('Timed out waiting for user to touch security key')
     28      }, 3000)),
     29      createCredential({
     30        options: {
     31          publicKey: {
     32            timeout: 3000,
     33            user: {
     34              id: new Uint8Array(16),
     35            },
     36          }
     37        }
     38      }),
     39    ]);
     40 
     41    self.assertion = await navigator.credentials.get({
     42      publicKey: {
     43        timeout: 3000,
     44        allowCredentials: [{
     45          id: cred.rawId,
     46          transports: ["usb", "nfc", "ble"],
     47          type: "public-key"
     48        }],
     49        challenge: challengeBytes,
     50      }
     51    });
     52  }
     53 );