Added main file for functions

This commit is contained in:
z0ccc 2021-08-23 20:31:52 -04:00
parent 871f89467d
commit 90cad36930
5 changed files with 32 additions and 38 deletions

View file

@ -10,14 +10,14 @@ Check it out at https://vytal.io
# Dev # Dev
Backend setup: Backend Django setup:
``` ```
cd backend cd backend
python manage.py runserver python manage.py runserver
``` ```
Frontend setup: Frontend React setup:
``` ```
cd frontend cd frontend

View file

@ -11,7 +11,7 @@ const FingerprintBlock = () => {
useEffect(() => { useEffect(() => {
axios axios
.get(`http://localhost:8000/fingerprint/?hash=${hash}`) .get(`https://api.vytal.io/fingerprint/?hash=${hash}`)
.then((response) => { .then((response) => {
if (response.data.length !== 0) { if (response.data.length !== 0) {
setName(response.data[response.data.length - 1].name); setName(response.data[response.data.length - 1].name);
@ -22,7 +22,7 @@ const FingerprintBlock = () => {
const handleSave = (e) => { const handleSave = (e) => {
e.preventDefault(); e.preventDefault();
axios.post('http://localhost:8000/fingerprint/', { axios.post('https://api.vytal.io/fingerprint/', {
name: e.target[0].value, name: e.target[0].value,
hash, hash,
}); });
@ -134,10 +134,10 @@ const FingerprintBlock = () => {
)} )}
</div> </div>
<p> <p>
<b>Explanation:</b> This is a unique identifier that can be <b>Explanation:</b> This is a unique identifier that can be used to
used to follow you around the web. Even if you clear cookies, change follow you around the web. Even if you clear cookies, change your IP or
your IP or use private mode the hash will stay the same. Enter use private mode the hash will stay the same. Enter your name below and
your name below and reload the page in private mode to test it out. reload the page in private mode to test it out.
</p> </p>
{saved ? ( {saved ? (
<p>Success! Re-scan browser.</p> <p>Success! Re-scan browser.</p>

View file

@ -9,11 +9,7 @@ const MainColumn = () => {
<div className="centerBlockOuter"> <div className="centerBlockOuter">
<div className="centerBlockInner"> <div className="centerBlockInner">
<Logo /> <Logo />
{scan ? ( {scan ? <ScanBlocks /> : <StartBlock scan={scan} setScan={setScan} />}
<ScanBlocks />
) : (
<StartBlock scan={scan} onScanClick={setScan} />
)}
</div> </div>
</div> </div>
); );

View file

@ -1,4 +1,3 @@
import { useCallback } from 'react';
import ContentList from './ContentList'; import ContentList from './ContentList';
import ScanBlock from './ScanBlock'; import ScanBlock from './ScanBlock';
@ -16,16 +15,11 @@ const contentItems = [
{ {
title: 'System Info', title: 'System Info',
icon: 'browser', icon: 'browser',
body: 'JavaScript can be used to find data about your computer\'s software and hardware. This information can be used to create a fingerprint.', body: "JavaScript can be used to find data about your computer's software and hardware. This information can be used to create a fingerprint.",
}, },
]; ];
const StartBlock = ({ onScanClick }) => { const StartBlock = ({ setScan }) => (
const startScan = useCallback(() => {
onScanClick(true);
}, [onScanClick]);
return (
<ScanBlock> <ScanBlock>
<h2>About</h2> <h2>About</h2>
<div className="contentBody"> <div className="contentBody">
@ -36,12 +30,11 @@ const StartBlock = ({ onScanClick }) => {
<ContentList items={contentItems} /> <ContentList items={contentItems} />
<input <input
type="submit" type="submit"
onClick={startScan} onClick={() => setScan(true)}
id="scanButton" id="scanButton"
value="Scan Browser" value="Scan Browser"
/> />
</ScanBlock> </ScanBlock>
); );
};
export default StartBlock; export default StartBlock;

View file

@ -0,0 +1,5 @@
import md5 from 'crypto-js/md5';
const getHash = (data) => md5(JSON.stringify(data)).toString();
export { getHash as default };