@itentialopensource/adapter-utils 4.48.13 → 4.48.15

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.15 [05-09-2023]
3
+
4
+ * Add healthcheck headers to adapter properties
5
+
6
+ Closes ADAPT-2662
7
+
8
+ See merge request itentialopensource/adapter-utils!256
9
+
10
+ ---
11
+
12
+ ## 4.48.14 [05-09-2023]
13
+
14
+ * modified connectorRest.js so that if there is a field named 'ca_file_content'...
15
+
16
+ Closes ADAPT-2603
17
+
18
+ See merge request itentialopensource/adapter-utils!255
19
+
20
+ ---
21
+
2
22
  ## 4.48.13 [04-10-2023]
3
23
 
4
24
  * Update xm2json dependency version in package
@@ -76,6 +76,7 @@ let ecdhAuto = false;
76
76
  let sslEnabled = false;
77
77
  let sslAcceptInvalid = false;
78
78
  let sslCAFile = null;
79
+ let sslCAFileContent = null;
79
80
  let sslKeyFile = null;
80
81
  let sslCertFile = null;
81
82
  let sslCiphers = null;
@@ -1900,7 +1901,11 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
1900
1901
  // if we are not accepting invalid certs, need the ca file in the options
1901
1902
  try {
1902
1903
  options.rejectUnauthorized = true;
1903
- options.ca = [fs.readFileSync(callProperties.ssl.ca_file)];
1904
+ if (sslCAFileContent && sslCAFileContent !== '') {
1905
+ options.ca = [sslCAFileContent];
1906
+ } else {
1907
+ options.ca = [fs.readFileSync(callProperties.ssl.ca_file)];
1908
+ }
1904
1909
  } catch (e) {
1905
1910
  const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [callProperties.ssl.ca_file], null, null, null);
1906
1911
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
@@ -1925,7 +1930,11 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
1925
1930
  // if we are not accepting invalid certs, need the ca file in the options
1926
1931
  try {
1927
1932
  options.rejectUnauthorized = true;
1928
- options.ca = [fs.readFileSync(sslCAFile)];
1933
+ if (sslCAFileContent && sslCAFileContent !== '') {
1934
+ options.ca = [sslCAFileContent];
1935
+ } else {
1936
+ options.ca = [fs.readFileSync(sslCAFile)];
1937
+ }
1929
1938
  } catch (e) {
1930
1939
  const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFile], null, null, null);
1931
1940
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
@@ -4058,6 +4067,10 @@ class ConnectorRest {
4058
4067
  sslCAFile = props.ssl.ca_file;
4059
4068
  }
4060
4069
 
4070
+ if (typeof props.ssl.ca_file_content === 'string') {
4071
+ sslCAFileContent = props.ssl.ca_file_content;
4072
+ }
4073
+
4061
4074
  // set the ssl key file (optional - default is null)
4062
4075
  if (typeof props.ssl.key_file === 'string') {
4063
4076
  sslKeyFile = props.ssl.key_file;
@@ -4150,7 +4163,7 @@ class ConnectorRest {
4150
4163
  return callback(false);
4151
4164
  }
4152
4165
  }
4153
- if (sslEnabled && !sslAcceptInvalid && !sslCAFile) {
4166
+ if (sslEnabled && !sslAcceptInvalid && (!sslCAFile || !sslCAFileContent)) {
4154
4167
  log.error(`${origin}: FAILED TO LOAD - missing required CA File`);
4155
4168
  return callback(false);
4156
4169
  }
@@ -4194,7 +4207,7 @@ class ConnectorRest {
4194
4207
  return callback(false);
4195
4208
  }
4196
4209
  }
