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

@cs124/client-id

Package Overview
Dependencies
Maintainers
1
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 2021.7.2 to 2022.3.0

79

dist/index.js
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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) {

@@ -20,2 +24,11 @@ if (k2 === undefined) k2 = k;

};
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) {

@@ -29,3 +42,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const uuid_1 = require("uuid");
exports.ClientIDContext = react_1.createContext({
exports.ClientIDContext = (0, react_1.createContext)({
browserID: "",

@@ -35,35 +48,27 @@ tabID: "",

const ClientIDProvider = ({ IPinterval = 5 * 6 * 1000, children }) => {
const [browserID, setBrowserID] = react_1.useState();
react_1.useEffect(() => {
const id = localStorage.getItem("client-id") || uuid_1.v4();
localStorage.setItem("client-id", id);
setBrowserID(id);
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)(() => {
localStorage.setItem("client-id", browser.current);
sessionStorage.setItem("client-id", tab.current);
}, []);
const [tabID, setTabID] = react_1.useState();
react_1.useEffect(() => {
const id = sessionStorage.getItem("client-id") || uuid_1.v4();
sessionStorage.setItem("client-id", id);
setTabID(id);
}, []);
const [IPv4, setIPv4] = react_1.useState(undefined);
const [IPv6, setIPv6] = react_1.useState(undefined);
react_1.useEffect(() => {
const checkIP = () => {
public_ip_1.default
.v4()
.then((_ip) => {
setIPv4(_ip);
})
.catch(() => {
setIPv4(undefined);
});
public_ip_1.default
.v6()
.then((_ip) => {
setIPv6(_ip);
})
.catch(() => {
setIPv6(undefined);
});
};
const [ip, setIP] = (0, react_1.useState)({});
(0, react_1.useEffect)(() => {
const checkIP = () => __awaiter(this, void 0, void 0, function* () {
let v4;
try {
v4 = yield public_ip_1.default.v4();
}
catch (err) {
//
}
let v6;
try {
v6 = yield public_ip_1.default.v6();
}
catch (err) {
//
}
setIP({ v4, v6 });
});
const timer = setInterval(() => checkIP, IPinterval);

@@ -74,8 +79,8 @@ checkIP();

};
}, [IPinterval, setIPv4, setIPv6]);
return react_1.default.createElement(exports.ClientIDContext.Provider, { value: { browserID, tabID, IPv4, IPv6 } }, children);
}, [IPinterval]);
return (react_1.default.createElement(exports.ClientIDContext.Provider, { value: { browserID: browser.current, tabID: tab.current, IPv4: ip.v4, IPv6: ip.v6 } }, children));
};
exports.ClientIDProvider = ClientIDProvider;
const useClientID = () => react_1.useContext(exports.ClientIDContext);
const useClientID = () => (0, react_1.useContext)(exports.ClientIDContext);
exports.useClientID = useClientID;
//# sourceMappingURL=index.js.map
{
"name": "@cs124/client-id",
"version": "2021.7.2",
"version": "2022.3.0",
"license": "MIT",

@@ -17,4 +17,4 @@ "main": "dist/index.js",

"dependencies": {
"public-ip": "^4.0.4",
"uuid": "^8.3.2"
"public-ip": "5.0.0",
"uuid": "8.3.2"
},

@@ -25,17 +25,17 @@ "peerDependencies": {

"devDependencies": {
"@types/react": "17.0.14",
"@types/uuid": "8.3.1",
"@typescript-eslint/eslint-plugin": "4.28.3",
"@typescript-eslint/parser": "4.28.3",
"eslint": "7.31.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-react-hooks": "^4.2.0",
"npm-check-updates": "11.8.3",
"prettier": "2.3.2",
"prettier-package-json": "2.6.0",
"prettier-plugin-organize-imports": "2.2.0",
"@types/react": "17.0.41",
"@types/uuid": "8.3.4",
"@typescript-eslint/eslint-plugin": "5.15.0",
"@typescript-eslint/parser": "5.15.0",
"eslint": "8.11.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-react-hooks": "4.3.0",
"npm-check-updates": "12.5.4",
"prettier": "2.6.0",
"prettier-package-json": "2.6.3",
"prettier-plugin-organize-imports": "2.3.4",
"react": "17.0.2",
"rimraf": "3.0.2",
"typescript": "4.3.5"
"typescript": "4.6.2"
}
}

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