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

@philiprehberger/mask-kit

v0.2.1

Published

Data masking and redaction for logs and APIs

Downloads

55

Readme

@philiprehberger/mask-kit

CI npm version Last updated

Data masking and redaction for logs and APIs

Installation

npm install @philiprehberger/mask-kit

Usage

import { maskEmail, maskCreditCard, maskObject } from '@philiprehberger/mask-kit';

maskEmail('[email protected]');     // "u***@e******.com"
maskCreditCard('4111111111111111'); // "************1111"

const safe = maskObject(requestBody, {
  rules: ['password', 'secret', /token/i, 'creditCard'],
});
logger.info('Request', safe);

Format-Preserving Masks

Keep delimiters and separators in place while masking alphanumeric characters:

import { maskFormatPreserving } from '@philiprehberger/mask-kit';

maskFormatPreserving('(555) 123-4567');
// "(***) ***-****"

maskFormatPreserving('(555) 123-4567', { revealLast: 4 });
// "(***) ***-4567"

maskFormatPreserving('4111-2222-3333-4444', { revealLast: 4, revealFirst: 4 });
// "4111-****-****-4444"

Configurable Reveal Count

Control exactly how many characters remain visible:

import { revealFirst, revealLast } from '@philiprehberger/mask-kit';

revealFirst('secretdata', 3);   // "sec*******"
revealLast('secretdata', 4);    // "******data"
revealFirst('abc', 5);          // "abc" (no masking if count >= length)
revealLast('token_xyz', 3, { char: '#' }); // "######xyz"

Regex-Based Masking

Mask substrings that match a regular expression:

import { maskByPattern } from '@philiprehberger/mask-kit';

// Mask all digits
maskByPattern('Order #12345 shipped', /\d+/);
// "Order #***** shipped"

// Mask email-like patterns in free text
maskByPattern('Contact [email protected] for info', /[^\s@]+@[^\s@]+/);
// "Contact ************* for info"

// Mask SSN patterns
maskByPattern('SSN: 123-45-6789', /\d{3}-\d{2}-\d{4}/);
// "SSN: ***********"

Deep Object Masking

Recursively traverse nested objects and arrays, masking values by key name:

import { maskDeep } from '@philiprehberger/mask-kit';

const input = {
  user: {
    name: 'Alice',
    password: 'hunter2',
    addresses: [
      { street: '123 Main St', ssn: '999-00-1234' },
    ],
  },
  apiKey: 'sk-abc123',
};

maskDeep(input, ['password', 'ssn', 'apiKey']);
// {
//   user: {
//     name: 'Alice',
//     password: '*******',
//     addresses: [
//       { street: '123 Main St', ssn: '***********' },
//     ],
//   },
//   apiKey: '********',
// }

API

| Function | Description | |----------|-------------| | maskEmail(email) | Mask email preserving structure | | maskCreditCard(card) | Show last 4 digits | | maskPhone(phone) | Show last 3 digits | | maskToken(token) | Show first/last 4 chars | | maskIP(ip) | Mask middle octets | | maskCustom(str, options?) | Custom masking with position control | | maskFormatPreserving(value, options?) | Mask alphanumeric chars while keeping delimiters | | revealFirst(value, count, options?) | Reveal first N characters, mask the rest | | revealLast(value, count, options?) | Reveal last N characters, mask the rest | | maskByPattern(value, regex, options?) | Mask substrings matching a regex pattern | | maskObject(obj, { rules }) | Deep-walk and mask matching keys with auto-detection | | maskDeep(obj, sensitiveKeys, options?) | Recursively mask values by key name | | detectType(value) | Auto-detect value type |

Development

npm install
npm run build
npm test

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT