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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pii-warden

v1.0.0

Published

Privacy-first, hybrid client-side PII detection and redaction engine using local regex/checksums and Transformers.js

Readme

🛡️ PII Warden

Privacy-first, client-side PII (Personally Identifiable Information) detection and redaction engine for web browsers and Node.js.

It combines 160+ local regex/checksum patterns with client-side ONNX machine learning models using Hugging Face's Transformers.js.


Features

  • Hybrid Two-Tier Engine:
    • Tier 1 (Instant & Offline): Identifies structured data (Credit Cards, Emails, Phone Numbers, Social Security Numbers, Passport IDs) using fast regexes and mathematical checksum validation (Luhn, Modulo 97, etc.).
    • Tier 2 (Context-Aware ML): Uses a fine-tuned token classification model (DistilBERT) executing client-side via ONNX Runtime Web to detect names, organizations, and addresses.
  • Deduplication & Collision Resolution: Auto-merges overlapping matches and resolves boundary clashes between local rules and machine learning predictions.
  • Privacy First: Zero API servers or network hops required for inference. The machine learning model is downloaded directly to the browser cache and executes locally.

Installation

npm install pii-warden

Usage

1. Basic (Offline / Rules Only)

For fast, offline-capable verification of credit cards, emails, phone numbers, and country-specific IDs.

import PIIWarden from 'pii-warden';

const warden = new PIIWarden();

const result = await warden.analyze("Please contact support at [email protected].");
console.log(result.redactedText);
// -> "Please contact support at [EMAIL_1]."

2. Hybrid (With Client-Side ML NER)

To enable name, location, and organization detection, load the ONNX machine learning model. The model files will be downloaded once to the browser cache and execute fully inside the user's browser tab.

import PIIWarden from 'pii-warden';

const warden = new PIIWarden();

// Warm up and load the ML model locally
await warden.loadModel();

const result = await warden.analyze(
  "My name is Samuel Olubukun and my email is [email protected]."
);

console.log(result.redactedText);
// -> "My name is [ID_1] [ID_2] and my email is [EMAIL_1]."

console.log(result.entities);
/*
[
  { entity_type: 'FIRSTNAME', text: 'Samuel', start: 11, end: 17, score: 0.94 },
  { entity_type: 'LASTNAME', text: 'Olubukun', start: 18, end: 26, score: 0.92 },
  { entity_type: 'EMAIL', text: '[email protected]', start: 44, end: 59, score: 1.0 }
]
*/

Configuration

You can customize minimum thresholds and patterns during instantiation:

const warden = new PIIWarden({
  minScores: {
    EMAIL: 0.9,
    PHONE: 0.85
  },
  modelName: 'samuelolubukun/pii-ner-edge-optimized' // Path to your custom ONNX NER model
});

Real-Time Form/Input Integration Example

You can easily bind the detector to textareas, inputs, or contenteditable divs to alert users or sanitize inputs on the fly:

<textarea id="chat-input" placeholder="Type message..."></textarea>
<div id="warning-msg" style="color: #ff3333; display: none; margin-top: 5px;">
  ⚠️ Warning: Sensitive PII detected!
</div>

<script type="module">
  import PIIWarden from 'pii-warden';

  const warden = new PIIWarden();
  
  // Warm up and load the ML model locally
  await warden.loadModel(); 

  const inputEl = document.getElementById('chat-input');
  const warningEl = document.getElementById('warning-msg');

  inputEl.addEventListener('input', async () => {
    const result = await warden.analyze(inputEl.value);
    
    if (result.entities.length > 0) {
      // Alert user
      warningEl.style.display = 'block';
      
      // Optional: Auto-redact in place
      // inputEl.value = result.redactedText;
    } else {
      warningEl.style.display = 'none';
    }
  });
</script>

Model Details & Provenance

The ML component of the hybrid engine uses a dual-stage architecture optimization:

  • Base Model: The core classification is powered by samuelolubukun/pii-ner-finetuned-distilbert. This model is a fine-tune of DistilBERT trained on top of AI4Privacy's high-quality multilingual PII dataset, optimized for Token Classification (NER).
  • Edge ONNX Model: To support fast, zero-latency, in-browser execution, the base model is quantized and compiled using Hugging Face's Optimum toolchain to create samuelolubukun/pii-ner-edge-optimized.
    • Quantization: INT8 quantization is applied to reduce the model size from ~260MB down to ~67MB.
    • Performance: This allows the model to download quickly, run on standard user devices using WebAssembly ONNX Runtime Web, and complete inferences client-side with negligible accuracy loss.

License

MIT