maskdata 1.2.2 → 1.2.4

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/index.js CHANGED
@@ -7,14 +7,19 @@ const MaskString = require('./lib/maskService/StringMask');
7
7
  const MaskPassword = require('./lib/maskService/PasswordMask');
8
8
  const MaskUuid = require('./lib/maskService/UuidMask');
9
9
  const JsonMask = require('./lib/maskService/JsonMask');
10
+ const JwtMask = require('./lib/maskService/JwtMask');
10
11
  const JsonGetSet = require('./lib/helpers/jsonGetSet');
11
12
 
12
13
  class MaskData {
13
-
14
14
  static maskPassword(password, options) {
15
15
  return MaskPassword.maskPassword(password, options);
16
16
  }
17
17
 
18
+ /**
19
+ *
20
+ * @deprecated
21
+ * Use maskJSON2 instead: https://www.npmjs.com/package/maskdata#mask-json
22
+ */
18
23
  static maskJSONFields(json, options) {
19
24
  return JsonMask.maskJSONFields(json, options);
20
25
  }
@@ -43,6 +48,10 @@ class MaskData {
43
48
  return MaskUuid.maskUuid(uuid, options);
44
49
  }
45
50
 
51
+ static maskJwt(jwt, options) {
52
+ return JwtMask.maskJwt(jwt, options);
53
+ }
54
+
46
55
  static getInnerProperty(object, field) {
47
56
  return JsonGetSet.get(object, field);
48
57
  }
@@ -50,7 +59,6 @@ class MaskData {
50
59
  static replaceValue(object, field, value) {
51
60
  return JsonGetSet.set(object, field, value);
52
61
  }
53
-
54
62
  }
55
63
 
56
- module.exports = MaskData;
64
+ module.exports = MaskData;
@@ -5,8 +5,8 @@ class BadOption {
5
5
  }
6
6
 
7
7
  throwBadOptionException() {
8
- throw `Bad config value : ${JSON.stringify({where : this.where, reasons : this.reasons})}`;
8
+ throw `Bad config value : ${JSON.stringify({ where: this.where, reasons: this.reasons })}`;
9
9
  }
10
10
  }
11
11
 
12
- module.exports = BadOption;
12
+ module.exports = BadOption;
@@ -1,72 +1,81 @@
1
1
  const defaultCardMaskOptions = {
2
- maskWith: "*",
3
- unmaskedStartDigits: 4,
4
- unmaskedEndDigits: 1
2
+ maskWith: '*',
3
+ unmaskedStartDigits: 4,
4
+ unmaskedEndDigits: 1
5
5
  };
6
6
 
7
7
  const defaultEmailMask2Options = {
8
- maskWith: "*",
9
- unmaskedStartCharactersBeforeAt: 3,
10
- unmaskedEndCharactersAfterAt: 2,
11
- maskAtTheRate: false
12
- };
8
+ maskWith: '*',
9
+ unmaskedStartCharactersBeforeAt: 3,
10
+ unmaskedEndCharactersAfterAt: 2,
11
+ maskAtTheRate: false
12
+ };
13
+
14
+ const defaultJwtMaskOptions = {
15
+ maskWith: '*',
16
+ maxMaskedCharacters: 512,
17
+ maskDot: true,
18
+ maskHeader: true,
19
+ maskPayload: true,
20
+ maskSignature: true
21
+ };
13
22
 
14
23
  const defaultJsonMaskOptions = {
15
- maskWith: "*",
16
- fields: [],
17
- maxMaskedCharactersStr: -1
24
+ maskWith: '*',
25
+ fields: [],
26
+ maxMaskedCharactersStr: -1
18
27
  };
19
28
 
20
29
  const defaultPasswordMaskOptions = {
21
- maskWith: "*",
22
- maxMaskedCharacters: 16,
23
- unmaskedStartCharacters: 0,
24
- unmaskedEndCharacters: 0
30
+ maskWith: '*',
31
+ maxMaskedCharacters: 16,
32
+ unmaskedStartCharacters: 0,
33
+ unmaskedEndCharacters: 0
25
34
  };
26
35
 
27
36
  const defaultPhoneMaskOptions = {
28
- maskWith: "*",
29
- unmaskedStartDigits: 4,
30
- unmaskedEndDigits: 1
37
+ maskWith: '*',
38
+ unmaskedStartDigits: 4,
39
+ unmaskedEndDigits: 1
31
40
  };
