Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@npmcli/redact

Package Overview
Dependencies
Maintainers
6
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@npmcli/redact

Redact sensitive npm information from output

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is @npmcli/redact?

@npmcli/redact is a utility for redacting sensitive information from strings. It is particularly useful for logging and debugging purposes where you want to ensure that sensitive data such as passwords, API keys, or personal information is not exposed.

What are @npmcli/redact's main functionalities?

Redact sensitive information

This feature allows you to redact specified sensitive information from a string. In this example, the words 'password' and 'secret' are redacted.

const { create } = require('@npmcli/redact');
const redactor = create(['password', 'secret']);
const redactedString = redactor('My password is password and my secret is secret.');
console.log(redactedString); // Output: My ****** is ****** and my ****** is ******.

Custom redaction patterns

This feature allows you to use custom regular expressions to define what should be redacted. In this example, a pattern for credit card numbers is used.

const { create } = require('@npmcli/redact');
const redactor = create([/\b\d{4}-\d{4}-\d{4}-\d{4}\b/]);
const redactedString = redactor('My credit card number is 1234-5678-1234-5678.');
console.log(redactedString); // Output: My credit card number is ********************.

Redact multiple patterns

This feature allows you to redact multiple patterns at once. In this example, both the word 'password' and a credit card number pattern are redacted.

const { create } = require('@npmcli/redact');
const redactor = create(['password', /\b\d{4}-\d{4}-\d{4}-\d{4}\b/]);
const redactedString = redactor('My password is password and my credit card number is 1234-5678-1234-5678.');
console.log(redactedString); // Output: My ****** is ****** and my credit card number is ********************.

Other packages similar to @npmcli/redact

FAQs

Package last updated on 25 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc