Skip to content

Commit

Permalink
Changes for bug mojaloop/project#1378
Browse files Browse the repository at this point in the history
  • Loading branch information
aenns committed Jun 16, 2020
1 parent 24812c9 commit 7c93bd7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/central-services-shared",
"version": "10.4.3",
"version": "10.4.4",
"description": "Shared code for central services",
"main": "src/index.js",
"scripts": {
Expand Down Expand Up @@ -56,7 +56,7 @@
"immutable": "3.8.2",
"lodash": "4.17.15",
"mustache": "4.0.1",
"openapi-backend": "3.5.0",
"openapi-backend": "3.5.1",
"raw-body": "2.4.1"
},
"devDependencies": {
Expand All @@ -77,7 +77,7 @@
"tap-xunit": "2.4.1",
"tape": "5.0.1",
"tapes": "4.1.0",
"uuid4": "1.1.4"
"uuid4": "2.0.2"
},
"standard": {
"ignore": []
Expand Down
7 changes: 5 additions & 2 deletions src/util/hapi/plugins/headerValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// accuracy of this statement has not been thoroughly tested.

const { Factory: { createFSPIOPError }, Enums } = require('@mojaloop/central-services-error-handling')
const { parseAcceptHeader, parseContentTypeHeader, protocolVersions } = require('../../headerValidation')
const { parseAcceptHeader, parseContentTypeHeader, protocolVersions, protocolVersionsMap } = require('../../headerValidation')

// Some defaults

Expand Down Expand Up @@ -94,7 +94,10 @@ const plugin = {
if (!supportedProtocolVersions.includes(contentType.version)) {
throw createFSPIOPError(
Enums.FSPIOPErrorCodes.UNACCEPTABLE_VERSION,
errorMessages.SUPPLIED_VERSION_NOT_SUPPORTED
errorMessages.SUPPLIED_VERSION_NOT_SUPPORTED,
null,
null,
protocolVersionsMap
)
}

Expand Down
8 changes: 7 additions & 1 deletion src/util/headerValidation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ const assert = require('assert').strict

const protocolVersions = {
anyVersion: Symbol('Any version'),
ONE: ['1', '1.0']
ONE: ['1', '1.0', '1.1']
}

const protocolVersionsMap = [
{ key: '1', value: '0' },
{ key: '1', value: '1' }
]

// Some convenience functions for generating regexes for header matching

const generateContentTypeRegex = resource =>
Expand Down Expand Up @@ -62,6 +67,7 @@ const parseAcceptHeader = (resource, header) => {

module.exports = {
protocolVersions,
protocolVersionsMap,
generateAcceptRegex,
generateContentTypeRegex,
parseAcceptHeader,
Expand Down

0 comments on commit 7c93bd7

Please sign in to comment.