Socket
Socket
Sign inDemoInstall

fast-redact

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-redact

very fast object redaction


Version published
Weekly downloads
5.4M
decreased by-12.54%
Maintainers
2
Weekly downloads
 
Created

What is fast-redact?

The fast-redact npm package is designed for redacting sensitive information from objects without mutating the original object. It is optimized for performance and can handle various patterns and paths for redaction.

What are fast-redact's main functionalities?

Static Redaction

Redacts specified paths from an object. In this example, the 'password' and 'ssn' fields of the 'user' object are redacted.

const redact = require('fast-redact')({ paths: ['user.password', 'user.ssn'] });
const user = { name: 'Alice', password: 's3cret', ssn: '123-45-6789' };
const safeUser = redact(user);
console.log(safeUser);

Dynamic Redaction

Allows for dynamic redaction based on the path of the property being redacted. In this example, all properties under 'user' are redacted with a '[REDACTED]' suffix.

const redact = require('fast-redact')({
  paths: ['user.*'],
  dynamicRedaction: {
    path: (path) => path + '[REDACTED]'
  }
});
const user = { name: 'Alice', password: 's3cret', ssn: '123-45-6789' };
const safeUser = redact(user);
console.log(safeUser);

Wildcard Redaction

Supports wildcard patterns to redact all matching paths. In this example, all properties of the 'user' object are redacted.

const redact = require('fast-redact')({ paths: ['user.*'] });
const user = { name: 'Alice', password: 's3cret', ssn: '123-45-6789', email: 'alice@example.com' };
const safeUser = redact(user);
console.log(safeUser);

Conditional Redaction

Allows redaction based on a condition. In this example, the 'ssn' field is redacted only if the user's age is less than 18.

const redact = require('fast-redact')({
  paths: ['user.ssn'],
  condition: (value, path, object) => object.user.age < 18
});
const user = { name: 'Alice', age: 17, ssn: '123-45-6789' };
const safeUser = redact(user);
console.log(safeUser);

Other packages similar to fast-redact

Keywords

FAQs

Package last updated on 28 Aug 2021

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