@itentialopensource/adapter-utils 4.48.2 → 4.48.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/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
1
 
2
+ ## 4.48.4 [10-25-2022]
3
+
4
+ * Clean xml string sent into the adapter task and troubleshoot openstack_nova adapter
5
+
6
+ Closes ADAPT-2382
7
+
8
+ See merge request itentialopensource/adapter-utils!241
9
+
10
+ ---
11
+
12
+ ## 4.48.3 [10-17-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!240
19
+
20
+ ---
21
+
2
22
  ## 4.48.2 [10-04-2022]
3
23
 
4
24
  * Changes to have token data passed in url instead of body
@@ -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
- bodyString = querystring.stringify(tokenEntity);
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
@@ -2179,10 +2213,12 @@ function getTokenItem(pathForToken, user, reqBody, invalidToken, callProperties,
2179
2213
  // No valid token found, Need to get a new token and add it to the token list
2180
2214
  buildTokenRequest(pathForToken, reqBody, callProperties, (dyntoken, berror) => {
2181
2215
  if (berror) {
2182
- done(null, berror);
2216
+ // done(null, berror);
2217
+ return done(berror);
2183
2218
  }
2184
2219
  if (!dyntoken) {
2185
- done(null, 'No Token returned');
2220
+ // done(null, 'No Token returned');
2221
+ return done(new Error('No Token returned'));
2186
2222
  }
2187
2223
 
2188
2224
  let timeout = tokenTimeout;
@@ -3356,6 +3392,11 @@ class ConnectorRest {
3356
3392
  choosepath = props.choosepath;
3357
3393
  }
3358
3394
 
3395
+ // set the encodeUri (optional - default is true)
3396
+ if (typeof props.encode_queryvars === 'boolean') {
3397
+ encodeUri = props.encode_queryvars;
3398
+ }
3399
+
3359
3400
  if (props.authentication) {
3360
3401
  // set the authentication method (required - default is null)
3361
3402
  if (typeof props.authentication.auth_method === 'string') {
@@ -3452,6 +3493,11 @@ class ConnectorRest {
3452
3493
  if (props.authentication.sso && typeof props.authentication.sso === 'object') {
3453
3494
  sso = props.authentication.sso;
3454
3495
  }
3496
+
3497
+ // set the authQueryEncode (optional - default is null)
3498
+ if (typeof props.authentication.authQueryEncode === 'boolean') {
3499
+ authQueryEncode = props.authentication.authQueryEncode;
3500
+ }
3455
3501
  }
3456
3502
 
3457
3503
  // set the stub mode (optional - default is false)
@@ -906,6 +906,8 @@ function buildPayload(entity, action, entitySchema, payload) {
906
906
  thisBdata = '';
907
907
  }
908
908
  if (typeof thisBdata !== 'object') {
909
+ thisBdata = thisBdata.replace(/(\r\n|\n|\r)/gm, '');
910
+ thisBdata = thisBdata.replace(/>\s+?</g, '><');
909
911
  return thisBdata;
910
912
  }
911
913
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "4.48.2",
3
+ "version": "4.48.4",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",