New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

8

lib/cjs/index.js

@@ -5,7 +5,7 @@ "use strict";

const domManipulation_1 = require("./util/domManipulation");
const initializeScript = (secretKey) => {
(0, domManipulation_1.addDeviceTrackingTags)(secretKey);
const initializeScript = (secretKey, tracker, domain) => {
(0, domManipulation_1.addDeviceTrackingTags)(secretKey, tracker, domain);
};
const initializeScriptAsync = (secretKey) => {
return (0, domManipulation_1.addDeviceTrackingTagsAsync)(secretKey);
const initializeScriptAsync = (secretKey, tracker, domain) => {
return (0, domManipulation_1.addDeviceTrackingTagsAsync)(secretKey, tracker, domain);
};

@@ -12,0 +12,0 @@ exports.default = {

declare const _default: {
initializeScript: (secretKey: string) => void;
initializeScriptAsync: (secretKey: string) => Promise<void>;
initializeScript: (secretKey: string, tracker: string, domain: string) => void;
initializeScriptAsync: (secretKey: string, tracker: string, domain: string) => Promise<void>;
Init: () => void;

@@ -5,0 +5,0 @@ AfterResult: (resultCallback: () => void) => void;

@@ -1,4 +0,4 @@

export declare const addDeviceTrackingTags: (secretKey: string) => void;
export declare const addDeviceTrackingTagsAsync: (secretKey: string) => Promise<void>;
export declare const addDeviceTrackingTags: (secretKey: string, tracker?: string, domain?: string) => void;
export declare const addDeviceTrackingTagsAsync: (secretKey: string, tracker?: string, domain?: string) => Promise<void>;
export default addDeviceTrackingTags;
//# sourceMappingURL=domManipulation.d.ts.map

@@ -5,13 +5,13 @@ "use strict";

const const_1 = require("./const");
const addDeviceTrackingTags = (secretKey) => {
const addDeviceTrackingTags = (secretKey, tracker = "*", domain = "www.ipqualityscore.com") => {
document.head.appendChild(getScriptTagWindowIPQInit());
document.head.appendChild(getScriptTagLoadSrc(secretKey));
document.head.appendChild(getNoscriptTag(secretKey));
document.head.appendChild(getScriptTagLoadSrc(secretKey, tracker, domain));
document.head.appendChild(getNoscriptTag(secretKey, tracker));
};
exports.addDeviceTrackingTags = addDeviceTrackingTags;
const addDeviceTrackingTagsAsync = (secretKey) => {
const addDeviceTrackingTagsAsync = (secretKey, tracker = "*", domain = "www.ipqualityscore.com") => {
return new Promise((resolve, reject) => {
document.head.appendChild(getScriptTagWindowIPQInit());
document.head.appendChild(getScriptTagLoadSrcAsync(secretKey, resolve, reject));
document.head.appendChild(getNoscriptTag(secretKey));
document.head.appendChild(getScriptTagLoadSrcAsync(secretKey, tracker, domain, resolve, reject));
document.head.appendChild(getNoscriptTag(secretKey, tracker));
});

@@ -31,16 +31,16 @@ };

};
const getScriptTagLoadSrc = (secretKey) => {
const srcFile = `https://www.ipqualityscore.com/api/*/${secretKey}/learn.js`;
const getScriptTagLoadSrc = (secretKey, tracker, domain) => {
const srcFile = `https://${domain}/api/${tracker}/${secretKey}/learn.js`;
const scriptTag = document.createElement("script");
scriptTag.setAttribute('src', srcFile);
scriptTag.setAttribute('id', const_1.DEVICE_FINGERPRINT_SCRIPT_ID);
scriptTag.setAttribute('crossorigin', 'anonymous');
scriptTag.setAttribute("src", srcFile);
scriptTag.setAttribute("id", const_1.DEVICE_FINGERPRINT_SCRIPT_ID);
scriptTag.setAttribute("crossorigin", "anonymous");
return scriptTag;
};
const getScriptTagLoadSrcAsync = (secretKey, resolveCb, rejectCb) => {
const srcFile = `https://www.ipqualityscore.com/api/*/${secretKey}/learn.js`;
const getScriptTagLoadSrcAsync = (secretKey, tracker, domain, resolveCb, rejectCb) => {
const srcFile = `https://${domain}/api/${tracker}/${secretKey}/learn.js`;
const scriptTag = document.createElement("script");
scriptTag.setAttribute('src', srcFile);
scriptTag.setAttribute('id', const_1.DEVICE_FINGERPRINT_SCRIPT_ID_ASYNC);
scriptTag.setAttribute('crossorigin', 'anonymous');
scriptTag.setAttribute("src", srcFile);
scriptTag.setAttribute("id", const_1.DEVICE_FINGERPRINT_SCRIPT_ID_ASYNC);
scriptTag.setAttribute("crossorigin", "anonymous");
// For async

@@ -55,13 +55,13 @@ scriptTag.onload = function () {

};
const getNoscriptTag = (secretKey) => {
const getNoscriptTag = (secretKey, domain) => {
const noscriptTag = document.createElement("noscript");
noscriptTag.appendChild(generateImageTag(secretKey));
noscriptTag.appendChild(generateImageTag(secretKey, domain));
return noscriptTag;
};
const generateImageTag = (secretKey) => {
const generateImageTag = (secretKey, domain) => {
const imageTag = document.createElement("img");
const srcImage = `https://www.ipqscdn.com/api/*/${secretKey}/pixel.png`;
imageTag.setAttribute('src', srcImage);
const srcImage = `https://www.ipqscdn.com/api/${domain}/${secretKey}/pixel.png`;
imageTag.setAttribute("src", srcImage);
return imageTag;
};
exports.default = exports.addDeviceTrackingTags;
import { Init, AfterResult, AfterFailure, SetFormFieldPrepend, Trigger, Store, Field, Pause, Resume, } from "./util/deviceFingerprintFunctions";
import { addDeviceTrackingTags, addDeviceTrackingTagsAsync } from "./util/domManipulation";
const initializeScript = (secretKey) => {
addDeviceTrackingTags(secretKey);
const initializeScript = (secretKey, tracker, domain) => {
addDeviceTrackingTags(secretKey, tracker, domain);
};
const initializeScriptAsync = (secretKey) => {
return addDeviceTrackingTagsAsync(secretKey);
const initializeScriptAsync = (secretKey, tracker, domain) => {
return addDeviceTrackingTagsAsync(secretKey, tracker, domain);
};

@@ -9,0 +9,0 @@ export default {

declare const _default: {
initializeScript: (secretKey: string) => void;
initializeScriptAsync: (secretKey: string) => Promise<void>;
initializeScript: (secretKey: string, tracker: string, domain: string) => void;
initializeScriptAsync: (secretKey: string, tracker: string, domain: string) => Promise<void>;
Init: () => void;

@@ -5,0 +5,0 @@ AfterResult: (resultCallback: () => void) => void;

@@ -1,4 +0,4 @@

export declare const addDeviceTrackingTags: (secretKey: string) => void;
export declare const addDeviceTrackingTagsAsync: (secretKey: string) => Promise<void>;
export declare const addDeviceTrackingTags: (secretKey: string, tracker?: string, domain?: string) => void;
export declare const addDeviceTrackingTagsAsync: (secretKey: string, tracker?: string, domain?: string) => Promise<void>;
export default addDeviceTrackingTags;
//# sourceMappingURL=domManipulation.d.ts.map

@@ -1,12 +0,12 @@

import { DEVICE_FINGERPRINT_SCRIPT_ID, DEVICE_FINGERPRINT_SCRIPT_ID_ASYNC } from "./const";
export const addDeviceTrackingTags = (secretKey) => {
import { DEVICE_FINGERPRINT_SCRIPT_ID, DEVICE_FINGERPRINT_SCRIPT_ID_ASYNC, } from "./const";
export const addDeviceTrackingTags = (secretKey, tracker = "*", domain = "www.ipqualityscore.com") => {
document.head.appendChild(getScriptTagWindowIPQInit());
document.head.appendChild(getScriptTagLoadSrc(secretKey));
document.head.appendChild(getNoscriptTag(secretKey));
document.head.appendChild(getScriptTagLoadSrc(secretKey, tracker, domain));
document.head.appendChild(getNoscriptTag(secretKey, tracker));
};
export const addDeviceTrackingTagsAsync = (secretKey) => {
export const addDeviceTrackingTagsAsync = (secretKey, tracker = "*", domain = "www.ipqualityscore.com") => {
return new Promise((resolve, reject) => {
document.head.appendChild(getScriptTagWindowIPQInit());
document.head.appendChild(getScriptTagLoadSrcAsync(secretKey, resolve, reject));
document.head.appendChild(getNoscriptTag(secretKey));
document.head.appendChild(getScriptTagLoadSrcAsync(secretKey, tracker, domain, resolve, reject));
document.head.appendChild(getNoscriptTag(secretKey, tracker));
});

@@ -25,16 +25,16 @@ };

};
const getScriptTagLoadSrc = (secretKey) => {
const srcFile = `https://www.ipqualityscore.com/api/*/${secretKey}/learn.js`;
const getScriptTagLoadSrc = (secretKey, tracker, domain) => {
const srcFile = `https://${domain}/api/${tracker}/${secretKey}/learn.js`;
const scriptTag = document.createElement("script");
scriptTag.setAttribute('src', srcFile);
scriptTag.setAttribute('id', DEVICE_FINGERPRINT_SCRIPT_ID);
scriptTag.setAttribute('crossorigin', 'anonymous');
scriptTag.setAttribute("src", srcFile);
scriptTag.setAttribute("id", DEVICE_FINGERPRINT_SCRIPT_ID);
scriptTag.setAttribute("crossorigin", "anonymous");
return scriptTag;
};
const getScriptTagLoadSrcAsync = (secretKey, resolveCb, rejectCb) => {
const srcFile = `https://www.ipqualityscore.com/api/*/${secretKey}/learn.js`;
const getScriptTagLoadSrcAsync = (secretKey, tracker, domain, resolveCb, rejectCb) => {
const srcFile = `https://${domain}/api/${tracker}/${secretKey}/learn.js`;
const scriptTag = document.createElement("script");
scriptTag.setAttribute('src', srcFile);
scriptTag.setAttribute('id', DEVICE_FINGERPRINT_SCRIPT_ID_ASYNC);
scriptTag.setAttribute('crossorigin', 'anonymous');
scriptTag.setAttribute("src", srcFile);
scriptTag.setAttribute("id", DEVICE_FINGERPRINT_SCRIPT_ID_ASYNC);
scriptTag.setAttribute("crossorigin", "anonymous");
// For async

@@ -49,13 +49,13 @@ scriptTag.onload = function () {

};
const getNoscriptTag = (secretKey) => {
const getNoscriptTag = (secretKey, domain) => {
const noscriptTag = document.createElement("noscript");
noscriptTag.appendChild(generateImageTag(secretKey));
noscriptTag.appendChild(generateImageTag(secretKey, domain));
return noscriptTag;
};
const generateImageTag = (secretKey) => {
const generateImageTag = (secretKey, domain) => {
const imageTag = document.createElement("img");
const srcImage = `https://www.ipqscdn.com/api/*/${secretKey}/pixel.png`;
imageTag.setAttribute('src', srcImage);
const srcImage = `https://www.ipqscdn.com/api/${domain}/${secretKey}/pixel.png`;
imageTag.setAttribute("src", srcImage);
return imageTag;
};
export default addDeviceTrackingTags;
{
"name": "node_js_ipqs_device_tracker",
"version": "1.0.4",
"version": "1.1.0",
"description": "NodeJS/React package to interface with the IPQS Device Fingerprint API.",

@@ -40,3 +40,3 @@ "types": "./lib/cjs/types/index.d.ts",

"@testing-library/react": "^14.0.0",
"@types/jest": "^29.4.3",
"@types/jest": "^29.5.10",
"@typescript-eslint/eslint-plugin": "^5.55.0",

@@ -48,2 +48,4 @@ "@typescript-eslint/parser": "^5.55.0",

"jest-environment-jsdom": "^29.5.0",
"rewire": "^7.0.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",

@@ -50,0 +52,0 @@ "typescript": "^4.9.5"

@@ -282,2 +282,61 @@ # IPQualityScore NPM Device Fingerprint Tracker Package for React

# Define the Device Tracker
IPQS device trackers can be tied to specific domains. This option is selected while creating the device tracker. Adding the defined domain to the device tracker only requires one additional step - pass the domain name ( or device tracker name ) as a second variable with the secret key.
```javascript
const secretKey = process.env.VUE_APP_IPQS_DT_KEY;
const tracker = "example.com";
DeviceFingerprint.initializeScriptAsync(secretKey, tracker)
.then(async () => {
DeviceFingerprint.AfterResult((result) => {
console.log("IPQS Fingerprint: ", result);
// ########################################
// Handle The Fingerprint Record
// ########################################
// Best practice is to save the fingerprint results to the Store. The
// example below saves the fingerprint results to a Vuex initialized store.
// this.$store.commit.save_fingerprint(result);
// return result;
});
DeviceFingerprint.Init();
});
</script>
```
# Define the Custom Domain
IPQS device trackers can be served through custom domains. Defining a custom domain for the device tracker host is similiar to the steps above. Simply pass the custom domain as a third option to the DeviceFingerprint.initializeScriptAsync() call.
Do not include 'https://' in the custom domain. Only add the subdomain (if needed), the domain, and TLD in the custom_domain string value.
Eg. example-host-domain.com
If passing a custom domain to the DeviceFingerprint.initializeScriptAsync() function, you MUST also include the tracker domain/name, too. If the device tracker is configured with a wildcard (\*), pass the wildcard as the tracker name.
```javascript
const secretKey = process.env.VUE_APP_IPQS_DT_KEY;
const tracker = "example.com";
const custom_domain = "example-host-domain.com"
DeviceFingerprint.initializeScriptAsync(secretKey, tracker, custom_domain)
.then(async () => {
DeviceFingerprint.AfterResult((result) => {
console.log("IPQS Fingerprint: ", result);
// ########################################
// Handle The Fingerprint Record
// ########################################
// Best practice is to save the fingerprint results to the Store. The
// example below saves the fingerprint results to a Vuex initialized store.
// this.$store.commit.save_fingerprint(result);
// return result;
});
DeviceFingerprint.Init();
});
</script>
```
# Need Help?

@@ -284,0 +343,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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