Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/components/Fingerprint/Fingerprint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const useStyles = makeStyles()((theme) => {
let fpPromise = null

const registerFingerprint = async () => {
fpPromise = FingerprintJS.load({
monitoring: false,
})
const fp = await localStorage.getItem('fingerprint')
if (isEmpty(fp)) {
await localStorage.setItem('fingerprint', uuidv4())
}
fpPromise = FingerprintJS.load({
monitoring: false,
})
}

const useFingerprint = async () => {
Expand All @@ -40,6 +40,10 @@ const Fingerprint = ({ guid=false, onFingerprint = () => { } }) => {
const { classes } = useStyles()

useEffect(() => {
if (guid) {
onFingerprint(localStorage.getItem('fingerprint'))
return
}
if (!fpPromise) throw new Error('FingerprintJS not loaded, add registerFingerprint() closest to root as possible (possibly index.js)')
const fetchFP = async () => {
const fp = await fpPromise
Expand Down