-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial commit with project setup
- 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
Showing
21 changed files
with
4,705 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
dist | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
}; |
Oops, something went wrong.