maskdata 1.2.3 → 1.2.5

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.
@@ -18,139 +18,6 @@ const jsonInput = {
18
18
  uuid1: '123e4567-e89b-12d3-a456-426614174000'
19
19
  };
20
20
 
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
21
  describe('JSON mask1', function () {
155
22
  describe('Mask json with default options', function () {
156
23
  let testData = {
@@ -375,6 +242,17 @@ describe('JSON mask2', function () {
375
242
  },
376
243
  uuids: {
377
244
  uuid1: '123e4567-e89b-12d3-a456-426614174000'
245
+ },
246
+ jwts: {
247
+ token1:
248
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
249
+ token2:
250
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJsb2wiLCJuYW1lIjoiVGVzdCIsImlhdCI6ImxvbCJ9.XNDxZcBWWEKYkCiu6XFGmAeuPF7iFnI7Sdv91gVZJMU',
251
+ token3List: [
252
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiVGVzdDEifQ.TvKsZHhAgnZeplD4YdkKAgjdhdtFSQn-xZJ7HiiS1ok',
253
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiVGVzdDIifQ.ekZkXoeOb4SE_YLlc0Iv8V3wm17xS1B7TzhtYHvIYl0',
254
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiVGVzdDMifQ.CNiJIr7TZgsVGS0dbFFwdPtG6v1wwSor9jFoVeUkrJ0'
255
+ ]
378
256
  }
379
257
  };
380
258
 
@@ -391,7 +269,11 @@ describe('JSON mask2', function () {
391
269
  outputWorkPhone: '+1 9********0',
392
270
  outputAddressLine1: 'This is my addressline 1. This is my home',
393
271
  outputAddressLine2: 'AddressLine 2',
394
- outputUuid: '********-****-****-****-************'
272
+ outputUuid: '********-****-****-****-************',
273
+ outputJwt1:
274
+ '***********************************************************************************************************************************************************',
275
+ outputJwt2:
276
+ '*************************************************************************************************************************************'
395
277
  }
396
278
  ];
397
279
 
@@ -408,7 +290,9 @@ describe('JSON mask2', function () {
408
290
  outputWorkPhone,
409
291
  outputAddressLine1,
410
292
  outputAddressLine2,
411
- outputUuid
293
+ outputUuid,
294
+ outputJwt1,
295
+ outputJwt2
412
296
  }) => {
413
297
  const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
414
298
  jsonMaskConfig['cardFields'] = [
@@ -422,6 +306,7 @@ describe('JSON mask2', function () {
422
306
  jsonMaskConfig['phoneFields'] = ['phones.homePhone', 'phones.workPhone'];
423
307
  jsonMaskConfig['stringFields'] = ['address.addressLine1', 'address.addressLine2'];
424
308
  jsonMaskConfig['uuidFields'] = ['uuids.uuid1'];
309
+ jsonMaskConfig['jwtFields'] = ['jwts.token1', 'jwts.token2'];
425
310
  it(`${title}`, function () {
426
311
  const masked = maskData.maskJSON2(input, jsonMaskConfig);
427
312
  expect(masked['cards']['creditCards'][0]).to.equal(outputCredit);
@@ -441,6 +326,9 @@ describe('JSON mask2', function () {
441
326
  expect(masked['address']['addressLine2']).to.equal(outputAddressLine2);
442
327
 
443
328
  expect(masked['uuids']['uuid1']).to.equal(outputUuid);
329
+
330
+ expect(masked['jwts']['token1']).to.equal(outputJwt1);
331
+ expect(masked['jwts']['token2']).to.equal(outputJwt2);
444
332
  });
445
333
  it('Test masking improper JSON', function () {
446
334
  const notAJson = 'Not a JSON. Just a String';
@@ -451,254 +339,6 @@ describe('JSON mask2', function () {
451
339
  );
452
340
  });
453
341
 
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
- ]
479
- },
480
- array: ['element1', 'element22', 'element333']
481
- };
482
-
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 }) => {
494
- const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
495
-
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
- };
507
-
508
- jsonMaskConfig['cardFields'] = ['cards[*].number'];
509
- jsonMaskConfig['emailFields'] = ['emails.*'];
510
-
511
- jsonMaskConfig['stringFields'] = ['array.*'];
512
- jsonMaskConfig['stringMaskOptions'] = {
513
- maskWith: '?',
514
- maskOnlyFirstOccurance: false,
515
- values: [],
516
- maskAll: true,
517
- maskSpace: false
518
- };
519
-
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);
526
-
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('??????????');
538
- });
539
- });
540
- });
541
-
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
342
  describe('Mask card fields with custom options', function () {
703
343
  let testData = [
704
344
  {
@@ -931,4 +571,173 @@ describe('JSON mask2', function () {
931
571
  });
932
572
  });
933
573
  });
