diff --git a/package-lock.json b/package-lock.json index abae467d..22b4c4b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "quoting-service", - "version": "11.1.0", + "version": "11.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -426,9 +426,9 @@ }, "dependencies": { "ajv": { - "version": "6.12.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", - "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", + "version": "6.12.5", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.5.tgz", + "integrity": "sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -438,12 +438,12 @@ } }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "strip-json-comments": { @@ -1690,9 +1690,9 @@ } }, "@mojaloop/central-services-shared": { - "version": "11.3.3", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-11.3.3.tgz", - "integrity": "sha512-2LuqxEiTSUsC0rh1I5xCZ+ZuspqEaUhoxAd9TMAmD5cz02/D2gNZl7DW0J0cUXgakmWrFqD1r958ayQFAa89qg==", + "version": "11.3.5", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-11.3.5.tgz", + "integrity": "sha512-jZvHMtd3hvatZ6ylEgDGgiXxHEbKZFSZIK0z3M9C96KEbl4C50xuIzj2cxnqkp6UuRn3T/2KsJZSCbdqlCUuuw==", "requires": { "@hapi/catbox": "11.1.1", "@hapi/catbox-memory": "5.0.0", @@ -1700,7 +1700,7 @@ "@mojaloop/central-services-logger": "10.6.0", "@mojaloop/central-services-metrics": "9.5.0", "@mojaloop/event-sdk": "10.6.0", - "ajv": "6.12.4", + "ajv": "6.12.5", "ajv-keywords": "3.5.2", "axios": "0.20.0", "base64url": "3.0.1", @@ -1711,16 +1711,16 @@ "immutable": "3.8.2", "lodash": "4.17.20", "mustache": "4.0.1", - "openapi-backend": "3.5.2", + "openapi-backend": "3.5.4", "raw-body": "2.4.1", "rc": "1.2.8", "uuid4": "2.0.2" }, "dependencies": { "ajv": { - "version": "6.12.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", - "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", + "version": "6.12.5", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.5.tgz", + "integrity": "sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==", "requires": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -2103,9 +2103,9 @@ } }, "@types/jest": { - "version": "26.0.13", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.13.tgz", - "integrity": "sha512-sCzjKow4z9LILc6DhBvn5AkIfmQzDZkgtVVKmGwVrs5tuid38ws281D4l+7x1kP487+FlKDh5kfMZ8WSPAdmdA==", + "version": "26.0.14", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.14.tgz", + "integrity": "sha512-Hz5q8Vu0D288x3iWXePSn53W7hAjP0H7EQ6QvDO9c7t46mR0lNOLlfuwQ+JkVxuhygHzlzPX+0jKdA3ZgSh+Vg==", "dev": true, "requires": { "jest-diff": "^25.2.1", @@ -2203,12 +2203,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -2225,12 +2225,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -4115,9 +4115,9 @@ } }, "eslint": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.8.1.tgz", - "integrity": "sha512-/2rX2pfhyUG0y+A123d0ccXtMm7DV7sH1m3lk9nk2DZ2LReq39FXHueR9xZwshE5MdfSf0xunSaMWRqyIA6M1w==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.9.0.tgz", + "integrity": "sha512-V6QyhX21+uXp4T+3nrNfI3hQNBDa/P8ga7LoQOenwrlEFXrEnUEE+ok1dMtaS3b6rmLXhT1TkTIsG75HMLbknA==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -4201,12 +4201,12 @@ "dev": true }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "semver": { @@ -5656,12 +5656,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -5688,12 +5688,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -9941,9 +9941,9 @@ } }, "npm-check-updates": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-8.1.1.tgz", - "integrity": "sha512-8YxCG/ExD9HdcvflEfPrvEeonkAc+1OZCbZ9ExANkDRqMrolOMHC52eJyQlF4bsFMAAtT3nS1EOjkCRaDaOiHQ==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-9.0.1.tgz", + "integrity": "sha512-xSMyNEIvsrNPDh5r1N/VxDGE+5ZkiEx8BxBvoEBWc/rsaHHfwKCvsY3qJjAn064pULH4uTrT7+kJwroHYsY/Yw==", "dev": true, "requires": { "chalk": "^4.1.0", @@ -10567,9 +10567,9 @@ } }, "openapi-backend": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/openapi-backend/-/openapi-backend-3.5.2.tgz", - "integrity": "sha512-B6VptLEvyDstDd2bY+7/Lk6IK1syEzHMyAZG7U4A+UiGLD+/NN39axVhFD+8ulBjo037AcrZ3OeQzoMV+nigPQ==", + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/openapi-backend/-/openapi-backend-3.5.4.tgz", + "integrity": "sha512-gGuq69ai/oxR9/DFiLK+6DWL4mJjtO3xGI/tp2GYI8HTL/W6PpDMeIk+jEw5Ep1Yo7aepPpuSUsibsh0yIbyDQ==", "requires": { "ajv": "^6.10.0", "bath-es5": "^3.0.3", @@ -11429,12 +11429,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -12156,9 +12156,9 @@ } }, "socks": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.4.2.tgz", - "integrity": "sha512-cE6P9R+/CET9XhIMvqhRgaNT1GXKIahioMjwwhgYOd+8UQWP50rrFm+faqG/4xkZsjTdVeBYr0Tb246BSC9/fg==", + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.4.4.tgz", + "integrity": "sha512-7LmHN4IHj1Vpd/k8D872VGCHJ6yIVyeFkfIBExRmGPYQ/kdUkpdg9eKh9oOzYYYKQhuxavayJHTnmBG+EzluUA==", "dev": true, "requires": { "ip": "^1.1.5", @@ -12177,12 +12177,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } diff --git a/package.json b/package.json index 0d49250d..330e8c4f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "quoting-service", "description": "Quoting Service hosted by a scheme", "license": "Apache-2.0", - "version": "11.1.0", + "version": "11.1.1", "author": "ModusBox", "contributors": [ "James Bush ", @@ -62,7 +62,7 @@ "@hapi/hapi": "20.0.0", "@mojaloop/central-services-error-handling": "10.6.0", "@mojaloop/central-services-logger": "10.6.0", - "@mojaloop/central-services-shared": "11.3.3", + "@mojaloop/central-services-shared": "11.3.5", "@mojaloop/event-sdk": "10.6.0", "@mojaloop/ml-number": "8.2.0", "@mojaloop/sdk-standard-components": "10.3.2", @@ -81,12 +81,12 @@ "rc": "1.2.8" }, "devDependencies": { - "@types/jest": "26.0.13", - "eslint": "7.8.1", + "@types/jest": "26.0.14", + "eslint": "7.9.0", "jest": "26.4.2", "jest-junit": "11.1.0", "npm-audit-resolver": "2.2.1", - "npm-check-updates": "8.1.1", + "npm-check-updates": "9.0.1", "nyc": "15.1.0", "pre-commit": "1.2.2", "proxyquire": "2.1.3", diff --git a/src/lib/util.js b/src/lib/util.js index f21508f3..bedf8af1 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -120,16 +120,27 @@ function removeEmptyKeys (originalObject) { return obj } +function applyResourceVersionHeaders (headers) { + let contentTypeHeader = headers['content-type'] || headers['Content-Type'] + let acceptHeader = headers.accept || headers.Accept + if (Enum.Http.Headers.FSPIOP.SWITCH.regex.test(headers['fspiop-source'])) { + if (Enum.Http.Headers.GENERAL.CONTENT_TYPE.regex.test(contentTypeHeader) && !!resourceVersions.quotes.contentVersion) { + contentTypeHeader = `application/vnd.interoperability.quotes+json;version=${resourceVersions.quotes.contentVersion}` + } + if (Enum.Http.Headers.GENERAL.ACCEPT.regex.test(acceptHeader) && !!resourceVersions.quotes.acceptVersion) { + acceptHeader = `application/vnd.interoperability.quotes+json;version=${resourceVersions.quotes.acceptVersion}` + } + } + return { contentTypeHeader, acceptHeader } +} + /** * Generates and returns an object containing API spec compliant HTTP request headers * * @returns {object} */ function generateRequestHeaders (headers, noAccept) { - let contentTypeHeader = headers['content-type'] || headers['Content-Type'] - if (Enum.Http.Headers.GENERAL.CONTENT_TYPE.regex.test(contentTypeHeader) && !!resourceVersions.quotes.contentVersion) { - contentTypeHeader = `application/vnd.interoperability.quotes+json;version=${resourceVersions.quotes.contentVersion}` - } + const { contentTypeHeader } = applyResourceVersionHeaders(headers) const ret = { 'Content-Type': contentTypeHeader, Date: headers.date, @@ -154,8 +165,9 @@ function generateRequestHeaders (headers, noAccept) { * @returns {object} */ function generateRequestHeadersForJWS (headers, noAccept) { + const { contentTypeHeader } = applyResourceVersionHeaders(headers) const ret = { - 'Content-Type': headers['content-type'] || headers['Content-Type'], + 'Content-Type': contentTypeHeader, date: headers.date, 'fspiop-source': headers['fspiop-source'], 'fspiop-destination': headers['fspiop-destination'], diff --git a/src/model/bulkQuotes.js b/src/model/bulkQuotes.js index 679fbdef..29ebc84c 100644 --- a/src/model/bulkQuotes.js +++ b/src/model/bulkQuotes.js @@ -86,8 +86,8 @@ class BulkQuotesModel { const fspiopDestination = headers[ENUM.Http.Headers.FSPIOP.DESTINATION] // validate - this will throw if the request is invalid - await this.validateBulkQuoteRequest(fspiopSource, fspiopDestination, bulkQuoteRequest) childSpan = span.getChild('qs_bulkquote_forwardBulkQuoteRequest') + await this.validateBulkQuoteRequest(fspiopSource, fspiopDestination, bulkQuoteRequest) // if we got here rules passed, so we can forward the quote on to the recipient dfsp await childSpan.audit({ headers, payload: bulkQuoteRequest }, EventSdk.AuditEventAction.start) await this.forwardBulkQuoteRequest(headers, bulkQuoteRequest.bulkQuoteId, bulkQuoteRequest, childSpan)