32
41
 
33
42
  const defaultStringMaskOptions = {
34
- maskWith: "*",
35
- maskOnlyFirstOccurance: false,
36
- values: [],
37
- maskAll: false,
38
- maskSpace: true
43
+ maskWith: '*',
44
+ maskOnlyFirstOccurance: false,
45
+ values: [],
46
+ maskAll: false,
47
+ maskSpace: true
39
48
  };
40
49
 
41
50
  const defaultUuidMaskOptions = {
42
- maskWith: "*",
43
- unmaskedStartCharacters: 0,
44
- unmaskedEndCharacters: 0
51
+ maskWith: '*',
52
+ unmaskedStartCharacters: 0,
53
+ unmaskedEndCharacters: 0
45
54
  };
46
55
 
47
56
  const defaultjsonMask2Configs = {
48
- cardMaskOptions: defaultCardMaskOptions,
49
- cardFields: [],
50
- emailMaskOptions: defaultEmailMask2Options,
51
- emailFields: [],
52
- passwordMaskOptions: defaultPasswordMaskOptions,
53
- passwordFields: [],
54
- phoneMaskOptions: defaultPhoneMaskOptions,
55
- phoneFields: [],
56
- stringMaskOptions: defaultStringMaskOptions,
57
- stringFields: [],
58
- uuidMaskOptions: defaultUuidMaskOptions,
59
- uuidFields: []
57
+ cardMaskOptions: defaultCardMaskOptions,
58
+ cardFields: [],
59
+ emailMaskOptions: defaultEmailMask2Options,
60
+ emailFields: [],
61
+ passwordMaskOptions: defaultPasswordMaskOptions,
62
+ passwordFields: [],
63
+ phoneMaskOptions: defaultPhoneMaskOptions,
64
+ phoneFields: [],
65
+ stringMaskOptions: defaultStringMaskOptions,
66
+ stringFields: [],
67
+ uuidMaskOptions: defaultUuidMaskOptions,
68
+ uuidFields: []
60
69
  };
61
70
 
62
-
63
71
  module.exports = {
64
- defaultPhoneMaskOptions,
65
- defaultCardMaskOptions,
66
- defaultEmailMask2Options,
67
- defaultJsonMaskOptions,
68
- defaultPasswordMaskOptions,
69
- defaultStringMaskOptions,
70
- defaultUuidMaskOptions,
71
- defaultjsonMask2Configs
72
- }
72
+ defaultPhoneMaskOptions,
73
+ defaultCardMaskOptions,
74
+ defaultEmailMask2Options,
75
+ defaultJsonMaskOptions,
76
+ defaultPasswordMaskOptions,
77
+ defaultStringMaskOptions,
78
+ defaultUuidMaskOptions,
79
+ defaultjsonMask2Configs,
80
+ defaultJwtMaskOptions
81
+ };
@@ -1,11 +1,11 @@
1
+ const { isBoolean } = require('lodash');
1
2
  const BadOption = require('../ExceptionsHandler/BadOption');
2
3
  const Constants = require('./Constants');
3
4
 
