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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>navigator.credentials.get() prf extension tests with authenticator support</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src=helpers.js></script>
<body></body>
<script>
standardSetup(async function(authenticator) {
"use strict";
const b64 = buf => btoa(String.fromCharCode.apply(null, new Uint8Array(buf)));
const b64url = buf => b64(buf).
replace(/\+/g, '-').
replace(/\//g, '_').
replace(/=+$/, '');
const credential = createCredential({
options: {
publicKey: {
extensions: {
prf: {},
},
},
},
});
const assert = (id, prfExt) =>
navigator.credentials.get({publicKey: {
challenge: new Uint8Array(),
allowCredentials: [{
id: id,
type: "public-key",
}],
extensions: {
prf: prfExt,
},
}});
promise_test(async t => {
const id = (await credential).rawId;
const assertion = await assert(id, {
eval: {
first: new Uint8Array([1,2,3,4]).buffer,
},
});
const results = assertion.getClientExtensionResults().prf.results;
assert_equals(results.first.byteLength, 32)
assert_not_own_property(results, 'second');
}, "navigator.credentials.get() with single evaluation point");
promise_test(async t => {
const id = (await credential).rawId;
const assertion = await assert(id, {
eval: {
first: new Uint8Array([1,2,3,4]).buffer,
second: new Uint8Array([1,2,3,4]).buffer,
},
});
const results = assertion.getClientExtensionResults().prf.results;
assert_equals(results.first.byteLength, 32)
assert_equals(results.second.byteLength, 32)
assert_equals(b64(results.first), b64(results.second));
}, "navigator.credentials.get() with two equal evaluation points");
promise_test(async t => {
const id = (await credential).rawId;
const assertion = await assert(id, {
eval: {
first: new Uint8Array([1,2,3,4]).buffer,
second: new Uint8Array([1,2,3,5]).buffer,
},
});
const results = assertion.getClientExtensionResults().prf.results;
assert_equals(results.first.byteLength, 32)
assert_equals(results.second.byteLength, 32)
assert_not_equals(b64(results.first), b64(results.second));
}, "navigator.credentials.get() with two distinct evaluation points");
promise_test(async t => {
const id = (await credential).rawId;
const byCred = {};
byCred[b64url(id)] = {
first: new Uint8Array([1,2,3,4]).buffer,
};
const assertion = await assert(id, {
evalByCredential: byCred,
});
const results = assertion.getClientExtensionResults().prf.results;
assert_equals(results.first.byteLength, 32)
assert_not_own_property(results, 'second');
}, "navigator.credentials.get() using credential ID with one evaluation point");
promise_test(async t => {
const id = (await credential).rawId;
const byCred = {};
byCred[b64url(id)] = {
first: new Uint8Array([1,2,3,4]).buffer,
second: new Uint8Array([1,2,3,4]).buffer,
};
const assertion = await assert(id, {
evalByCredential: byCred,
});
const results = assertion.getClientExtensionResults().prf.results;
assert_equals(results.first.byteLength, 32)
assert_equals(results.second.byteLength, 32)
assert_equals(b64(results.first), b64(results.second));
}, "navigator.credentials.get() using credential ID with two evaluation points");
promise_test(async t => {
const id = (await credential).rawId;
const byCred = {};
byCred["Zm9v"] = {
first: new Uint8Array([1,2,3,4]).buffer,
};
return promise_rejects_dom(t, "SyntaxError", assert(id, {
evalByCredential: byCred,
}));
}, "navigator.credentials.get() with credential ID not in allowedCredentials");
promise_test(async t => {
const id = (await credential).rawId;
const byCred = {};
byCred["Zm9v"] = {
first: new Uint8Array([1,2,3,4]),
};
return promise_rejects_dom(t, "SyntaxError", assert(id, {
evalByCredential: byCred,
}));
}, "navigator.credentials.get() with Uint8Array credential ID not in allowedCredentials");
promise_test(async t => {
const id = (await credential).rawId;
const byCred = {};
byCred["Zm9v="] = {
first: new Uint8Array([1,2,3,4]).buffer,
};
return promise_rejects_dom(
t, "SyntaxError", assert(id, {evalByCredential: byCred }));
}, "navigator.credentials.get() using invalid base64url credential ID");
promise_test(async t => {
const id = (await credential).rawId;
const byCred = {};
byCred["Zm9v"] = {
first: new Uint8Array([1,2,3,4]).buffer,
};
const promise = navigator.credentials.get({publicKey: {
challenge: new Uint8Array(),
extensions: {
prf: {evalByCredential: byCred },
},
}});
return promise_rejects_dom(t, "NotSupportedError", promise);
}, "navigator.credentials.get() with an empty allow list but also using evalByCredential");
}, {
protocol: "ctap2_1",
extensions: ["prf"],
hasUserVerification: true,
isUserVerified: true,
});
</script>
|