Skip to content
/ redact Public

Redact sensitive npm information from output

License

Notifications You must be signed in to change notification settings

npm/redact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9868381 · Jan 29, 2025

History

23 Commits
Sep 24, 2024
Jan 29, 2025
Jun 5, 2024
Jan 29, 2025
Aug 29, 2024
Apr 3, 2024
Aug 27, 2024
Apr 3, 2024
Jan 29, 2025
Jan 29, 2025
Apr 3, 2024
Apr 3, 2024
Apr 2, 2024
Apr 3, 2024
Aug 27, 2024
Jan 29, 2025
Aug 27, 2024

Repository files navigation

@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/',
// ]