Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
anonymous-user-id
Advanced tools
[![npm](https://img.shields.io/npm/v/anonymous-user-id)](https://www.npmjs.com/package/anonymous-user-id) [![node-current](https://img.shields.io/node/v/anonymous-user-id)](package.json) [![CI](https://github.com/omegavesko/anonymous-user-id/actions/workf
anonymous-user-id
is a JavaScript library that allows you to anonymously identify unique users on your website without requiring them to store (and consent to) a tracking cookie. Instead, we generate a unique ID for each user based on information that can be pulled out of a regular HTTP request, mainly the source IP address and User-Agent
header.
The method we use to do this is heavily inspired by Plausible Analytics, with BLAKE2s as the hash function.
hash(salt + domain + ip + user_agent)
- This is the same algorithm used by Plausible Analytics. It relies on a salt you need to rotate at least once a day, preventing you (or anyone else) from tracking the actions of a single user for longer than the lifespan of a single salt.
hash(hash(secret + date) + domain + ip + user_agent)
- This is a modified (and less secure) variant of the original algorithm, meant for apps that can't reliably keep state (such as serverless functions), preventing them from storing a salt. Instead, we generate the salt from a long-lived secret (which you can set as e.g. an environment variable) and the current date.
npm:
npm i anonymous-user-id
yarn:
yarn add anonymous-user-id
For each algorithm this package supports, it exports a function you can use to generate an ID with it.
getAnonymousUserId(salt: string, request: RequestDetails)
hash(salt + domain + ip + user_agent)
getAnonymousUserIdWithSecret(secret: string, request: RequestDetails)
hash(hash(secret + date) + domain + ip + user_agent)
import {
getAnonymousUserId,
getAnonymousUserIdWithSecret,
} from 'anonymous-user-id';
const requestDetails = {
domain: 'test.test',
ip: '1.1.1.1',
userAgent: 'test/1.0',
};
const id1 = getAnonymousUserId('salt', requestDetails);
const id2 = getAnonymousUserIdWithSecret('secret', requestDetails);
If you have Docker and Docker Compose installed, you can run docker-compose up
to immediately get a working development environment for this package, with Jest running the tests in watch mode.
You can also use yarn link
to use your local version of the package in a different project.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
[![npm](https://img.shields.io/npm/v/anonymous-user-id)](https://www.npmjs.com/package/anonymous-user-id) [![node-current](https://img.shields.io/node/v/anonymous-user-id)](package.json) [![CI](https://github.com/omegavesko/anonymous-user-id/actions/workf
We found that anonymous-user-id demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.