Code Monkey home page Code Monkey logo

browser-fingerprint-react's Introduction

Browser fingerprint generation in React

using fingerprintJS

Clone the project

  • Fork the repo
  • Clone this repo using HTTPS by doing git clone https://github.com/<your_github_username>/browser-fingerprint-react.git.

Environment Variables

This project uses Vite. Vite requires you to prefix your environment variables with VITE_ to be able to expose to the frontend. Variables which are only to be used at the backend, don't need a prefix.

Create a .env file at the root of the project where you can set your environment variables. An example env file has already been created for you (.env.example).

Getting env variables

There are four env variables you need:

VITE_FPJS_API_KEY=your_public_api_key
SERVER_FPJS_API_KEY=your_secret_server_key
VITE_FPJS_REGION=your_fpjs_region
FPJS_REGION=your_fpjs_region
  1. You can get the public API key for your application from the Fingerprint dashboard by navigating to App Settings, selecting the API Keys tab, and locating it under the Public Keys section. Set it against VITE_FPJS_API_KEY.

Fingerprint dashboard

  1. To get the server API secret key, go to Dashboard > App Settings > API Keys > Secret Keys. Set it against SERVER_FPJS_API_KEY.

Server API key

  1. For VITE_FPJS_REGION and FPJS_REGION, specify the region you selected during registration. For example, eu or ap.

What is it about

This repo contains a simple authentication project using fingerprinting provided by FingerprintJS. It shows you how you can generate a unique fingerprint in the browser using React and also, it has examples to some common server side validations which you can perform when using fingerprinting.

Run it locally

Start the server

npm run app:server

It will be live at port 5000.


Run React

npm run app:client

The app should start at port 3000.

Navigate to the Sign Up page and try to register as a user:

Sign-up

On successful sign-up, you will be redirected to the dashboard page:

Dashboard

If you try to sign up again with the same username, you won't be able to because of the visitorId validation on the server. Log in to go to the dashboard again.

Sign-up failed

You can also try this in an incognito window. The sign-up would still fail because fingerprinting isn't affected by incognito mode.

browser-fingerprint-react's People

Contributors

murtuzaalisurti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.