maskdata 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MASKDATA_FOR_TYPESCRIPT.md +22 -9
- package/README.md +23 -7
- package/index.d.ts +2 -0
- package/lib/helpers/Constants.js +3 -1
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ console.log(maskedPassword);
|
|
|
23
23
|
|
|
24
24
|
## Available mask configs/option
|
|
25
25
|
### 1. PasswordMaskOptions
|
|
26
|
-
|
|
26
|
+
Usage: [Password Masking](./README.md#mask-password)
|
|
27
27
|
```javascript
|
|
28
28
|
{
|
|
29
29
|
maskWith?: string;
|
|
@@ -34,7 +34,7 @@ Used in [Password Masking](#mask-password)
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### 2. CardMaskOptions
|
|
37
|
-
|
|
37
|
+
Usage: [Card masking](./README.md#mask-card-number)
|
|
38
38
|
```javascript
|
|
39
39
|
{
|
|
40
40
|
maskWith?: string;
|
|
@@ -44,7 +44,7 @@ Used in [Card masking](./README.md#mask-card-number)
|
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
### 3. EmailMask2Options
|
|
47
|
-
|
|
47
|
+
Usage: [Email masking](./README.md#mask-email-id)
|
|
48
48
|
```javascript
|
|
49
49
|
{
|
|
50
50
|
maskWith?: string;
|
|
@@ -55,7 +55,7 @@ Used in [Email masking](./README.md#mask-email-id)
|
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
### 4. PhoneMaskOptions
|
|
58
|
-
|
|
58
|
+
Usage: [Phone Number Masking](./README.md#mask-phone-number)
|
|
59
59
|
```javascript
|
|
60
60
|
{
|
|
61
61
|
maskWith?: string;
|
|
@@ -64,7 +64,7 @@ Used in [Phone Number Masking](#mask-phone-number)
|
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
66
|
### 5. StringMaskOptions
|
|
67
|
-
|
|
67
|
+
Usage: [String masking](./README.md#mask-the-characters-or-words-in-the-string)
|
|
68
68
|
```javascript
|
|
69
69
|
{
|
|
70
70
|
maskWith?: string;
|
|
@@ -76,7 +76,7 @@ Used in [String masking](./README.md#mask-the-characters-or-words-in-the-string)
|
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
### 6. UuidMaskOptions
|
|
79
|
-
|
|
79
|
+
Usage: [UUID Masking](./README.md#mask-uuid)
|
|
80
80
|
```javascript
|
|
81
81
|
{
|
|
82
82
|
maskWith?: string;
|
|
@@ -86,7 +86,7 @@ Used in [UUID Masking](#mask-uuid)
|
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
### 7. JsonMask2Configs
|
|
89
|
-
|
|
89
|
+
Usage: [JSON fields masking](./README.md#mask-json)
|
|
90
90
|
```javascript
|
|
91
91
|
{
|
|
92
92
|
cardMaskOptions?: CardMaskOptions;
|
|
@@ -101,12 +101,25 @@ Used in [JSON fields masking](#mask-json)
|
|
|
101
101
|
stringFields?: string[];
|
|
102
102
|
uuidMaskOptions?: UuidMaskOptions;
|
|
103
103
|
uuidFields?: string[];
|
|
104
|
+
jwtMaskOptions?: JwtMaskOptions;
|
|
105
|
+
jwtFields?: string[];
|
|
104
106
|
}
|
|
105
107
|
```
|
|
106
|
-
|
|
108
|
+
### 8. Mask JWT
|
|
109
|
+
Usage: [JWT masking](./README.md#mask-jwt-token)
|
|
110
|
+
```javascript
|
|
111
|
+
const defaultJwtMaskOptions = {
|
|
112
|
+
maskWith: '*',
|
|
113
|
+
maxMaskedCharacters: 512,
|
|
114
|
+
maskDot: true,
|
|
115
|
+
maskHeader: true,
|
|
116
|
+
maskPayload: true,
|
|
117
|
+
maskSignature: true
|
|
118
|
+
};
|
|
119
|
+
```
|
|
107
120
|
<br/>
|
|
108
121
|
|
|
109
122
|
## Available functions to import along with their configs
|
|
110
123
|
```javascript
|
|
111
|
-
import { maskPassword, PasswordMaskOptions, maskJSON2, JsonMask2Configs, maskPhone, PhoneMaskOptions, maskEmail2, EmailMask2Options, maskCard, CardMaskOptions, maskString, StringMaskOptions, maskUuid, UuidMaskOptions, getInnerProperty, replaceValue } from 'maskdata';
|
|
124
|
+
import { maskPassword, PasswordMaskOptions, maskJSON2, JsonMask2Configs, maskPhone, PhoneMaskOptions, maskEmail2, EmailMask2Options, maskCard, CardMaskOptions, maskString, StringMaskOptions, maskUuid, UuidMaskOptions, maskJwt, JwtMaskOptions, getInnerProperty, replaceValue } from 'maskdata';
|
|
112
125
|
```
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ maskdata is a Node.js module to mask various kinds of data. With the help of mas
|
|
|
4
4
|
# Table of Contents
|
|
5
5
|
- [Features](#features)
|
|
6
6
|
- [Install maskdata](#install-maskdata)
|
|
7
|
-
- [Version 1.2.
|
|
7
|
+
- [Version 1.2.6 Features](#release-features)
|
|
8
8
|
- [How to Use](#how-to-use)
|
|
9
9
|
- [Maskdata for Typescript](#maskdata-for-typescript)
|
|
10
10
|
- [Mask Card number](#mask-card-number)
|
|
@@ -43,7 +43,7 @@ maskdata is a Node.js module to mask various kinds of data. With the help of mas
|
|
|
43
43
|
> npm i maskdata
|
|
44
44
|
|
|
45
45
|
# Release Features
|
|
46
|
-
### Version 1.2.
|
|
46
|
+
### Version 1.2.6
|
|
47
47
|
- JWT token masking: Mask JWT tokens with configs to mask as per your need. More details: [Mask JWT Token](#mask-jwt-token)
|
|
48
48
|
- Mask Json now supports JWT token masking also. More details: [Mask JWT in a JSON](#mask-json)
|
|
49
49
|
- Bug fix in maskJson2 where it was not checking for the empty/null/undefined fields and was resulting in error `"TypeError: validatedConfig[typeToFunctionMap[key][1]] is not iterable"`
|
|
@@ -195,13 +195,13 @@ const defaultjsonMask2Configs = {
|
|
|
195
195
|
stringFields: [], // List of String fields to be masked
|
|
196
196
|
|
|
197
197
|
uuidMaskOptions: defaultUuidMaskOptions, // Optional
|
|
198
|
-
uuidFields: [] // List of UUID fields to be masked
|
|
198
|
+
uuidFields: [], // List of UUID fields to be masked
|
|
199
199
|
|
|
200
200
|
jwtMaskOptions: defaultJwtMaskOptions, // Optional
|
|
201
201
|
jwtFields: [] // List of JWT fields to be masked
|
|
202
202
|
};
|
|
203
203
|
```
|
|
204
|
-
<b>NOTE: For defaultCardMaskOptions, defaultEmailMask2Options, defaultPasswordMaskOptions, defaultPhoneMaskOptions, defaultStringMaskOptions and
|
|
204
|
+
<b>NOTE: For defaultCardMaskOptions, defaultEmailMask2Options, defaultPasswordMaskOptions, defaultPhoneMaskOptions, defaultStringMaskOptions, defaultUuidMaskOptions and defaultJwtMaskOptions refer corresponding masking features. </b>
|
|
205
205
|
|
|
206
206
|
```javascript
|
|
207
207
|
const defaultjsonMask2Configs = {
|
|
@@ -249,7 +249,17 @@ const defaultjsonMask2Configs = {
|
|
|
249
249
|
unmaskedStartCharacters: 0,
|
|
250
250
|
unmaskedEndCharacters: 0
|
|
251
251
|
},
|
|
252
|
-
uuidFields: []
|
|
252
|
+
uuidFields: [],
|
|
253
|
+
|
|
254
|
+
jwtMaskOptions: {
|
|
255
|
+
maskWith: '*',
|
|
256
|
+
maxMaskedCharacters: 512,
|
|
257
|
+
maskDot: true,
|
|
258
|
+
maskHeader: true,
|
|
259
|
+
maskPayload: true,
|
|
260
|
+
maskSignature: true
|
|
261
|
+
},
|
|
262
|
+
jwtFields: [],
|
|
253
263
|
};
|
|
254
264
|
|
|
255
265
|
```
|
|
@@ -387,7 +397,8 @@ const jsonInput2 = {
|
|
|
387
397
|
},
|
|
388
398
|
uuids: {
|
|
389
399
|
uuid1: '123e4567-e89b-12d3-a456-426614174000'
|
|
390
|
-
}
|
|
400
|
+
},
|
|
401
|
+
jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjJ9.tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ'
|
|
391
402
|
};
|
|
392
403
|
|
|
393
404
|
const jsonMaskConfig2 = {
|
|
@@ -414,6 +425,10 @@ const jsonMaskConfig2 = {
|
|
|
414
425
|
// UUID
|
|
415
426
|
uuidMaskOptions: { maskWith: "*", unmaskedStartCharacters: 4, unmaskedEndCharacters: 2 },
|
|
416
427
|
uuidFields: ['uuids.uuid1']
|
|
428
|
+
|
|
429
|
+
// JWT
|
|
430
|
+
jwtMaskOptions: { maskWith: '*', maxMaskedCharacters: 512, maskDot: true, maskHeader: true, maskPayload: true, maskSignature: true},
|
|
431
|
+
jwtFields: ['jwt']
|
|
417
432
|
};
|
|
418
433
|
|
|
419
434
|
const maskedJsonOutput2 = MaskData.maskJSON2(jsonInput2, jsonMaskConfig2);
|
|
@@ -433,7 +448,8 @@ const maskedJsonOutput2 = MaskData.maskJSON2(jsonInput2, jsonMaskConfig2);
|
|
|
433
448
|
addressLine1: '**** ** ** *********** ** **** ** ** ****',
|
|
434
449
|
addressLine2: '*********** *'
|
|
435
450
|
},
|
|
436
|
-
uuids: { uuid1: '123e****-****-****-****-**********00' }
|
|
451
|
+
uuids: { uuid1: '123e****-****-****-****-**********00' },
|
|
452
|
+
jwt: '*********************************************************************************************************'
|
|
437
453
|
}
|
|
438
454
|
|
|
439
455
|
```
|
package/index.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ declare module 'maskdata' {
|
|
|
67
67
|
stringFields?: string[];
|
|
68
68
|
uuidMaskOptions?: UuidMaskOptions;
|
|
69
69
|
uuidFields?: string[];
|
|
70
|
+
jwtMaskOptions?: JwtMaskOptions;
|
|
71
|
+
jwtFields?: string[];
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
export function maskPassword(password?: string, options?: PasswordMaskOptions): string;
|
package/lib/helpers/Constants.js
CHANGED
|
@@ -65,7 +65,9 @@ const defaultjsonMask2Configs = {
|
|
|
65
65
|
stringMaskOptions: defaultStringMaskOptions,
|
|
66
66
|
stringFields: [],
|
|
67
67
|
uuidMaskOptions: defaultUuidMaskOptions,
|
|
68
|
-
uuidFields: []
|
|
68
|
+
uuidFields: [],
|
|
69
|
+
jwtMaskOptions: defaultJwtMaskOptions,
|
|
70
|
+
jwtFields: []
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
module.exports = {
|