Detects if there is a name before showing hash

This commit is contained in:
z0ccc 2021-08-26 14:18:05 -04:00
parent 783eee3799
commit e4072d5134
2 changed files with 14 additions and 8 deletions

View file

@ -13,18 +13,23 @@ import {
const FingerprintBlock = () => {
const [name, setName] = useState('');
const [load, setLoad] = useState(false);
const [saved, setSaved] = useState('');
const hash = getHash([...getHardware(), ...getWebGL(), ...getSoftware()]);
getName(hash, setName);
getName(hash, setName, setLoad);
return (
<ScanBlock>
<h1>Fingerprint</h1>
{name ? (
<Table data={getFingerprint(name, hash)} />
) : (
<div className="boxWrap">
<div className="hash">{hash}</div>
</div>
{load && (
<>
{name ? (
<Table data={getFingerprint(name, hash)} />
) : (
<div className="boxWrap">
<div className="hash">{hash}</div>
</div>
)}
</>
)}
<p>
<b>Explanation:</b> This is a unique identifier that can be used to

View file

@ -322,13 +322,14 @@ const getFingerprint = (name, hash) => {
const getHash = (data) => md5(JSON.stringify(data)).toString();
const getName = (hash, setName) => {
const getName = (hash, setName, setLoad) => {
axios
.get(`https://api.vytal.io/fingerprint/?hash=${hash}`)
.then((response) => {
if (response.data.length !== 0) {
setName(response.data[response.data.length - 1].name);
}
setLoad(true);
});
};