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

@tracegraph/trace-sanitizer

v0.3.1

Published

Value redaction and size-limiting for TraceGraph events

Readme

@tracegraph/trace-sanitizer

Value redaction and size-limiting for TraceGraph events. Ensures that sensitive data (passwords, tokens, API keys, card numbers, PII) is never written to trace files, and that captured payloads stay within configurable size limits. Also provides a normaliseForDiff function that replaces volatile values (UUIDs, timestamps, JWTs, numeric IDs) with stable placeholders so that behaviour diffs don't generate noise from non-deterministic values.

What's in this package

| Export | Description | |--------|-------------| | sanitize(value, config?) | Recursively redacts sensitive keys and enforces size limits on any value | | sanitizeHeaders(headers, config?) | Sanitizes HTTP headers: always redacts authorization, cookie, set-cookie, x-api-key; retains safe informational headers | | normaliseForDiff(value) | Replaces UUIDs, ISO timestamps, JWTs, and large numeric IDs with stable placeholders (<uuid>, <timestamp>, <token>, <id>) for stable baseline comparisons | | SanitizerConfig | Configuration type for sanitize and sanitizeHeaders | | SanitizedValue | Return type of sanitize |

Installation

npm install @tracegraph/trace-sanitizer

Usage

Sanitizing request/response bodies

import { sanitize } from '@tracegraph/trace-sanitizer';

const body = {
  customerId: 'cust_123',
  password:   's3cr3t',          // ← will be redacted
  cardNumber: '4111111111111111', // ← will be redacted
  items: [{ sku: 'A1', qty: 2 }],
};

const safe = sanitize(body);
// {
//   customerId: 'cust_123',
//   password:   '[REDACTED]',
//   cardNumber: '[REDACTED]',
//   items: [{ sku: 'A1', qty: 2 }],
// }

Custom configuration

import { sanitize } from '@tracegraph/trace-sanitizer';

const safe = sanitize(value, {
  redactKeys:      ['internalToken', 'legacyPass'],  // merged with built-in list
  maxDepth:        3,
  maxStringLength: 200,
  maxArrayLength:  20,
  maxObjectKeys:   50,
});

Sanitizing HTTP headers

import { sanitizeHeaders } from '@tracegraph/trace-sanitizer';

const safeHeaders = sanitizeHeaders(req.headers);
// authorization → '[REDACTED]'
// cookie        → '[REDACTED]'
// content-type  → 'application/json'  (retained)

Normalising for diff stability

import { normaliseForDiff } from '@tracegraph/trace-sanitizer';

const raw = {
  id:        '550e8400-e29b-41d4-a716-446655440000',  // UUID
  createdAt: '2026-05-30T12:00:00.000Z',              // ISO timestamp
  userId:    12345678,                                 // large numeric ID
};

const stable = normaliseForDiff(raw);
// { id: '<uuid>', createdAt: '<timestamp>', userId: '<id>' }

Passing the normalised value to JSON.stringify and hashing it produces a stable identity hash that survives UUID rotation and timestamp drift between runs.

Built-in redacted keys

The following key names (case-insensitive, separator-stripped) are always redacted regardless of configuration:

password, token, accesstoken, refreshtoken, authorization, cookie, set-cookie, session, secret, apikey, privatekey, cardnumber, cvv, cvc, pin, otp, ssn, x-api-key, x-auth-token, and more.

Notes

  • sanitize() is a pure function — it never mutates the input.
  • Applied to all user-controlled data before it enters the trace pipeline: request bodies, response bodies, function arguments, DB rows.
  • normaliseForDiff is used at comparison time (inside @tracegraph/graph-engine), not during event capture.