diff --git a/frontend/src/components/FingerprintBlock.js b/frontend/src/components/FingerprintBlock.js index 59ae30f..48c3d3b 100644 --- a/frontend/src/components/FingerprintBlock.js +++ b/frontend/src/components/FingerprintBlock.js @@ -1,19 +1,40 @@ /* eslint-disable no-unused-vars */ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import Block from './Block'; import Table from './Table'; -import getHash from '../utils/fingerprint'; +import { + getSignature, + postSignature, + getHash, + getFingerprint, +} from '../utils/fingerprint'; const FingerprintBlock = ({ workerData }) => { const [signature, setSignature] = useState(); + useEffect(() => { + if (signature) { + postSignature(hash, signature); + } else { + console.log(signature); + + getSignature(hash, setSignature); + } + }, [signature]); + const hash = getHash(workerData); return (

Fingerprint

-
-
{hash}
-
+ <> + {signature ? ( + + ) : ( +
+
{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 @@ -21,7 +42,7 @@ const FingerprintBlock = ({ workerData }) => { reload the page in private mode to test it out.

{signature ? ( -

Success! Reload browser.

+

Success! Reload page.

) : ( setSignature(e.target[0].value)}> { + console.log('1'); + axios + .get(`https://api.vytal.io/fingerprint/?hash=${hash}`) + .then((response) => { + console.log(response.data[response.data.length - 1]); + + if (response.data.length !== 0) { + setSignature(response.data[response.data.length - 1].name); + } + }); +}; + +const postSignature = (hash, signature) => { + axios.post('https://api.vytal.io/fingerprint/', { + name: signature, + hash, + }); +}; + const getHash = (data) => md5(JSON.stringify(data)).toString(); -export default getHash; +const getFingerprint = (signature, hash) => [ + { + key: 'Signature', + value: signature, + issues: [], + }, + { + key: 'Hash', + value: hash, + issues: [], + }, +];