~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Tools/TestWebKitAPI/Tests/WebKitCocoa/web-authentication-get-assertion-nfc.html

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<input type="text" id="input">
 
2
<script>
 
3
    const testNfcCtapVersionBase64 = "RklET18yXzCQAA==";
 
4
    const testGetInfoResponseApduBase64 =
 
5
        "AKYBgmZVMkZfVjJoRklET18yXzACgWtobWFjLXNlY3JldANQbUS6m/bsLkm5MAyP" +
 
6
        "6SDLcwSkYnJr9WJ1cPVkcGxhdPRpY2xpZW50UGlu9AUZBLAGgQGQAA==";
 
7
    const testAssertionMessageApduBase64 =
 
8
        "AKMBomJpZFhAKAitzuj+Tslzelf3/vZwIGtDQNgoKeFd5oEieYzhyzA65saf0tK2" +
 
9
        "w/mooa7tQtGgDdwZIjOhjcuZ0pQ1ajoE4GR0eXBlanB1YmxpYy1rZXkCWCVGzH+5" +
 
10
        "Z51VstuQkuHI2eXh0Ct1gPC0gSx3CWLh5I9a2AEAAABQA1hHMEUCIQCSFTuuBWgB" +
 
11
        "4/F0VB7DlUVM09IHPmxe1MzHUwRoCRZbCAIgGKov6xoAx2MEf6/6qNs8OutzhP2C" +
 
12
        "QoJ1L7Fe64G9uBeQAA==";
 
13
    if (window.internals) {
 
14
        internals.setMockWebAuthenticationConfiguration({ silentFailure: true, nfc: { payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testAssertionMessageApduBase64] } });
 
15
        internals.withUserGesture(() => { input.focus(); });
 
16
    }
 
17
 
 
18
    const options = {
 
19
        publicKey: {
 
20
            challenge: new Uint8Array(16),
 
21
            timeout: 100,
 
22
            allowCredentials: [
 
23
                { type: "public-key", id: new Uint8Array(16), transports: ["nfc"] }
 
24
            ],
 
25
        }
 
26
    };
 
27
 
 
28
    navigator.credentials.get(options).then(credential => {
 
29
        // console.log("Succeeded!");
 
30
        window.webkit.messageHandlers.testHandler.postMessage("Succeeded!");
 
31
    }, error => {
 
32
        // console.log(error.message);
 
33
        window.webkit.messageHandlers.testHandler.postMessage(error.message);
 
34
    });
 
35
</script>