Gathering detailed insights and metrics for @wemnyelezxnpm/ab-rem-cupiditate
Gathering detailed insights and metrics for @wemnyelezxnpm/ab-rem-cupiditate
Gathering detailed insights and metrics for @wemnyelezxnpm/ab-rem-cupiditate
Gathering detailed insights and metrics for @wemnyelezxnpm/ab-rem-cupiditate
npm install @wemnyelezxnpm/ab-rem-cupiditate
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
20 Commits
1 Branches
Updated on Apr 27, 2024
Latest Version
1.0.0
Package Id
@wemnyelezxnpm/ab-rem-cupiditate@1.0.0
Unpacked Size
19.36 kB
Size
7.21 kB
File Count
10
NPM Version
10.5.0
Node Version
20.12.2
Published on
Apr 25, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
33
Mask sensitive data eg. write debugging data to log files, etc. Supports the below-mentioned items:
1npm install @wemnyelezxnpm/ab-rem-cupiditate
1import maskSensitiveData, { maskString } from '@wemnyelezxnpm/ab-rem-cupiditate' 2 3const objectToBeMasked = { 4 email: 'john.doe@example.com', 5 creditCard: '1234 5678 9000 9876', 6 id: '3f8a43fd-6489-4ec7-bd55-7a1ba172d77b', 7 name: 'John', 8 surname: 'Doe', 9 phone: '+358 40 1234567', 10 token: 'eyJhbGciOiJIUzI1NiJ9.ew0KICAic3ViIjogIjEyMzQ1Njc4OTAiLA0KICAibmFtZSI6ICJBbGV4IEtvemxvdiIsDQogICJpYXQiOiAxNTE2MjM5MDIyDQp9.PNKysYFTCenU5bekHCmwIxCUXoYG41H_xc3uN3ZF_b8', 11 subuser: { 12 email: 'john.smith@example.com', 13 creditCard: '0987 6543 2100 1234', 14 id: '7c942511-969b-4363-af11-9667bf756733', 15 name: 'John', 16 surname: 'Smith', 17 phone: '+358 (0)40 1234567', 18 token: 'eyJraWQiOiJlOTRmODk4Mi02YWI1LTQxZjQtODlkYS03MTYxYmFjZDUzM2UiLCJhbGciOiJFUzI1NiJ9.ew0KICAic3ViIjogIjEyMzQ1Njc4OTAiLA0KICAibmFtZSI6ICJBbGV4IEtvemxvdiIsDQogICJpYXQiOiAxNTE2MjM5MDIyDQp9.CtiBkSYbhs5hEvMA7w4_Dbs3S5IHnxJgRo-fI8UhunY9BCUxBcb9vTRB4uRKLbhCL8MRYR90rzdzE7EcllyyDw', 19 subuser: { 20 email: 'don.johnson@example.com', 21 creditCard: '1234-0987-6543-0000', 22 id: '12882e75-a726-4615-8631-6ee428e07592', 23 name: 'Don', 24 surname: 'Johnson', 25 phone: '040-1234567', 26 token: 'eyJraWQiOiIxNDQzZWU0NS01ZGY4LTRlZmYtYmU2Yi1jYjRmMWI3MDA5YjMiLCJhbGciOiJFUzUxMiJ9.ew0KICAic3ViIjogIjEyMzQ1Njc4OTAiLA0KICAibmFtZSI6ICJBbGV4IEtvemxvdiIsDQogICJpYXQiOiAxNTE2MjM5MDIyDQp9.AB0kMsJ1wGlLG-Z89O-a1eZH0RJf3VYO7uoW3otcqV-xF6THYK3v14yppzv10sQ-HZWyUek6MW8-UzB-uq5Pm917ANZUXIw0XVY794W-u1JYrl36rKRi_DqSEEQ9X-hz9BhVFQEaGyNGZSDdKiVdix6MEMgN_4Nt5O-GXwGk6SLFdpBI', 27 }, 28 }, 29} 30 31// Mask object properties with default options 32maskSensitiveData(objectToBeMasked) 33// -> { 34// creditCard: '1234 5#########9876', 35// email: 'john.d#############.com', 36// id: '3f8a43##########################d77b', 37// name: 'John', 38// surname: 'Doe', 39// phone: '+358 4#####4567', 40// token: 'eyJhbG###################################F_b8', 41// subuser: { 42// creditCard: '0987 6#########1234', 43// email: 'john.s###############.com', 44// id: '7c9425##########################6733', 45// name: 'John', 46// surname: 'Smith', 47// phone: '+358 (########4567', 48// token: "eyJraW###################################yyDw", 49// subuser: { 50// creditCard: '1234-0#########0000', 51// email: 'don.jo################.com', 52// id: '12882e##########################7592', 53// name: 'Don', 54// surname: 'Johnson', 55// phone: '040-12#4567', 56// token: 'eyJraW###################################dpBI', 57// }, 58// }, 59// } 60 61// Mask uuid string with default options 62maskSensitiveData(objectToBeMasked.id) 63// -> 3f8a43##########################d77b 64 65// Mask credit card number string with custom options 66maskSensitiveData( 67 objectToBeMasked.creditCard, 68 { 69 ...defaultMaskOptions, 70 visibleCharsFromStart: 0, 71 } 72) 73// -> ###############9876 74 75// Mask array of UUIDs with default options 76maskSensitiveData([ 77 '439a02e5-390e-49f3-a0a3-80d8def9ace4', 78 '43982692-386c-42dc-8837-93f479503c56' 79]) 80// -> [ 81// '439a02##########################ace4', 82// '439826##########################3c56' 83// ] 84 85// Mask object properties with custom options (skip UUID strings from masking) 86maskSensitiveData( 87 objectToBeMasked, 88 { 89 ...defaultMaskOptions, 90 uuidPattern: undefined, 91 } 92) 93// -> { 94// creditCard: '1234 5#########9876', 95// email: 'john.d#############.com', 96// id: '3f8a43fd-6489-4ec7-bd55-7a1ba172d77b', 97// name: 'John', 98// surname: 'Smith', 99// phone: '+358 4#####4567', 100// token: 'eyJhbG###################################F_b8', 101// subuser: { 102// creditCard: '0987 6#########1234', 103// email: 'john.s###############.com', 104// id: '7c942511-969b-4363-af11-9667bf756733', 105// name: 'John', 106// surname: 'Doe', 107// phone: '+358 (########4567', 108// token: "eyJraW###################################yyDw", 109// subuser: { 110// creditCard: '1234-0#########0000', 111// email: 'don.jo################.com', 112// id: '12882e75-a726-46#####31-6ee428e07592', 113// name: 'Don', 114// surname: 'Johnson', 115// phone: '040-12#4567', 116// token: 'eyJraW###################################dpBI', 117// }, 118// }, 119// } 120 121// Mask plain string 122maskString('john.doe@example.com') 123// -> john.d##########.com 124 125// Mask plain string with custom configuration 126maskString( 127 'john.doe@example.com', 128 { 129 maskSymbol: '#', 130 maxCharsToMask: 'john.doe@example.com'.length, 131 visibleCharsFromStart: 0, 132 visibleCharsFromEnd: 0, 133 } 134) 135// -> ####################
Usage
1maskSensitiveData(objectToBeMasked, options)
objectToBeMasked
Object, Array of strings, or just string to be masked
options
bankCardNumberPattern: RegExp|undefined - RegExp pattern to recognize bank card numbers
emailPattern: RegExp|undefined - RegExp pattern to recognize email addresses
jwtPattern: RegExp|undefined - RegExp pattern to recognize JWT tokens
phoneNumberPattern: RegExp|undefined - RegExp pattern to recognize phone numbers
uuidPattern: RegExp|undefined - RegExp pattern to recognize UUID identificators
maskSymbol: string - Symbol to replace masked chars
maxCharsToMask: string - Maximal length on masking chars
visibleCharsFromEnd: number - Amount of chars visible from the end of the string
visibleCharsFromStart: number - Amount of chars visible from the beginning of the string
Default options
1{ 2 bankCardNumberPattern: /([\d]{4}\W){3}[\d]{4}/g, 3 emailPattern: /[\w+\.+\-]+@+[\w+\.+\-]+[\.\w]{2,}/g, 4 jwtPattern: /[\w-]#\.[\w-]#\.[\w-]#/g, 5 phoneNumberPattern: /[\+]?[\d]{1,3}?[-\s\.]?[(]?[\d]{1,3}[)]?[-\s\.]?([\d-\s\.]){7,12}/g, 6 uuidPattern: /[\w]{8}\b-[\w]{4}\b-[\w]{4}\b-[\w]{4}\b-[\w]{12}/g, 7 maskSymbol: '#', 8 maxCharsToMask: 35, 9 visibleCharsFromEnd: 4, 10 visibleCharsFromStart: 6, 11}
No vulnerabilities found.
No security vulnerabilities found.