@itentialopensource/adapter-utils 4.48.1 → 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 +20 -0
- package/lib/connectorRest.js +55 -0
- package/lib/propertyUtil.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
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
|
+
|
|
12
|
+
## 4.48.2 [10-04-2022]
|
|
13
|
+
|
|
14
|
+
* Changes to have token data passed in url instead of body
|
|
15
|
+
|
|
16
|
+
Closes ADAPT-2404
|
|
17
|
+
|
|
18
|
+
See merge request itentialopensource/adapter-utils!239
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
2
22
|
## 4.48.1 [09-22-2022]
|
|
3
23
|
|
|
4
24
|
* Add capability to send base64 and buffer in formData
|
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;
|
|
@@ -1988,6 +1990,49 @@ function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1988
1990
|
bodyString = JSON.stringify(tokenEntity);
|
|
1989
1991
|
} else if (tokenSchema.requestDatatype && tokenSchema.requestDatatype.toUpperCase() === 'URLENCODE') {
|
|
1990
1992
|
bodyString = querystring.stringify(tokenEntity);
|
|
1993
|
+
} else if (tokenSchema.requestDatatype && tokenSchema.requestDatatype.toUpperCase() === 'URLQUERY') {
|
|
1994
|
+
// if the datatype is URLQUERY need to put into the query on the request
|
|
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
|
+
}
|
|
2028
|
+
|
|
2029
|
+
// append to the path
|
|
2030
|
+
if (options.path.indexOf('?') < 0) {
|
|
2031
|
+
options.path = `${options.path}?${bodyString}`;
|
|
2032
|
+
} else {
|
|
2033
|
+
options.path = `${options.path}&${bodyString}`;
|
|
2034
|
+
}
|
|
2035
|
+
bodyString = '';
|
|
1991
2036
|
}
|
|
1992
2037
|
|
|
1993
2038
|
// if there is a body, set the content length of the body and add it to
|
|
@@ -3345,6 +3390,11 @@ class ConnectorRest {
|
|
|
3345
3390
|
choosepath = props.choosepath;
|
|
3346
3391
|
}
|
|
3347
3392
|
|
|
3393
|
+
// set the encodeUri (optional - default is true)
|
|
3394
|
+
if (typeof props.encode_queryvars === 'boolean') {
|
|
3395
|
+
encodeUri = props.encode_queryvars;
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3348
3398
|
if (props.authentication) {
|
|
3349
3399
|
// set the authentication method (required - default is null)
|
|
3350
3400
|
if (typeof props.authentication.auth_method === 'string') {
|
|
@@ -3441,6 +3491,11 @@ class ConnectorRest {
|
|
|
3441
3491
|
if (props.authentication.sso && typeof props.authentication.sso === 'object') {
|
|
3442
3492
|
sso = props.authentication.sso;
|
|
3443
3493
|
}
|
|
3494
|
+
|
|
3495
|
+
// set the authQueryEncode (optional - default is null)
|
|
3496
|
+
if (typeof props.authentication.authQueryEncode === 'boolean') {
|
|
3497
|
+
authQueryEncode = props.authentication.authQueryEncode;
|
|
3498
|
+
}
|
|
3444
3499
|
}
|
|
3445
3500
|
|
|
3446
3501
|
// set the stub mode (optional - default is false)
|
package/lib/propertyUtil.js
CHANGED
|
@@ -326,8 +326,8 @@ class AdapterPropertyUtil {
|
|
|
326
326
|
|
|
327
327
|
// need to make sure we have supported datatypes - PLAIN is best if not supported - no translation or encoding
|
|
328
328
|
if (entitySchema.requestDatatype.toUpperCase() !== 'JSON' && entitySchema.requestDatatype.toUpperCase() !== 'XML'
|
|
329
|
-
&& entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== '
|
|
330
|
-
&& entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
|
|
329
|
+
&& entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== 'URLQUERY'
|
|
330
|
+
&& entitySchema.requestDatatype.toUpperCase() !== 'FORM' && entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
|
|
331
331
|
entitySchema.requestDatatype = 'PLAIN';
|
|
332
332
|
}
|
|
333
333
|
if (entitySchema.responseDatatype.toUpperCase() !== 'JSON' && entitySchema.responseDatatype.toUpperCase() !== 'XML'
|
|
@@ -761,8 +761,8 @@ class AdapterPropertyUtil {
|
|
|
761
761
|
|
|
762
762
|
// need to make sure we have supported datatypes - PLAIN is best if not supported - no translation or encoding
|
|
763
763
|
if (entitySchema.requestDatatype.toUpperCase() !== 'JSON' && entitySchema.requestDatatype.toUpperCase() !== 'XML'
|
|
764
|
-
&& entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== '
|
|
765
|
-
&& entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
|
|
764
|
+
&& entitySchema.requestDatatype.toUpperCase() !== 'URLENCODE' && entitySchema.requestDatatype.toUpperCase() !== 'URLQUERY'
|
|
765
|
+
&& entitySchema.requestDatatype.toUpperCase() !== 'FORM' && entitySchema.requestDatatype.toUpperCase() !== 'JSON2XML') {
|
|
766
766
|
entitySchema.requestDatatype = 'PLAIN';
|
|
767
767
|
}
|
|
768
768
|
if (entitySchema.responseDatatype.toUpperCase() !== 'JSON' && entitySchema.responseDatatype.toUpperCase() !== 'XML'
|