Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@npmcli/redact

npm18.3mISC3.2.2

Redact sensitive npm information from output

readme

@npmcli/redact

Redact sensitive npm information from output.

API

This will redact npm_ prefixed tokens and UUIDs from values.

It will also replace passwords in stringified URLs.

redact(string)

Redact values from a single value

const { redact } = require('@npmcli/redact')

redact('https://user:pass@registry.npmjs.org/')
// https://user:***@registry.npmjs.org/

redact(`https://registry.npmjs.org/path/npm_${'a'.repeat('36')}`)
// https://registry.npmjs.org/path/npm_***

redactLog(string | string[])

Redact values from a string or array of strings.

This method will also split all strings on \s and = and iterate over them.

const { redactLog } = require('@npmcli/redact')

redactLog([
  'Something --x=https://user:pass@registry.npmjs.org/ foo bar',
  '--url=http://foo:bar@registry.npmjs.org',
])
// [
//   'Something --x=https://user:***@registry.npmjs.org/ foo bar',
//   '--url=http://foo:***@registry.npmjs.org/',
// ]

changelog

Changelog

3.2.2 (2025-05-05)

Bug Fixes

  • 254415e #45 check if buffer is available instead of using Buffer module (#45) (@reggi)

3.2.1 (2025-05-02)

Bug Fixes

  • 2aca0ac #42 check if Buffer is available (#42) (@reggi)

    Chores

  • 40f41d9 #43 adds codeql workflow (#43) (@reggi)
  • ce4294a #41 bumping @npmcli/template-oss from 4.23.3 to 4.24.3 (#41) (@owlstronaut)

3.2.0 (2025-04-21)

Features

  • e30b453 #39 adds cookie to redaction list (#39) (@reggi)

    Chores

  • 9868381 #36 use throws and rejects assertions (#36) (@hashtagchris)

3.1.1 (2025-01-29)

Bug Fixes

  • f509ae4 #34 server: redactThrow should return function (#34) (@reggi)

3.1.0 (2025-01-29)

Features

  • d1837d1 #32 server: introduces serializeError and redactError (#32) (@reggi)

3.0.0 (2024-09-24)

⚠️ BREAKING CHANGES

  • @npmcli/redact now supports node ^18.17.0 || >=20.5.0

    Bug Fixes

  • 2ffd026 #28 align to npm 10 node engine range (@hashtagchris)

    Chores

  • 864a01a #28 run template-oss-apply (@hashtagchris)
  • 1d90363 #26 bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (@dependabot[bot])
  • 96c5285 #27 postinstall for dependabot template-oss PR (@hashtagchris)
  • 01daecd #27 bump @npmcli/template-oss from 4.23.1 to 4.23.3 (@dependabot[bot])

2.0.1 (2024-06-05)

Bug Fixes

  • 670847f #15 filter properties of error (#15) (@reggi)
  • 826b60d #14 prevent redact for buffers (#14) (@reggi)

2.0.0 (2024-04-26)

⚠️ BREAKING CHANGES

  • This package now uses package.json exports. The only allowed entry points are @npmcli/redact and @npmcli/redact/server in addition to the package.json itself.

Features

1.1.0 (2024-04-03)

Features

  • c681d24 #4 add node 16 support (#4) (@lukekarrys)

1.0.0 (2024-04-03)

⚠️ BREAKING CHANGES

  • initial implementation (#1)

Features

  • 44c4ede #1 initial implementation (#1) (@lukekarrys)