From c5c96afc79969ca2cded1edec5a935e0403f25ae Mon Sep 17 00:00:00 2001 From: Miguel de Barros Date: Wed, 2 Mar 2022 17:58:27 +0200 Subject: [PATCH] feat(mojaloop/#2704): core-services support for non-breaking backward api compatibility - updated default.json based on https://github.com/mojaloop/project/issues/2660 - re-factored config to load the changes correctly - updated plugins to correctly configure the FSPIOPHeaderValidation options - fixed unit tests TODO: update latest central-services-shared release after merging https://github.com/mojaloop/central-services-shared/pull/325 --- audit-resolve.json | 5 + config/default.json | 9 +- package-lock.json | 248 ++++++++++++++++++++--------- package.json | 2 +- src/handlers/notification/index.js | 2 +- src/lib/config.js | 22 ++- src/shared/plugins.js | 5 +- test/unit/lib/config.test.js | 23 ++- 8 files changed, 233 insertions(+), 83 deletions(-) diff --git a/audit-resolve.json b/audit-resolve.json index a7db778f..ee367e5f 100644 --- a/audit-resolve.json +++ b/audit-resolve.json @@ -176,6 +176,11 @@ "decision": "ignore", "madeAt": 1645104323030, "expiresAt": 1647696313138 + }, + "1007050|@mojaloop/central-services-shared>widdershins>urijs": { + "decision": "ignore", + "madeAt": 1646235001499, + "expiresAt": 1648826992822 } }, "rules": {}, diff --git a/config/default.json b/config/default.json index cc7f2269..f19682fc 100644 --- a/config/default.json +++ b/config/default.json @@ -8,11 +8,18 @@ "generateTimeout": 30000 }, "PROTOCOL_VERSIONS": { - "CONTENT": "1.1", + "CONTENT": { + "DEFAULT": "1.1", + "VALIDATELIST": [ + "1.1", + "1.0" + ] + }, "ACCEPT": { "DEFAULT": "1", "VALIDATELIST": [ "1", + "1.0", "1.1" ] } diff --git a/package-lock.json b/package-lock.json index 37672471..6fa5714d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -477,9 +477,9 @@ "integrity": "sha512-dDnQizD94EdBwEj/fh3zPRa/HWCS9O5au2PuHhZBbuM3xWHxuaKzPBOEWze7Nn0xW68MIpZ7Xdyn1CoCpjKCuQ==" }, "@gar/promisify": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.2.tgz", - "integrity": "sha512-82cpyJyKRoQoRi+14ibCeGPu0CwypgtBAdBhq1WfvagpCZNKqwXbKwXllYSMG91DhmG4jt9gN8eP6lGOtozuaw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", + "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", "dev": true }, "@grpc/proto-loader": { @@ -1353,9 +1353,9 @@ } }, "@npmcli/fs": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.1.0.tgz", - "integrity": "sha512-VhP1qZLXcrXRIaPoqb4YA55JQxLNF3jNR4T55IdOJa3+IFJKNYHtPvtXx8slmeMavj37vCzCfrqQM1vWLsYKLA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.1.1.tgz", + "integrity": "sha512-8KG5RD0GVP4ydEzRn/I4BNDuxDtqVbOdm8675T49OIG/NGhaK0pjPX7ZcDlvKYbA+ulvVK3ztfcF4uBdOxuJbQ==", "dev": true, "requires": { "@gar/promisify": "^1.0.1", @@ -1374,21 +1374,28 @@ } }, "@npmcli/git": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-2.1.0.tgz", - "integrity": "sha512-/hBFX/QG1b+N7PZBFs0bi+evgRZcK9nWBxQKZkGoXUT5hJSwl5c4d7y8/hm+NQZRPhQ67RzFaj5UM9YeyKoryw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-3.0.0.tgz", + "integrity": "sha512-xfSBJ+KBMZWWqRHFbEgIaXG/LtELHrQZMJ72Gkb3yWdHysu/7+VGOs8ME0c3td7QNQX57Ggo3kYL6ylcd70/kA==", "dev": true, "requires": { "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^6.0.0", + "lru-cache": "^7.3.1", "mkdirp": "^1.0.4", - "npm-pick-manifest": "^6.1.1", + "npm-pick-manifest": "^7.0.0", + "proc-log": "^2.0.0", "promise-inflight": "^1.0.1", "promise-retry": "^2.0.1", "semver": "^7.3.5", "which": "^2.0.2" }, "dependencies": { + "lru-cache": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.4.0.tgz", + "integrity": "sha512-YOfuyWa/Ee+PXbDm40j9WXyJrzQUynVbgn4Km643UYcWNcrSfRkKL0WaiUcxcIbkXcVTgNpDqSnPXntWXT75cw==", + "dev": true + }, "semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -1396,6 +1403,17 @@ "dev": true, "requires": { "lru-cache": "^6.0.0" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + } } }, "which": { @@ -1445,15 +1463,15 @@ } }, "@npmcli/run-script": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-2.0.0.tgz", - "integrity": "sha512-fSan/Pu11xS/TdaTpTB0MRn9guwGU8dye+x56mEVgBEd/QsybBbYcAL0phPXi8SGWFEChkQd6M9qL4y6VOpFig==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-3.0.0.tgz", + "integrity": "sha512-jIdmUepw+kVP2WEE/+XrBIvrSF5miDutdGBrQ8May6uHVAvpAb0m3NRHcJ0lKWbQ1BxsRFsmTrjkdY99qTTVIw==", "dev": true, "requires": { - "@npmcli/node-gyp": "^1.0.2", + "@npmcli/node-gyp": "^1.0.3", "@npmcli/promise-spawn": "^1.3.2", - "node-gyp": "^8.2.0", - "read-package-json-fast": "^2.0.1" + "node-gyp": "^8.4.1", + "read-package-json-fast": "^2.0.3" } }, "@protobufjs/aspromise": { @@ -1730,9 +1748,9 @@ } }, "agentkeepalive": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.2.0.tgz", - "integrity": "sha512-0PhAp58jZNw13UJv7NVdTGb0ZcghHUb3DrZ046JiiJY/BOaTTpbwdHq2VObPCBV8M2GPh7sgrJ3AQ8Ey468LJw==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.2.1.tgz", + "integrity": "sha512-Zn4cw2NEqd+9fiSVWMscnjyQ1a8Yfoc5oBajLeo5w+YBHgDUcEBY2hS4YpTz6iN5f/2zQiktcuM6tS8x1p9dpA==", "dev": true, "requires": { "debug": "^4.1.0", @@ -7620,20 +7638,20 @@ } }, "gauge": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.0.tgz", - "integrity": "sha512-F8sU45yQpjQjxKkm1UOAhf0U/O0aFt//Fl7hsrNVto+patMHjs7dPI9mFOGUKbhrgKm0S3EjW3scMFuQmWSROw==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.2.tgz", + "integrity": "sha512-aSPRm2CvA9R8QyU5eXMFPd+cYkyxLsXHd2l5/FOH2V/eml//M04G6KZOmTap07O1PvEwNcl2NndyLfK8g3QrKA==", "dev": true, "requires": { "ansi-regex": "^5.0.1", "aproba": "^1.0.3 || ^2.0.0", - "color-support": "^1.1.2", - "console-control-strings": "^1.0.0", + "color-support": "^1.1.3", + "console-control-strings": "^1.1.0", "has-unicode": "^2.0.1", - "signal-exit": "^3.0.0", + "signal-exit": "^3.0.7", "string-width": "^4.2.3", "strip-ansi": "^6.0.1", - "wide-align": "^1.1.2" + "wide-align": "^1.1.5" } }, "npmlog": { @@ -7657,6 +7675,12 @@ "lru-cache": "^6.0.0" } }, + "signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -7851,15 +7875,15 @@ } }, "npm-check-updates": { - "version": "12.3.0", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-12.3.0.tgz", - "integrity": "sha512-NcVpbVYZymmr7lVCwqz1wpkAgWNQ/XyyPy/yyR2IjCHU4Dr1lpIJgIgtC0PCDobcYuYXpYSIgIWZA7RFvq8+Rw==", + "version": "12.5.0", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-12.5.0.tgz", + "integrity": "sha512-nrryXO9IZdJsAIXo8LdtllrsGiTDE4IMAod7fl1jd5C38tOdZZG/crNNii4IkctxltQRmK/ziZwsMDTlhszZXg==", "dev": true, "requires": { "chalk": "^4.1.2", "cint": "^8.2.1", "cli-table": "^0.3.11", - "commander": "^8.3.0", + "commander": "^9.0.0", "fast-memoize": "^2.5.2", "find-up": "5.0.0", "fp-and-or": "^0.1.3", @@ -7870,9 +7894,9 @@ "jsonlines": "^0.1.1", "libnpmconfig": "^1.2.1", "lodash": "^4.17.21", - "minimatch": "^3.0.4", + "minimatch": "^5.0.0", "p-map": "^4.0.0", - "pacote": "^12.0.2", + "pacote": "^13.0.2", "parse-github-url": "^1.0.2", "progress": "^2.0.3", "prompts": "^2.4.2", @@ -7896,6 +7920,15 @@ "color-convert": "^2.0.1" } }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -7921,12 +7954,6 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "commander": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", - "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", - "dev": true - }, "find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -7961,6 +7988,15 @@ "p-locate": "^5.0.0" } }, + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, "p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -8026,13 +8062,13 @@ "dev": true }, "npm-package-arg": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz", - "integrity": "sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.0.0.tgz", + "integrity": "sha512-yhzXxeor+Zfhe5MGwPdDumz6HtNlj2pMekWB95IX3CC6uDNgde0oPKHDCLDPoJqQfd0HqAWt+y4Hs5m7CK1+9Q==", "dev": true, "requires": { - "hosted-git-info": "^4.0.1", - "semver": "^7.3.4", + "hosted-git-info": "^4.1.0", + "semver": "^7.3.5", "validate-npm-package-name": "^3.0.0" }, "dependencies": { @@ -8069,15 +8105,15 @@ } }, "npm-pick-manifest": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-6.1.1.tgz", - "integrity": "sha512-dBsdBtORT84S8V8UTad1WlUyKIY9iMsAmqxHbLdeEeBNMLQDlDWWra3wYUx9EBEIiG/YwAy0XyNHDd2goAsfuA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-7.0.0.tgz", + "integrity": "sha512-njM1AcdioFaKd0JSGtLO09YA1WRwctjGQJbnHGmKS+u+uwP8oFvtZtOQWPYdxrnY5eJud3wn8OpH4sEIx6+GEQ==", "dev": true, "requires": { "npm-install-checks": "^4.0.0", "npm-normalize-package-bin": "^1.0.1", - "npm-package-arg": "^8.1.2", - "semver": "^7.3.4" + "npm-package-arg": "^9.0.0", + "semver": "^7.3.5" }, "dependencies": { "semver": { @@ -8092,17 +8128,18 @@ } }, "npm-registry-fetch": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-12.0.2.tgz", - "integrity": "sha512-Df5QT3RaJnXYuOwtXBXS9BWs+tHH2olvkCLh6jcR/b/u3DvPMlp3J0TvvYwplPKxHMOwfg287PYih9QqaVFoKA==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-13.0.0.tgz", + "integrity": "sha512-MmiMuV9DU5gRuAU0jia952Qq+E4h7ZoUaeltCXivhClcqfOVKqNLZEQsRUOb6a8WQY+um8x97JcUuaWFoPoBBw==", "dev": true, "requires": { - "make-fetch-happen": "^10.0.1", + "make-fetch-happen": "^10.0.2", "minipass": "^3.1.6", "minipass-fetch": "^1.4.1", "minipass-json-stream": "^1.0.1", "minizlib": "^2.1.2", - "npm-package-arg": "^8.1.5" + "npm-package-arg": "^9.0.0", + "proc-log": "^2.0.0" }, "dependencies": { "@tootallnate/once": { @@ -8132,15 +8169,15 @@ } }, "lru-cache": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.3.1.tgz", - "integrity": "sha512-nX1x4qUrKqwbIAhv4s9et4FIUVzNOpeY07bsjGUy8gwJrXH/wScImSQqXErmo/b2jZY2r0mohbLA9zVj7u1cNw==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.4.0.tgz", + "integrity": "sha512-YOfuyWa/Ee+PXbDm40j9WXyJrzQUynVbgn4Km643UYcWNcrSfRkKL0WaiUcxcIbkXcVTgNpDqSnPXntWXT75cw==", "dev": true }, "make-fetch-happen": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.0.1.tgz", - "integrity": "sha512-xJVRzemKMb9r2gZ5DJfkvbeSGbBKOtwI4G8hJ1Ak/2jIFJFveyQxN3d2OhXlAk7rLzAL/O+Ge8u+nb6/Zrrd9w==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.0.3.tgz", + "integrity": "sha512-CzarPHynPpHjhF5in/YapnO44rSZeYX5VCMfdXa99+gLwpbfFLh20CWa6dP/taV9Net9PWJwXNKtp/4ZTCQnag==", "dev": true, "requires": { "agentkeepalive": "^4.2.0", @@ -8149,7 +8186,7 @@ "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.0", "is-lambda": "^1.0.1", - "lru-cache": "^7.3.0", + "lru-cache": "^7.3.1", "minipass": "^3.1.6", "minipass-collect": "^1.0.2", "minipass-fetch": "^1.4.1", @@ -8844,30 +8881,85 @@ } }, "pacote": { - "version": "12.0.3", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-12.0.3.tgz", - "integrity": "sha512-CdYEl03JDrRO3x18uHjBYA9TyoW8gy+ThVcypcDkxPtKlw76e4ejhYB6i9lJ+/cebbjpqPW/CijjqxwDTts8Ow==", + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-13.0.3.tgz", + "integrity": "sha512-8thQ06YoO01O1k5rvSpHS/XPJZucw2DPiiT1jI+ys8QaTN6ifAyxfyoABHBa8nIt/4wPdzly4GEPqshctHFoYA==", "dev": true, "requires": { - "@npmcli/git": "^2.1.0", - "@npmcli/installed-package-contents": "^1.0.6", + "@npmcli/git": "^3.0.0", + "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/promise-spawn": "^1.2.0", - "@npmcli/run-script": "^2.0.0", - "cacache": "^15.0.5", + "@npmcli/run-script": "^3.0.0", + "cacache": "^15.3.0", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "infer-owner": "^1.0.4", - "minipass": "^3.1.3", - "mkdirp": "^1.0.3", - "npm-package-arg": "^8.0.1", + "minipass": "^3.1.6", + "mkdirp": "^1.0.4", + "npm-package-arg": "^9.0.0", "npm-packlist": "^3.0.0", - "npm-pick-manifest": "^6.0.0", - "npm-registry-fetch": "^12.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0", "promise-retry": "^2.0.1", - "read-package-json-fast": "^2.0.1", + "read-package-json": "^4.1.1", + "read-package-json-fast": "^2.0.3", "rimraf": "^3.0.2", "ssri": "^8.0.1", - "tar": "^6.1.0" + "tar": "^6.1.11" + }, + "dependencies": { + "hosted-git-info": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", + "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "minipass": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz", + "integrity": "sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "normalize-package-data": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", + "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", + "dev": true, + "requires": { + "hosted-git-info": "^4.0.1", + "is-core-module": "^2.5.0", + "semver": "^7.3.4", + "validate-npm-package-license": "^3.0.1" + } + }, + "read-package-json": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-4.1.1.tgz", + "integrity": "sha512-P82sbZJ3ldDrWCOSKxJT0r/CXMWR0OR3KRh55SgKo3p91GSIEEC32v3lSHAvO/UcH3/IoL7uqhOFBduAnwdldw==", + "dev": true, + "requires": { + "glob": "^7.1.1", + "json-parse-even-better-errors": "^2.3.0", + "normalize-package-data": "^3.0.0", + "npm-normalize-package-bin": "^1.0.0" + } + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } } }, "parent-module": { @@ -9238,6 +9330,12 @@ "plur": "^1.0.0" } }, + "proc-log": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.0.tgz", + "integrity": "sha512-I/35MfCX2H8jBUhKN8JB8nmqvQo/nKdrBodBY7L3RhDSPPyvOHwLYNmPuhwuJq7a7C3vgFKWGQM+ecPStcvOHA==", + "dev": true + }, "process": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/process/-/process-0.10.1.tgz", diff --git a/package.json b/package.json index 16282cff..dedeb579 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "license-checker": "25.0.1", "nodemon": "2.0.15", "npm-audit-resolver": "2.3.1", - "npm-check-updates": "12.3.0", + "npm-check-updates": "12.5.0", "npm-run-all": "4.1.5", "nyc": "15.1.0", "pre-commit": "1.2.2", diff --git a/src/handlers/notification/index.js b/src/handlers/notification/index.js index 856d638c..8efdddff 100644 --- a/src/handlers/notification/index.js +++ b/src/handlers/notification/index.js @@ -260,7 +260,7 @@ const processMessage = async (msg, span) => { // Injected Configuration for outbound Content-Type & Accept headers. const protocolVersions = { - content: Config.PROTOCOL_VERSIONS.CONTENT.toString(), + content: Config.PROTOCOL_VERSIONS.CONTENT.DEFAULT.toString(), accept: Config.PROTOCOL_VERSIONS.ACCEPT.DEFAULT.toString() } diff --git a/src/lib/config.js b/src/lib/config.js index 28d69c28..f00d2e9a 100644 --- a/src/lib/config.js +++ b/src/lib/config.js @@ -11,11 +11,18 @@ const getFileContent = (path) => { } const DEFAULT_PROTOCOL_VERSION = { - CONTENT: '1.1', + CONTENT: { + DEFAULT: '1.1', + VALIDATELIST: [ + '1.0', + '1.1' + ] + }, ACCEPT: { DEFAULT: '1', VALIDATELIST: [ '1', + '1.0', '1.1' ] } @@ -26,12 +33,25 @@ const getProtocolVersions = (defaultProtocolVersions, overrideProtocolVersions) ...defaultProtocolVersions, ...overrideProtocolVersions } + if (overrideProtocolVersions && overrideProtocolVersions.CONTENT) { + T_PROTOCOL_VERSION.CONTENT = { + ...defaultProtocolVersions.CONTENT, + ...overrideProtocolVersions.CONTENT + } + } + if (overrideProtocolVersions && overrideProtocolVersions.ACCEPT) { T_PROTOCOL_VERSION.ACCEPT = { ...defaultProtocolVersions.ACCEPT, ...overrideProtocolVersions.ACCEPT } } + if (T_PROTOCOL_VERSION.CONTENT && + T_PROTOCOL_VERSION.CONTENT.VALIDATELIST && + (typeof T_PROTOCOL_VERSION.CONTENT.VALIDATELIST === 'string' || + T_PROTOCOL_VERSION.CONTENT.VALIDATELIST instanceof String)) { + T_PROTOCOL_VERSION.CONTENT.VALIDATELIST = JSON.parse(T_PROTOCOL_VERSION.CONTENT.VALIDATELIST) + } if (T_PROTOCOL_VERSION.ACCEPT && T_PROTOCOL_VERSION.ACCEPT.VALIDATELIST && (typeof T_PROTOCOL_VERSION.ACCEPT.VALIDATELIST === 'string' || diff --git a/src/shared/plugins.js b/src/shared/plugins.js index bf64cb9b..564c7a71 100644 --- a/src/shared/plugins.js +++ b/src/shared/plugins.js @@ -69,7 +69,10 @@ const registerPlugins = async (server) => { // Helper to construct FSPIOPHeaderValidation option configuration const getOptionsForFSPIOPHeaderValidation = () => { // configure supported FSPIOP Content-Type versions - const supportedProtocolContentVersions = [Config.PROTOCOL_VERSIONS.CONTENT.toString()] + const supportedProtocolContentVersions = [] + for (const version of Config.PROTOCOL_VERSIONS.CONTENT.VALIDATELIST) { + supportedProtocolContentVersions.push(version.toString()) + } // configure supported FSPIOP Accept version const supportedProtocolAcceptVersions = [] diff --git a/test/unit/lib/config.test.js b/test/unit/lib/config.test.js index 0f7c986e..56e9c598 100644 --- a/test/unit/lib/config.test.js +++ b/test/unit/lib/config.test.js @@ -65,6 +65,7 @@ Test('Config tests', configTest => { DefaultStub.ENDPOINT_SECURITY.JWS.JWS_SIGN = true // set env var const validateList = ['1'] + process.env.MLAPI_PROTOCOL_VERSIONS__CONTENT__VALIDATELIST = JSON.stringify(validateList) process.env.MLAPI_PROTOCOL_VERSIONS__ACCEPT__VALIDATELIST = JSON.stringify(validateList) const Config = Proxyquire(`${src}/lib/config`, { '../../config/default.json': DefaultStub @@ -73,8 +74,13 @@ Test('Config tests', configTest => { console.log('config', JSON.stringify(Config.PROTOCOL_VERSIONS)) test.ok('pass') test.deepEqual(Config.PROTOCOL_VERSIONS.ACCEPT.VALIDATELIST, validateList) + test.deepEqual(Config.PROTOCOL_VERSIONS.CONTENT.VALIDATELIST, validateList) } catch (e) { test.fail('should throw') + } finally { + // remove env vars so they will not impact other tests + delete process.env.MLAPI_PROTOCOL_VERSIONS__CONTENT__VALIDATELIST + delete process.env.MLAPI_PROTOCOL_VERSIONS__ACCEPT__VALIDATELIST } test.end() }) @@ -83,17 +89,28 @@ Test('Config tests', configTest => { // Arrange const DefaultStub = Util.clone(Default) DefaultStub.PROTOCOL_VERSIONS = { - CONTENT: '1.1', + CONTENT: { + DEFAULT: '1.1', + VALIDATELIST: [ + '1.1' + ] + }, ACCEPT: { + DEFAULT: '1.0', VALIDATELIST: [ '1' ] } } const expected = { - CONTENT: '1.1', + CONTENT: { + DEFAULT: '1.1', + VALIDATELIST: [ + '1.1' + ] + }, ACCEPT: { - DEFAULT: '1', + DEFAULT: '1.0', VALIDATELIST: [ '1' ]