@itentialopensource/adapter-utils 4.48.7 → 4.48.9

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/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
1
 
2
+ ## 4.48.9 [03-23-2023]
3
+
4
+ * Add logic to strip escapes from the request body
5
+
6
+ Closes ADAPT-2611
7
+
8
+ See merge request itentialopensource/adapter-utils!249
9
+
10
+ ---
11
+
12
+ ## 4.48.8 [03-09-2023]
13
+
14
+ * Mask sensitive fields in reqHdr
15
+
16
+ Closes ADAPT-2575
17
+
18
+ See merge request itentialopensource/adapter-utils!247
19
+
20
+ ---
21
+
2
22
  ## 4.48.7 [01-31-2023]
3
23
 
4
24
  * Multi Step Authentication
@@ -22,7 +22,7 @@ let globalRequestGl = null;
22
22
  let returnRawGl = false;
23
23
  let encodePath = true;
24
24
  let encodeUri = true;
25
-
25
+ let stripEscapes = false;
26
26
  // INTERNAL FUNCTIONS
27
27
  /*
28
28
  * INTERNAL FUNCTION: Get the best match for the mock data response
@@ -967,7 +967,13 @@ function buildPayload(entity, action, entitySchema, payload) {
967
967
  return '';
968
968
  }
969
969
  }
970
-
970
+ // strip escapes if payload is double escaped
971
+ if (stripEscapes && systemEntity) {
972
+ let newPayload = JSON.stringify(systemEntity);
973
+ newPayload = newPayload.replace(/\\\\/g, '\\');
974
+ log.debug(`STRIPPED BODY HERE: ${newPayload}`);
975
+ return newPayload;
976
+ }
971
977
  // return the payload
972
978
  return JSON.stringify(systemEntity);
973
979
  } catch (e) {
@@ -1021,6 +1027,11 @@ class RestHandler {
1021
1027
  this.encodeQ = properties.encode_queryvars;
1022
1028
  encodeUri = this.encodeQ;
1023
1029
 
1030
+ // optional to strip extra escapes - default is false
1031
+ if (properties.stripEscapes) {
1032
+ stripEscapes = properties.stripEscapes;
1033
+ }
1034
+
1024
1035
  // only need to set returnRaw if the property is true - defaults to false
1025
1036
  if (properties.request && properties.request.return_raw) {
1026
1037
  returnRawGl = properties.request.return_raw;
@@ -1032,6 +1032,17 @@ class AdapterTranslatorUtil {
1032
1032
  if (sysRes) {
1033
1033
  errorObject.IAPerror.raw_response = sysRes;
1034
1034
  }
1035
+
1036
+ // Mask sensitive fields in reqHdr
1037
+ const sensitiveWords = /auth|token|x|key/i;
1038
+ if (errorObject.IAPerror.raw_response && errorObject.IAPerror.raw_response.reqHdr) {
1039
+ Object.keys(errorObject.IAPerror.raw_response.reqHdr).forEach((key) => {
1040
+ if (sensitiveWords.test(key)) {
1041
+ errorObject.IAPerror.raw_response.reqHdr[key] = '****';
1042
+ }
1043
+ });
1044
+ }
1045
+
1035
1046
  if (stack) {
1036
1047
  errorObject.IAPerror.stack = stack;
1037
1048
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "4.48.7",
3
+ "version": "4.48.9",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",