574
+
575
+ describe('Mask UUID fields with invalid options', function () {
576
+ let testData = [
577
+ {
578
+ title: 'Mask UUID fields with custom options',
579
+ input: JSON.parse(JSON.stringify(jsonInput)),
580
+ outputUuid: '123e4567-e89b-12d3-a456-426614174000'
581
+ }
582
+ ];
583
+
584
+ testData.forEach(({ title, input, outputUuid }) => {
585
+ const jsonMaskConfig = JSON.parse(JSON.stringify(Constants.defaultjsonMask2Configs));
586
+ const uuidMaskOptions = JSON.parse(JSON.stringify(Constants.defaultUuidMaskOptions));
587
+ // const defaultUuidMaskOptions = {
588
+ // maskWith: "*",
589
+ // unmaskedStartCharacters: 0,
590
+ // unmaskedEndCharacters: 0
591
+ // };
592
+ uuidMaskOptions['maskWith'] = 'X';
593
+ uuidMaskOptions['unmaskedStartCharacters'] = 8;
594
+ uuidMaskOptions['unmaskedEndCharacters'] = 12;
595
+ jsonMaskConfig['uuidFields'] = ['uuid1.*.invalidField'];
596
+ jsonMaskConfig['uuidMaskOptions'] = uuidMaskOptions;
597
+ it(`${title}`, function () {
598
+ const masked = maskData.maskJSON2(input, jsonMaskConfig);
599
+ expect(masked['credit']).to.equal(input['credit']);
600
+ expect(masked['debit']).to.equal(input['debit']);
601
+ expect(masked['primaryEmail']).to.equal(input['primaryEmail']);
602
+ expect(masked['secondaryEmail']).to.equal(input['secondaryEmail']);
603
+ expect(masked['password']).to.equal(input['password']);
604
+ expect(masked['homePhone']).to.equal(input['homePhone']);
605
+ expect(masked['workPhone']).to.equal(input['workPhone']);
606
+ expect(masked['addressLine1']).to.equal(input['addressLine1']);
607
+ expect(masked['addressLine2']).to.equal(input['addressLine2']);
608
+ expect(masked['uuid1']).to.equal(outputUuid);
609
+ });
610
+ });
611
+ });
612
+
613
+ describe('Test Json mask with .* and [*].', function () {
614
+ const jsonInput = {
615
+ cards: [
616
+ {
617
+ number: '1234-5678-8765-1234'
618
+ },
619
+ {
620
+ number: '1111-2222-1111-2222'
621
+ },
622
+ {
623
+ number: '0000-1111-2222-3333'
624
+ },
625
+ {
626
+ name: 'No card number here'
627
+ }
628
+ ],
629
+ emails: {
630
+ primaryEmail: 'primary@Email.com',
631
+ secondaryEmail: 'secondary@Email.com',
632
+ moreEmails: [
633
+ 'email1@email.com',
634
+ 'email2@email.com',
635
+ 'email3@email.com',
636
+ { childEmail: 'child@child.com', secondChild: { nestedkid: 'hello@hello.com' } }
637
+ ]
638
+ },
639
+ array: ['element1', 'element22', 'element333'],
640
+ jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJsb2wiLCJuYW1lIjoiVGVzdCIsImlhdCI6ImxvbCJ9.XNDxZcBWWEKYkCiu6XFGmAeuPF7iFnI7Sdv91gVZJMU'
641
+ };
642
+
643
+ let testData = [
644
+ {
645
+ title: 'Mask UUID fields with custom options',
646
+ input: JSON.parse(JSON.stringify(jsonInput)),
647
+ output: {
648
+ cards: [
649
+ {
650
+ number: 'XXXX-XXXX-XXXX-XXXX'
651
+ },
652
+ {
653
+ number: 'XXXX-XXXX-XXXX-XXXX'
654
+ },
655
+ {
656
+ number: 'XXXX-XXXX-XXXX-XXXX'
657
+ },
658
+ {
659
+ name: 'No card number here'
660
+ }
661
+ ],
662
+ emails: {
663
+ primaryEmail: '*******@*********',
664
+ secondaryEmail: '*********@*********',
665
+ moreEmails: [
666
+ '******@*********',
667
+ '******@*********',
668
+ '******@*********',
669
+ {
670
+ childEmail: '*****@*********',
671
+ secondChild: {
672
+ nestedkid: '*****@*********'
673
+ }
674
+ }
675
+ ]
676
+ },
677
+ array: ['????????', '?????????', '??????????'],
678
+ jwt: '************.**********.**********'
679
+ }
680
+ }
681
+ ];
682
+
683
+ const jsonMaskConfig = {
684
+ cardMaskOptions: { maskWith: 'X', unmaskedStartDigits: 0, unmaskedEndDigits: 0 },
685
+
686
+ emailMaskOptions: {
687
+ maskWith: '*',
688
+ unmaskedStartCharactersBeforeAt: 0,
689
+ unmaskedEndCharactersAfterAt: 0,
690
+ maskAtTheRate: false
691
+ },
692
+
693
+ stringMaskOptions: {
694
+ maskWith: '?',
695
+ maskOnlyFirstOccurance: false,
696
+ values: [],
697
+ maskAll: true,
698
+ maskSpace: false
699
+ },
700
+ jwtMaskOptions: {
701
+ maskWith: '*',
702
+ maxMaskedCharacters: 32,
703
+ maskDot: false,
704
+ maskHeader: true,
705
+ maskPayload: true,
706
+ maskSignature: true
707
+ },
708
+
709
+ cardFields: ['cards[*].number'],
710
+ emailFields: ['emails.*'],
711
+ stringFields: ['array.*'],
712
+ jwtFields: ['jwt']
713
+ };
714
+
715
+ testData.forEach(({ title, input, output }) => {
716
+ it(`${title}`, function () {
717
+ const masked = maskData.maskJSON2(input, jsonMaskConfig);
718
+ expect(masked['cards'][0].number).to.equal(output['cards'][0].number);
719
+ expect(masked['cards'][1].number).to.equal(output['cards'][1].number);
720
+ expect(masked['cards'][2].number).to.equal(output['cards'][2].number);
721
+ expect(masked['cards'][3].number).to.equal(undefined);
722
+
723
+ expect(masked['emails'].primaryEmail).to.equal(output['emails'].primaryEmail);
724
+ expect(masked['emails'].secondaryEmail).to.equal(output['emails'].secondaryEmail);
725
+ expect(masked['emails'].moreEmails[0]).to.equal(output['emails'].moreEmails[0]);
726
+ expect(masked['emails'].moreEmails[1]).to.equal(output['emails'].moreEmails[1]);
727
+ expect(masked['emails'].moreEmails[2]).to.equal(output['emails'].moreEmails[2]);
728
+ expect(masked['emails'].moreEmails[3].childEmail).to.equal(
729
+ output['emails'].moreEmails[3].childEmail
730
+ );
731
+ expect(masked['emails'].moreEmails[3].secondChild.nestedkid).to.equal(
732
+ output['emails'].moreEmails[3].secondChild.nestedkid
733
+ );
734
+
735
+ expect(masked['array'][0]).to.equal(output['array'][0]);
736
+ expect(masked['array'][1]).to.equal(output['array'][1]);
737
+ expect(masked['array'][2]).to.equal(output['array'][2]);
738
+
739
+ expect(masked['jwt']).to.equal(output['jwt']);
740
+ });
741
+ });
742
+ });
934
743
  });