4

I am trying to get the browser fingerprint from react application using clientJS. When I import clientJS module and try to access get fingerprint function, it's throwing error saying Get Finger Print is not a function. But If i create a clientJS instance from window.ClientJS(). I am able to generate the fingerprint. Why am i not able get the fingerprint function from instance of ClientJS?

Not working

import ClientJS from "clientjs";

const client = new ClientJS()

const fingerPrint = client.getFingerprint()

console.log(client)

enter image description here Working

import ClientJS from "clientjs";

const client = new ClientJS()
const windowClient = new window.ClientJS();

const fingerPrint = windowClient.getFingerprint()

console.log(windowClient);

enter image description here

Dinesh
  • 426
  • 5
  • 15

3 Answers3

1

I haven't done much with client Js but I have a tiny package I built that you can use to get a browser fingerprint with ease.

You can use it in any of your frontend application.

It is available here https://github.com/successtar/browser-signature

successtar
  • 319
  • 3
  • 4
  • awesome package man but if i open an incognito window then the fingerprint changes. Any way to make the fingerprint constant? – VII Aug 12 '21 at 01:50
1

This worked for me in a react application

import ClientJS from 'clientjs'
import { useState, useEffect } from 'react'

let clientJs: any

const MyComponent = () => {
   const [fingerprint, setFingerprint] = useState('')
   
   useEffect(() => {
     clientJs = new ClientJS()
   }, []) // initiate on the first load

   setFingerprint(clientJs.getFingerprint)
}
Taher
  • 732
  • 1
  • 9
  • 26
-1

Code below is working for me in React.

import ClientJS from 'clientjs';

var client = new ClientJS();

client.getBrowser()
Ante
  • 85
  • 2
  • 8