maskdata 1.2.2 → 1.2.3

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.
@@ -6,194 +6,372 @@ const maskData = require('../index');
6
6
  const Constants = require('../lib/helpers/Constants');
7
7
 
8
8
  const jsonInput = {
9
- 'credit': '1234-5678-8765-1234',
10
- 'debit': '0000-1111-2222-3333',
11
- 'primaryEmail': 'primary@Email.com',
12
- 'secondaryEmail': 'secondary@Email.com',
13
- 'password': 'dummyPassword',
14
- 'homePhone': "+1 1234567890",
15
- 'workPhone': "+1 9876543210",
16
- 'addressLine1': "This is my addressline 1. This is my home",
17
- 'addressLine2': "AddressLine 2",
18
- 'uuid1': '123e4567-e89b-12d3-a456-426614174000'
9
+ credit: '1234-5678-8765-1234',
10
+ debit: '0000-1111-2222-3333',
11
+ primaryEmail: 'primary@Email.com',
12
+ secondaryEmail: 'secondary@Email.com',
13
+ password: 'dummyPassword',
14
+ homePhone: '+1 1234567890',
15
+ workPhone: '+1 9876543210',
16
+ addressLine1: 'This is my addressline 1. This is my home',
17
+ addressLine2: 'AddressLine 2',
18
+ uuid1: '123e4567-e89b-12d3-a456-426614174000'
19
19
  };
20
20
 
