Giter Club home page Giter Club logo

browser_fingerprint's Introduction

Browser Fingerprint

test

NPM

Note: This package requires node v8, as it makes uses of native classes.

This module attempts to uniquely identify browsers by examining their header and connection information. This information can be used as a "poor-man's" session identifier in your node projects. This module can optionally set a cookie to 'lock' in a consistent fingerprint.

Resuming sessions require that either the cookie be returned to the server, or a x-header x-__browserFingerprint in the default case, be sent on subsequent requests

const http = require("http");
const port = 8080;

const { BrowserFingerprint } = require("browser_fingerprint");

// these are the default options
const options = {
  cookieKey: "__browser_fingerprint",
  toSetCookie: true,
  onlyStaticElements: true,
  settings: {
    path: "/",
    expires: 3600000,
    httpOnly: null,
  },
};

const fingerPrinter = new BrowserFingerprint(options);

http
  .createServer((req, res) => {
    let { fingerprint, elementsHash, headersHash } = fingerPrinter.fingerprint(
      req
    );
    headersHash["Content-Type"] = "text/plain"; // append any other headers you want
    res.writeHead(200, headersHash);

    let resp = `Your Browser Fingerprint: ${fingerprint} \r\n\r\n`;
    for (let i in elementsHash) {
      resp += `Element ${i}: ${elementsHash[i]}\r\n`;
    }

    res.end(resp);
    console.log(
      "request from " +
        req.connection.remoteAddress +
        ", fingerprint -> " +
        fingerprint
    );
  })
  .listen(port);

console.log(`server running at http://127.0.0.1:${port}`);

browser_fingerprint's People

Contributors

benlowry avatar dependabot-preview[bot] avatar dependabot[bot] avatar dscho avatar e1himself avatar evantahler avatar greenkeeper[bot] avatar macrauder avatar reiscracker avatar waldoibarra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

browser_fingerprint's Issues

request: use traditional node style callbacks

problem statement

  • the bfp callback has the signature function (hash) { ... } vs the more widely known and conventional function (err, hash, ...) { ... }

this means that error handling cannot be a thing and that promisification doesn't work through the normal venues

fingerprint seems to change every time

I am trying to use this lib in nextjs.

I do it server-side:

const fingerPrinter = new BrowserFingerprint({
  cookieKey: "__browser_fingerprint",
  toSetCookie: true,
  onlyStaticElements: true,
  settings: {
    path: "/",
    expires: 3600000,
    httpOnly: null,
  },
})

export const getServerSideProps = async ({ req }) => {
  const { fingerprint } = fingerPrinter.fingerprint(req)
  return { props: { fingerprint } }
}

Then, in my component:

export default ({ fingerprint }) => (
  <pre>{ fingerprint }</pre>
)

It changes every time.

Chrome Version 89.0.4389.82 (Official Build) (x86_64)

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.