-
Notifications
You must be signed in to change notification settings - Fork 0
/
detect-fingerprint.html
56 lines (52 loc) · 2.03 KB
/
detect-fingerprint.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fingerprint Detection</title>
</head>
<body>
<button id="detectFingerprintButton">Detect Fingerprint</button>
<p id="status"></p>
<script>
document.getElementById('detectFingerprintButton').addEventListener('click', () => {
if (!window.PublicKeyCredential) {
document.getElementById('status').textContent = "WebAuthn is not supported in this browser.";
return;
}
const publicKey = {
challenge: new Uint8Array(32),
rp: {
name: "Example Corp"
},
user: {
id: new Uint8Array(16),
name: "[email protected]",
displayName: "User Example"
},
pubKeyCredParams: [{
type: "public-key",
alg: -7 // ES256
}],
authenticatorSelection: {
authenticatorAttachment: "platform",
userVerification: "required"
}
};
navigator.credentials.create({ publicKey })
.then(credential => {
console.log('Fingerprint detected and used for registration.', credential);
document.getElementById('status').textContent = "Fingerprint detected and used for registration.";
// Redirect to registered.php after 5 seconds
setTimeout(() => {
window.location.href = 'log_in/login.php';
}, 5000);
})
.catch(err => {
console.error('Error or fingerprint not detected', err);
document.getElementById('status').textContent = "Error or fingerprint not detected.";
});
});
</script>
</body>
</html>