-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
72 lines (62 loc) · 2.07 KB
/
index.html
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
<html>
<head>
<script type="text/javascript"
src="./lib/webauth-helpers.min.js"></script>
</head>
<body>
<button id="btnCreate" onclick="createCredentials()" type="button">Create Credential</button>
<button id="btnAuth" onclick="assertCredentials()" type="button">Verify Credential</button>
<script type="text/javascript">
var publicKey = {
'challenge': "somebase64encodedrandomsamplesdsddssd",
'rp': {
'name': 'Naman Aggarwal Corp'
},
'user': {
'id': "somebase64encodeduserid",
'name': '[email protected]',
'displayName': 'Alice Liddell'
},
'pubKeyCredParams': [
{ 'type': 'public-key', 'alg': -7 },
],
'excludeCredentials': [
{
'id': "somebase64encodedrandomsamplesdsddssd",
'type': "public-key"
}
]
};
function createCredentials() {
const transformedKey = WebAuthHelpers.formatRequest(publicKey);
console.log(transformedKey);
navigator.credentials.create({ 'publicKey': transformedKey })
.then((newCredentialInfo) => {
console.log(newCredentialInfo.id);
console.log(WebAuthHelpers.formatResponse(newCredentialInfo.response));
})
.catch((error) => {
console.log('FAIL', error)
})
}
var getCredentials = {
'challenge': "somebase64encodedrandomsampleweewwewweewew",
'allowCredentials': [
{id: "ALXyXXbmh0jf5IrNe6bUeqDosVLmpK_43RxZfQGE_Uo1AqyS6bPWB7Eg57F5iixXL1QRw3tu0GaLiqF2F0ZDQ0O7pWZie8Qtj2z4-4hpCV8", type: 'public-key'}
],
};
function assertCredentials() {
const transformedKey = WebAuthHelpers.formatRequest(getCredentials);
console.log(transformedKey);
navigator.credentials.get({'publicKey': transformedKey})
.then((newCredentialInfo) => {
console.log(newCredentialInfo);
console.group('SUCCESS', WebAuthHelpers.formatResponse(newCredentialInfo.response))
})
.catch((error) => {
console.log('FAIL', error)
})
}
</script>
</body>
</html>