@itentialopensource/adapter-utils 5.8.0 → 5.9.0
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 +8 -0
- package/lib/connectorRest.js +79 -64
- package/lib/propertyUtil.js +1 -1
- package/lib/restHandler.js +8 -0
- package/package.json +1 -1
- package/refs?service=git-upload-pack +0 -0
- package/compliance-report.json +0 -9
- package/compliance-report.txt +0 -5
package/CHANGELOG.md
CHANGED
package/lib/connectorRest.js
CHANGED
|
@@ -127,6 +127,9 @@ let crest = null;
|
|
|
127
127
|
let cacheHHead = null;
|
|
128
128
|
let cacheHSchema = null;
|
|
129
129
|
let cacheHPay = null;
|
|
130
|
+
let sslCAFilePath = null;
|
|
131
|
+
let sslKeyFilePath = null;
|
|
132
|
+
let sslCertFilePath = null;
|
|
130
133
|
|
|
131
134
|
const mfaStepsResults = []; // keeps requested result for each step
|
|
132
135
|
|
|
@@ -2028,34 +2031,32 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
2028
2031
|
options.rejectUnauthorized = false;
|
|
2029
2032
|
} else {
|
|
2030
2033
|
// if we are not accepting invalid certs, need the ca file in the options
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
} catch (e) {
|
|
2039
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFile], null, null, null);
|
|
2034
|
+
options.rejectUnauthorized = true;
|
|
2035
|
+
if (sslCAFileContent && sslCAFileContent !== '') {
|
|
2036
|
+
options.ca = [sslCAFileContent];
|
|
2037
|
+
} else if (sslCAFile) {
|
|
2038
|
+
options.ca = sslCAFile;
|
|
2039
|
+
} else {
|
|
2040
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFilePath], null, null, null);
|
|
2040
2041
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2041
2042
|
return reject(errorObj);
|
|
2042
2043
|
}
|
|
2043
2044
|
// if there is a cert file, try to read in a cert file in the options
|
|
2044
|
-
if (
|
|
2045
|
-
|
|
2046
|
-
options.cert =
|
|
2047
|
-
}
|
|
2048
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [
|
|
2045
|
+
if (sslCertFilePath) {
|
|
2046
|
+
if (sslCertFile) {
|
|
2047
|
+
options.cert = sslCertFile;
|
|
2048
|
+
} else {
|
|
2049
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCertFilePath], null, null, null);
|
|
2049
2050
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2050
2051
|
return reject(errorObj);
|
|
2051
2052
|
}
|
|
2052
2053
|
}
|
|
2053
2054
|
// if there is a key file, try to read in a key file in the options
|
|
2054
|
-
if (
|
|
2055
|
-
|
|
2056
|
-
options.key =
|
|
2057
|
-
}
|
|
2058
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [
|
|
2055
|
+
if (sslKeyFilePath) {
|
|
2056
|
+
if (sslKeyFile) {
|
|
2057
|
+
options.key = sslKeyFile;
|
|
2058
|
+
} else {
|
|
2059
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslKeyFilePath], null, null, null);
|
|
2059
2060
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2060
2061
|
return reject(errorObj);
|
|
2061
2062
|
}
|
|
@@ -4453,22 +4454,40 @@ class ConnectorRest {
|
|
|
4453
4454
|
}
|
|
4454
4455
|
|
|
4455
4456
|
// set the ssl ca file (optional - default is null)
|
|
4456
|
-
if (typeof props.ssl.ca_file === 'string') {
|
|
4457
|
-
|
|
4457
|
+
if (typeof props.ssl.ca_file === 'string' && props.ssl.ca_file.trim() !== '') {
|
|
4458
|
+
sslCAFilePath = props.ssl.ca_file;
|
|
4459
|
+
try {
|
|
4460
|
+
sslCAFile = [fs.readFileSync(props.ssl.ca_file)];
|
|
4461
|
+
} catch (err) {
|
|
4462
|
+
log.error(`Failed to read CA file: ${err.message}`);
|
|
4463
|
+
sslCAFile = null;
|
|
4464
|
+
}
|
|
4458
4465
|
}
|
|
4459
4466
|
|
|
4460
|
-
if (typeof props.ssl.ca_file_content === 'string') {
|
|
4467
|
+
if (typeof props.ssl.ca_file_content === 'string' && props.ssl.ca_file_content.trim() !== '') {
|
|
4461
4468
|
sslCAFileContent = props.ssl.ca_file_content;
|
|
4462
4469
|
}
|
|
4463
4470
|
|
|
4464
4471
|
// set the ssl key file (optional - default is null)
|
|
4465
|
-
if (typeof props.ssl.key_file === 'string') {
|
|
4466
|
-
|
|
4472
|
+
if (typeof props.ssl.key_file === 'string' && props.ssl.key_file.trim() !== '') {
|
|
4473
|
+
sslKeyFilePath = props.ssl.key_file;
|
|
4474
|
+
try {
|
|
4475
|
+
sslKeyFile = [fs.readFileSync(props.ssl.key_file)];
|
|
4476
|
+
} catch (err) {
|
|
4477
|
+
log.error(`Failed to read SSL file: ${err.message}`);
|
|
4478
|
+
sslKeyFile = null;
|
|
4479
|
+
}
|
|
4467
4480
|
}
|
|
4468
4481
|
|
|
4469
4482
|
// set the ssl cert file (optional - default is null)
|
|
4470
|
-
if (typeof props.ssl.cert_file === 'string') {
|
|
4471
|
-
|
|
4483
|
+
if (typeof props.ssl.cert_file === 'string' && props.ssl.cert_file.trim() !== '') {
|
|
4484
|
+
sslCertFilePath = props.ssl.cert_file;
|
|
4485
|
+
try {
|
|
4486
|
+
sslCertFile = [fs.readFileSync(props.ssl.cert_file)];
|
|
4487
|
+
} catch (err) {
|
|
4488
|
+
log.error(`Failed to read SSL Cert file: ${err.message}`);
|
|
4489
|
+
sslCertFile = null;
|
|
4490
|
+
}
|
|
4472
4491
|
}
|
|
4473
4492
|
|
|
4474
4493
|
// set the ssl ciphers (optional - default is null)
|
|
@@ -4741,34 +4760,32 @@ class ConnectorRest {
|
|
|
4741
4760
|
options.rejectUnauthorized = false;
|
|
4742
4761
|
} else {
|
|
4743
4762
|
// if we are not accepting invalid certs, need the ca file in the options
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
} catch (e) {
|
|
4752
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFile], null, null, null);
|
|
4763
|
+
options.rejectUnauthorized = true;
|
|
4764
|
+
if (sslCAFileContent && sslCAFileContent !== '') {
|
|
4765
|
+
options.ca = [sslCAFileContent];
|
|
4766
|
+
} else if (sslCAFile) {
|
|
4767
|
+
options.ca = sslCAFile;
|
|
4768
|
+
} else {
|
|
4769
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFilePath], null, null, null);
|
|
4753
4770
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4754
4771
|
return callback(null, errorObj);
|
|
4755
4772
|
}
|
|
4756
4773
|
// if there is a cert file, try to read in a cert file in the options
|
|
4757
|
-
if (
|
|
4758
|
-
|
|
4759
|
-
options.cert =
|
|
4760
|
-
}
|
|
4761
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [
|
|
4774
|
+
if (sslCertFilePath) {
|
|
4775
|
+
if (sslCertFile) {
|
|
4776
|
+
options.cert = sslCertFile;
|
|
4777
|
+
} else {
|
|
4778
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCertFilePath], null, null, null);
|
|
4762
4779
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4763
4780
|
return callback(null, errorObj);
|
|
4764
4781
|
}
|
|
4765
4782
|
}
|
|
4766
4783
|
// if there is a key file, try to read in a key file in the options
|
|
4767
|
-
if (
|
|
4768
|
-
|
|
4769
|
-
options.key =
|
|
4770
|
-
}
|
|
4771
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [
|
|
4784
|
+
if (sslKeyFilePath) {
|
|
4785
|
+
if (sslKeyFile) {
|
|
4786
|
+
options.key = sslKeyFile;
|
|
4787
|
+
} else {
|
|
4788
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslKeyFilePath], null, null, null);
|
|
4772
4789
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4773
4790
|
return callback(null, errorObj);
|
|
4774
4791
|
}
|
|
@@ -4938,34 +4955,32 @@ class ConnectorRest {
|
|
|
4938
4955
|
options.rejectUnauthorized = false;
|
|
4939
4956
|
} else {
|
|
4940
4957
|
// if we are not accepting invalid certs, need the ca file in the options
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
} catch (e) {
|
|
4949
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFile], null, null, null);
|
|
4958
|
+
options.rejectUnauthorized = true;
|
|
4959
|
+
if (sslCAFileContent && sslCAFileContent !== '') {
|
|
4960
|
+
options.ca = [sslCAFileContent];
|
|
4961
|
+
} else if (sslCAFile) {
|
|
4962
|
+
options.ca = sslCAFile;
|
|
4963
|
+
} else {
|
|
4964
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFilePath], null, null, null);
|
|
4950
4965
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4951
4966
|
return callback(null, errorObj);
|
|
4952
4967
|
}
|
|
4953
4968
|
// if there is a cert file, try to read in a cert file in the options
|
|
4954
|
-
if (
|
|
4955
|
-
|
|
4956
|
-
options.cert =
|
|
4957
|
-
}
|
|
4958
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [
|
|
4969
|
+
if (sslCertFilePath) {
|
|
4970
|
+
if (sslCertFile) {
|
|
4971
|
+
options.cert = sslCertFile;
|
|
4972
|
+
} else {
|
|
4973
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCertFilePath], null, null, null);
|
|
4959
4974
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4960
4975
|
return callback(null, errorObj);
|
|
4961
4976
|
}
|
|
4962
4977
|
}
|
|
4963
4978
|
// if there is a key file, try to read in a key file in the options
|
|
4964
|
-
if (
|
|
4965
|
-
|
|
4966
|
-
options.key =
|
|
4967
|
-
}
|
|
4968
|
-
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [
|
|
4979
|
+
if (sslKeyFilePath) {
|
|
4980
|
+
if (sslKeyFile) {
|
|
4981
|
+
options.key = sslKeyFile;
|
|
4982
|
+
} else {
|
|
4983
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslKeyFilePath], null, null, null);
|
|
4969
4984
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4970
4985
|
return callback(null, errorObj);
|
|
4971
4986
|
}
|
package/lib/propertyUtil.js
CHANGED
|
@@ -1023,7 +1023,7 @@ class AdapterPropertyUtil {
|
|
|
1023
1023
|
errorObj.exception = e;
|
|
1024
1024
|
|
|
1025
1025
|
// return the error message
|
|
1026
|
-
log.info(`unable to get adapter config from database: ${e}`);
|
|
1026
|
+
log.info(`unable to get adapter config from database: ${e}, using config from file system`);
|
|
1027
1027
|
return callback(null, errorObj);
|
|
1028
1028
|
}
|
|
1029
1029
|
}
|
package/lib/restHandler.js
CHANGED
|
@@ -683,6 +683,10 @@ function buildRequestPath(entity, action, entitySchema, reqPath, uriPathVars, ur
|
|
|
683
683
|
// with the provided id
|
|
684
684
|
let idString = '';
|
|
685
685
|
|
|
686
|
+
// if encoding is changed in call properties that overrides the default
|
|
687
|
+
if (callProperties && Object.hasOwnProperty.call(callProperties, 'encode_pathvars')) {
|
|
688
|
+
encodePath = callProperties.encode_pathvars;
|
|
689
|
+
}
|
|
686
690
|
// check if the current URI path ends with a slash (may require
|
|
687
691
|
// slash at end)
|
|
688
692
|
if (uriPath[hindex - 2] === '/' || uriPath[hindex - 2] === ':') {
|
|
@@ -793,6 +797,10 @@ function buildRequestPath(entity, action, entitySchema, reqPath, uriPathVars, ur
|
|
|
793
797
|
addquery = entitySchema.querykey;
|
|
794
798
|
}
|
|
795
799
|
if (systemQuery !== null) {
|
|
800
|
+
// if encoding is changed in call properties that overrides the default
|
|
801
|
+
if (callProperties && Object.hasOwnProperty.call(callProperties, 'encode_queryvars')) {
|
|
802
|
+
encodeUri = callProperties.encode_queryvars;
|
|
803
|
+
}
|
|
796
804
|
// if we are encoding - use querystring since it does it all!
|
|
797
805
|
if (encodeUri === true) {
|
|
798
806
|
addquery += querystring.stringify(systemQuery);
|
package/package.json
CHANGED
|
Binary file
|
package/compliance-report.json
DELETED
package/compliance-report.txt
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
---------------------------------------------------------------------------------------------
|
|
2
|
-
**** Project Compliance Summary ****
|
|
3
|
-
0 project(s) are not valid
|
|
4
|
-
0 project(s) are valid
|
|
5
|
-
---------------------------------------------------------------------------------------------
|