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

@cs124/client-id

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cs124/client-id - npm Package Compare versions

Comparing version 2023.8.0 to 2024.7.0

2

.ncurc.json
{
"reject": ["public-ip"]
"reject": ["eslint"]
}

@@ -5,2 +5,3 @@ import React, { PropsWithChildren } from "react";

disableIP?: boolean;
verbose?: boolean;
}

@@ -7,0 +8,0 @@ export interface ClientIDContext {

@@ -1,62 +0,27 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useClientID = exports.ClientIDProvider = exports.ClientIDContext = void 0;
const public_ip_1 = __importDefault(require("public-ip"));
const react_1 = __importStar(require("react"));
const uuid_1 = require("uuid");
exports.ClientIDContext = (0, react_1.createContext)({
import crypto from "crypto";
import { publicIpv4, publicIpv6 } from "public-ip";
import React, { createContext, useContext, useEffect, useRef, useState } from "react";
const generateRandomID = () => crypto.randomBytes(20).toString("base64");
export const ClientIDContext = createContext({
browserID: "",
tabID: "",
});
const ClientIDProvider = ({ IPinterval = 5 * 6 * 1000, disableIP, children, }) => {
const browser = (0, react_1.useRef)((typeof window !== "undefined" && localStorage.getItem("client-id")) || (0, uuid_1.v4)());
const tab = (0, react_1.useRef)((typeof window !== "undefined" && sessionStorage.getItem("client-id")) || (0, uuid_1.v4)());
(0, react_1.useEffect)(() => {
export const ClientIDProvider = ({ IPinterval = 5 * 6 * 1000, disableIP, verbose, children, }) => {
const browser = useRef((typeof window !== "undefined" && localStorage.getItem("client-id")) || generateRandomID());
const tab = useRef((typeof window !== "undefined" && sessionStorage.getItem("client-id")) || generateRandomID());
useEffect(() => {
verbose && console.log(`Browser: ${browser.current}, Tab: ${tab.current}`);
localStorage.setItem("client-id", browser.current);
sessionStorage.setItem("client-id", tab.current);
}, []);
const [ip, setIP] = (0, react_1.useState)({});
(0, react_1.useEffect)(() => {
}, [verbose]);
const [ip, setIP] = useState({});
useEffect(() => {
if (disableIP) {
return;
}
const checkIP = () => __awaiter(void 0, void 0, void 0, function* () {
const checkIP = async () => {
let v4;
try {
v4 = yield public_ip_1.default.v4();
v4 = await publicIpv4();
verbose && console.log(`IPv4: ${v4}`);
}

@@ -68,3 +33,4 @@ catch (err) {

try {
v6 = yield public_ip_1.default.v6();
v6 = await publicIpv6();
verbose && console.log(`IPv6: ${v4}`);
}

@@ -75,3 +41,3 @@ catch (err) {

setIP({ v4, v6 });
});
};
const timer = setInterval(() => checkIP, IPinterval);

@@ -82,8 +48,6 @@ checkIP();

};
}, [IPinterval, disableIP]);
return (react_1.default.createElement(exports.ClientIDContext.Provider, { value: { browserID: browser.current, tabID: tab.current, IPv4: ip.v4, IPv6: ip.v6 } }, children));
}, [IPinterval, disableIP, verbose]);
return (React.createElement(ClientIDContext.Provider, { value: { browserID: browser.current, tabID: tab.current, IPv4: ip.v4, IPv6: ip.v6 } }, children));
};
exports.ClientIDProvider = ClientIDProvider;
const useClientID = () => (0, react_1.useContext)(exports.ClientIDContext);
exports.useClientID = useClientID;
export const useClientID = () => useContext(ClientIDContext);
//# sourceMappingURL=index.js.map
{
"name": "@cs124/client-id",
"version": "2023.8.0",
"version": "2024.7.0",
"license": "MIT",
"type": "module",
"main": "dist/index.js",

@@ -10,3 +11,3 @@ "scripts": {

"clean": "rimraf dist",
"depcheck": "depcheck --ignores=prettier-plugin-*,rimraf",
"depcheck": "depcheck --ignores=prettier-plugin-*,rimraf --ignore-dirs=dist",
"eslint": "eslint src/**",

@@ -22,4 +23,3 @@ "ncu": "ncu",

"dependencies": {
"public-ip": "4.0.4",
"uuid": "9.0.0"
"public-ip": "7.0.1"
},

@@ -30,18 +30,17 @@ "peerDependencies": {

"devDependencies": {
"@types/react": "18.2.20",
"@types/uuid": "9.0.2",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
"depcheck": "1.4.3",
"@types/react": "18.3.3",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"depcheck": "1.4.7",
"eslint": "8.47.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-react-hooks": "4.6.0",
"npm-check-updates": "16.12.2",
"prettier": "3.0.2",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-react-hooks": "4.6.2",
"npm-check-updates": "17.0.0",
"prettier": "3.3.3",
"prettier-package-json": "2.8.0",
"prettier-plugin-organize-imports": "3.2.3",
"react": "18.2.0",
"rimraf": "5.0.1",
"typescript": "5.1.6"
"prettier-plugin-organize-imports": "4.0.0",
"react": "18.3.1",
"rimraf": "6.0.1",
"typescript": "5.5.4"
}
}

@@ -5,4 +5,3 @@ {

"outDir": "dist",
"target": "es6",
"module": "commonjs",
"target": "esnext",
"lib": ["es6", "DOM"],

@@ -9,0 +8,0 @@ "moduleResolution": "node",

Sorry, the diff of this file is not supported yet

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