@itentialopensource/adapter-utils 4.48.8 → 4.48.10
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 +20 -0
- package/lib/connectorRest.js +11 -0
- package/lib/restHandler.js +22 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
|
|
2
|
+
## 4.48.10 [03-24-2023]
|
|
3
|
+
|
|
4
|
+
* Added option to remove username and password from auth body and option to remove response headers
|
|
5
|
+
|
|
6
|
+
Closes ADAPT-2628
|
|
7
|
+
|
|
8
|
+
See merge request itentialopensource/adapter-utils!250
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 4.48.9 [03-23-2023]
|
|
13
|
+
|
|
14
|
+
* Add logic to strip escapes from the request body
|
|
15
|
+
|
|
16
|
+
Closes ADAPT-2611
|
|
17
|
+
|
|
18
|
+
See merge request itentialopensource/adapter-utils!249
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
2
22
|
## 4.48.8 [03-09-2023]
|
|
3
23
|
|
|
4
24
|
* Mask sensitive fields in reqHdr
|
package/lib/connectorRest.js
CHANGED
|
@@ -101,6 +101,7 @@ let healthcheck = false;
|
|
|
101
101
|
const healthchecklock = 0;
|
|
102
102
|
let encodeUri = true;
|
|
103
103
|
let authQueryEncode = null;
|
|
104
|
+
let addCreds = true;
|
|
104
105
|
|
|
105
106
|
// Other global variables
|
|
106
107
|
let id = null;
|
|
@@ -2009,6 +2010,12 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
2009
2010
|
}
|
|
2010
2011
|
}
|
|
2011
2012
|
|
|
2013
|
+
if (actReqBody && !addCreds) {
|
|
2014
|
+
// remove the username and password from the creds
|
|
2015
|
+
delete creds.username;
|
|
2016
|
+
delete creds.password;
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2012
2019
|
if (tokenSchema.headers && tokenSchema.headers.Authorization) {
|
|
2013
2020
|
// remove the username and password from the creds
|
|
2014
2021
|
delete creds.username;
|
|
@@ -3837,6 +3844,10 @@ class ConnectorRest {
|
|
|
3837
3844
|
if (typeof props.authentication.authQueryEncode === 'boolean') {
|
|
3838
3845
|
authQueryEncode = props.authentication.authQueryEncode;
|
|
3839
3846
|
}
|
|
3847
|
+
|
|
3848
|
+
if (typeof props.authentication.addCreds === 'boolean') {
|
|
3849
|
+
addCreds = props.authentication.addCreds;
|
|
3850
|
+
}
|
|
3840
3851
|
}
|
|
3841
3852
|
|
|
3842
3853
|
// set the stub mode (optional - default is false)
|
package/lib/restHandler.js
CHANGED
|
@@ -22,7 +22,8 @@ let globalRequestGl = null;
|
|
|
22
22
|
let returnRawGl = false;
|
|
23
23
|
let encodePath = true;
|
|
24
24
|
let encodeUri = true;
|
|
25
|
-
|
|
25
|
+
let stripEscapes = false;
|
|
26
|
+
let returnResponseHeaders = true;
|
|
26
27
|
// INTERNAL FUNCTIONS
|
|
27
28
|
/*
|
|
28
29
|
* INTERNAL FUNCTION: Get the best match for the mock data response
|
|
@@ -360,6 +361,10 @@ function handleRestRequest(request, entityId, entitySchema, callProperties, filt
|
|
|
360
361
|
delete retObject.reqHdr;
|
|
361
362
|
}
|
|
362
363
|
|
|
364
|
+
if (returnResponseHeaders === false && retObject.headers) {
|
|
365
|
+
delete retObject.headers;
|
|
366
|
+
}
|
|
367
|
+
|
|
363
368
|
// if we want the raw response
|
|
364
369
|
if (returnRawGl || (callProperties && callProperties.request && callProperties.request.return_raw)) {
|
|
365
370
|
retObject.raw = resObj.response;
|
|
@@ -967,7 +972,13 @@ function buildPayload(entity, action, entitySchema, payload) {
|
|
|
967
972
|
return '';
|
|
968
973
|
}
|
|
969
974
|
}
|
|
970
|
-
|
|
975
|
+
// strip escapes if payload is double escaped
|
|
976
|
+
if (stripEscapes && systemEntity) {
|
|
977
|
+
let newPayload = JSON.stringify(systemEntity);
|
|
978
|
+
newPayload = newPayload.replace(/\\\\/g, '\\');
|
|
979
|
+
log.debug(`STRIPPED BODY HERE: ${newPayload}`);
|
|
980
|
+
return newPayload;
|
|
981
|
+
}
|
|
971
982
|
// return the payload
|
|
972
983
|
return JSON.stringify(systemEntity);
|
|
973
984
|
} catch (e) {
|
|
@@ -1021,6 +1032,11 @@ class RestHandler {
|
|
|
1021
1032
|
this.encodeQ = properties.encode_queryvars;
|
|
1022
1033
|
encodeUri = this.encodeQ;
|
|
1023
1034
|
|
|
1035
|
+
// optional to strip extra escapes - default is false
|
|
1036
|
+
if (properties.stripEscapes) {
|
|
1037
|
+
stripEscapes = properties.stripEscapes;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1024
1040
|
// only need to set returnRaw if the property is true - defaults to false
|
|
1025
1041
|
if (properties.request && properties.request.return_raw) {
|
|
1026
1042
|
returnRawGl = properties.request.return_raw;
|
|
@@ -1031,6 +1047,10 @@ class RestHandler {
|
|
|
1031
1047
|
this.globalRequest = properties.request.global_request;
|
|
1032
1048
|
globalRequestGl = this.globalRequest;
|
|
1033
1049
|
}
|
|
1050
|
+
|
|
1051
|
+
if (typeof properties.request.returnResponseHeaders === 'boolean') {
|
|
1052
|
+
returnResponseHeaders = properties.request.returnResponseHeaders;
|
|
1053
|
+
}
|
|
1034
1054
|
}
|
|
1035
1055
|
|
|
1036
1056
|
/**
|