-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
57 lines (53 loc) · 1.44 KB
/
Copy pathindex.html
File metadata and controls
57 lines (53 loc) · 1.44 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>U2F Demo</title>
</head>
<body>
<script src="u2f.js"></script>
<script src="u2f-Parse.js"></script>
<input type="button" onclick="Register()" value="Register">
<input type="button" onclick="Sign()" value="Sign">
<div id="divMessage"></div>
<script>
var parser = new U2FParse();
var U2FRegistration = {};
var U2FSign = {};
function Register()
{
let registerRequest = {
challenge: 'RegisterChallenge',
version: 'U2F_V2'
}
u2f.register('https://localhost', [registerRequest], [],
(response) => {
console.log(response);
U2FRegistration = parser.parseRegistration(response.registrationData);
console.log(U2FRegistration);
document.getElementById("divMessage").innerHTML = "Key Handle:" + U2FRegistration.keyHandle;
}
);
}
function Sign()
{
let registeredKey = {
keyHandle: U2FRegistration.keyHandle,
version: 'U2F_V2'
}
u2f.sign('https://localhost', 'SigningChallenge', [registeredKey],
(response) => {
console.log(response);
U2FSign = parser.parseSign(response.signatureData);
console.log(U2FSign);
document.getElementById("divMessage").innerHTML = "User Counter:" + U2FSign.userCounter;
}
);
}
</script>
</body>
</html>