1.0.2 β€’ Published 11 months ago

@burakbey/redacted v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

NPM Version GitHub Actions Workflow Status Codecov GitHub License GitHub Repo stars

πŸ” @burakbey/redacted

This is a library designed to safeguard sensitive data in your code. It provides a Redacted class that uses various techniques to prevent unintentional exposure of sensitive information. Even if an attempt is made to expose the data, it will appear as <redacted>.

πŸ“š Credits

This library is inspired by concepts discussed in this YouTube video.

πŸš€ Installation

To install the package, use your preferred package manager. Here’s an example using pnpm:

pnpm add @burakbey/redacted

πŸ“ Example Usage

The following example demonstrates usage in TypeScript. The library is also compatible with JavaScript.

import { Redacted } from '@burakbey/redacted';

// Unsafe Example:
// The value can be exposed if logged or written to a file without caution.
const password = 'super-secret-password';
console.log(password); // super-secret-password

// Safe Example:
// Use the `wrap` method to protect the value.
// The `unwrap` method explicitly reveals the original value, ensuring intentional access.
const password = Redacted.wrap('super-secret-password');
console.log(password); // <redacted>
console.log(Redacted.unwrap(password)); // super-secret-password

πŸ”„ Change the Redacted Message

You can customize the default redacted message (<redacted>) to any string you prefer. To do this, set the environment variable REDACTED_MESSAGE to your desired value.

For example, if you set REDACTED_MESSAGE="[REDACTED]" and run the code, the output will reflect this change.

import { Redacted } from '@burakbey/redacted';

const password = Redacted.wrap('super-secret-password');
console.log(password); // [REDACTED]

πŸ§ͺ Code Coverage and Tests

Tests are crucial for ensuring that the library functions as expected. You can review the code coverage reports by visiting Codecov. The primary objective is to achieve complete coverage of the entire codebase through rigorous testing.

β˜• Support

If you find this project useful and would like to support me, you can do so by visiting my website.

1.0.2

11 months ago

1.0.1

12 months ago

1.0.0

12 months ago