import * as Fingerprint2 from 'fingerprintjs2'
function _getFingerprint () {
return new Promise((resolve, reject) => {
async function getHash () {
const options = {
excludes: {
plugins: true,
localStorage: true,
adBlock: true,
screenResolution: true,
availableScreenResolution: true,
enumerateDevices: true,
pixelRatio: true,
doNotTrack: true
}
}
try {
const components = await Fingerprint2.getPromise(options)
const values = components.map(component => component.value)
console.log('fingerprint hash components', components)
return String(Fingerprint2.x64hash128(values.join(''), 31))
} catch (e) {
reject(e)
}
}
if (window.requestIdleCallback) {
console.log('requestIdleCallback')
requestIdleCallback(async () => resolve(await getHash()))
} else {
console.log('setTimeout')
setTimeout(async () => resolve(await getHash()), 500)
}
})
}
-
-
Save galchenkov/d063599ccaece148868123c7aeab563c to your computer and use it in GitHub Desktop.
Get browser fingerprint example (fingerprintjs2)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment