Skip to content

Commit

Permalink
feat: Initial commit with project setup
Browse files Browse the repository at this point in the history
- Set up TypeScript project with `tsconfig.json`.
- Added main masking functions in `src/maskify.ts` (maskCardNumber, maskEmail, maskPassword, maskPhoneNumber, maskSubstring, maskUUID, maskJWT, maskJSON).
- Implemented utility functions in `src/utils.ts` (getNestedField, setNestedField).
- Created `Maskify` class with static methods for masking operations.
- Set default options for masking in `Maskify` class.
- Created unit tests for all masking functions and utilities in `tests/maskify.test.ts`.
- Added `package.json` with scripts for building (`npm run build`) and testing (`npm test`).
- Installed TypeScript, Jest, and ts-jest as dev dependencies.

This initial commit sets up the project structure, TypeScript configuration, masking and utility functions, and unit tests to ensure proper functionality.
  • Loading branch information
Ali Jaradat committed Jul 7, 2024
0 parents commit 0f55d1c
Show file tree
Hide file tree
Showing 21 changed files with 4,705 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install
- run: npm run build
- run: npm test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
coverage
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Maskify

Maskify is a library for masking sensitive data in various formats such as card numbers, email addresses, passwords, phone numbers, and more.

## Installation

```sh
npm install maskify
```

## Usage

```js
import { Maskify } from './maskify';

// Mask card number with custom options
console.log(Maskify.maskCardNumber('1234567812345678', { maskChar: '#', unmaskedStartDigits: 2, unmaskedEndDigits: 4 })); // 12##########1234

// Mask email address with custom options
console.log(Maskify.maskEmail('example@example.com', { maskChar: '#', emailMaskVisibleChars: 3 })); // exa######@example.com

// Mask password with custom mask character
console.log(Maskify.maskPassword('supersecret', { maskChar: '#' })); // ###########

// Mask phone number with custom options
console.log(Maskify.maskPhoneNumber('123-456-7890', { maskChar: '#', unmaskedStartDigits: 2, unmaskedEndDigits: 1 })); // 12#-###-###0

// Mask substring with custom options
console.log(Maskify.maskSubstring('hello world', 'world', { maskChar: '#', maskOnlyFirstOccurrence: true })); // hello #####

// Mask UUID with custom options
console.log(Maskify.maskUUID('123e4567-e89b-12d3-a456-426614174000', { maskChar: '#', unmaskedStartDigits: 4, unmaskedEndDigits: 2 })); // 123e####-####-####-####-########00

// Mask JWT token with custom mask character
console.log(Maskify.maskJWT('header.payload.signature', { maskChar: '#' })); // ######.######.########

// Mask JSON fields with custom options
const json = { card: '1234567812345678', email: 'example@example.com' };
console.log(Maskify.maskJSON(json, ['card', 'email'], { maskChar: '#', emailMaskVisibleChars: 3 })); // { card: '12##########1234', email: 'exa######@example.com' }
```

## Testing

To run tests, use the following command:

```sh
npm test
```

## Contributing

Feel free to submit issues or pull requests for improvements and new features.

## License

This project is licensed under the MIT License.
5 changes: 5 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/tests/**/*.test.ts'],
};
Loading

0 comments on commit 0f55d1c

Please sign in to comment.