4197
- if (sslEnabled && !sslAcceptInvalid && !sslCAFile) {
4210
+ if (sslEnabled && !sslAcceptInvalid && (!sslCAFile || !sslCAFileContent)) {
4198
4211
  log.error(`${origin}: FAILED TO LOAD - missing required CA File`);
4199
4212
  return callback(false);
4200
4213
  }
@@ -4309,7 +4322,11 @@ class ConnectorRest {
4309
4322
  // if we are not accepting invalid certs, need the ca file in the options
4310
4323
  try {
4311
4324
  options.rejectUnauthorized = true;
4312
- options.ca = [fs.readFileSync(callProperties.ssl.ca_file)];
4325
+ if (sslCAFileContent && sslCAFileContent !== '') {
4326
+ options.ca = [sslCAFileContent];
4327
+ } else {
4328
+ options.ca = [fs.readFileSync(callProperties.ssl.ca_file)];
4329
+ }
4313
4330
  } catch (e) {
4314
4331
  const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [callProperties.ssl.ca_file], null, null, null);
4315
4332
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
@@ -4334,7 +4351,11 @@ class ConnectorRest {
4334
4351
  // if we are not accepting invalid certs, need the ca file in the options
4335
4352
  try {
4336
4353
  options.rejectUnauthorized = true;
4337
- options.ca = [fs.readFileSync(sslCAFile)];
4354
+ if (sslCAFileContent && sslCAFileContent !== '') {
4355
+ options.ca = [sslCAFileContent];
4356
+ } else {
4357
+ options.ca = [fs.readFileSync(sslCAFile)];
4358
+ }
4338
4359
  } catch (e) {
4339
4360
  const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFile], null, null, null);
4340
4361
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
@@ -4496,7 +4517,11 @@ class ConnectorRest {
4496
4517
  // if we are not accepting invalid certs, need the ca file in the options
4497
4518
  try {
4498
4519
  options.rejectUnauthorized = true;
4499
- options.ca = [fs.readFileSync(callProperties.ssl.ca_file)];
4520
+ if (sslCAFileContent && sslCAFileContent !== '') {
4521
+ options.ca = [sslCAFileContent];
4522
+ } else {
4523
+ options.ca = [fs.readFileSync(callProperties.ssl.ca_file)];
4524
+ }
4500
4525
  } catch (e) {
4501
4526
  const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [callProperties.ssl.ca_file], null, null, null);
4502
4527
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
@@ -4521,7 +4546,11 @@ class ConnectorRest {
4521
4546
  // if we are not accepting invalid certs, need the ca file in the options
4522
4547
  try {
4523
4548
  options.rejectUnauthorized = true;
4524
- options.ca = [fs.readFileSync(sslCAFile)];
4549
+ if (sslCAFileContent && sslCAFileContent !== '') {
4550
+ options.ca = [sslCAFileContent];
4551
+ } else {
4552
+ options.ca = [fs.readFileSync(sslCAFile)];
4553
+ }
4525
4554
  } catch (e) {
4526
4555
  const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFile], null, null, null);
4527
4556
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
@@ -256,6 +256,7 @@ class AdapterPropertyUtil {
256
256
  }
257
257
 
258
258
  // Merge the information into the entity schema
259
+ entitySchema.name = actionName;
259
260
  entitySchema.protocol = actionInfo.protocol;
260
261
  entitySchema.method = actionInfo.method;
261
262
  entitySchema.timeout = actionInfo.timeout;
@@ -690,6 +691,7 @@ class AdapterPropertyUtil {
690
691
  };
691
692
 
692
693
  // Merge the information into the entity schema
694
+ entitySchema.name = actionName;
693
695
  entitySchema.protocol = actionInfo.protocol;
694
696
  entitySchema.method = actionInfo.method;
695
697
  entitySchema.timeout = actionInfo.timeout;
@@ -24,6 +24,7 @@ let encodePath = true;
24
24
  let encodeUri = true;
25
25
  let stripEscapes = false;
26
26
  let returnResponseHeaders = true;
27
+ let healthcheckHeaders = null;
27
28
  // INTERNAL FUNCTIONS
28
29
  /*
29
30
  * INTERNAL FUNCTION: Get the best match for the mock data response
@@ -825,6 +826,13 @@ function mergeHeaders(addlHeaders, entitySchema) {
825
826
  thisAHdata = transUtilInst.mergeObjects(thisAHdata, entitySchema.headers);
826
827
  }
827
828
 
829
+ // add healthcheck headers if there are healthcheck headers to add
830
+ if (entitySchema && entitySchema.name === 'healthcheck') {
831
+ if (healthcheckHeaders && Object.keys(healthcheckHeaders).length > 0) {
832
+ thisAHdata = transUtilInst.mergeObjects(thisAHdata, healthcheckHeaders);
833
+ }
834
+ }
835
+
828
836
  // only add global headers if there are global headers to add
829
837
  if (globalRequestGl && globalRequestGl.addlHeaders && Object.keys(globalRequestGl.addlHeaders).length > 0) {
830
838
  thisAHdata = transUtilInst.mergeObjects(thisAHdata, globalRequestGl.addlHeaders);
@@ -1051,6 +1059,10 @@ class RestHandler {
1051
1059
  if (typeof properties.request.returnResponseHeaders === 'boolean') {
1052
1060
  returnResponseHeaders = properties.request.returnResponseHeaders;
1053
1061
  }
1062
+
1063
+ if (properties.healthcheck && typeof properties.healthcheck.addlHeaders === 'object') {
1064
+ healthcheckHeaders = properties.healthcheck.addlHeaders;
1065
+ }
1054
1066
  }
1055
1067
 
1056
1068
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "4.48.13",
3
+ "version": "4.48.15",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",