@itentialopensource/adapter-utils 4.48.2 → 4.48.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.
- package/CHANGELOG.md +10 -0
- package/lib/connectorRest.js +46 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
## 4.48.3 [10-17-2022]
|
|
3
|
+
|
|
4
|
+
* Changes to have token data passed in url instead of body
|
|
5
|
+
|
|
6
|
+
Closes ADAPT-2404
|
|
7
|
+
|
|
8
|
+
See merge request itentialopensource/adapter-utils!240
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
2
12
|
## 4.48.2 [10-04-2022]
|
|
3
13
|
|
|
4
14
|
* Changes to have token data passed in url instead of body
|
package/lib/connectorRest.js
CHANGED
|
@@ -97,6 +97,8 @@ let healthy = false;
|
|
|
97
97
|
const healthlock = 0;
|
|
98
98
|
let healthcheck = false;
|
|
99
99
|
const healthchecklock = 0;
|
|
100
|
+
let encodeUri = true;
|
|
101
|
+
let authQueryEncode = null;
|
|
100
102
|
|
|
101
103
|
// Other global variables
|
|
102
104
|
let id = null;
|
|
@@ -1990,7 +1992,39 @@ function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1990
1992
|
bodyString = querystring.stringify(tokenEntity);
|
|
1991
1993
|
} else if (tokenSchema.requestDatatype && tokenSchema.requestDatatype.toUpperCase() === 'URLQUERY') {
|
|
1992
1994
|
// if the datatype is URLQUERY need to put into the query on the request
|
|
1993
|
-
|
|
1995
|
+
if (authQueryEncode != null) {
|
|
1996
|
+
if (authQueryEncode === true) {
|
|
1997
|
+
bodyString = querystring.stringify(tokenEntity);
|
|
1998
|
+
} else {
|
|
1999
|
+
bodyString = '';
|
|
2000
|
+
// if not encoding we need to build
|
|
2001
|
+
const qkeys = Object.keys(tokenEntity);
|
|
2002
|
+
// add each query parameter and its value
|
|
2003
|
+
for (let k = 0; k < qkeys.length; k += 1) {
|
|
2004
|
+
// need to add separator for everything after the first one
|
|
2005
|
+
if (k > 0) {
|
|
2006
|
+
bodyString += '&';
|
|
2007
|
+
}
|
|
2008
|
+
// adds key=value
|
|
2009
|
+
bodyString += `${qkeys[k]}=${tokenEntity[qkeys[k]]}`;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
} else if (encodeUri === true) {
|
|
2013
|
+
bodyString = querystring.stringify(tokenEntity);
|
|
2014
|
+
} else {
|
|
2015
|
+
bodyString = '';
|
|
2016
|
+
// if not encoding we need to build
|
|
2017
|
+
const qkeys = Object.keys(tokenEntity);
|
|
2018
|
+
// add each query parameter and its value
|
|
2019
|
+
for (let k = 0; k < qkeys.length; k += 1) {
|
|
2020
|
+
// need to add separator for everything after the first one
|
|
2021
|
+
if (k > 0) {
|
|
2022
|
+
bodyString += '&';
|
|
2023
|
+
}
|
|
2024
|
+
// adds key=value
|
|
2025
|
+
bodyString += `${qkeys[k]}=${tokenEntity[qkeys[k]]}`;
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
1994
2028
|
|
|
1995
2029
|
// append to the path
|
|
1996
2030
|
if (options.path.indexOf('?') < 0) {
|
|
@@ -1998,7 +2032,7 @@ function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1998
2032
|
} else {
|
|
1999
2033
|
options.path = `${options.path}&${bodyString}`;
|
|
2000
2034
|
}
|
|
2001
|
-
bodyString = '
|
|
2035
|
+
bodyString = '';
|
|
2002
2036
|
}
|
|
2003
2037
|
|
|
2004
2038
|
// if there is a body, set the content length of the body and add it to
|
|
@@ -3356,6 +3390,11 @@ class ConnectorRest {
|
|
|
3356
3390
|
choosepath = props.choosepath;
|
|
3357
3391
|
}
|
|
3358
3392
|
|
|
3393
|
+
// set the encodeUri (optional - default is true)
|
|
3394
|
+
if (typeof props.encode_queryvars === 'boolean') {
|
|
3395
|
+
encodeUri = props.encode_queryvars;
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3359
3398
|
if (props.authentication) {
|
|
3360
3399
|
// set the authentication method (required - default is null)
|
|
3361
3400
|
if (typeof props.authentication.auth_method === 'string') {
|
|
@@ -3452,6 +3491,11 @@ class ConnectorRest {
|
|
|
3452
3491
|
if (props.authentication.sso && typeof props.authentication.sso === 'object') {
|
|
3453
3492
|
sso = props.authentication.sso;
|
|
3454
3493
|
}
|
|
3494
|
+
|
|
3495
|
+
// set the authQueryEncode (optional - default is null)
|
|
3496
|
+
if (typeof props.authentication.authQueryEncode === 'boolean') {
|
|
3497
|
+
authQueryEncode = props.authentication.authQueryEncode;
|
|
3498
|
+
}
|
|
3455
3499
|
}
|
|
3456
3500
|
|
|
3457
3501
|
// set the stub mode (optional - default is false)
|