4
5
  class MaskHelper {
5
-
6
6
  static mapWithDefaultValues(options, defaultOptions) {
7
- for(let key of Object.keys(defaultOptions)) {
8
- if(options[key] === undefined || options[key] === null) {
7
+ for (let key of Object.keys(defaultOptions)) {
8
+ if (options[key] === undefined || options[key] === null) {
9
9
  options[key] = defaultOptions[key];
10
10
  }
11
11
  }
@@ -14,30 +14,35 @@ class MaskHelper {
14
14
 
15
15
  static validatePasswordOptions(options) {
16
16
  let reasons = [];
17
- try{
17
+ try {
18
18
  options.maxMaskedCharacters = parseInt(options.maxMaskedCharacters);
19
19
  options.unmaskedStartCharacters = parseInt(options.unmaskedStartCharacters);
20
20
  options.unmaskedEndCharacters = parseInt(options.unmaskedEndCharacters);
21
- if(isNaN(options.maxMaskedCharacters) || isNaN(options.unmaskedStartCharacters) ||
22
- isNaN(options.unmaskedEndCharacters)) {
21
+ if (
22
+ isNaN(options.maxMaskedCharacters) ||
23
+ isNaN(options.unmaskedStartCharacters) ||
24
+ isNaN(options.unmaskedEndCharacters)
25
+ ) {
23
26
  throw Error();
24
- };
25
- } catch(err) {
26
- reasons.push('maxMaskedCharacters, unmaskedStartCharacters and unmaskedEndCharacters must be positive integer');
27
+ }
28
+ } catch (err) {
29
+ reasons.push(
30
+ 'maxMaskedCharacters, unmaskedStartCharacters and unmaskedEndCharacters must be positive integer'
31
+ );
27
32
  }
28
- if(options.maxMaskedCharacters < 0) {
33
+ if (options.maxMaskedCharacters < 0) {
29
34
  options.maxMaskedCharacters = 16;
30
35
  }
31
- if(options.unmaskedStartCharacters < 0) {
36
+ if (options.unmaskedStartCharacters < 0) {
32
37
  options.unmaskedStartCharacters = 0;
33
38
  }
34
- if(options.unmaskedEndCharacters < 0) {
39
+ if (options.unmaskedEndCharacters < 0) {
35
40
  options.unmaskedEndCharacters = 0;
36
41
  }
37
- if((!options.maskWith) || options.maskWith.toString().length <= 0) {
42
+ if (!options.maskWith || options.maskWith.toString().length <= 0) {
38
43
  options.maskWith = '*';
39
44
  }
40
- if(reasons.length > 0) {
45
+ if (reasons.length > 0) {
41
46
  const badOptions = new BadOption('Password mask configuration', reasons);
42
47
  badOptions.throwBadOptionException();
43
48
  }
@@ -45,25 +50,25 @@ class MaskHelper {
45
50
 
46
51
  static validatePhoneOptions(options) {
47
52
  let reasons = [];
48
- try{
53
+ try {
49
54
  options.unmaskedStartDigits = parseInt(options.unmaskedStartDigits);
50
55
  options.unmaskedEndDigits = parseInt(options.unmaskedEndDigits);
51
- if(isNaN(options.unmaskedStartDigits) || isNaN(options.unmaskedEndDigits)){
56
+ if (isNaN(options.unmaskedStartDigits) || isNaN(options.unmaskedEndDigits)) {
52
57
  throw Error();
53
- };
54
- }catch(err) {
58
+ }
59
+ } catch (err) {
55
60
  reasons.push('unmaskedStartDigits and unmaskedEndDigits must be positive integers');
56
61
  }
57
- if(options.unmaskedStartDigits < 0) {
62
+ if (options.unmaskedStartDigits < 0) {
58
63
  options.unmaskedStartDigits = 0;
59
64
  }
60
- if(options.unmaskedEndDigits < 0) {
65
+ if (options.unmaskedEndDigits < 0) {
61
66
  options.unmaskedEndDigits = 0;
62
67
  }
63
- if((!options.maskWith) || options.maskWith.toString().length <= 0) {
68
+ if (!options.maskWith || options.maskWith.toString().length <= 0) {
64
69
  options.maskWith = '*';
65
70
  }
66
- if(reasons.length > 0) {
71
+ if (reasons.length > 0) {
67
72
  const badOptions = new BadOption('Phone mask configuration', reasons);
68
73
  badOptions.throwBadOptionException();
69
74
  }
@@ -71,72 +76,87 @@ class MaskHelper {
71
76
 
72
77
  static validateEmailOptions(email, options) {
73
78
  let reasons = [];
74
- if(!email || email.indexOf('@') < 0) {
79
+ if (!email || email.indexOf('@') < 0) {
75
80
  reasons.push(`Email must contain one '@'`);
76
81
  }
77
- try{
82
+ try {
78
83
  options.unmaskedStartCharacters = parseInt(options.unmaskedStartCharacters);
79
84
  options.unmaskedEndCharacters = parseInt(options.unmaskedEndCharacters);
80
- options.maxMaskedCharactersBeforeAtTheRate = parseInt(options.maxMaskedCharactersBeforeAtTheRate);
81
- options.maxMaskedCharactersAfterAtTheRate = parseInt(options.maxMaskedCharactersAfterAtTheRate);
82
- if(isNaN(options.unmaskedStartCharacters) || isNaN(options.unmaskedEndCharacters) ||
83
- isNaN(options.maxMaskedCharactersBeforeAtTheRate) || isNaN(options.maxMaskedCharactersAfterAtTheRate)){
85
+ options.maxMaskedCharactersBeforeAtTheRate = parseInt(
86
+ options.maxMaskedCharactersBeforeAtTheRate
87
+ );
88
+ options.maxMaskedCharactersAfterAtTheRate = parseInt(
89
+ options.maxMaskedCharactersAfterAtTheRate
90
+ );
91
+ if (
92
+ isNaN(options.unmaskedStartCharacters) ||
93
+ isNaN(options.unmaskedEndCharacters) ||
94
+ isNaN(options.maxMaskedCharactersBeforeAtTheRate) ||
95
+ isNaN(options.maxMaskedCharactersAfterAtTheRate)
96
+ ) {
84
97
  throw Error();
85
- };
86
- }catch(err) {
87
- reasons.push('unmaskedStartCharacters, unmaskedEndCharacters, maxMaskedCharactersBeforeAtTheRate and maxMaskedCharactersAfterAtTheRate must be positive integers');
98
+ }
99
+ } catch (err) {
100
+ reasons.push(
101
+ 'unmaskedStartCharacters, unmaskedEndCharacters, maxMaskedCharactersBeforeAtTheRate and maxMaskedCharactersAfterAtTheRate must be positive integers'
102
+ );
88
103
  }
89
- if(options.unmaskedStartCharacters < 0) {
104
+ if (options.unmaskedStartCharacters < 0) {
90
105
  options.unmaskedStartCharacters = 0;
91
106
  }
92
- if(options.unmaskedEndCharacters < 0) {
107
+ if (options.unmaskedEndCharacters < 0) {
93
108
  options.unmaskedEndCharacters = 0;
94
109
  }
95
- if(options.maxMaskedCharactersBeforeAtTheRate < 0) {
110
+ if (options.maxMaskedCharactersBeforeAtTheRate < 0) {
96
111
  options.maxMaskedCharactersBeforeAtTheRate = 20;
97
112
  }
98
- if(options.maxMaskedCharactersAfterAtTheRate < 0) {
113
+ if (options.maxMaskedCharactersAfterAtTheRate < 0) {
99
114
  options.maxMaskedCharactersAfterAtTheRate = 20;
100
115
  }
101
- if((!options.maskWith) || options.maskWith.toString().length <= 0) {
116
+ if (!options.maskWith || options.maskWith.toString().length <= 0) {
102
117
  options.maskWith = '*';
103
118
  }
104
- if(typeof(options.maskAtTheRate) !== 'boolean') {
119
+ if (typeof options.maskAtTheRate !== 'boolean') {
105
120
  reasons.push('maskAtTheRate should be a boolean field');
106
121
  }
107
- if(reasons.length > 0) {
122
+ if (reasons.length > 0) {
108
123
  const badOptions = new BadOption('Email mask configuration', reasons);
109
124
  badOptions.throwBadOptionException();
110
125
  }
111
126
  }
112
-
127
+
113
128
  static validateEmailOptions2(email, options) {
114
129
  let reasons = [];
115
- if(!email || email.indexOf('@') < 0) {
130
+ if (!email || email.indexOf('@') < 0) {
116
131
  reasons.push(`Email must contain one '@'`);
117
132
  }
118
- try{
133
+ try {
119
134
  options.unmaskedStartCharactersBeforeAt = parseInt(options.unmaskedStartCharactersBeforeAt);
120
135
  options.unmaskedEndCharactersAfterAt = parseInt(options.unmaskedEndCharactersAfterAt);
121
- if(isNaN(options.unmaskedStartCharactersBeforeAt) || isNaN(options.unmaskedEndCharactersAfterAt)){
136
+ if (
137
+ isNaN(options.unmaskedStartCharactersBeforeAt) ||
138
+ isNaN(options.unmaskedEndCharactersAfterAt)
139
+ ) {
122
140
  throw Error();
123
- };
124
- }catch(err) {
125
- reasons.push('unmaskedStartCharactersBeforeAt, unmaskedEndCharactersAfterAt must be positive integers');
141
+ }
142
+ } catch (err) {
143
+ reasons.push(
144
+ 'unmaskedStartCharactersBeforeAt, unmaskedEndCharactersAfterAt must be positive integers'
145
+ );
126
146
  }
127
- if(options.unmaskedStartCharactersBeforeAt < 0) {
147
+ if (options.unmaskedStartCharactersBeforeAt < 0) {
128
148
  options.unmaskedStartCharactersBeforeAt = 0;
129
149
  }
130
- if(options.unmaskedEndCharactersAfterAt < 0) {
150
+ if (options.unmaskedEndCharactersAfterAt < 0) {
131
151
  options.unmaskedEndCharactersAfterAt = 0;
132
152
  }
133
- if((!options.maskWith) || options.maskWith.toString().length <= 0) {
153
+ if (!options.maskWith || options.maskWith.toString().length <= 0) {
134
154
  options.maskWith = '*';
135
155
  }
136
- if(typeof(options.maskAtTheRate) !== 'boolean') {
156
+ if (typeof options.maskAtTheRate !== 'boolean') {
137
157
  reasons.push('maskAtTheRate should be a boolean field');
138
158
  }
139
- if(reasons.length > 0) {
159
+ if (reasons.length > 0) {
140
160
  const badOptions = new BadOption('Email mask configuration', reasons);
141
161
  badOptions.throwBadOptionException();
142
162
  }
@@ -144,16 +164,20 @@ class MaskHelper {
144
164
 
145
165
  static validateJSONOptions(options) {
146
166
  let reasons = [];
147
- if(!(options.fields instanceof Array)) {
167
+ if (!(options.fields instanceof Array)) {
148
168
  reasons.push(`fields should be an Array`);
149
169
  }
150
- if((!options.maskWith) || options.maskWith.toString().length <= 0) {
170
+ if (!options.maskWith || options.maskWith.toString().length <= 0) {
151
171
  options.maskWith = '*';
152
172
  }
153
- if(!options.maxMaskedCharactersStr || typeof(options.maxMaskedCharactersStr) !== 'number' || options.maxMaskedCharactersStr <= 0) {
173
+ if (
174
+ !options.maxMaskedCharactersStr ||
175
+ typeof options.maxMaskedCharactersStr !== 'number' ||
176
+ options.maxMaskedCharactersStr <= 0
177
+ ) {
154
178
  options.maxMaskedCharactersStr = -1;
155
179
  }
156
- if(reasons.length > 0) {
180
+ if (reasons.length > 0) {
157
181
  const badOptions = new BadOption('JSON mask configuration', reasons);
158
182
  badOptions.throwBadOptionException();
159
183
  }
@@ -161,22 +185,22 @@ class MaskHelper {
161
185
 
162
186
  static validateStringOptions(options) {
163
187
  let reasons = [];
164
- if(!(options.values instanceof Array)) {
188
+ if (!(options.values instanceof Array)) {
165
189
  reasons.push(`values should be an Array`);
166
190
  }
167
- if(typeof(options.maskOnlyFirstOccurance) !== 'boolean') {
191
+ if (typeof options.maskOnlyFirstOccurance !== 'boolean') {
168
192
  reasons.push('maskOnlyFirstOccurance should be a boolean field');
169
193
  }
170
- if(typeof(options.maskAll) !== 'boolean') {
194
+ if (typeof options.maskAll !== 'boolean') {
171
195
  reasons.push('maskAll should be a boolean field');
172
196
  }
173
- if(typeof(options.maskSpace) !== 'boolean') {
197
+ if (typeof options.maskSpace !== 'boolean') {
174
198
  reasons.push('maskSpace should be a boolean field');
175
199
  }
176
- if((!options.maskWith) || options.maskWith.toString().length <= 0) {
200
+ if (!options.maskWith || options.maskWith.toString().length <= 0) {
177
201
  options.maskWith = '*';
178
202
  }
179
- if(reasons.length > 0) {
203
+ if (reasons.length > 0) {
180
204
  const badOptions = new BadOption('string mask configuration', reasons);
181
205
  badOptions.throwBadOptionException();
182
206
  }
@@ -184,114 +208,151 @@ class MaskHelper {
184
208
 
185
209
  static validateUuidMaskOptions(options) {
186
210
  let reasons = [];
187
- try{
211
+ try {
188
212
  options.unmaskedStartCharacters = parseInt(options.unmaskedStartCharacters);
189
213
  options.unmaskedEndCharacters = parseInt(options.unmaskedEndCharacters);
190
- if(isNaN(options.unmaskedStartCharacters) || isNaN(options.unmaskedEndCharacters)){
214
+ if (isNaN(options.unmaskedStartCharacters) || isNaN(options.unmaskedEndCharacters)) {
191
215
  throw Error();
192
- };
193
- }catch(err) {
216
+ }
217
+ } catch (err) {
194
218
  reasons.push('unmaskedStartCharacters, unmaskedEndCharacters must be positive integers');
195
219
  }
196
220
 
197
- if(options.unmaskedStartCharacters > 32 || options.unmaskedEndCharacters > 32) {
221
+ if (options.unmaskedStartCharacters > 32 || options.unmaskedEndCharacters > 32) {
198
222
  options.unmaskedStartCharacters = 32;
199
223
  options.unmaskedEndCharacters = 0;
200
224
  }
201
-
202
- if((!options.maskWith) || options.maskWith.toString().length <= 0) {
225
+
226
+ if (!options.maskWith || options.maskWith.toString().length <= 0) {
203
227
  options.maskWith = '*';
204
228
  }
205
- if(reasons.length > 0) {
229
+ if (reasons.length > 0) {
206
230
  const badOptions = new BadOption('Uuid mask configuration: ', reasons);
207
231
  badOptions.throwBadOptionException();
208
232
  }
209
233
  }
210
234
 
235
+ static validateJwtMaskOptions(options) {
236
+ let reasons = [];
237
+ try {
238
+ options.maxMaskedCharacters = parseInt(options.maxMaskedCharacters);
239
+ if (isNaN(options.maxMaskedCharacters)) {
240
+ throw Error();
241
+ }
242
+ } catch (err) {
243
+ reasons.push('maxMaskedCharacters must be a positive integera');
244
+ }
245
+
246
+ if (options.maskDot === null || options.maskDot === undefined) {
247
+ options.maskDot = true;
248
+ }
249
+
250
+ if (options.maskHeader === null || options.maskHeader === undefined) {
251
+ options.maskHeader = true;
252
+ }
253
+
254
+ if (options.maskPayload === null || options.maskPayload === undefined) {
255
+ options.maskPayload = true;
256
+ }
257
+
258
+ if (options.maskSignature === null || options.maskSignature === undefined) {
259
+ options.maskSignature = true;
260
+ }
261
+
262
+ if (!options.maskWith || options.maskWith.toString().length === 0) {
263
+ options.maskWith = '*';
264
+ }
265
+ if (reasons.length > 0) {
266
+ const badOptions = new BadOption('Jwt mask configuration: ', reasons);
267
+ badOptions.throwBadOptionException();
268
+ }
269
+ }
270
+
211
271
  static validateCardMaskOptions(options, cardLength) {
212
272
  let reasons = [];
213
- try{
273
+ try {
214
274
  options.unmaskedStartDigits = parseInt(options.unmaskedStartDigits);
215
275
  options.unmaskedEndDigits = parseInt(options.unmaskedEndDigits);
216
- if(isNaN(options.unmaskedStartDigits) || isNaN(options.unmaskedEndDigits)){
276
+ if (isNaN(options.unmaskedStartDigits) || isNaN(options.unmaskedEndDigits)) {
217
277
  throw Error();
218
- };
219
- }catch(err) {
278
+ }
279
+ } catch (err) {
220
280
  reasons.push('unmaskedStartDigits and unmaskedEndDigits must be positive integers');
221
281
  }
222
- if(options.unmaskedStartDigits < 0) {
282
+ if (options.unmaskedStartDigits < 0) {
223
283
  options.unmaskedStartDigits = 0;
224
- } else if(options.unmaskedStartDigits > cardLength) {
284
+ } else if (options.unmaskedStartDigits > cardLength) {
225
285
  options.unmaskedStartDigits = cardLength;
226
286
  }
227
- if(options.unmaskedEndDigits < 0) {
287
+ if (options.unmaskedEndDigits < 0) {
228
288
  options.unmaskedEndDigits = 0;
229
- } else if(options.unmaskedEndDigits > cardLength) {
289
+ } else if (options.unmaskedEndDigits > cardLength) {
230
290
  options.unmaskedEndDigits = cardLength;
231
291
  }
232
- if((!options.maskWith) || options.maskWith.toString().length <= 0) {
292
+ if (!options.maskWith || options.maskWith.toString().length <= 0) {
233
293
  options.maskWith = '*';
234
294
  }
235
- if(reasons.length > 0) {
295
+ if (reasons.length > 0) {
236
296
  const badOptions = new BadOption('Phone mask configuration', reasons);
237
297
  badOptions.throwBadOptionException();
238
298
  }
239
299
  }
240
300
 
241
301
  static getValidatedJsonMask2Configs(configs) {
242
- if(!configs) return JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
302
+ if (!configs) return JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
243
303
 
244
- if(!configs.cardMaskOptions) {
304
+ if (!configs.cardMaskOptions) {
245
305
  configs.cardMaskOptions = JSON.parse(JSON.stringify(Constants.defaultCardMaskOptions));
246
306
  }
247
307
 
248
- if(!configs.cardFields) {
308
+ if (!configs.cardFields) {
249
309
  configs.cardFields = [];
250
310
  }
251
311
 
252
- if(!configs.emailFields) {
312
+ if (!configs.emailFields) {
253
313
  configs.emailFields = [];
254
314
  }
255
315
 
256
- if(!configs.passwordFields) {
316
+ if (!configs.passwordFields) {
257
317
  configs.passwordFields = [];
258
318
  }
259
319
 
260
- if(!configs.phoneFields) {
320
+ if (!configs.phoneFields) {
261
321
  configs.phoneFields = [];
262
322
  }
263
323
 
264
- if(!configs.stringFields) {
324
+ if (!configs.stringFields) {
265
325
  configs.stringFields = [];
266
326
  }
267
327
 
268
- if(!configs.uuidFields) {
328
+ if (!configs.uuidFields) {
269
329
  configs.uuidFields = [];
270
330
  }
271
331
 
272
- if(!configs.emailMaskOptions) {
332
+ if (!configs.emailMaskOptions) {
273
333
  configs.emailMaskOptions = JSON.parse(JSON.stringify(Constants.defaultEmailMask2Options));
274
334
  }
275
335
 
276
- if(!configs.passwordMaskOptions) {
277
- configs.passwordMaskOptions = JSON.parse(JSON.stringify(Constants.defaultPasswordMaskOptions));
336
+ if (!configs.passwordMaskOptions) {
337
+ configs.passwordMaskOptions = JSON.parse(
338
+ JSON.stringify(Constants.defaultPasswordMaskOptions)
339
+ );
278
340
  }
279
341
 
280
- if(!configs.phoneMaskOptions) {
342
+ if (!configs.phoneMaskOptions) {
281
343
  configs.phoneMaskOptions = JSON.parse(JSON.stringify(Constants.defaultPhoneMaskOptions));
282
344
  }
283
345
 
284
- if(!configs.stringMaskOptions) {
346
+ if (!configs.stringMaskOptions) {
285
347
  configs.stringMaskOptions = JSON.parse(JSON.stringify(Constants.defaultStringMaskOptions));
286
348
  }
287
349
 
288
- if(!configs.uuidMaskOptions) {
350
+ if (!configs.uuidMaskOptions) {
289
351
  configs.uuidMaskOptions = JSON.parse(JSON.stringify(Constants.defaultUuidMaskOptions));
290
352
  }
291
-
353
+
292
354
  return configs;
293
355
  }
294
-
295
356
  }
296
357
 
297
- module.exports = MaskHelper;
358
+ module.exports = MaskHelper;
@@ -1,14 +1,13 @@
1
- const {get, set} = require('lodash');
1
+ const { get, set } = require('lodash');
2
2
 
3
3
  class JsonGetSet {
4
- static get(object, field) {
5
- return get(object, field);
6
- }
4
+ static get(object, field) {
5
+ return get(object, field);
6
+ }
7
7
 
8
- static set(object, field, value) {
9
- return set(object, field, value);
10
- }
8
+ static set(object, field, value) {
9
+ return set(object, field, value);
10
+ }
11
11
  }
12
12
 
13
- module.exports = JsonGetSet
14
-
13
+ module.exports = JsonGetSet;