About Data Guardian
Introducing Data Guardian, a robust utility crafted for developers prioritizing data security. Protect sensitive strings, objects, and ensure data immutability with zero dependencies.
Key Features
String Masking
Conceal parts of strings, safeguarding sensitive data.
Object Masking
Automatically masks identified sensitive properties in objects.
Configurable
Define your custom logic for pinpointed masking. Set masking characters, content length, and more.
Argument Masking
Securely masks function arguments to prevent sensitive data leakage.
Error Object Masking
Gracefully handles Error objects by masking any sensitive information in the error message and stack trace.
Customizable Masking
Offers various customization options for masking, including custom patterns, fixed mask lengths, and different masking characters.
Getting Started
Documentation:
For a detailed API reference, usage examples, and more, you can check out the official documentation on Data Guardian's npm page or the GitHub repository.
Installation
npm install data-guardian
Basic Usage
import { maskString, maskData } from 'data-guardian';
// Masking a string
const maskedString = maskString("Sensitive Data");
console.log(maskedString); // Output: "*************"
// Masking an object
const user = { name: "John Doe", password: "mysecretpassword" };
const maskedUser = maskData(user);
console.log(maskedUser); // Output: { name: "John Doe", password: "*************" }
Customization
const options = {
maskingChar: '.',
fixedMaskLength: true,
maskLength: 5
};
const maskedString = maskString("Example log line with my 1AG2ccxL#!.?X$ super secret password", options);
console.log(maskedString); // Output: "Example log line with my ..... super secret password"
Core Concepts:
Masking Patterns:
Data Guardian utilizes predefined and custom regular expressions to identify and mask sensitive data like credit card numbers, email addresses, passwords, etc.
Immutability:
By default, Data Guardian performs masking operations immutably, ensuring the original data remains unchanged.
Configurable Masking:
You can control the masking process through a plethora of options provided. For instance, you can specify a fixed length for masked data, choose different masking characters, or even supply custom patterns for more targeted masking.
Smart Masking:
The library smartly identifies keys in objects that are likely to contain sensitive information based on common naming conventions (e.g., password, secretKey, etc.) and applies masking to them.
Recursive Masking:
Data Guardian can recursively traverse and mask data in nested objects, arrays, Maps, and Sets, making it a one-stop solution for all your data masking needs.
Exception Handling:
Even Error objects are handled gracefully by masking any sensitive information in the error message and stack trace.
Custom Regular Expressions:
Utilizes custom regular expressions to accurately identify and mask various types of sensitive data.
️ Disclaimer
data-guardian is designed to provide an additional layer of security by masking strings and object properties that contain sensitive information. However, it is not a substitute for comprehensive security practices. Ensure you follow industry standards and regulations for data protection and privacy.
Contributing
If you have ideas on how to improve `data-guardian` or want to report a bug, please open an issue or submit a pull request. We appreciate your help and contributions!
License
Data Guardian is released under the MIT License . You are free to use, modify, distribute, and sublicense it under the MIT License terms.