21
- describe('JSON mask1', function() {
22
- describe('Mask json with default options', function() {
21
+ const jsonInput2 = {
22
+ cards: {
23
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222'],
24
+ debitCards: ['0000-1111-2222-3333', '2222-1111-3333-4444']
25
+ },
26
+ emails: {
27
+ primaryEmail: 'primary@Email.com',
28
+ secondaryEmail: 'secondary@Email.com'
29
+ },
30
+ passwords: [['dummyPasswordANDdummyPassword', 'dummyPasswordANDdummyPassword']],
31
+ phones: {
32
+ homePhone: '+1 1234567890',
33
+ workPhone: '+1 9876543210'
34
+ },
35
+ address: {
36
+ addressLine1: 'This is my addressline 1. This is my home',
37
+ addressLine2: 'AddressLine 2'
38
+ },
39
+ string1: [
40
+ {
41
+ id: '1111',
42
+ name: 'Test',
43
+ primaryEmail: 'primary@Email.com',
44
+ items: [
45
+ {
46
+ id: '11111',
47
+ passwords: ['dummyPasswordANDdummyPassword', 'dummyPasswordANDdummyPassword'],
48
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222'],
49
+ phone: '+1 1234567890',
50
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
51
+ primaryEmail: 'primary@Email.com',
52
+ name: '11111',
53
+ child: [
54
+ {
55
+ child1: 'child1111111',
56
+ phone: '+1 1234567890',
57
+ passwords: ['dummyPasswordANDdummyPassword', 'dummyPasswordANDdummyPassword'],
58
+ primaryEmail: 'primary@Email.com',
59
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222']
60
+ },
61
+ {
62
+ child1: 'child2222222',
63
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222']
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ id: '11112',
69
+ phone: '+1 1234567890',
70
+ name: '11112',
71
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
72
+ primaryEmail: 'primary@Email.com',
73
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222'],
74
+ child: [
75
+ {
76
+ child1: 'child1111111',
77
+ passwords: ['dummyPasswordANDdummyPassword', 'dummyPasswordANDdummyPassword'],
78
+ primaryEmail: 'primary@Email.com',
79
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222'],
80
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
81
+ phone: '+1 1234567890'
82
+ },
83
+ {
84
+ child1: 'child2222222',
85
+ primaryEmail: 'a@b.c',
86
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222'],
87
+ phone: '+1 1234567890',
88
+ uuid1: '123e4567-e89b-12d3-a456-426614174000'
89
+ }
90
+ ]
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ id: '2222',
96
+ name: 'Test',
97
+ items: [
98
+ {
99
+ id: '22221',
100
+ phone: '+1 1234567890',
101
+ passwords: ['dummyPasswordANDdummyPassword', 'dummyPasswordANDdummyPassword'],
102
+ name: '22221',
103
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
104
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222'],
105
+ child: [
106
+ {
107
+ child1: 'child1111111',
108
+ phone: '+1 1234567890',
109
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
110
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222']
111
+ },
112
+ {
113
+ child1: 'child2222222',
114
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
115
+ passwords: ['dummyPasswordANDdummyPassword', 'dummyPasswordANDdummyPassword'],
116
+ phone: '+1 1234567890',
117
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222']
118
+ }
119
+ ]
120
+ },
121
+ {
122
+ id: '22222',
123
+ name: '22222',
124
+ phone: '+1 1234567890',
125
+ primaryEmail: 'primary@Email.com',
126
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
127
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222'],
128
+ child: [
129
+ {
130
+ child1: 'child1111111',
131
+ phone: '+1 1234567890',
132
+ passwords: ['dummyPasswordANDdummyPassword', 'dummyPasswordANDdummyPassword'],
133
+ primaryEmail: 'primary@Email.com',
134
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
135
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222']
136
+ },
137
+ {
138
+ child1: 'child2222222',
139
+ phone: '+1 1234567890',
140
+ passwords: ['dummyPasswordANDdummyPassword', 'dummyPasswordANDdummyPassword'],
141
+ uuid1: '123e4567-e89b-12d3-a456-426614174000',
142
+ creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222']
143
+ }
144
+ ]
145
+ }
146
+ ]
147
+ }
148
+ ],
149
+ uuids: {
150
+ uuid1: '123e4567-e89b-12d3-a456-426614174000'
151
+ }
152
+ };
153
+
154
+ describe('JSON mask1', function () {
155
+ describe('Mask json with default options', function () {
23
156
  let testData = {
24
- title: "Mask json with default options",
157
+ title: 'Mask json with default options',
25
158
  input: {
26
159
  level1: {
27
- field1: "field1Value",
160
+ field1: 'field1Value',
28
161
  level2: {
29
- field2: "field2Value",
30
- field3: [ { Hello: "Hello", Hi: "one" }, { Hello: "Hello again" } ],
162
+ field2: 'field2Value',
163
+ field3: [{ Hello: 'Hello', Hi: 'one' }, { Hello: 'Hello again' }],
31
164
  level3: {
32
- field4: "field4Value",
33
- field5: "field5Value"
165
+ field4: 'field4Value',
166
+ field5: 'field5Value'
34
167
  }
35
168
  }
36
169
  },
37
- value1: "value"
170
+ value1: 'value'
38
171
  }
39
- }
172
+ };
40
173
 
41
- it(`${testData.title}`, function() {
174
+ it(`${testData.title}`, function () {
42
175
  const jsonMaskConfig = {
43
- fields : ['level1.level2.field3[*].Hello', 'level1.level2.level3.*', 'value1']
176
+ fields: ['level1.level2.field3[*].Hello', 'level1.level2.level3.*', 'value1']
44
177
  };
45
178
  const masked = maskData.maskJSONFields(testData.input, jsonMaskConfig);
46
- expect(masked['level1']['level2']['field3'][0]['Hello']).to.equal("*****");
47
- expect(masked['level1']['level2']['field3'][1]['Hello']).to.equal("***********");
48
- expect(masked['level1']['level2']['level3']['field4']).to.equal("***********");
49
- expect(masked['level1']['level2']['level3']['field5']).to.equal("***********");
50
- expect(masked['value1']).to.equal("*****");
179
+ expect(masked['level1']['level2']['field3'][0]['Hello']).to.equal('*****');
180
+ expect(masked['level1']['level2']['field3'][1]['Hello']).to.equal('***********');
181
+ expect(masked['level1']['level2']['level3']['field4']).to.equal('***********');
182
+ expect(masked['level1']['level2']['level3']['field5']).to.equal('***********');
183
+ expect(masked['value1']).to.equal('*****');
51
184
  });
52
185
 
53
- it('Mask json with maxMaskedCharactersStr', function() {
186
+ it('Mask json with maxMaskedCharactersStr', function () {
54
187
  const jsonMaskConfig = {
55
- fields : ['key1'],
188
+ fields: ['key1'],
56
189
  maxMaskedCharactersStr: 10
57
190
  };
58
- const masked = maskData.maskJSONFields({key1: "value1WithTooManyCharacters"}, jsonMaskConfig);
59
- expect(masked['key1']).to.equal("**********");
191
+ const masked = maskData.maskJSONFields(
192
+ { key1: 'value1WithTooManyCharacters' },
193
+ jsonMaskConfig
194
+ );
195
+ expect(masked['key1']).to.equal('**********');
60
196
  });
61
197
  });
62
198
 
63
- describe('Mask json without passing configs', function() {
199
+ describe('Mask json without passing configs', function () {
64
200
  let testData = {
65
- title: "Mask json with default options",
201
+ title: 'Mask json with default options',
66
202
  input: {
67
203
  level1: {
68
- field1: "field1Value",
204
+ field1: 'field1Value',
69
205
  level2: {
70
- field2: "field2Value",
71
- field3: [ { Hello: "Hello", Hi: "one" }, { Hello: "Hello again" }, { NoHello: "No Hello"} ],
206
+ field2: 'field2Value',
207
+ field3: [
208
+ { Hello: 'Hello', Hi: 'one' },
209
+ { Hello: 'Hello again' },
210
+ { NoHello: 'No Hello' }
211
+ ],
72
212
  level3: {
73
- field4: "field4Value",
74
- field5: "field5Value"
213
+ field4: 'field4Value',
214
+ field5: 'field5Value'
75
215
  }
76
216
  }
77
217
  },
78
- value1: "value"
218
+ value1: 'value'
79
219
  }
80
- }
220
+ };
81
221
 
82
- it(`${testData.title}`, function() {
222
+ it(`${testData.title}`, function () {
83
223
  const jsonMaskConfig = {
84
- fields : ['level1.level2.field3[*].Hello', 'level1.level2.level3.*', 'value1', 'unknownField']
224
+ fields: [
225
+ 'level1.level2.field3[*].Hello',
226
+ 'level1.level2.level3.*',
227
+ 'value1',
228
+ 'unknownField'
229
+ ]
85
230
  };
86
231
  const masked = maskData.maskJSONFields(testData.input);
87
- expect(masked['level1']['level2']['field3'][0]['Hello']).to.equal(testData.input['level1']['level2']['field3'][0]['Hello']);
88
- expect(masked['level1']['level2']['field3'][1]['Hello']).to.equal(testData.input['level1']['level2']['field3'][1]['Hello']);
89
- expect(masked['level1']['level2']['level3']['field4']).to.equal(testData.input['level1']['level2']['level3']['field4']);
90
- expect(masked['level1']['level2']['level3']['field5']).to.equal(testData.input['level1']['level2']['level3']['field5']);
232
+ expect(masked['level1']['level2']['field3'][0]['Hello']).to.equal(
233
+ testData.input['level1']['level2']['field3'][0]['Hello']
234
+ );
235
+ expect(masked['level1']['level2']['field3'][1]['Hello']).to.equal(
236
+ testData.input['level1']['level2']['field3'][1]['Hello']
237
+ );
238
+ expect(masked['level1']['level2']['level3']['field4']).to.equal(
239
+ testData.input['level1']['level2']['level3']['field4']
240
+ );
241
+ expect(masked['level1']['level2']['level3']['field5']).to.equal(
242
+ testData.input['level1']['level2']['level3']['field5']
243
+ );
91
244
  expect(masked['value1']).to.equal(testData.input['value1']);
92
245
  });
93
246
  });
94
-
95
247
  });
96
248
 
97
- describe('JSON mask2', function() {
98
-
99
- describe('Mask with default options and no fields', function() {
249
+ describe('JSON mask2', function () {
250
+ describe('Mask with default options and no fields', function () {
100
251
  let testData = [
101
252
  {
102
253
  title: 'test json masking with default options and no fields',
103
254
  input: JSON.parse(JSON.stringify(jsonInput)),
104
- outputCredit: '1234-5678-8765-1234',
105
- outputDebit: '0000-1111-2222-3333',
106
- outputPrimaryEmail: 'primary@Email.com',
255
+ outputCredit: '1234-5678-8765-1234',
256
+ outputDebit: '0000-1111-2222-3333',
257
+ outputPrimaryEmail: 'primary@Email.com',
107
258
  outputSecondaryEmail: 'secondary@Email.com',
108
259
  outputPassword: 'dummyPassword',
109
- outputHomePhone: "+1 1234567890",
110
- outputWorkPhone: "+1 9876543210",
111
- outputAddressLine1: "This is my addressline 1. This is my home",
112
- outputAddressLine2: "AddressLine 2",
113
- outputUuid: "123e4567-e89b-12d3-a456-426614174000"
114
- },
115
- ]
116
-
117
- testData.forEach(({title, input, outputCredit, outputDebit, outputPrimaryEmail, outputSecondaryEmail,
118
- outputPassword, outputHomePhone, outputWorkPhone, outputAddressLine1, outputAddressLine2, outputUuid}) => {
119
- it(`${title}`, function() {
120
- const masked = maskData.maskJSON2(input, Constants.defaultjsonMask2Configs);
121
- expect(masked['credit']).to.equal(outputCredit);
122
- expect(masked['debit']).to.equal(outputDebit);
123
- expect(masked['primaryEmail']).to.equal(outputPrimaryEmail);
124
- expect(masked['secondaryEmail']).to.equal(outputSecondaryEmail);
125
- expect(masked['password']).to.equal(outputPassword);
126
- expect(masked['homePhone']).to.equal(outputHomePhone);
127
- expect(masked['workPhone']).to.equal(outputWorkPhone);
128
- expect(masked['addressLine1']).to.equal(outputAddressLine1);
129
- expect(masked['addressLine2']).to.equal(outputAddressLine2);
130
- expect(masked['uuid1']).to.equal(outputUuid);
131
- });
132
- })
260
+ outputHomePhone: '+1 1234567890',
261
+ outputWorkPhone: '+1 9876543210',
262
+ outputAddressLine1: 'This is my addressline 1. This is my home',
263
+ outputAddressLine2: 'AddressLine 2',
264
+ outputUuid: '123e4567-e89b-12d3-a456-426614174000'
265
+ }
266
+ ];
267
+
268
+ testData.forEach(
269
+ ({
270
+ title,
271
+ input,
272
+ outputCredit,
273
+ outputDebit,
274
+ outputPrimaryEmail,
275
+ outputSecondaryEmail,
276
+ outputPassword,
277
+ outputHomePhone,
278
+ outputWorkPhone,
279
+ outputAddressLine1,
280
+ outputAddressLine2,
281
+ outputUuid
282
+ }) => {
283
+ it(`${title}`, function () {
284
+ const masked = maskData.maskJSON2(input, Constants.defaultjsonMask2Configs);
285
+ expect(masked['credit']).to.equal(outputCredit);
286
+ expect(masked['debit']).to.equal(outputDebit);
287
+ expect(masked['primaryEmail']).to.equal(outputPrimaryEmail);
288
+ expect(masked['secondaryEmail']).to.equal(outputSecondaryEmail);
289
+ expect(masked['password']).to.equal(outputPassword);
290
+ expect(masked['homePhone']).to.equal(outputHomePhone);
291
+ expect(masked['workPhone']).to.equal(outputWorkPhone);
292
+ expect(masked['addressLine1']).to.equal(outputAddressLine1);
293
+ expect(masked['addressLine2']).to.equal(outputAddressLine2);
294
+ expect(masked['uuid1']).to.equal(outputUuid);
295
+ });
296
+ }
297
+ );
133
298
  });
134
299
 
135
- describe('Mask all fields with default options', function() {
300
+ describe('Mask all fields with default options', function () {
136
301
  let testData = [
137
302
  {
138
303
  title: 'test json masking with default options and all types of fields',
139
304
  input: JSON.parse(JSON.stringify(jsonInput)),
140
- outputCredit: '1234-****-****-***4',
141
- outputDebit: '0000-****-****-***3',
142
- outputPrimaryEmail: 'pri****@*******om',
305
+ outputCredit: '1234-****-****-***4',
306
+ outputDebit: '0000-****-****-***3',
307
+ outputPrimaryEmail: 'pri****@*******om',
143
308
  outputSecondaryEmail: 'sec******@*******om',
144
309
  outputPassword: '*************',
145
- outputHomePhone: "+1 1********0",
146
- outputWorkPhone: "+1 9********0",
147
- outputAddressLine1: "This is my addressline 1. This is my home",
148
- outputAddressLine2: "AddressLine 2",
149
- outputUuid: "********-****-****-****-************"
150
- },
151
- ]
152
-
153
- testData.forEach(({title, input, outputCredit, outputDebit, outputPrimaryEmail, outputSecondaryEmail,
154
- outputPassword, outputHomePhone, outputWorkPhone, outputAddressLine1, outputAddressLine2, outputUuid}) => {
155
-
156
- const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
157
- jsonMaskConfig['cardFields'] = ['credit', 'debit'];
158
- jsonMaskConfig['emailFields'] = ['primaryEmail', 'secondaryEmail'];
159
- jsonMaskConfig['passwordFields'] = ['password'];
160
- jsonMaskConfig['phoneFields'] = ['homePhone', 'workPhone'];
161
- jsonMaskConfig['stringFields'] = ['addressLine1', 'addressLine2'];
162
- jsonMaskConfig['uuidFields'] = ['uuid1'];
163
- it(`${title}`, function() {
164
- const masked = maskData.maskJSON2(input, jsonMaskConfig);
165
- expect(masked['credit']).to.equal(outputCredit);
166
- expect(masked['debit']).to.equal(outputDebit);
167
- expect(masked['primaryEmail']).to.equal(outputPrimaryEmail);
168
- expect(masked['secondaryEmail']).to.equal(outputSecondaryEmail);
169
- expect(masked['password']).to.equal(outputPassword);
170
- expect(masked['homePhone']).to.equal(outputHomePhone);
171
- expect(masked['workPhone']).to.equal(outputWorkPhone);
172
- expect(masked['addressLine1']).to.equal(outputAddressLine1);
173
- expect(masked['addressLine2']).to.equal(outputAddressLine2);
174
- expect(masked['uuid1']).to.equal(outputUuid);
175
- });
176
- })
310
+ outputHomePhone: '+1 1********0',
311
+ outputWorkPhone: '+1 9********0',
312
+ outputAddressLine1: 'This is my addressline 1. This is my home',
313
+ outputAddressLine2: 'AddressLine 2',
314
+ outputUuid: '********-****-****-****-************'
315
+ }
316
+ ];
317
+
318
+ testData.forEach(
319
+ ({
320
+ title,
321
+ input,
322
+ outputCredit,
323
+ outputDebit,
324
+ outputPrimaryEmail,
325
+ outputSecondaryEmail,
326
+ outputPassword,
327
+ outputHomePhone,
328
+ outputWorkPhone,
329
+ outputAddressLine1,
330
+ outputAddressLine2,
331
+ outputUuid
332
+ }) => {
333
+ const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
334
+ jsonMaskConfig['cardFields'] = ['credit', 'debit'];
335
+ jsonMaskConfig['emailFields'] = ['primaryEmail', 'secondaryEmail'];
336
+ jsonMaskConfig['passwordFields'] = ['password'];
337
+ jsonMaskConfig['phoneFields'] = ['homePhone', 'workPhone'];
338
+ jsonMaskConfig['stringFields'] = ['addressLine1', 'addressLine2'];
339
+ jsonMaskConfig['uuidFields'] = ['uuid1'];
340
+ it(`${title}`, function () {
341
+ const masked = maskData.maskJSON2(input, jsonMaskConfig);
342
+ expect(masked['credit']).to.equal(outputCredit);
343
+ expect(masked['debit']).to.equal(outputDebit);
344
+ expect(masked['primaryEmail']).to.equal(outputPrimaryEmail);
345
+ expect(masked['secondaryEmail']).to.equal(outputSecondaryEmail);
346
+ expect(masked['password']).to.equal(outputPassword);
347
+ expect(masked['homePhone']).to.equal(outputHomePhone);
348
+ expect(masked['workPhone']).to.equal(outputWorkPhone);
349
+ expect(masked['addressLine1']).to.equal(outputAddressLine1);
350
+ expect(masked['addressLine2']).to.equal(outputAddressLine2);
351
+ expect(masked['uuid1']).to.equal(outputUuid);
352
+ });
353
+ }
354
+ );
177
355
  });
178
356
 
179
- describe('Mask all nested fields with default options', function() {
357
+ describe('Mask all nested fields with default options', function () {
180
358
  const jsonInput2 = {
181
359
  cards: {
182
360
  creditCards: ['1234-5678-8765-1234', '1111-2222-1111-2222'],
183
361
  debitCards: ['0000-1111-2222-3333', '2222-1111-3333-4444']
184
362
  },
185
363
  emails: {
186
- primaryEmail: 'primary@Email.com',
364
+ primaryEmail: 'primary@Email.com',
187
365
  secondaryEmail: 'secondary@Email.com'
188
366
  },
189
367
  password: 'dummyPasswordANDdummyPassword',
190
368
  phones: {
191
- homePhone: "+1 1234567890",
192
- workPhone: "+1 9876543210",
369
+ homePhone: '+1 1234567890',
370
+ workPhone: '+1 9876543210'
193
371
  },
194
372
  address: {
195
- addressLine1: "This is my addressline 1. This is my home",
196
- addressLine2: "AddressLine 2"
373
+ addressLine1: 'This is my addressline 1. This is my home',
374
+ addressLine2: 'AddressLine 2'
197
375
  },
198
376
  uuids: {
199
377
  uuid1: '123e4567-e89b-12d3-a456-426614174000'
@@ -204,82 +382,347 @@ describe('JSON mask2', function() {
204
382
  {
205
383
  title: 'test json masking with default options and all types of fields',
206
384
  input: jsonInput2,
207
- outputCredit: '1234-****-****-***4',
208
- outputDebit: '0000-****-****-***3',
209
- outputPrimaryEmail: 'pri****@*******om',
385
+ outputCredit: '1234-****-****-***4',
386
+ outputDebit: '0000-****-****-***3',
387
+ outputPrimaryEmail: 'pri****@*******om',
210
388
  outputSecondaryEmail: 'sec******@*******om',
211
389
  outputPassword: '****************',
212
- outputHomePhone: "+1 1********0",
213
- outputWorkPhone: "+1 9********0",
214
- outputAddressLine1: "This is my addressline 1. This is my home",
215
- outputAddressLine2: "AddressLine 2",
216
- outputUuid: "********-****-****-****-************"
390
+ outputHomePhone: '+1 1********0',
391
+ outputWorkPhone: '+1 9********0',
392
+ outputAddressLine1: 'This is my addressline 1. This is my home',
393
+ outputAddressLine2: 'AddressLine 2',
394
+ outputUuid: '********-****-****-****-************'
395
+ }
396
+ ];
397
+
398
+ testData.forEach(
399
+ ({
400
+ title,
401
+ input,
402
+ outputCredit,
403
+ outputDebit,
404
+ outputPrimaryEmail,
405
+ outputSecondaryEmail,
406
+ outputPassword,
407
+ outputHomePhone,
408
+ outputWorkPhone,
409
+ outputAddressLine1,
410
+ outputAddressLine2,
411
+ outputUuid
412
+ }) => {
413
+ const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
414
+ jsonMaskConfig['cardFields'] = [
415
+ 'cards.creditCards[0]',
416
+ 'cards.creditCards[1]',
417
+ 'cards.debitCards[0]',
418
+ 'cards.debitCards[1]'
419
+ ];
420
+ jsonMaskConfig['emailFields'] = ['emails.primaryEmail', 'emails.secondaryEmail'];
421
+ jsonMaskConfig['passwordFields'] = ['password'];
422
+ jsonMaskConfig['phoneFields'] = ['phones.homePhone', 'phones.workPhone'];
423
+ jsonMaskConfig['stringFields'] = ['address.addressLine1', 'address.addressLine2'];
424
+ jsonMaskConfig['uuidFields'] = ['uuids.uuid1'];
425
+ it(`${title}`, function () {
426
+ const masked = maskData.maskJSON2(input, jsonMaskConfig);
427
+ expect(masked['cards']['creditCards'][0]).to.equal(outputCredit);
428
+ expect(masked['cards']['creditCards'][1]).to.equal('1111-****-****-***2');
429
+ expect(masked['cards']['debitCards'][0]).to.equal(outputDebit);
430
+ expect(masked['cards']['debitCards'][1]).to.equal('2222-****-****-***4');
431
+
432
+ expect(masked['emails']['primaryEmail']).to.equal(outputPrimaryEmail);
433
+ expect(masked['emails']['secondaryEmail']).to.equal(outputSecondaryEmail);
434
+
435
+ expect(masked['password']).to.equal(outputPassword);
436
+
437
+ expect(masked['phones']['homePhone']).to.equal(outputHomePhone);
438
+ expect(masked['phones']['workPhone']).to.equal(outputWorkPhone);
439
+
440
+ expect(masked['address']['addressLine1']).to.equal(outputAddressLine1);
441
+ expect(masked['address']['addressLine2']).to.equal(outputAddressLine2);
442
+
443
+ expect(masked['uuids']['uuid1']).to.equal(outputUuid);
444
+ });
445
+ it('Test masking improper JSON', function () {
446
+ const notAJson = 'Not a JSON. Just a String';
447
+ const masked = maskData.maskJSON2(notAJson, jsonMaskConfig);
448
+ expect(masked).to.equal(notAJson);
449
+ });
450
+ }
451
+ );
452
+ });
453
+
454
+ describe('Test .[*] and .*', function () {
455
+ const jsonInput2 = {
456
+ cards: [
457
+ {
458
+ number: '1234-5678-8765-1234'
459
+ },
460
+ {
461
+ number: '1111-2222-1111-2222'
462
+ },
463
+ {
464
+ number: '0000-1111-2222-3333'
465
+ },
466
+ {
467
+ name: 'No card number here'
468
+ }
469
+ ],
470
+ emails: {
471
+ primaryEmail: 'primary@Email.com',
472
+ secondaryEmail: 'secondary@Email.com',
473
+ moreEmails: [
474
+ 'email1@email.com',
475
+ 'email2@email.com',
476
+ 'email3@email.com',
477
+ { childEmail: 'child@child.com', secondChild: { nestedkid: 'hello@hello.com' } }
478
+ ]
217
479
  },
218
- ]
480
+ array: ['element1', 'element22', 'element333']
481
+ };
219
482
 
220
- testData.forEach(({title, input, outputCredit, outputDebit, outputPrimaryEmail, outputSecondaryEmail,
221
- outputPassword, outputHomePhone, outputWorkPhone, outputAddressLine1, outputAddressLine2, outputUuid}) => {
222
-
483
+ let testData = [
484
+ {
485
+ title: 'test .[*] and .*',
486
+ input: jsonInput2,
487
+ outputCard: 'XXXX-XXXX-XXXX-XXXX',
488
+ outputPrimaryEmail: '*******@*********',
489
+ outputSecondaryEmail: '*********@*********'
490
+ }
491
+ ];
492
+
493
+ testData.forEach(({ title, input, outputCard, outputPrimaryEmail, outputSecondaryEmail }) => {
223
494
  const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
224
- jsonMaskConfig['cardFields'] = ['cards.creditCards[0]', 'cards.creditCards[1]', 'cards.debitCards[0]', 'cards.debitCards[1]'];
225
- jsonMaskConfig['emailFields'] = ['emails.primaryEmail', 'emails.secondaryEmail'];
226
- jsonMaskConfig['passwordFields'] = ['password'];
227
- jsonMaskConfig['phoneFields'] = ['phones.homePhone', 'phones.workPhone'];
228
- jsonMaskConfig['stringFields'] = ['address.addressLine1', 'address.addressLine2'];
229
- jsonMaskConfig['uuidFields'] = ['uuids.uuid1'];
230
- it(`${title}`, function() {
231
- const masked = maskData.maskJSON2(input, jsonMaskConfig);
232
- expect(masked['cards']['creditCards'][0]).to.equal(outputCredit);
233
- expect(masked['cards']['creditCards'][1]).to.equal('1111-****-****-***2');
234
- expect(masked['cards']['debitCards'][0]).to.equal(outputDebit);
235
- expect(masked['cards']['debitCards'][1]).to.equal('2222-****-****-***4');
236
495
 
237
- expect(masked['emails']['primaryEmail']).to.equal(outputPrimaryEmail);
238
- expect(masked['emails']['secondaryEmail']).to.equal(outputSecondaryEmail);
496
+ jsonMaskConfig['cardMaskOptions'] = {
497
+ maskWith: 'X',
498
+ unmaskedStartDigits: 0,
499
+ unmaskedEndDigits: 0
500
+ };
501
+ jsonMaskConfig['emailMaskOptions'] = {
502
+ maskWith: '*',
503
+ unmaskedStartCharactersBeforeAt: 0,
504
+ unmaskedEndCharactersAfterAt: 0,
505
+ maskAtTheRate: false
506
+ };
239
507
 
240
- expect(masked['password']).to.equal(outputPassword);
508
+ jsonMaskConfig['cardFields'] = ['cards[*].number'];
509
+ jsonMaskConfig['emailFields'] = ['emails.*'];
241
510
 
242
- expect(masked['phones']['homePhone']).to.equal(outputHomePhone);
243
- expect(masked['phones']['workPhone']).to.equal(outputWorkPhone);
511
+ jsonMaskConfig['stringFields'] = ['array.*'];
512
+ jsonMaskConfig['stringMaskOptions'] = {
513
+ maskWith: '?',
514
+ maskOnlyFirstOccurance: false,
515
+ values: [],
516
+ maskAll: true,
517
+ maskSpace: false
518
+ };
244
519
 
245
- expect(masked['address']['addressLine1']).to.equal(outputAddressLine1);
246
- expect(masked['address']['addressLine2']).to.equal(outputAddressLine2);
520
+ it(`${title}`, function () {
521
+ const masked = maskData.maskJSON2(input, jsonMaskConfig);
522
+ expect(masked['cards'][0]['number']).to.equal(outputCard);
523
+ expect(masked['cards'][1]['number']).to.equal(outputCard);
524
+ expect(masked['cards'][2]['number']).to.equal(outputCard);
525
+ expect(masked['cards'][3]['number']).to.equal(undefined);
247
526
 
248
- expect(masked['uuids']['uuid1']).to.equal(outputUuid);
249
- });
250
- it('Test masking improper JSON', function() {
251
- const notAJson = "Not a JSON. Just a String";
252
- const masked = maskData.maskJSON2(notAJson, jsonMaskConfig);
253
- expect(masked).to.equal(notAJson);
527
+ expect(masked['emails']['primaryEmail']).to.equal(outputPrimaryEmail);
528
+ expect(masked['emails']['secondaryEmail']).to.equal(outputSecondaryEmail);
529
+ expect(masked['emails']['moreEmails'][0]).to.equal('******@*********');
530
+ expect(masked['emails']['moreEmails'][1]).to.equal('******@*********');
531
+ expect(masked['emails']['moreEmails'][2]).to.equal('******@*********');
532
+ expect(masked['emails']['moreEmails'][3].childEmail).to.equal('*****@*********');
533
+ expect(masked['emails']['moreEmails'][3].secondChild.nestedkid).to.equal('*****@*********');
534
+
535
+ expect(masked['array'][0]).to.equal('????????');
536
+ expect(masked['array'][1]).to.equal('?????????');
537
+ expect(masked['array'][2]).to.equal('??????????');
254
538
  });
255
- })
539
+ });
256
540
  });
257
541
 
258
- describe('Mask card fields with custom options', function() {
542
+ describe('Mask all nested fields in god json with default options', function () {
543
+ let testData = [
544
+ {
545
+ title: 'test json masking with default options and all types of fields',
546
+ input: jsonInput2,
547
+ outputCard: 'XXXX-XXXX-XXXX-XXXX',
548
+ outputPrimaryEmail: '*******@*********',
549
+ outputSecondaryEmail: '*********@*********',
550
+ outputPassword: '**********',
551
+ outputPhone: '*************',
552
+ outputAddressLine1: '**** ** ** *********** ** **** ** ** ****',
553
+ outputAddressLine2: '*********** *',
554
+ outputUuid: '********-****-****-****-************'
555
+ }
556
+ ];
557
+
558
+ testData.forEach(
559
+ ({
560
+ title,
561
+ input,
562
+ outputCard,
563
+ outputPrimaryEmail,
564
+ outputSecondaryEmail,
565
+ outputPassword,
566
+ outputPhone,
567
+ outputAddressLine1,
568
+ outputAddressLine2,
569
+ outputUuid
570
+ }) => {
571
+ const jsonMaskConfig = {
572
+ cardMaskOptions: { maskWith: 'X', unmaskedStartDigits: 0, unmaskedEndDigits: 0 },
573
+ cardFields: [
574
+ 'string1[*].items[*].creditCards.*',
575
+ 'string1[*].items[*].child[*].creditCards.*',
576
+ 'cards.creditCards[0]',
577
+ 'cards.creditCards[1]',
578
+ 'cards.debitCards[0]',
579
+ 'cards.debitCards[1]'
580
+ ],
581
+
582
+ // Email
583
+ emailMaskOptions: {
584
+ maskWith: '*',
585
+ unmaskedStartCharactersBeforeAt: 0,
586
+ unmaskedEndCharactersAfterAt: 0,
587
+ maskAtTheRate: false
588
+ },
589
+ emailFields: [
590
+ 'string1[*].items[*].primaryEmail',
591
+ 'string1[*].items[*].child[*].primaryEmail',
592
+ 'string1[*].primaryEmail',
593
+ 'emails.primaryEmail',
594
+ 'emails.secondaryEmail'
595
+ ],
596
+
597
+ // Password
598
+ passwordMaskOptions: {
599
+ maskWith: '*',
600
+ maxMaskedCharacters: 10,
601
+ unmaskedStartCharacters: 0,
602
+ unmaskedEndCharacters: 0
603
+ },
604
+ passwordFields: [
605
+ 'passwords[0][0]]',
606
+ 'passwords[0][1]',
607
+ 'string1[*].items[*].passwords.*',
608
+ 'string1[*].items[*].child[*].passwords.*'
609
+ ],
610
+
611
+ // Phone
612
+ phoneMaskOptions: { maskWith: '*', unmaskedStartDigits: 0, unmaskedEndDigits: 0 },
613
+ phoneFields: [
614
+ 'string1[*].items[*].phone',
615
+ 'string1[*].items[*].child[*].phone',
616
+ 'phones.homePhone',
617
+ 'phones.workPhone'
618
+ ],
619
+
620
+ // String
621
+ stringMaskOptions: {
622
+ maskWith: '*',
623
+ maskOnlyFirstOccurance: false,
624
+ values: [],
625
+ maskAll: true,
626
+ maskSpace: false
627
+ },
628
+ stringFields: [
629
+ 'string1[*].items[*].id',
630
+ 'string1[*].items[*].child[*].child1',
631
+ 'address.addressLine1',
632
+ 'address.addressLine2'
633
+ ],
634
+
635
+ // UUID
636
+ uuidMaskOptions: { maskWith: '*', unmaskedStartCharacters: 0, unmaskedEndCharacters: 0 },
637
+ uuidFields: [
638
+ 'uuids.uuid1',
639
+ 'string1[*].items[*].uuid1',
640
+ 'string1[*].items[*].child[*].uuid1'
641
+ ]
642
+ };
643
+ it(`${title}`, function () {
644
+ const masked = maskData.maskJSON2(input, jsonMaskConfig);
645
+ expect(masked['cards']['creditCards'][0]).to.equal(outputCard);
646
+ expect(masked['cards']['creditCards'][1]).to.equal(outputCard);
647
+ expect(masked['cards']['debitCards'][0]).to.equal(outputCard);
648
+ expect(masked['cards']['debitCards'][1]).to.equal(outputCard);
649
+
650
+ expect(masked['emails']['primaryEmail']).to.equal(outputPrimaryEmail);
651
+ expect(masked['emails']['secondaryEmail']).to.equal(outputSecondaryEmail);
652
+
653
+ expect(masked['passwords'][0][0]).to.equal(outputPassword);
654
+ expect(masked['passwords'][0][1]).to.equal(outputPassword);
655
+
656
+ expect(masked['string1'][0]['items'][0]['child'][0]['passwords'][0]).to.equal(
657
+ outputPassword
658
+ );
659
+ expect(masked['string1'][0]['items'][0]['child'][0]['passwords'][1]).to.equal(
660
+ outputPassword
661
+ );
662
+ expect(masked['string1'][0]['items'][0]['child'][1]['passwords']).to.equal(undefined);
663
+
664
+ expect(masked['string1'][0]['items'][1]['child'][0]['passwords'][0]).to.equal(
665
+ outputPassword
666
+ );
667
+ expect(masked['string1'][0]['items'][1]['child'][0]['passwords'][1]).to.equal(
668
+ outputPassword
669
+ );
670
+ expect(masked['string1'][0]['items'][1]['child'][1]['passwords']).to.equal(undefined);
671
+ expect(masked['string1'][0]['items'][1]['child'][1]['passwords']).to.equal(undefined);
672
+
673
+ expect(masked['string1'][0]['items'][1]['creditCards'][0]).to.equal(outputCard);
674
+ expect(masked['string1'][0]['items'][1]['creditCards'][1]).to.equal(outputCard);
675
+ expect(masked['string1'][0]['items'][1]['child'][0]['creditCards'][0]).to.equal(
676
+ outputCard
677
+ );
678
+ expect(masked['string1'][1]['items'][1]['child'][1]['creditCards'][1]).to.equal(
679
+ outputCard
680
+ );
681
+
682
+ expect(masked['phones']['homePhone']).to.equal(outputPhone);
683
+ expect(masked['phones']['workPhone']).to.equal(outputPhone);
684
+
685
+ expect(masked['address']['addressLine1']).to.equal(outputAddressLine1);
686
+ expect(masked['address']['addressLine2']).to.equal(outputAddressLine2);
687
+
688
+ expect(masked['uuids']['uuid1']).to.equal(outputUuid);
689
+ });
690
+
691
+ const jsonMaskConfig2 = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
692
+ jsonMaskConfig2.cardFields = ['string1[*].items[*].creditCards.*[0]'];
693
+
694
+ it('Test masking with improper field with .*', function () {
695
+ const masked = maskData.maskJSON2(jsonInput2, jsonMaskConfig2);
696
+ expect(JSON.stringify(masked)).to.equal(JSON.stringify(jsonInput2));
697
+ });
698
+ }
699
+ );
700
+ });
701
+
702
+ describe('Mask card fields with custom options', function () {
259
703
  let testData = [
260
704
  {
261
705
  title: 'Mask card fields with custom options',
262
706
  input: JSON.parse(JSON.stringify(jsonInput)),
263
- outputCredit: 'XXXX-XXXX-XXXX-1234',
707
+ outputCredit: 'XXXX-XXXX-XXXX-1234',
264
708
  outputDebit: 'XXXX-XXXX-XXXX-3333'
265
709
  }
266
- ]
710
+ ];
267
711
 
268
- testData.forEach(({title, input, outputCredit, outputDebit}) => {
269
-
270
- const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
271
- const cardMaskOptions = JSON.parse(JSON.stringify(Constants.defaultCardMaskOptions));
272
- // const defaultCardMaskOptions = {
273
- // maskWith: "*",
274
- // unmaskedStartDigits: 4,
275
- // unmaskedEndDigits: 1
276
- // };
277
- cardMaskOptions['maskWith'] = "X"
278
- cardMaskOptions['unmaskedStartDigits'] = 0
279
- cardMaskOptions['unmaskedEndDigits'] = 4
280
- jsonMaskConfig['cardFields'] = ['credit', 'debit'];
281
- jsonMaskConfig['cardMaskOptions'] = cardMaskOptions;
282
- it(`${title}`, function() {
712
+ testData.forEach(({ title, input, outputCredit, outputDebit }) => {
713
+ const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
714
+ const cardMaskOptions = JSON.parse(JSON.stringify(Constants.defaultCardMaskOptions));
715
+ // const defaultCardMaskOptions = {
716
+ // maskWith: "*",
717
+ // unmaskedStartDigits: 4,
718
+ // unmaskedEndDigits: 1
719
+ // };
720
+ cardMaskOptions['maskWith'] = 'X';
721
+ cardMaskOptions['unmaskedStartDigits'] = 0;
722
+ cardMaskOptions['unmaskedEndDigits'] = 4;
723
+ jsonMaskConfig['cardFields'] = ['credit', 'debit'];
724
+ jsonMaskConfig['cardMaskOptions'] = cardMaskOptions;
725
+ it(`${title}`, function () {
283
726
  const masked = maskData.maskJSON2(input, jsonMaskConfig);
284
727
  expect(masked['credit']).to.equal(outputCredit);
285
728
  expect(masked['debit']).to.equal(outputDebit);
@@ -291,21 +734,20 @@ describe('JSON mask2', function() {
291
734
  expect(masked['addressLine1']).to.equal(input['addressLine1']);
292
735
  expect(masked['addressLine2']).to.equal(input['addressLine2']);
293
736
  });
294
- })
737
+ });
295
738
  });
296
739
 
297
- describe('Mask email fields with custom options', function() {
740
+ describe('Mask email fields with custom options', function () {
298
741
  let testData = [
299
742
  {
300
743
  title: 'Mask email fields with custom options',
301
744
  input: JSON.parse(JSON.stringify(jsonInput)),
302
- outputPrimaryEmail: 'prim...@........m',
745
+ outputPrimaryEmail: 'prim...@........m',
303
746
  outputSecondaryEmail: 'seco.....@........m'
304
- },
305
- ]
306
-
307
- testData.forEach(({title, input, outputPrimaryEmail, outputSecondaryEmail}) => {
747
+ }
748
+ ];
308
749
 
750
+ testData.forEach(({ title, input, outputPrimaryEmail, outputSecondaryEmail }) => {
309
751
  const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
310
752
  const emailMaskOptions = JSON.parse(JSON.stringify(Constants.defaultEmailMask2Options));
311
753
  // const defaultEmailMask2Options = {
@@ -314,13 +756,13 @@ describe('JSON mask2', function() {
314
756
  // unmaskedEndCharactersAfterAt: 2,
315
757
  // maskAtTheRate: false
316
758
  // };
317
- emailMaskOptions['maskWith'] = "."
318
- emailMaskOptions['unmaskedStartCharactersBeforeAt'] = 4
319
- emailMaskOptions['unmaskedEndCharactersAfterAt'] = 1
759
+ emailMaskOptions['maskWith'] = '.';
760
+ emailMaskOptions['unmaskedStartCharactersBeforeAt'] = 4;
761
+ emailMaskOptions['unmaskedEndCharactersAfterAt'] = 1;
320
762
  jsonMaskConfig['emailFields'] = ['primaryEmail', 'secondaryEmail'];
321
763
  jsonMaskConfig['emailMaskOptions'] = emailMaskOptions;
322
764
 
323
- it(`${title}`, function() {
765
+ it(`${title}`, function () {
324
766
  const masked = maskData.maskJSON2(input, jsonMaskConfig);
325
767
  expect(masked['credit']).to.equal(input['credit']);
326
768
  expect(masked['debit']).to.equal(input['debit']);
@@ -332,20 +774,19 @@ describe('JSON mask2', function() {
332
774
  expect(masked['addressLine1']).to.equal(input['addressLine1']);
333
775
  expect(masked['addressLine2']).to.equal(input['addressLine2']);
334
776
  });
335
- })
777
+ });
336
778
  });
337
779
 
338
- describe('Mask password fields with custom options', function() {
780
+ describe('Mask password fields with custom options', function () {
339
781
  let testData = [
340
782
  {
341
783
  title: 'Mask password fields with custom options',
342
784
  input: JSON.parse(JSON.stringify(jsonInput)),
343
785
  outputPassword: 'd????d'
344
- },
345
- ]
786
+ }
787
+ ];
346
788
 
347
- testData.forEach(({title, input, outputPassword}) => {
348
-
789
+ testData.forEach(({ title, input, outputPassword }) => {
349
790
  const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
350
791
  const passwordMaskOptions = JSON.parse(JSON.stringify(Constants.defaultPasswordMaskOptions));
351
792
  // const defaultPasswordMaskOptions = {
@@ -354,13 +795,13 @@ describe('JSON mask2', function() {
354
795
  // unmaskedStartCharacters: 0,
355
796
  // unmaskedEndCharacters: 0
356
797
  // };
357
- passwordMaskOptions['maskWith'] = "?"
358
- passwordMaskOptions['maxMaskedCharacters'] = 6
359
- passwordMaskOptions['unmaskedStartCharacters'] = 1
360
- passwordMaskOptions['unmaskedEndCharacters'] = 1
798
+ passwordMaskOptions['maskWith'] = '?';
799
+ passwordMaskOptions['maxMaskedCharacters'] = 6;
800
+ passwordMaskOptions['unmaskedStartCharacters'] = 1;
801
+ passwordMaskOptions['unmaskedEndCharacters'] = 1;
361
802
  jsonMaskConfig['passwordFields'] = ['password'];
362
803
  jsonMaskConfig['passwordMaskOptions'] = passwordMaskOptions;
363
- it(`${title}`, function() {
804
+ it(`${title}`, function () {
364
805
  const masked = maskData.maskJSON2(input, jsonMaskConfig);
365
806
  expect(masked['credit']).to.equal(input['credit']);
366
807
  expect(masked['debit']).to.equal(input['debit']);
@@ -372,21 +813,20 @@ describe('JSON mask2', function() {
372
813
  expect(masked['addressLine1']).to.equal(input['addressLine1']);
373
814
  expect(masked['addressLine2']).to.equal(input['addressLine2']);
374
815
  });
375
- })
816
+ });
376
817
  });
377
818
 
378
- describe('Mask phone fields with custom options', function() {
819
+ describe('Mask phone fields with custom options', function () {
379
820
  let testData = [
380
821
  {
381
822
  title: 'Mask phone fields with custom options',
382
823
  input: JSON.parse(JSON.stringify(jsonInput)),
383
824
  outputHomePhone: '+1 #######890',
384
825
  outputWorkPhone: '+1 #######210'
385
- },
386
- ]
826
+ }
827
+ ];
387
828
 
388
- testData.forEach(({title, input, outputHomePhone, outputWorkPhone}) => {
389
-
829
+ testData.forEach(({ title, input, outputHomePhone, outputWorkPhone }) => {
390
830
  const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
391
831
  const phoneMaskOptions = JSON.parse(JSON.stringify(Constants.defaultPhoneMaskOptions));
392
832
  // const defaultPhoneMaskOptions = {
@@ -394,12 +834,12 @@ describe('JSON mask2', function() {
394
834
  // unmaskedStartDigits: 4,
395
835
  // unmaskedEndDigits: 1
396
836
  // };
397
- phoneMaskOptions['maskWith'] = "#"
398
- phoneMaskOptions['unmaskedStartDigits'] = 3
399
- phoneMaskOptions['unmaskedEndDigits'] = 3
837
+ phoneMaskOptions['maskWith'] = '#';
838
+ phoneMaskOptions['unmaskedStartDigits'] = 3;
839
+ phoneMaskOptions['unmaskedEndDigits'] = 3;
400
840
  jsonMaskConfig['phoneFields'] = ['homePhone', 'workPhone'];
401
841
  jsonMaskConfig['phoneMaskOptions'] = phoneMaskOptions;
402
- it(`${title}`, function() {
842
+ it(`${title}`, function () {
403
843
  const masked = maskData.maskJSON2(input, jsonMaskConfig);
404
844
  expect(masked['credit']).to.equal(input['credit']);
405
845
  expect(masked['debit']).to.equal(input['debit']);
@@ -411,21 +851,20 @@ describe('JSON mask2', function() {
411
851
  expect(masked['addressLine1']).to.equal(input['addressLine1']);
412
852
  expect(masked['addressLine2']).to.equal(input['addressLine2']);
413
853
  });
414
- })
854
+ });
415
855
  });
416
856
 
417
- describe('Mask String fields with custom options', function() {
857
+ describe('Mask String fields with custom options', function () {
418
858
  let testData = [
419
859
  {
420
860
  title: 'Mask String fields with custom options',
421
861
  input: JSON.parse(JSON.stringify(jsonInput)),
422
862
  outputAddressLine1: 'XXXX is my addressline 1. This is my home',
423
863
  outputAddressLine2: 'AddressLine 2'
424
- },
425
- ]
864
+ }
865
+ ];
426
866
 
427
- testData.forEach(({title, input, outputAddressLine1, outputAddressLine2}) => {
428
-
867
+ testData.forEach(({ title, input, outputAddressLine1, outputAddressLine2 }) => {
429
868
  const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
430
869
  const stringMaskOptions = JSON.parse(JSON.stringify(Constants.defaultStringMaskOptions));
431
870
  // const defaultStringMaskOptions = {
@@ -435,12 +874,12 @@ describe('JSON mask2', function() {
435
874
  // maskAll: false,
436
875
  // maskSpace: true
437
876
  // };
438
- stringMaskOptions['maskWith'] = "X"
439
- stringMaskOptions['maskOnlyFirstOccurance'] = true
440
- stringMaskOptions['values'] = ['This']
877
+ stringMaskOptions['maskWith'] = 'X';
878
+ stringMaskOptions['maskOnlyFirstOccurance'] = true;
879
+ stringMaskOptions['values'] = ['This'];
441
880
  jsonMaskConfig['stringFields'] = ['addressLine1', 'addressLine2'];
442
881
  jsonMaskConfig['stringMaskOptions'] = stringMaskOptions;
443
- it(`${title}`, function() {
882
+ it(`${title}`, function () {
444
883
  const masked = maskData.maskJSON2(input, jsonMaskConfig);
445
884
  expect(masked['credit']).to.equal(input['credit']);
446
885
  expect(masked['debit']).to.equal(input['debit']);
@@ -452,20 +891,19 @@ describe('JSON mask2', function() {
452
891
  expect(masked['addressLine1']).to.equal(outputAddressLine1);
453
892
  expect(masked['addressLine2']).to.equal(outputAddressLine2);
454
893
  });
455
- })
894
+ });
456
895
  });
457
896
 
458
- describe('Mask UUID fields with custom options', function() {
897
+ describe('Mask UUID fields with custom options', function () {
459
898
  let testData = [
460
899
  {
461
900
  title: 'Mask UUID fields with custom options',
462
901
  input: JSON.parse(JSON.stringify(jsonInput)),
463
- outputUuid: "123e4567-XXXX-XXXX-XXXX-426614174000"
464
- },
465
- ]
902
+ outputUuid: '123e4567-XXXX-XXXX-XXXX-426614174000'
903
+ }
904
+ ];
466
905
 
467
- testData.forEach(({title, input, outputUuid}) => {
468
-
906
+ testData.forEach(({ title, input, outputUuid }) => {
469
907
  const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
470
908
  const uuidMaskOptions = JSON.parse(JSON.stringify(Constants.defaultUuidMaskOptions));
471
909
  // const defaultUuidMaskOptions = {
@@ -473,12 +911,12 @@ describe('JSON mask2', function() {
473
911
  // unmaskedStartCharacters: 0,
474
912
  // unmaskedEndCharacters: 0
475
913
  // };
476
- uuidMaskOptions['maskWith'] = "X"
477
- uuidMaskOptions['unmaskedStartCharacters'] = 8
478
- uuidMaskOptions['unmaskedEndCharacters'] = 12
914
+ uuidMaskOptions['maskWith'] = 'X';
915
+ uuidMaskOptions['unmaskedStartCharacters'] = 8;
916
+ uuidMaskOptions['unmaskedEndCharacters'] = 12;
479
917
  jsonMaskConfig['uuidFields'] = ['uuid1'];
480
918
  jsonMaskConfig['uuidMaskOptions'] = uuidMaskOptions;
481
- it(`${title}`, function() {
919
+ it(`${title}`, function () {
482
920
  const masked = maskData.maskJSON2(input, jsonMaskConfig);
483
921
  expect(masked['credit']).to.equal(input['credit']);
484
922
  expect(masked['debit']).to.equal(input['debit']);
@@ -491,7 +929,6 @@ describe('JSON mask2', function() {
491
929
  expect(masked['addressLine2']).to.equal(input['addressLine2']);
492
930
  expect(masked['uuid1']).to.equal(outputUuid);
493
931
  });
494
- })
932
+ });
495
933
  });
496
-
497
- });
934
+ });