npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@financial-times/pseudonymous-id-generator

v1.1.0

Published

A lightweight utility to generate a secure pseudonymous ID using HMAC-SHA256, ideal for anonymizing users while preserving uniqueness.

Downloads

367

Readme

pseudonymous-id-generator

pseudonymous-id-generator is a lightweight utility for generating pseudonymous IDs based on user input and a secret anonymization key. It’s perfect for scenarios where you need to anonymize user data while still maintaining a consistent and unique identifier for tracking or analysis.

Features

  • Generate pseudonymous IDs from user-provided data.
  • Supports passing an anonymization key to ensure IDs are anonymized securely.
  • Easy integration into projects for privacy-centric user tracking.

Installation

You can install this package via npm:

npm install pseudonymous-id-generator
yarn add pseudonymous-id-generator

Usage

Basic Example

Here’s a basic example of how to use pseudonymous-id-generator to generate a pseudonymous ID:

const generatePseudonymousId = require("pseudonymous-id-generator");

const userId = "12345";
const anonymizationKey = "my-secret-key";

const pseudonymousId = generatePseudonymousId(userId, anonymizationKey);
console.log(pseudonymousId); // Outputs a unique pseudonymous ID

Detailed Example

You can use this package in combination with user tracking or analytics systems to create anonymized user identifiers:

const generatePseudonymousId = require("pseudonymous-id-generator");

const user = { id: "user123", email: "[email protected]" };
const anonymizationKey = process.env.ANONYMIZATION_KEY;

// Generate a pseudonymous ID based on the user's ID or email
const pseudonymousId = generatePseudonymousId(
  user.id || user.email,
  anonymizationKey
);

// Use pseudonymousId for tracking purposes without exposing personal data
console.log(`Anonymized User ID: ${pseudonymousId}`);

API

generatePseudonymousId(input, anonymizationKey)

  • input (String | Required): The user-specific input you want to anonymize (e.g., a user ID, email, or any unique value).
  • anonymizationKey (String | Required): A secret key that ensures the ID is pseudonymized in a secure and unique way.

Returns: A pseudonymous ID (String) generated from the input and anonymization key.

Why Use This?

Using pseudonymous IDs can help ensure privacy while allowing you to perform essential tracking or analytics tasks. This is especially important for GDPR and other data privacy regulations, where you need to protect user identities but still need to track usage or performance.

Contributing

Contributions are welcome! Please feel free to open issues or submit pull requests if you find bugs or have suggestions for improvements.

License

This project is licensed under the MIT License. See the LICENSE file for more details.