@itentialopensource/adapter-utils 5.8.0 → 5.9.1
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 +16 -0
- package/error.json +6 -0
- package/lib/connectorRest.js +157 -107
- 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
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
## 5.9.1 [09-26-2024]
|
|
3
|
+
|
|
4
|
+
* Update refresh token logic
|
|
5
|
+
|
|
6
|
+
See merge request itentialopensource/adapter-utils!304
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 5.9.0 [09-23-2024]
|
|
11
|
+
|
|
12
|
+
* Cache ssl file contents in memory
|
|
13
|
+
|
|
14
|
+
See merge request itentialopensource/adapter-utils!303
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
2
18
|
## 5.8.0 [09-09-2024]
|
|
3
19
|
|
|
4
20
|
* Add support for RESTCONF endpoints
|
package/error.json
CHANGED
|
@@ -144,6 +144,12 @@
|
|
|
144
144
|
"displayString": "The Adapter has run out of time for the request",
|
|
145
145
|
"recommendation": "Increase your adapter request.attempt_timeout property"
|
|
146
146
|
},
|
|
147
|
+
{
|
|
148
|
+
"key": "Disconnect",
|
|
149
|
+
"icode": "AD.502",
|
|
150
|
+
"displayString": "The connection was terminated by the network or external system",
|
|
151
|
+
"recommendation": "Check connectivity to the external system and that the system is up"
|
|
152
|
+
},
|
|
147
153
|
{
|
|
148
154
|
"key": "Caught Exception",
|
|
149
155
|
"icode": "AD.900",
|
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
|
}
|
|
@@ -2130,7 +2131,7 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
2130
2131
|
|
|
2131
2132
|
// if this is not a get, need to add the info to the request
|
|
2132
2133
|
if (options.method !== 'GET') {
|
|
2133
|
-
if (authMethod !== 'multi_step_authentication') {
|
|
2134
|
+
if (authMethod !== 'multi_step_authentication' && !runRefreshToken) {
|
|
2134
2135
|
creds = {
|
|
2135
2136
|
username: useUser,
|
|
2136
2137
|
password: usePass
|
|
@@ -2202,16 +2203,17 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
2202
2203
|
Object.assign(creds, body);
|
|
2203
2204
|
// If there are query variables, add them to the path
|
|
2204
2205
|
if (Object.keys(query).length > 0) {
|
|
2206
|
+
const systemQuery = transUtilInst.mapToOutboundEntity(query, tokenSchema.requestSchema);
|
|
2205
2207
|
let refTokenQueryString = '';
|
|
2206
2208
|
if (encodeUri === true) {
|
|
2207
|
-
refTokenQueryString += querystring.stringify(
|
|
2209
|
+
refTokenQueryString += querystring.stringify(systemQuery);
|
|
2208
2210
|
} else {
|
|
2209
|
-
const refTokenQueryKeys = Object.keys(
|
|
2211
|
+
const refTokenQueryKeys = Object.keys(systemQuery);
|
|
2210
2212
|
for (let k = 0; k < refTokenQueryKeys.length; k += 1) {
|
|
2211
2213
|
if (k > 0) {
|
|
2212
2214
|
refTokenQueryString += '&';
|
|
2213
2215
|
}
|
|
2214
|
-
refTokenQueryString += `${refTokenQueryKeys[k]}=${
|
|
2216
|
+
refTokenQueryString += `${refTokenQueryKeys[k]}=${systemQuery[refTokenQueryKeys[k]]}`;
|
|
2215
2217
|
}
|
|
2216
2218
|
}
|
|
2217
2219
|
// append to the path
|
|
@@ -2524,6 +2526,36 @@ function getCachedRefToken(cachedTokenIdentifier, invalidToken) {
|
|
|
2524
2526
|
});
|
|
2525
2527
|
}
|
|
2526
2528
|
|
|
2529
|
+
function handleToken(dyntoken, user, reqBody, done) {
|
|
2530
|
+
let timeout = tokenTimeout;
|
|
2531
|
+
// if we should use the timeout from the token request
|
|
2532
|
+
if (timeout === 0) {
|
|
2533
|
+
timeout = findExpireInResult(dyntoken);
|
|
2534
|
+
} else {
|
|
2535
|
+
// otherwise add the timeout to the current time
|
|
2536
|
+
timeout += new Date().getTime();
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
const tokenObj = {
|
|
2540
|
+
token: findPrimaryTokenInResult(dyntoken, dyntoken.front, dyntoken.end),
|
|
2541
|
+
tokenp2: findSecondaryTokenInResult(dyntoken, dyntoken.front, dyntoken.end),
|
|
2542
|
+
refreshToken: dyntoken.refreshToken
|
|
2543
|
+
};
|
|
2544
|
+
|
|
2545
|
+
// if this is worth caching
|
|
2546
|
+
if (timeout && timeout > 0) {
|
|
2547
|
+
// since this is adding the token for future use, do not care when it comes back
|
|
2548
|
+
addTokenItem(user, reqBody, tokenObj, timeout, (addedtoken, aerror) => {
|
|
2549
|
+
if (aerror) {
|
|
2550
|
+
return done(null, aerror);
|
|
2551
|
+
}
|
|
2552
|
+
done(tokenObj, null);
|
|
2553
|
+
});
|
|
2554
|
+
} else {
|
|
2555
|
+
done(tokenObj, null);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2527
2559
|
/*
|
|
2528
2560
|
* INTERNAL FUNCTION: getTokenItem is used to retrieve a token items from
|
|
2529
2561
|
* memory based on the user provided
|
|
@@ -2550,7 +2582,7 @@ function getTokenItem(pathForToken, user, reqBody, invalidToken, callProperties,
|
|
|
2550
2582
|
done(null, rerror);
|
|
2551
2583
|
}
|
|
2552
2584
|
if (refToken !== null) {
|
|
2553
|
-
log.debug(`${origin}
|
|
2585
|
+
log.debug(`${origin}: Returning cached refresh token`);
|
|
2554
2586
|
if (!callProperties) {
|
|
2555
2587
|
callProperties = {};
|
|
2556
2588
|
}
|
|
@@ -2561,48 +2593,44 @@ function getTokenItem(pathForToken, user, reqBody, invalidToken, callProperties,
|
|
|
2561
2593
|
// Refresh the token if getRefreshToken entity exists
|
|
2562
2594
|
if (tokenSchema) {
|
|
2563
2595
|
runRefreshToken = true;
|
|
2596
|
+
} else {
|
|
2597
|
+
log.debug(`${origin}: Refresh token schema does not exist, will not refresh token`);
|
|
2598
|
+
runRefreshToken = false;
|
|
2564
2599
|
}
|
|
2565
2600
|
});
|
|
2566
|
-
} else
|
|
2601
|
+
} else {
|
|
2602
|
+
runRefreshToken = false;
|
|
2603
|
+
}
|
|
2567
2604
|
});
|
|
2568
2605
|
// No valid token found, Need to get a new token and add it to the token list
|
|
2569
2606
|
buildTokenRequest(pathForToken, reqBody, callProperties, (dyntoken, berror) => {
|
|
2570
|
-
if (berror) {
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
const tokenObj = {
|
|
2590
|
-
token: findPrimaryTokenInResult(dyntoken, dyntoken.front, dyntoken.end),
|
|
2591
|
-
tokenp2: findSecondaryTokenInResult(dyntoken, dyntoken.front, dyntoken.end),
|
|
2592
|
-
refreshToken: dyntoken.refreshToken
|
|
2593
|
-
};
|
|
2594
|
-
|
|
2595
|
-
// if this is worth caching
|
|
2596
|
-
if (timeout && timeout > 0) {
|
|
2597
|
-
// since this is adding the token for future use, do not care when it comes back
|
|
2598
|
-
addTokenItem(user, reqBody, tokenObj, timeout, (addedtoken, aerror) => {
|
|
2599
|
-
if (aerror) {
|
|
2600
|
-
done(null, aerror);
|
|
2607
|
+
if (berror || !dyntoken) {
|
|
2608
|
+
if (runRefreshToken) {
|
|
2609
|
+
log.debug(`${origin}: Failed to refresh token, use auth steps to get a new token`);
|
|
2610
|
+
runRefreshToken = false;
|
|
2611
|
+
buildTokenRequest(pathForToken, reqBody, callProperties, (innerDyntoken, innerBerror) => {
|
|
2612
|
+
if (innerBerror) {
|
|
2613
|
+
// done(null, innerBerror);
|
|
2614
|
+
return done(innerBerror);
|
|
2615
|
+
}
|
|
2616
|
+
if (!innerDyntoken) {
|
|
2617
|
+
// done(null, 'No Token returned');
|
|
2618
|
+
return done(new Error('No Token returned'));
|
|
2619
|
+
}
|
|
2620
|
+
handleToken(innerDyntoken, user, reqBody, done);
|
|
2621
|
+
});
|
|
2622
|
+
} else {
|
|
2623
|
+
if (berror) {
|
|
2624
|
+
// done(null, berror);
|
|
2625
|
+
return done(berror);
|
|
2601
2626
|
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2627
|
+
if (!dyntoken) {
|
|
2628
|
+
// done(null, 'No Token returned');
|
|
2629
|
+
return done(new Error('No Token returned'));
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2604
2632
|
} else {
|
|
2605
|
-
|
|
2633
|
+
handleToken(dyntoken, user, reqBody, done);
|
|
2606
2634
|
}
|
|
2607
2635
|
});
|
|
2608
2636
|
}
|
|
@@ -3075,17 +3103,19 @@ async function getMfaFinalTokens(request, callProperties, invalidToken) {
|
|
|
3075
3103
|
// If cached refresh token is valid and there is action for getRefreshToken, run refresh token
|
|
3076
3104
|
if (tokenSchema) {
|
|
3077
3105
|
runRefreshToken = true;
|
|
3106
|
+
} else {
|
|
3107
|
+
log.debug(`${origin}: Refresh token schema does not exist, will not refresh token`);
|
|
3108
|
+
runRefreshToken = false;
|
|
3078
3109
|
}
|
|
3079
3110
|
});
|
|
3080
3111
|
if (runRefreshToken) {
|
|
3081
3112
|
finalTokens = await buildTokenRequest(request.header.path, request.authData, callProperties).catch((error) => { // eslint-disable-line no-await-in-loop
|
|
3082
|
-
log.
|
|
3083
|
-
throw error;
|
|
3113
|
+
log.debug(`${origin}: Failed to refresh token, run auth steps to obtain a new token`);
|
|
3084
3114
|
});
|
|
3085
3115
|
if (finalTokens) {
|
|
3086
3116
|
await cacheMfaToken(cachedTokenIdentifier, finalTokens).catch((error) => log.error(error));
|
|
3117
|
+
return;
|
|
3087
3118
|
}
|
|
3088
|
-
return;
|
|
3089
3119
|
}
|
|
3090
3120
|
}
|
|
3091
3121
|
runRefreshToken = false;
|
|
@@ -3580,6 +3610,8 @@ function handleEndResponse(request, makeResp, overallTime, callback) {
|
|
|
3580
3610
|
|
|
3581
3611
|
if (makeResp.code === -2) {
|
|
3582
3612
|
errorObj = transUtilInst.formatErrorObject(origin, 'Request Timeout', [makeResp.code], makeResp.code, makeResp, null);
|
|
3613
|
+
} else if (makeResp.code === -1) {
|
|
3614
|
+
errorObj = transUtilInst.formatErrorObject(origin, 'Disconnect', [makeResp.code], makeResp.code, makeResp, null);
|
|
3583
3615
|
} else {
|
|
3584
3616
|
errorObj = transUtilInst.formatErrorObject(origin, 'Error On Request', [makeResp.code], makeResp.code, makeResp, null);
|
|
3585
3617
|
}
|
|
@@ -3709,6 +3741,8 @@ function handleEndThrottleResponse(request, myTransTime, claimedLic, makeResp, r
|
|
|
3709
3741
|
|
|
3710
3742
|
if (makeResp.code === -2) {
|
|
3711
3743
|
errorObj = transUtilInst.formatErrorObject(origin, 'Request Timeout', [makeResp.code], makeResp.code, makeResp, null);
|
|
3744
|
+
} else if (makeResp.code === -1) {
|
|
3745
|
+
errorObj = transUtilInst.formatErrorObject(origin, 'Disconnect', [makeResp.code], makeResp.code, makeResp, null);
|
|
3712
3746
|
} else {
|
|
3713
3747
|
errorObj = transUtilInst.formatErrorObject(origin, 'Error On Request', [makeResp.code], makeResp.code, makeResp, null);
|
|
3714
3748
|
}
|
|
@@ -4453,22 +4487,40 @@ class ConnectorRest {
|
|
|
4453
4487
|
}
|
|
4454
4488
|
|
|
4455
4489
|
// set the ssl ca file (optional - default is null)
|
|
4456
|
-
if (typeof props.ssl.ca_file === 'string') {
|
|
4457
|
-
|
|
4490
|
+
if (typeof props.ssl.ca_file === 'string' && props.ssl.ca_file.trim() !== '') {
|
|
4491
|
+
sslCAFilePath = props.ssl.ca_file;
|
|
4492
|
+
try {
|
|
4493
|
+
sslCAFile = [fs.readFileSync(props.ssl.ca_file)];
|
|
4494
|
+
} catch (err) {
|
|
4495
|
+
log.error(`Failed to read CA file: ${err.message}`);
|
|
4496
|
+
sslCAFile = null;
|
|
4497
|
+
}
|
|
4458
4498
|
}
|
|
4459
4499
|
|
|
4460
|
-
if (typeof props.ssl.ca_file_content === 'string') {
|
|
4500
|
+
if (typeof props.ssl.ca_file_content === 'string' && props.ssl.ca_file_content.trim() !== '') {
|
|
4461
4501
|
sslCAFileContent = props.ssl.ca_file_content;
|
|
4462
4502
|
}
|
|
4463
4503
|
|
|
4464
4504
|
// set the ssl key file (optional - default is null)
|
|
4465
|
-
if (typeof props.ssl.key_file === 'string') {
|
|
4466
|
-
|
|
4505
|
+
if (typeof props.ssl.key_file === 'string' && props.ssl.key_file.trim() !== '') {
|
|
4506
|
+
sslKeyFilePath = props.ssl.key_file;
|
|
4507
|
+
try {
|
|
4508
|
+
sslKeyFile = [fs.readFileSync(props.ssl.key_file)];
|
|
4509
|
+
} catch (err) {
|
|
4510
|
+
log.error(`Failed to read SSL file: ${err.message}`);
|
|
4511
|
+
sslKeyFile = null;
|
|
4512
|
+
}
|
|
4467
4513
|
}
|
|
4468
4514
|
|
|
4469
4515
|
// set the ssl cert file (optional - default is null)
|
|
4470
|
-
if (typeof props.ssl.cert_file === 'string') {
|
|
4471
|
-
|
|
4516
|
+
if (typeof props.ssl.cert_file === 'string' && props.ssl.cert_file.trim() !== '') {
|
|
4517
|
+
sslCertFilePath = props.ssl.cert_file;
|
|
4518
|
+
try {
|
|
4519
|
+
sslCertFile = [fs.readFileSync(props.ssl.cert_file)];
|
|
4520
|
+
} catch (err) {
|
|
4521
|
+
log.error(`Failed to read SSL Cert file: ${err.message}`);
|
|
4522
|
+
sslCertFile = null;
|
|
4523
|
+
}
|
|
4472
4524
|
}
|
|
4473
4525
|
|
|
4474
4526
|
// set the ssl ciphers (optional - default is null)
|
|
@@ -4741,34 +4793,32 @@ class ConnectorRest {
|
|
|
4741
4793
|
options.rejectUnauthorized = false;
|
|
4742
4794
|
} else {
|
|
4743
4795
|
// 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);
|
|
4796
|
+
options.rejectUnauthorized = true;
|
|
4797
|
+
if (sslCAFileContent && sslCAFileContent !== '') {
|
|
4798
|
+
options.ca = [sslCAFileContent];
|
|
4799
|
+
} else if (sslCAFile) {
|
|
4800
|
+
options.ca = sslCAFile;
|
|
4801
|
+
} else {
|
|
4802
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFilePath], null, null, null);
|
|
4753
4803
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4754
4804
|
return callback(null, errorObj);
|
|
4755
4805
|
}
|
|
4756
4806
|
// 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', [
|
|
4807
|
+
if (sslCertFilePath) {
|
|
4808
|
+
if (sslCertFile) {
|
|
4809
|
+
options.cert = sslCertFile;
|
|
4810
|
+
} else {
|
|
4811
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCertFilePath], null, null, null);
|
|
4762
4812
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4763
4813
|
return callback(null, errorObj);
|
|
4764
4814
|
}
|
|
4765
4815
|
}
|
|
4766
4816
|
// 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', [
|
|
4817
|
+
if (sslKeyFilePath) {
|
|
4818
|
+
if (sslKeyFile) {
|
|
4819
|
+
options.key = sslKeyFile;
|
|
4820
|
+
} else {
|
|
4821
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslKeyFilePath], null, null, null);
|
|
4772
4822
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4773
4823
|
return callback(null, errorObj);
|
|
4774
4824
|
}
|
|
@@ -4828,6 +4878,8 @@ class ConnectorRest {
|
|
|
4828
4878
|
|
|
4829
4879
|
if (pres.code === -2) {
|
|
4830
4880
|
errorObj = transUtilInst.formatErrorObject(origin, 'Request Timeout', [pres.code], pres.code, pres, null);
|
|
4881
|
+
} else if (pres.code === -1) {
|
|
4882
|
+
errorObj = transUtilInst.formatErrorObject(origin, 'Disconnect', [pres.code], pres.code, pres, null);
|
|
4831
4883
|
} else {
|
|
4832
4884
|
errorObj = transUtilInst.formatErrorObject(origin, 'Error On Request', [pres.code], pres.code, pres, null);
|
|
4833
4885
|
}
|
|
@@ -4938,34 +4990,32 @@ class ConnectorRest {
|
|
|
4938
4990
|
options.rejectUnauthorized = false;
|
|
4939
4991
|
} else {
|
|
4940
4992
|
// 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);
|
|
4993
|
+
options.rejectUnauthorized = true;
|
|
4994
|
+
if (sslCAFileContent && sslCAFileContent !== '') {
|
|
4995
|
+
options.ca = [sslCAFileContent];
|
|
4996
|
+
} else if (sslCAFile) {
|
|
4997
|
+
options.ca = sslCAFile;
|
|
4998
|
+
} else {
|
|
4999
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCAFilePath], null, null, null);
|
|
4950
5000
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4951
5001
|
return callback(null, errorObj);
|
|
4952
5002
|
}
|
|
4953
5003
|
// 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', [
|
|
5004
|
+
if (sslCertFilePath) {
|
|
5005
|
+
if (sslCertFile) {
|
|
5006
|
+
options.cert = sslCertFile;
|
|
5007
|
+
} else {
|
|
5008
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslCertFilePath], null, null, null);
|
|
4959
5009
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4960
5010
|
return callback(null, errorObj);
|
|
4961
5011
|
}
|
|
4962
5012
|
}
|
|
4963
5013
|
// 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', [
|
|
5014
|
+
if (sslKeyFilePath) {
|
|
5015
|
+
if (sslKeyFile) {
|
|
5016
|
+
options.key = sslKeyFile;
|
|
5017
|
+
} else {
|
|
5018
|
+
const errorObj = this.transUtil.formatErrorObject(origin, 'Missing File', [sslKeyFilePath], null, null, null);
|
|
4969
5019
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4970
5020
|
return callback(null, errorObj);
|
|
4971
5021
|
}
|
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
|
-
---------------------------------------------------------------------------------------------
|