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