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/.prettierrc.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ semi: true,
3
+ trailingComma: 'none',
4
+ singleQuote: true,
5
+ printWidth: 100,
6
+ tabWidth: 2
7
+ };
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.2 Features](#release-features)
7
+ - [Version 1.2.4 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)
@@ -12,16 +12,16 @@ maskdata is a Node.js module to mask various kinds of data. With the help of mas
12
12
  - [Mask Email id with the default configuration](#mask-email-id-with-the-default-configuration)
13
13
  - [Mask JSON fields](#mask-json)
14
14
  - [JSON mask examples with nested fields](#json-mask-examples)
15
+ - [Mask multiple fields at once using .* and [*].](#mask-multiple-fields)
15
16
  - [Mask Password](#mask-password)
16
17
  - [Mask Password with the default configuration](#mask-password-with-the-default-configuration)
17
18
  - [Mask Phone Number](#mask-phone-number)
18
19
  - [Mask Phone Number with the default configuration](#mask-phone-number-with-the-default-configuration)
19
20
  - [Mask words/characters in a string](#mask-the-characters-or-words-in-the-string)
20
21
  - [Mask UUID](#mask-uuid)
22
+ - [Mask JWT Token](#mask-jwt-token)
21
23
  - [Get Nested JSON Property](#get-nested-json-property)
22
24
  - [Replace the value of a JSON field](#replace-the-value-of-a-json-field)
23
- - [Mask JSON fields](#mask-fields-in-a-json)
24
- - [Mask nested JSON fields](#mask-fields-of-a-nested-object)
25
25
  - [Report Bugs](#report-bugs)
26
26
  - [Give a Star](#give-a-star)
27
27
  - [LICENSE - "MIT"](#license---mit)
@@ -33,6 +33,7 @@ maskdata is a Node.js module to mask various kinds of data. With the help of mas
33
33
  * Mask Phone numbers
34
34
  * Mask the given words/substrings from throughout a String
35
35
  * Mask UUIDs
36
+ * Mask JWT tokens
36
37
  * Mask JSON - JSON can contain cards, emails, passwords, phones, strings, and UUIDs. Mask all of them with a single call using - [Mask JSON fields](#mask-json)
37
38
  * Get nested field from JSON
38
39
  * Set/Replace nested field values from JSON
@@ -42,6 +43,14 @@ maskdata is a Node.js module to mask various kinds of data. With the help of mas
42
43
  > npm i maskdata
43
44
 
44
45
  # Release Features
46
+ ### Version 1.2.4
47
+ - JWT token masking: Mask JWT tokens with configs to mask as per your need. More details: [Mask JWT Token](#mask-jwt-token)
48
+ - Mask Json now supports JWT token masking also. More details: [Mask JWT in a JSON](#mask-json)
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"`
50
+ - Better test coverage to the module with the addition of new test cases
51
+ ### Version 1.2.3
52
+ - Bug fix for masking a list of elements in the nested json. More details: [Mask multiple fields](#mask-multiple-fields)
53
+ - Deprecated *maskJsonFields*(For documentation on the maskJsonFields, check previous version README.md files) function and will be removed in the subsequent versions. Use *maksJson2* instead: https://www.npmjs.com/package/maskdata#mask-json
45
54
  ### Version 1.2.2
46
55
  - Type definitions for the typescript developers. Yay!!!
47
56
  But there is a small change in how you import and use the library. Follow this to know how you can import and use the masking functions in a typescript project: [Mask data for Typescript](#maskdata-for-typescript)
@@ -51,15 +60,6 @@ But there is a small change in how you import and use the library. Follow this t
51
60
  - Minor bug fix in card masking.
52
61
  - Extensive testing with the help of mocha test cases for all features covering more than 110 test cases.
53
62
  - Improved Documentation
54
- ### Version: 1.1.10
55
- - Support of maxMaskedCharacters in masking JSON fields: https://github.com/Sumukha1496/maskdata/issues/21
56
- - This is applicable only if the type of value is a string. Details: [Mask JSON fields](#mask-fields-in-a-json)
57
- ### Version: 1.1.8
58
- - Mocha test cases for most of the use cases.
59
- https://github.com/Sumukha1496/maskdata/pull/23
60
- - Handling null/Empty inputs --> Mask function will return the input itself.
61
- ### Version: 1.1.6
62
- - Feature to mask all the characters in the String along with mask/visible spaces in the string.
63
63
 
64
64
  # How to Use
65
65
  ```javascript
@@ -196,6 +196,9 @@ const defaultjsonMask2Configs = {
196
196
 
197
197
  uuidMaskOptions: defaultUuidMaskOptions, // Optional
198
198
  uuidFields: [] // List of UUID fields to be masked
199
+
200
+ jwtMaskOptions: defaultJwtMaskOptions, // Optional
201
+ jwtFields: [] // List of JWT fields to be masked
199
202
  };
200
203
  ```
201
204
  <b>NOTE: For defaultCardMaskOptions, defaultEmailMask2Options, defaultPasswordMaskOptions, defaultPhoneMaskOptions, defaultStringMaskOptions and defaultUuidMaskOptions refer the corresponding masking features. </b>
@@ -661,111 +664,151 @@ const uuidAfterMasking = MaskData.maskUuid(uuidInput, maskUuidOptions);
661
664
 
662
665
  ```
663
666
 
664
- ## Get Nested JSON Property
665
- This method returns the value of the nested JSON property if it exists. Otherwise, it returns ```undefined```
667
+ ## Mask JWT Token
668
+ This function returns the masked JWT tokens. A JWT token consists of 3 parts separated by 2 dots. i.e, `{header}.{payload}.{signature}`. Based on the usecase, we will have to mask/keep a part/s of jwt token. With maskdata you can mask JWT tokens with all possible combinations.
669
+ If the input is null, undefined, non-string, string with length < 5, doesn't contain 2 dots(invalid JWT format), the function will return the input as it is without masking.
670
+
666
671
  ```javascript
672
+
667
673
  const MaskData = require('./maskdata');
668
674
 
669
- const innerPropety = Maskdata.getInnerProperty(object, field);
675
+ const jwtMaskOptions = {
676
+ // Character to mask the data. The default value is '*'
677
+ maskWith: '*',
670
678
 
671
- Example:
679
+ // Max masked characters in the output(EXCLUDING the unmasked characters). Default value is 512
680
+ maxMaskedCharacters: 512,
672
681
 
673
- const nestedObject = {
674
- level1: {
675
- field1: "field1",
676
- level2: {
677
- field2: "field2",
678
- level3: {
679
- field3: "field3",
680
- field4: [ { Hello: "world" }, { Hello: "Newworld" }, "Just a String" ]
681
- }
682
- }
683
- },
684
- value1: "value"
682
+ // Config to mask OR keep the dots(.). Default value is true, i.e, mask dots
683
+ maskDot: true,
684
+
685
+ // Config to mask OR keep the first part of the JWT. i.e, the header part. Default value is true, i.e, mask the header part
686
+ maskHeader: true,
687
+
688
+ // Config to mask OR keep the second part of the JWT. i.e, the payload part. Default value is true, i.e, mask the payload part
689
+ maskPayload: true,
690
+
691
+ // Config to mask OR keep the third part of the JWT. i.e, the signature part. Default value is true, i.e, mask the signature part
692
+ maskSignature: true
685
693
  };
686
694
 
687
- const innerPropety = Maskdata.getInnerProperty(nestedObject, 'level1.level2.level3.field4[0].Hello');
695
+ const jwt =
696
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjJ9.tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ';
697
+
698
+ /** In this example,
699
+ * Header = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
700
+ * Payload = eyJpYXQiOjE1MTYyMzkwMjJ9
701
+ * Signature = tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ
702
+ */
703
+ const maskedJwt = MaskData.maskJwt(jwt, jwtMaskOptions);
704
+ console.log(maskedJwt);
705
+
706
+ // Output:
707
+ *********************************************************************************************************
688
708
 
689
709
  ```
690
710
 
711
+ #### Example: Mask only the signature part
691
712
 
692
- ## Replace the value of a JSON field
693
- To replace a value by keeping the type.
694
713
  ```javascript
695
714
 
696
- const input = {
697
- name: "John",
698
- age: 33,
699
- married: true
700
- }
715
+ const MaskData = require('./maskdata');
701
716
 
702
- let afterReplacing = MaskData.replaceValue(input, 'age', 99);
703
- afterReplacing = MaskData.replaceValue(input, 'married', false);
717
+ const jwtMaskOptions = {
718
+ maskWith: '*',
719
+ maxMaskedCharacters: 512,
720
+ maskDot: false,
721
+ maskHeader: false,
722
+ maskPayload: false,
723
+ maskSignature: true
724
+ };
704
725
 
705
- //Output:
706
- Before replacing: {"name":"John","age":33,"married":true}
707
- After replacing: {"name":"John","age":99,"married":false}
726
+ const jwt =
727
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjJ9.tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ';
708
728
 
709
- Type of age: number
710
- Type of married: boolean
729
+ /** In this example,
730
+ * Header = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
731
+ * Payload = eyJpYXQiOjE1MTYyMzkwMjJ9
732
+ * Signature = tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ
733
+ */
734
+ const maskedJwt = MaskData.maskJwt(jwt, jwtMaskOptions);
735
+ console.log(maskedJwt);
736
+
737
+ // Output:
738
+ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjJ9.*******************************************
711
739
 
712
740
  ```
713
741
 
714
- ## Mask fields in a JSON
715
- <b> NOTE: This is an old functionality. For more flexibility and single masking call to mask different types of data in the json object, start using the new maskJson2() function - [Mask JSON fields](#mask-json)</b>
742
+ #### Example: Mask header and the signature part
716
743
 
717
- This method masks the field value if present in the given object.
718
744
  ```javascript
719
- const MaskData = require('./maskdata');
720
745
 
721
- const maskJSONOptions = {
722
- // Character to mask the data. The default value is '*'
723
- maskWith: "*",
746
+ const MaskData = require('./maskdata');
724
747
 
725
- // It should be an array
726
- // Field names to mask. Can give multiple fields.
727
- fields: ['password', 'firstName'],
728
-
729
- // If the type of value is a string and if we want to limit the number of characters in the output, then we can use this. The default value is -1 means, by default this feature is disabled. It is enabled if we provide a positive integer value. This is not a mandatory field in the config and if not provided, it will take the default value -1 and disable the feature.
730
- maxMaskedCharactersStr: 4 // Default value is -1 (Disable feature)
748
+ const jwtMaskOptions = {
749
+ maskWith: '*',
750
+ maxMaskedCharacters: 512,
751
+ maskDot: false,
752
+ maskHeader: true,
753
+ maskPayload: false,
754
+ maskSignature: true
731
755
  };
732
756
 
733
- const obj = {
734
- password: "IKnowNothing",
735
- firstName: "Jon",
736
- lastName: "Snoww"
737
- };
757
+ const jwt =
758
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjJ9.tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ';
738
759
 
739
- const maskedObj = MaskData.maskJSONFields(obj, maskJSONOptions);
760
+ /** In this example,
761
+ * Header = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
762
+ * Payload = eyJpYXQiOjE1MTYyMzkwMjJ9
763
+ * Signature = tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ
764
+ */
765
+ const maskedJwt = MaskData.maskJwt(jwt, jwtMaskOptions);
766
+ console.log(maskedJwt);
740
767
 
741
- //Output: { password: '****', firstName: '***', lastName: 'Snoww' }
768
+ // Output:
769
+ ************************************.eyJpYXQiOjE1MTYyMzkwMjJ9.*******************************************
742
770
 
743
771
  ```
744
772
 
773
+ #### Example: Mask all parts except dots and limit the max masked characters in the output to lower value, say 16
774
+
775
+ ```javascript
776
+
777
+ const MaskData = require('./maskdata');
745
778
 
746
- ## Mask fields of a nested Object
747
- <b>NOTE: USE [Mask JSON fields](#mask-json) for better functionalities.</b>
779
+ const jwtMaskOptions = {
780
+ maskWith: '*',
781
+ maxMaskedCharacters: 16,
782
+ maskDot: false,
783
+ maskHeader: true,
784
+ maskPayload: true,
785
+ maskSignature: true
786
+ };
748
787
 
749
- This method masks the field value if present in the given object.
750
- The masked value type will always be a string. Won't mask if the value is ```null```.
788
+ const jwt =
789
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjJ9.tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ';
751
790
 
752
- If the field doesn't exist or if there is any syntax error, then it will ignore it without throwing any error.
791
+ /** In this example,
792
+ * Header = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
793
+ * Payload = eyJpYXQiOjE1MTYyMzkwMjJ9
794
+ * Signature = tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ
795
+ */
796
+ const maskedJwt = MaskData.maskJwt(jwt, jwtMaskOptions);
797
+ console.log(maskedJwt);
798
+
799
+ // Output:
800
+ ******.*****.*****
801
+
802
+ ```
803
+
804
+ ## Get Nested JSON Property
805
+ This method returns the value of the nested JSON property if it exists. Otherwise, it returns ```undefined```
753
806
  ```javascript
754
807
  const MaskData = require('./maskdata');
755
808
 
756
- const maskJSONOptions = {
757
- // Character to mask the data. The default value is '*'
758
- maskWith: "*",
809
+ const innerPropety = Maskdata.getInnerProperty(object, field);
759
810
 
760
- // It should be an array
761
- // Field names to mask. Can give multiple fields.
762
- fields : [ 'level1.level2.level3.field3',
763
- 'level1.level2.field2',
764
- 'level1.field1',
765
- 'value1',
766
- 'level1.level2.level3.field4[0].Hello',
767
- 'level1.level2.level3.field4[2]']
768
- };
811
+ Example:
769
812
 
770
813
  const nestedObject = {
771
814
  level1: {
@@ -774,95 +817,121 @@ const nestedObject = {
774
817
  field2: "field2",
775
818
  level3: {
776
819
  field3: "field3",
777
- field4: [{ Hello: "world" }, { Hello: "Newworld" }, "Just a String"]
820
+ field4: [ { Hello: "world" }, { Hello: "Newworld" }, "Just a String" ]
778
821
  }
779
822
  }
780
823
  },
781
824
  value1: "value"
782
825
  };
783
- const maskedObj = MaskData.maskJSONFields(nestedObject, defaultJSONMaskOptions2);
784
826
 
785
- //Output:
786
- {
787
- "level1": {
788
- "field1": "******",
789
- "level2": {
790
- "field2": "******",
791
- "level3": {
792
- "field3": "******",
793
- "field4": [
794
- {
795
- "Hello": null
796
- },
797
- {
798
- "Hello": "Newworld"
799
- },
800
- "*************"
801
- ]
802
- }
803
- }
804
- },
805
- "value1": "*****"
806
- }
807
- ```
827
+ const innerPropety = Maskdata.getInnerProperty(nestedObject, 'level1.level2.level3.field4[0].Hello');
808
828
 
829
+ ```
809
830
 
810
- ### Example2: To mask all the keys of an object or to mask a field from all the elements of an array.
811
831
 
832
+ ## Replace the value of a JSON field
833
+ To replace a value by keeping the type.
812
834
  ```javascript
813
- Limitations:
814
- 1. Only one * is allowed per field. Either ARRAY[*].FIELD or JSON.*
815
- 2. It will not work for nested fields like ARRAY[*].FIELD1.FIELD2
816
- 3. It will not mask all array elements if given ARRAY[*] or ARRAY[*].
817
- 4. Will not mask null values.
818
- 5. If ARRAY[*].FIELD is an object, then it will mask that entire object including the key.
819
835
 
820
- const nestedObject = {
821
- level1: {
822
- field1: "field1Value",
823
- level2: {
824
- field2: "field2Value",
825
- field3: [ { Hello: "Hello", Hi: "one" }, { Hello: "Hello again" } ],
826
- level3: {
827
- field4: "field4Value",
828
- field5: "field5Value"
829
- }
836
+ const input = {
837
+ name: "John",
838
+ age: 33,
839
+ married: true
840
+ }
841
+
842
+ let afterReplacing = MaskData.replaceValue(input, 'age', 99);
843
+ afterReplacing = MaskData.replaceValue(input, 'married', false);
844
+
845
+ //Output:
846
+ Before replacing: {"name":"John","age":33,"married":true}
847
+ After replacing: {"name":"John","age":99,"married":false}
848
+
849
+ Type of age: number
850
+ Type of married: boolean
851
+
852
+ ```
853
+
854
+ ### Mask Multiple Fields
855
+ ```javascript
856
+ const jsonInput = {
857
+ cards: [
858
+ {
859
+ number: '1234-5678-8765-1234'
860
+ },
861
+ {
862
+ number: '1111-2222-1111-2222'
863
+ },
864
+ {
865
+ number: '0000-1111-2222-3333'
866
+ },
867
+ {
868
+ name: "No card number here"
830
869
  }
870
+ ],
871
+ emails: {
872
+ primaryEmail: 'primary@Email.com',
873
+ secondaryEmail: 'secondary@Email.com',
874
+ moreEmails: ["email1@email.com", "email2@email.com", "email3@email.com", {childEmail: "child@child.com", secondChild: {nestedkid: "hello@hello.com"}}]
831
875
  },
832
- value1: "value"
876
+ array: ["element1", "element22", "element333"],
877
+ jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJsb2wiLCJuYW1lIjoiVGVzdCIsImlhdCI6ImxvbCJ9.XNDxZcBWWEKYkCiu6XFGmAeuPF7iFnI7Sdv91gVZJMU'
833
878
  };
834
879
 
835
- const maskAllFields = {
836
- fields : ['level1.level2.field3[*].Hello', 'level1.level2.level3.*']
837
- };
880
+ const jsonMaskConfig = {
881
+ cardMaskOptions: { maskWith: "X", unmaskedStartDigits: 0, unmaskedEndDigits: 0},
882
+
883
+ emailMaskOptions: { maskWith: "*", unmaskedStartCharactersBeforeAt: 0,
884
+ unmaskedEndCharactersAfterAt: 0, maskAtTheRate: false },
838
885
 
839
- const maskedObject = MaskData.maskJSONFields(nestedObject, maskAllFields);
886
+ stringMaskOptions: { maskWith: "?", maskOnlyFirstOccurance: false, values: [], maskAll: true, maskSpace: false },
887
+ jwtMaskOptions: { maskWith: '*', maxMaskedCharacters: 32, maskDot: false, maskHeader: true, maskPayload: true, maskSignature: true},
888
+
889
+ cardFields: ['cards[*].number'],
890
+ emailFields: ['emails.*'],
891
+ stringFields: ['array.*'],
892
+ jwtFields: ['jwt']
893
+ }
894
+
895
+ const maskedOutput = maskData.maskJSON2(jsonInput, jsonMaskConfig);
840
896
 
841
897
  // Output:
842
898
  {
843
- "level1": {
844
- "field1": "field1Value",
845
- "level2": {
846
- "field2": "field2Value",
847
- "field3": [
848
- {
849
- "Hello": "*****",
850
- "Hi": "one"
851
- },
852
- {
853
- "Hello": "***********"
899
+ "cards": [
900
+ {
901
+ "number": "XXXX-XXXX-XXXX-XXXX"
902
+ },
903
+ {
904
+ "number": "XXXX-XXXX-XXXX-XXXX"
905
+ },
906
+ {
907
+ "number": "XXXX-XXXX-XXXX-XXXX"
908
+ },
909
+ {
910
+ "name": "No card number here"
911
+ }
912
+ ],
913
+ "emails": {
914
+ "primaryEmail": "*******@*********",
915
+ "secondaryEmail": "*********@*********",
916
+ "moreEmails": [
917
+ "******@*********",
918
+ "******@*********",
919
+ "******@*********",
920
+ {
921
+ "childEmail": "*****@*********",
922
+ "secondChild": {
923
+ "nestedkid": "*****@*********"
854
924
  }
855
- ],
856
- "level3": {
857
- "field4": "***********",
858
- "field5": "***********"
859
925
  }
860
- }
926
+ ]
861
927
  },
862
- "value1": "value"
928
+ "array": ["????????", "?????????", "??????????"],
929
+ "jwt": "************.**********.**********"
863
930
  }
931
+
864
932
  ```
865
933
 
934
+
866
935
  # Report Bugs
867
936
  If there is any help needed with the library functionalities or if there is any bug/issue, please raise an issue in GitHub: https://github.com/Sumukha1496/maskdata/issues
868
937
 
package/index.d.ts CHANGED
@@ -1,73 +1,87 @@
1
- declare module 'maskdata' {
2
- export interface CardMaskOptions {
3
- maskWith?: string;
4
- unmaskedStartDigits?: number;
5
- unmaskedEndDigits?: number;
6
- }
7
-
8
- export interface EmailMask2Options {
9
- maskWith?: string;
10
- unmaskedStartCharactersBeforeAt?: number;
11
- unmaskedEndCharactersAfterAt?: number;
12
- maskAtTheRate?: boolean;
13
- }
14
-
15
- export interface JsonMaskOptions {
16
- maskWith?: string;
17
- fields?: string[];
18
- maxMaskedCharactersStr?: number;
19
- }
20
-
21
- export interface PasswordMaskOptions {
22
- maskWith?: string;
23
- maxMaskedCharacters?: number;
24
- unmaskedStartCharacters?: number;
25
- unmaskedEndCharacters?: number;
26
- }
27
-
28
- export interface PhoneMaskOptions {
29
- maskWith?: string;
30
- unmaskedStartDigits?: number;
31
- unmaskedEndDigits?: number;
32
- }
33
-
34
- export interface StringMaskOptions {
35
- maskWith?: string;
36
- maskOnlyFirstOccurance?: boolean;
37
- values?: string[];
38
- maskAll?: boolean;
39
- maskSpace?: boolean;
40
- }
41
-
42
- export interface UuidMaskOptions {
43
- maskWith?: string;
44
- unmaskedStartCharacters?: number;
45
- unmaskedEndCharacters?: number;
46
- }
1
+ declare module 'maskdata' {
2
+ export interface CardMaskOptions {
3
+ maskWith?: string;
4
+ unmaskedStartDigits?: number;
5
+ unmaskedEndDigits?: number;
6
+ }
47
7
 
48
- export interface JsonMask2Configs {
49
- cardMaskOptions?: CardMaskOptions;
50
- cardFields?: string[];
51
- emailMaskOptions?: EmailMask2Options;
52
- emailFields?: string[];
53
- passwordMaskOptions?: PasswordMaskOptions;
54
- passwordFields?: string[];
55
- phoneMaskOptions?: PhoneMaskOptions;
56
- phoneFields?: string[];
57
- stringMaskOptions?: StringMaskOptions;
58
- stringFields?: string[];
59
- uuidMaskOptions?: UuidMaskOptions;
60
- uuidFields?: string[];
61
- }
62
-
63
- export function maskPassword(password?: string, options?: PasswordMaskOptions): string;
64
- export function maskJSONFields<T extends object>(json?: T, options?: JsonMaskOptions): T;
65
- export function maskJSON2<T extends object>(json?: T, options?: JsonMask2Configs): T;
66
- export function maskPhone(phone?: string, options?: PhoneMaskOptions): string;
67
- export function maskEmail2(email?: string, options?: EmailMask2Options): string;
68
- export function maskCard(cardNumber?: string, options?: CardMaskOptions): string;
69
- export function maskString(str?: string, options?: StringMaskOptions): string;
70
- export function maskUuid(uuid?: string, options?: UuidMaskOptions): string;
71
- export function getInnerProperty(object: object, field: string): any;
72
- export function replaceValue(object: object, field: string, value: any): object;
73
- }
8
+ export interface EmailMask2Options {
9
+ maskWith?: string;
10
+ unmaskedStartCharactersBeforeAt?: number;
11
+ unmaskedEndCharactersAfterAt?: number;
12
+ maskAtTheRate?: boolean;
13
+ }
14
+
15
+ export interface JsonMaskOptions {
16
+ maskWith?: string;
17
+ fields?: string[];
18
+ maxMaskedCharactersStr?: number;
19
+ }
20
+
21
+ export interface PasswordMaskOptions {
22
+ maskWith?: string;
23
+ maxMaskedCharacters?: number;
24
+ unmaskedStartCharacters?: number;
25
+ unmaskedEndCharacters?: number;
26
+ }
27
+
28
+ export interface PhoneMaskOptions {
29
+ maskWith?: string;
30
+ unmaskedStartDigits?: number;
31
+ unmaskedEndDigits?: number;
32
+ }
33
+
34
+ export interface StringMaskOptions {
35
+ maskWith?: string;
36
+ maskOnlyFirstOccurance?: boolean;
37
+ values?: string[];
38
+ maskAll?: boolean;
39
+ maskSpace?: boolean;
40
+ }
41
+
42
+ export interface UuidMaskOptions {
43
+ maskWith?: string;
44
+ unmaskedStartCharacters?: number;
45
+ unmaskedEndCharacters?: number;
46
+ }
47
+
48
+ export interface JwtMaskOptions {
49
+ maskWith?: string;
50
+ maxMaskedCharacters?: number;
51
+ maskDot?: boolean;
52
+ maskHeader?: boolean;
53
+ maskPayload?: boolean;
54
+ maskSignature?: boolean;
55
+ }
56
+
57
+ export interface JsonMask2Configs {
58
+ cardMaskOptions?: CardMaskOptions;
59
+ cardFields?: string[];
60
+ emailMaskOptions?: EmailMask2Options;
61
+ emailFields?: string[];
62
+ passwordMaskOptions?: PasswordMaskOptions;
63
+ passwordFields?: string[];
64
+ phoneMaskOptions?: PhoneMaskOptions;
65
+ phoneFields?: string[];
66
+ stringMaskOptions?: StringMaskOptions;
67
+ stringFields?: string[];
68
+ uuidMaskOptions?: UuidMaskOptions;
69
+ uuidFields?: string[];
70
+ }
71
+
72
+ export function maskPassword(password?: string, options?: PasswordMaskOptions): string;
73
+ /**
74
+ * @deprecated
75
+ * Use maskJSON2 instead: https://www.npmjs.com/package/maskdata#mask-json
76
+ */
77
+ export function maskJSONFields<T extends object>(json?: T, options?: JsonMaskOptions): T;
78
+ export function maskJSON2<T extends object>(json?: T, options?: JsonMask2Configs): T;
79
+ export function maskPhone(phone?: string, options?: PhoneMaskOptions): string;
80
+ export function maskEmail2(email?: string, options?: EmailMask2Options): string;
81
+ export function maskCard(cardNumber?: string, options?: CardMaskOptions): string;
82
+ export function maskString(str?: string, options?: StringMaskOptions): string;
83
+ export function maskUuid(uuid?: string, options?: UuidMaskOptions): string;
84
+ export function maskJwt(jwt?: string, options?: JwtMaskOptions): string;
85
+ export function getInnerProperty(object: object, field: string): any;
86
+ export function replaceValue(object: object, field: string, value: any): object;
87
+ }