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

sachii-safe-logger

v1.2.0

Published

A lightweight TypeScript library to mask sensitive data (emails, credit cards, phone numbers, API tokens) in logs for security and compliance.

Downloads

11

Readme

sachii-safe-logger

A lightweight TypeScript library to automatically detect and mask sensitive data (emails, credit cards, phone numbers, API tokens, SSN, passwords, etc.) in logs for security and compliance.

Installation

npm install sachii-safe-logger

🚀 Quick Start - Auto-Mask All Console Logs

Just add ONE line at the top of your app and all console.log calls will automatically mask sensitive data!

// At the very top of your app entry point (index.js, app.js, server.js)
require('sachii-safe-logger').enableGlobalMasking();

// That's it! Now ALL console.log calls anywhere in your app auto-mask sensitive data!
console.log("User email: [email protected]");     // → "User email: j***@example.com"
console.log("Card: 4111111111111111");           // → "Card: ************1111"
console.log("Call 555-123-4567");                // → "Call *******4567"
console.log("SSN: 123-45-6789");                 // → "SSN: ***-**-6789"
console.log({ password: "secret123" });          // → { password: "sec****123" }

What Gets Auto-Detected & Masked

| Data Type | Example Input | Masked Output | |-----------|---------------|---------------| | Email | [email protected] | j***@example.com | | Credit Card | 4111111111111111 | ************1111 | | Phone | 555-123-4567 | *******4567 | | SSN | 123-45-6789 | ***-**-6789 | | JWT Tokens | eyJhbGci... | eyJh****... | | Passwords | password=secret | password=****** | | IP Addresses | 192.168.1.100 | 192.***.***100 | | AWS Keys | AKIAIOSFODNN7EXAMPLE | AKIA****MPLE | | Basic Auth | Basic dXNlcjpwYXNz | Basic [REDACTED] | | URLs with creds | https://user:[email protected] | https://user:********@host.com |

API Reference

enableGlobalMasking(options?)

Enable auto-masking for all console methods globally. Call once at app startup.

const { enableGlobalMasking } = require('sachii-safe-logger');

// Enable with default options (masks everything)
enableGlobalMasking();

// Or customize what to mask
enableGlobalMasking({
  maskEmail: true,        // default: true
  maskPhone: true,        // default: true
  maskCreditCard: true,   // default: true
  maskSSN: true,          // default: true
  maskIP: true,           // default: true
  maskJWT: true,          // default: true
  maskPasswords: true,    // default: true
  maskMAC: false,         // default: false
});

disableGlobalMasking()

Restore original console behavior.

const { disableGlobalMasking } = require('sachii-safe-logger');
disableGlobalMasking();

autoMask(input, options?)

Mask sensitive data in a single string.

const { autoMask } = require('sachii-safe-logger');

const text = "Contact [email protected] or 555-123-4567";
console.log(autoMask(text));
// Output: "Contact j***@example.com or *******4567"

autoMaskObject(obj, options?)

Deep-traverse and mask sensitive data in objects.

const { autoMaskObject } = require('sachii-safe-logger');

const user = {
  email: "[email protected]",
  password: "secret123",
  payment: { cardNumber: "4111111111111111" }
};

console.log(autoMaskObject(user));
// Output: { email: "j***@example.com", password: "sec****123", payment: { cardNumber: "************1111" }}

createSafeLogger(logger?, options?)

Wrap any logger (console, winston, pino, bunyan) with auto-masking.

const { createSafeLogger } = require('sachii-safe-logger');
const winston = require('winston');

const safeLogger = createSafeLogger(winston);
safeLogger.info("User email: [email protected]"); // Auto-masked!

Individual Maskers

const { maskEmail, maskPhone, maskCreditCard, maskToken } = require('sachii-safe-logger');

maskEmail("[email protected]");      // "j***@example.com"
maskPhone("555-123-4567");          // "*******4567"
maskCreditCard("4111111111111111"); // "************1111"
maskToken("sk_live_abc123xyz789");  // "sk_l****9789"

Access Regex Patterns

const { PATTERNS } = require('sachii-safe-logger');

// Use patterns for your own validation/detection
PATTERNS.EMAIL      // Email regex
PATTERNS.CREDIT_CARD // Credit card regex
PATTERNS.SSN        // SSN regex
PATTERNS.JWT        // JWT regex
// ... and more

Custom Patterns

Add your own regex patterns:

enableGlobalMasking({
  customPatterns: [
    { name: 'employeeId', pattern: /EMP-\d{6}/g },
    { name: 'internalCode', pattern: /INT-[A-Z]{3}-\d{4}/g }
  ]
});

TypeScript Support

Full TypeScript support with type definitions included.

import { enableGlobalMasking, autoMask, AutoMaskOptions } from 'sachii-safe-logger';

const options: AutoMaskOptions = {
  maskEmail: true,
  maskPhone: false
};

enableGlobalMasking(options);

License

MIT

Author

Sachinandan [email protected]