Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node_js_ipqs_device_tracker

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node_js_ipqs_device_tracker

NodeJS/React package to interface with the IPQS Device Fingerprint API.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
681
increased by24.04%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Device Fingerprint Tracker Package for React

This is the NPM/Yarn package for implementing the Device Fingerprint Tracker API in React

Further Reading

  • Creating a Device Fingerprint Tracker
  • Device Fingerprint Overview
  • Device Fingerprint API

Installation

npm i node_js_ipqs_device_tracker

Initialization

To initialize the Device Tracker Package in React, you can do it in one of two ways

import DeviceFingerprint from 'ipqs-device-fingerprint-for-react';

function App() {
    const secretKey = `YourSecretKey`;
    useEffect(() => {
        DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
            DeviceFingerprint.Init();
        }).catch(() => {
            // Any errors loading the external script will be caught here
        });
    });
}

This is not recommended as this will not tell you when the external script has been loaded, nor will it be easy to catch any errors loading an external script

import DeviceFingerprint from 'ipqs-device-fingerprint-for-react';

function App() {
    useEffect(() => {
        DeviceFingerprint.initializeScript();
        setTimeout( function() {
          DeviceFingerprint.AfterResult(afterResult);
          DeviceFingerprint.Init();
        }, 1000);
    });
}

Other Methods

NOTE: The following methods will only work after initializeScriptAsync() or initializeScriptAsync() have successfully loaded

Init();

Initializes the Device Tracker

DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
    const callback = (result) => {
        console.log(result);
    }
    DeviceFingerprint.AfterResult(callback);
    DeviceFingerprint.Init();
});

AfterResult(callback);

Enables a callback function to be called when DeviceFingerprint.Init() succeeds

DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
    const callback = (result) => {
        console.log(result);
    }
    DeviceFingerprint.AfterResult(callback);
    DeviceFingerprint.Init();
});

AfterFailure(callback);

Enables a callback function to be called when DeviceFingerprint.Init() fails

DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
    const callback = (result) => {
        console.log(result);
    }
    DeviceFingerprint.AfterFailure(callback);
    DeviceFingerprint.Init();
});

Pause();

Pauses the Device Tracker

DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
    DeviceFingerprint.Init();
    DeviceFingerprint.Pause();
});

Resume();

Resumes the Device Tracker. This works in conjunction with Resume()

DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
    DeviceFingerprint.Init();
    DeviceFingerprint.Pause();
    DeviceFingerprint.Resume();
});

Trigger(formId, callback);

Sets a trigger on a form based on a specific id, and assigns a callback for when that form is submitted.

If used in conjunction with AfterResult(), you will not fire the result callback until that specific form is submitted.

This must be called before Init()

DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
    const formId = "someFormId";
    const callback = (event) => {
        event.preventDefault();
    }
    DeviceFingerprint.Trigger(`#${formId}`, callback);
    DeviceFingerprint.Init();
});
<form id={formId}>
    <button type="submit">Submit</button>
</form>

SetFormFieldPrepend(prefix: string);

Sets the Form Field Prepend prefix for form submission triggers.

This works in conjunction with Trigger() and must be called before Init()

DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
    const prefix = "somePrefix";
    DeviceFingerprint.SetFormFieldPrepend(prefix);
    
    const formId = "someFormId";
    const callback = (event) => {
        event.preventDefault();
    }
    DeviceFingerprint.Trigger(`#${formId}`, callback);
    DeviceFingerprint.Init();
});
<form id={formId}>
    <button type="submit">Submit</button>
</form>

Field(fieldName: string, fieldId: number);

Allows you to specify additional fields for order submission and payment processing

DeviceFingerprint.initializeScriptAsync(secretKey).then(() => {
    const fieldName = "someField";
    const fieldId = "#someFieldId";
    DeviceFingerprint.Field(fieldName, fieldId);
    DeviceFingerprint.Init();
});

FAQs

Package last updated on 14 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc