diff --git a/frontend/src/components/FingerprintBlock.js b/frontend/src/components/FingerprintBlock.js index fcd6e22..db4da20 100644 --- a/frontend/src/components/FingerprintBlock.js +++ b/frontend/src/components/FingerprintBlock.js @@ -1,65 +1,32 @@ /* eslint-disable no-unused-vars */ import { useState, useEffect } from 'react'; -import axios from 'axios'; import ScanBlock from './ScanBlock'; import Table from './Table'; -import { getHash, getHardware, getWebGL, getBattery } from './main'; +import { + getHardware, + getWebGL, + getSoftware, + getFingerprint, + getHash, + getName, + handleSave, +} from './main'; const FingerprintBlock = () => { - const [data, setData] = useState([]); const [name, setName] = useState(''); const [saved, setSaved] = useState(''); - const [display, setDisplay] = useState('none'); - - useEffect(() => { - setData([...getHardware(), ...getWebGL()]); - - axios - .get(`https://api.vytal.io/fingerprint/?hash=${hash}`) - .then((response) => { - if (response.data.length !== 0) { - setName(response.data[response.data.length - 1].name); - } - setDisplay('block'); - }); - }, []); - - const handleSave = (e) => { - e.preventDefault(); - axios.post('https://api.vytal.io/fingerprint/', { - name: e.target[0].value, - hash, - }); - setSaved(true); - }; - - const hash = getHash(data); - - const tableData = [ - { - key: 'name', - title: 'Name', - value: name, - }, - { - key: 'hash', - title: 'Hash', - value: hash, - }, - ]; - + const hash = getHash([...getHardware(), ...getWebGL(), ...getSoftware()]); + getName(hash, setName); return (

Fingerprint

-
- {name ? ( - - ) : ( -
-
{hash}
-
- )} - + {name ? ( +
+ ) : ( +
+
{hash}
+
+ )}

Explanation: This is a unique identifier that can be used to follow you around the web. Even if you clear cookies, change your IP or @@ -71,7 +38,7 @@ const FingerprintBlock = () => { ) : (
{ - handleSave(e); + handleSave(e, hash, setSaved); }} > diff --git a/frontend/src/components/SoftwareBlock.js b/frontend/src/components/SoftwareBlock.js index e933d58..1a678d7 100644 --- a/frontend/src/components/SoftwareBlock.js +++ b/frontend/src/components/SoftwareBlock.js @@ -2,7 +2,7 @@ import ScanBlock from './ScanBlock'; import Table from './Table'; import { getSoftware } from './main'; -const HardwareBlock = () => ( +const SoftwareBlock = () => (

Software

@@ -13,4 +13,4 @@ const HardwareBlock = () => ( ); -export default HardwareBlock; +export default SoftwareBlock; diff --git a/frontend/src/components/main.js b/frontend/src/components/main.js index 6861d80..d4651ef 100644 --- a/frontend/src/components/main.js +++ b/frontend/src/components/main.js @@ -1,5 +1,6 @@ import md5 from 'crypto-js/md5'; import Bowser from 'bowser'; +import axios from 'axios'; const getHardware = () => { const data = [ @@ -192,67 +193,50 @@ const sortPlugins = (data) => { return list; }; -// const getFingerprint = () => { -// const data = [ -// { -// key: 'name', -// title: 'Name', -// value: name, -// }, -// { -// key: 'hash', -// title: 'Hash', -// value: hash, -// }, -// ]; -// return data; - -// const data = [ -// { -// key: 'platform', -// value: navigator.platform, -// }, -// { -// key: 'userAgent', -// value: navigator.userAgent, -// }, -// { -// key: 'preferredLanguage', -// value: navigator.language, -// }, -// { -// key: 'languages', -// title: 'Languages', -// value: navigator.languages, -// }, -// { -// key: 'timezone', -// value: Intl.DateTimeFormat().resolvedOptions().timeZone || 'N/A', -// }, -// { -// key: 'cookiesEnabled', -// value: navigator.cookieEnabled, -// }, -// { -// key: 'javaEnabled', -// value: navigator.javaEnabled(), -// }, -// { -// key: 'dntHeader', -// value: navigator.doNotTrack, -// }, -// { -// key: 'automatedBrowser', -// value: navigator.webdriver, -// }, -// { -// key: 'plugins', -// value: navigator.plugins, -// }, -// ]; -// return data; -// }; +const getFingerprint = (name, hash) => { + const data = [ + { + key: 'name', + title: 'Name', + value: name, + }, + { + key: 'hash', + title: 'Hash', + value: hash, + }, + ]; + return data; +}; const getHash = (data) => md5(JSON.stringify(data)).toString(); -export { getHash, getSoftware, getHardware, getWebGL, getBattery }; +const getName = (hash, setName) => { + axios + .get(`https://api.vytal.io/fingerprint/?hash=${hash}`) + .then((response) => { + if (response.data.length !== 0) { + setName(response.data[response.data.length - 1].name); + } + }); +}; + +const handleSave = (e, hash, setSaved) => { + e.preventDefault(); + axios.post('https://api.vytal.io/fingerprint/', { + name: e.target[0].value, + hash, + }); + setSaved(true); +}; + +export { + getSoftware, + getHardware, + getWebGL, + getBattery, + getFingerprint, + getHash, + getName, + handleSave, +};