Socket
Socket
Sign inDemoInstall

lib-redactor

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lib-redactor

Another library that will help you ██████ texts with ease.


Version published
Maintainers
1
Install size
7.46 kB
Created

Readme

Source

lib-redactor

Another library that will help you ██████ texts with ease.

GitHub Workflow Status WTFPL Known Vulnerabilities npm


Installation

npm install -S lib-redactor

Usage

import redactor from "lib-redactor";
  
const redactMe = {
  first_name: "John",
  last_name: "Doe",
  phone_number: "6969696969",
  email: "john.doe69@email.com"
};

const redactionRule = redactor(["phone_number", "email"]);

const redacted = redactionRule(redactMe);

console.log(redacted);
/// will log the following:
/// {
///   "first_name": "John",
///   "last_name": "Doe",
///   "phone_number: "6████████9",
///   "email": "j██████████████████m"
/// }

Changing mask character

import redactor from "lib-redactor";
  
const redactMe = {
  first_name: "John",
  last_name: "Doe",
  phone_number: "6969696969",
  email: "john.doe69@email.com"
};
const options = {
  maskCharacter: "X"
};
const redactionRule = redactor(["phone_number", "email"], options);

const redacted = redactionRule(redactMe);

console.log(redacted);
/// will log the following:
/// {
///   "first_name": "John",
///   "last_name": "Doe",
///   "phone_number: "6XXXXXXXX9",
///   "email": "jXXXXXXXXXXXXXXXXXXm"
/// }

Redacting based on supplied keywords or basic pattern

import redactor from "lib-redactor";
  

const redactMe = {
  phrase: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
}
;
const options = {
  maskCharacter: "X",
  fullRedaction: true,
  blacklistedWords: [
    /Lorem/g,
    "elit",
    "non",
    "dolor"
  ]
};
const redactionRule = redactor([], options);

const redacted = redactionRule(redactMe);

console.log(redacted);
/// will log the following:
/// {
///   "phrase_full": "XXXXX ipsum XXXXX sit amet, consectetur adipiscing XXXX, sed do eiusmod tempor incididunt ut labore et XXXXXe magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure XXXXX in reprehenderit in voluptate vXXXX esse cillum XXXXXe eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat XXX proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
/// }

License

lib-redactor is WTFPL licensed.

Keywords

FAQs

Last updated on 26 Aug 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc