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

har-redaction-kit

v0.1.0

Published

Redact sensitive fields from HAR files with deterministic reports.

Readme

har-redaction-kit

License: MPL-2.0 CI

Redact sensitive fields from HAR files with deterministic reports.

har-redaction-kit is a small TypeScript package for local-first HAR cleanup workflows. It accepts a parsed HAR object or a HAR JSON string, returns a cloned sanitized HAR, and lists every changed path without copying secret values into the report.

Links: Demo · GitHub

Package quality

  • TypeScript types are generated from the source.
  • ESM-only package with no runtime dependencies.
  • Marked as side-effect free for bundlers.
  • Browser-friendly implementation with no Node-only APIs.
  • CI runs npm ci, typecheck, build, and test.
  • Tested on Node.js 20 and 22 with GitHub Actions.

Publication status

This package is currently a GitHub preview and is queued for npm publication. The browser demo is available now, and the install command below is the command to use once the npm package is published.

Install after npm publication

npm install har-redaction-kit

Quick start

import { redactHar } from "har-redaction-kit";

const result = redactHar(harJson, {
  placeholder: "[support-redacted]"
});

if (!result.ok) {
  console.log(result.diagnostics);
} else {
  console.log(result.summary);
  console.log(result.changes);
  sendToSupport(result.har);
}

What it redacts

By default, redactHar redacts:

  • request Authorization, Proxy-Authorization, X-API-Key, X-Auth-Token and X-CSRF-Token headers;
  • request Cookie headers and response Set-Cookie headers;
  • request and response cookies;
  • sensitive query parameters in request.queryString;
  • the same sensitive parameters inside request.url;
  • sensitive fields in request.postData.params;
  • sensitive keys in JSON request.postData.text;
  • sensitive keys in application/x-www-form-urlencoded request.postData.text;
  • sensitive keys in JSON response.content.text.

The report stores the path, rule, reason, and value lengths. It does not store the original value.

API

redactHar(input, options?)

const result = redactHar(JSON.stringify(har));

Returns:

type HarRedactionResult =
  | {
      ok: true;
      har: unknown;
      changes: HarRedactionChange[];
      diagnostics: HarRedactionDiagnostic[];
      summary: HarRedactionSummary;
    }
  | {
      ok: false;
      har: null;
      changes: [];
      diagnostics: HarRedactionDiagnostic[];
      summary: HarRedactionSummary;
    };

Expected invalid input returns { ok: false } instead of throwing. Object inputs must be JSON-serializable, which matches the HAR format and avoids mutating circular or non-JSON data.

summary.changedEntries counts HAR entries where at least one request or response value changed. summary.changedRequests is kept as a compatibility alias with the same value.

createHarRedactor(defaultOptions?)

const redactor = createHarRedactor({
  rules: ["authorization-headers", "cookies"]
});

const result = redactor.redact(har);

Per-call options override the defaults:

const result = redactor.redact(har, {
  placeholder: "[hidden]"
});

summarizeHarRedactions(changes)

const byRule = summarizeHarRedactions(result.ok ? result.changes : []);

Builds a per-rule count from a saved change list.

isHarRedactionRule(rule)

import { isHarRedactionRule } from "har-redaction-kit";

if (isHarRedactionRule(configRule)) {
  enabledRules.push(configRule);
}

Validates user-provided rule names before passing them to redactHar.

harRedactionRules

import { harRedactionRules } from "har-redaction-kit";

console.log(harRedactionRules);

Exports the built-in rule names for UI controls, config validation and documentation.

defaultHarSensitiveKeys

import { defaultHarSensitiveKeys } from "har-redaction-kit";

console.log(defaultHarSensitiveKeys);

Exports the default key names used by query, form and JSON redaction.

Options

| Option | Default | Description | | --- | --- | --- | | rules | all built-in rules | Select which redaction rules run. | | placeholder | [REDACTED] | Replacement value written into the cloned HAR. | | sensitiveKeys | common token, secret, session and password names | Query, form and JSON key names to redact. | | sensitiveKeyMatch | contains | Use contains for broad matching or exact for stricter integrations. | | maxRedactions | unlimited | Stop changing values after this count. | | keepOriginalUrl | false | Keep request.url unchanged while still redacting queryString. |

Invalid runtime options are ignored with an invalid-options diagnostic instead of throwing. Empty sensitive key names are ignored so they cannot match every key accidentally.

For strict tooling, use exact key matching to avoid broad matches such as key matching monkey:

redactHar(har, {
  sensitiveKeys: ["token", "api_key", "session_id"],
  sensitiveKeyMatch: "exact"
});

Rules

type HarRedactionRule =
  | "authorization-headers"
  | "cookie-headers"
  | "cookies"
  | "query-sensitive-keys"
  | "post-data-sensitive-keys"
  | "response-content-sensitive-keys"
  | "security-headers";

Use rules to run only a subset:

redactHar(har, {
  rules: ["authorization-headers", "cookie-headers", "cookies"]
});

Diagnostics

Diagnostics are stable strings intended for logs, UI hints and tests:

  • invalid-input
  • invalid-json
  • invalid-har-shape
  • invalid-options
  • unserializable-input
  • unknown-rule
  • entry-without-request
  • entry-without-response
  • redaction-limit-reached

Security notes

This package is a deterministic redaction helper, not a complete data-loss prevention system. It does not guarantee exhaustive secret detection.

Use conservative defaults, review the changes report, and add project-specific sensitiveKeys when your system uses custom parameter names.

Scope and limits

har-redaction-kit does not:

  • read or write files;
  • upload HAR data;
  • validate the full HAR schema;
  • render a HAR waterfall;
  • inspect every vendor-specific HAR extension;
  • decode and rewrite base64-encoded response bodies;
  • mutate circular, BigInt-containing or otherwise non-JSON-serializable object input;
  • guarantee that all secrets are removed.

The core is designed for browser workbenches, support tools and thin CLIs.

License

MPL-2.0