|
390 | 390 | tester.response.req.headers = error.response.config.headers; |
391 | 391 | tester.response.header = error.response.headers; |
392 | 392 | tester.response.status = error.response.status; |
393 | | - |
| 393 | + |
394 | 394 | try { |
395 | | - // 404 is caused by missing resource / resource not found |
| 395 | + // 404 is caused by missing resource / resource not found |
396 | 396 | tester.response.text = JSON.stringify(error.response.data); |
397 | 397 | } catch(err) { |
398 | | - // 404 is caused by unexpected end of stream or stream not found |
| 398 | + // 404 is caused by unexpected end of stream or stream not found |
399 | 399 | tester.response.text = error.message; |
400 | 400 | } |
401 | 401 | return tester; |
|
433 | 433 | tester.text = JSON.stringify(response.data); |
434 | 434 | return tester; |
435 | 435 | } |
436 | | - |
| 436 | + |
437 | 437 | // Code added by Infosys dev team |
438 | 438 |
|
439 | 439 | /** |
440 | 440 | * This method will set the merchantConfig object global |
441 | | - * |
| 441 | + * |
442 | 442 | * @param {Configuration} configObject merchantConfiguration properties. |
443 | 443 | */ |
444 | 444 | exports.prototype.setConfiguration = function (configObject) { |
445 | 445 |
|
446 | 446 | this.merchantConfig = new MerchantConfig(configObject); |
447 | 447 | this.constants = Constants; |
448 | 448 | if(this.merchantConfig.getIntermediateHost()) { |
449 | | - if(this.merchantConfig.getIntermediateHost().startsWith(this.constants.HTTP_URL_PREFIX) || |
| 449 | + if(this.merchantConfig.getIntermediateHost().startsWith(this.constants.HTTP_URL_PREFIX) || |
450 | 450 | this.merchantConfig.getIntermediateHost().startsWith('http://')) { |
451 | 451 | this.basePath = this.merchantConfig.getIntermediateHost(); |
452 | 452 | } else { |
|
460 | 460 |
|
461 | 461 | /** |
462 | 462 | * This method is to generate headers for http and jwt authentication. |
463 | | - * |
464 | | - * @param {String} httpMethod |
465 | | - * @param {String} requestTarget |
466 | | - * @param {String} requestBody |
| 463 | + * |
| 464 | + * @param {String} httpMethod |
| 465 | + * @param {String} requestTarget |
| 466 | + * @param {String} requestBody |
467 | 467 | */ |
468 | 468 | exports.prototype.callAuthenticationHeader = function (httpMethod, requestTarget, requestBody, headerParams) { |
469 | 469 |
|
470 | 470 | this.merchantConfig.setRequestTarget(requestTarget); |
471 | 471 | this.merchantConfig.setRequestType(httpMethod) |
472 | 472 | this.merchantConfig.setRequestJsonData(requestBody); |
473 | | - |
| 473 | +
|
474 | 474 | this.logger.info('Authentication Type : ' + this.merchantConfig.getAuthenticationType()); |
475 | 475 | this.logger.info(this.constants.REQUEST_TYPE + ' : ' + httpMethod.toUpperCase()); |
476 | 476 |
|
|
479 | 479 | // var clientId = getClientId(); |
480 | 480 |
|
481 | 481 | // headerParams['v-c-client-id'] = clientId; |
482 | | - |
483 | | - // if (this.merchantConfig.getSolutionId() != null && this.merchantConfig.getSolutionId() != '') { |
| 482 | +
|
| 483 | + // if (this.merchantConfig.getSolutionId() != null && this.merchantConfig.getSolutionId() != '') { |
484 | 484 | // headerParams['v-c-solution-id'] = this.merchantConfig.getSolutionId(); |
485 | 485 | // } |
486 | 486 |
|
|
527 | 527 | var packageInfo = require('./../package.json'); |
528 | 528 | return "cybs-rest-sdk-node-" + packageInfo.version; |
529 | 529 | } |
530 | | - |
| 530 | + |
531 | 531 | {{#emitJSDoc}}{{^usePromises}} /** |
532 | 532 | * Callback function to receive the result of the operation. |
533 | 533 | * @callback module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback |
|
578 | 578 |
|
579 | 579 | if (useProxy && (proxyAddress != null && proxyAddress != '')) { |
580 | 580 | if ((proxyUser != null && proxyUser != '') && (proxyPassword!= null && proxyPassword != '')) { |
581 | | - var proxy = process.env.http_proxy || 'http://' + proxyUser + ':' + proxyPassword + '@' + proxyAddress + ':' + proxyPort; |
| 581 | + var proxy = process.env.http_proxy || 'http://' + proxyUser + ':' + proxyPassword + '@' + proxyAddress + ':' + proxyPort; |
582 | 582 | } |
583 | 583 | else { |
584 | 584 | var proxy = process.env.http_proxy || 'http://' + proxyAddress + ':' + proxyPort; |
|
594 | 594 | if(enableClientCert) { |
595 | 595 | var certFile = pathlib.resolve(pathlib.join(this.merchantConfig.getClientCertDir(), this.merchantConfig.getSSLClientCert())); |
596 | 596 | var keyFile = pathlib.resolve(pathlib.join(this.merchantConfig.getClientCertDir(), this.merchantConfig.getPrivateKey())); |
597 | | - axiosConfig.httpsAgent = new https.Agent({ |
598 | | - cert: fslib.readFileSync(certFile), |
599 | | - key: fslib.readFileSync(keyFile) |
600 | | - }); |
| 597 | +
|
| 598 | + if (axiosConfig.httpsAgent) { |
| 599 | + axiosConfig.httpsAgent.cert = fslib.readFileSync(certFile); |
| 600 | + axiosConfig.httpsAgent.key = fslib.readFileSync(keyFile); |
| 601 | + } else { |
| 602 | + axiosConfig.httpsAgent = new https.Agent({ |
| 603 | + cert: fslib.readFileSync(certFile), |
| 604 | + key: fslib.readFileSync(keyFile) |
| 605 | + }); |
| 606 | + } |
601 | 607 | } |
602 | 608 |
|
603 | 609 | // apply authentications |
|
712 | 718 | if (this.enableCookies){ |
713 | 719 | axiosConfig.jar = this.cookieJar; |
714 | 720 | } |
715 | | - |
716 | | - axiosConfig.url = requestTarget; |
| 721 | + |
| 722 | + axiosConfig.url = requestTarget; |
717 | 723 |
|
718 | 724 | {{#usePromises}} return axios.request(axiosConfig).then(function(response) { |
719 | 725 | try { |
|
722 | 728 |
|
723 | 729 | resolve({data: data, response: response}); |
724 | 730 | } catch(err) { |
725 | | - reject(err); |
726 | | - } |
| 731 | + reject(err); |
| 732 | + } |
727 | 733 | }).catch(function(error, response) { |
728 | 734 | source.cancel('Stream ended.'); |
729 | 735 | var userError = {}; |
|
761 | 767 |
|
762 | 768 | callback(userError, null, response); |
763 | 769 | }); |
764 | | - |
| 770 | + |
765 | 771 | process.on('uncaughtException', (reason, p) => { |
766 | 772 | // console.log('Uncaught exception at Promise :' + p + ' with Reason : ' + reason); |
767 | 773 | }); |
768 | 774 | {{/usePromises}} }; |
769 | 775 |
|
770 | 776 | /** |
771 | 777 | * Build request target required for the signature generation |
772 | | - * @param {String} path |
773 | | - * @param {Object} pathParams |
| 778 | + * @param {String} path |
| 779 | + * @param {Object} pathParams |
774 | 780 | */ |
775 | 781 | exports.prototype.buildRequestTarget = function (path, pathParams, queryParams) { |
776 | 782 | if (!path.match(/^\//)) { |
|
805 | 811 | } |
806 | 812 | return requestTarget; |
807 | 813 | }; |
808 | | - |
| 814 | + |
809 | 815 | {{#emitJSDoc}} /** |
810 | 816 | * Parses an ISO-8601 string representation of a date value. |
811 | 817 | * @param {String} str The date value as a string. |
|
0 commit comments