From e36000645bf928792c4324282de562c54910185a Mon Sep 17 00:00:00 2001 From: Kevin Leyow Date: Wed, 9 Mar 2022 17:36:11 -0500 Subject: [PATCH] refactor!: update api to v1.0 (#65) * refactor: update api to v1.0 * chore: fix tests * chore: rebuild * chore: readd * chore: rebuild types * chore: remove generate challenge --- audit-resolve.json | 120 ++++++++ package-lock.json | 182 ++++++------ package.json | 7 +- src/domain/consents.ts | 131 -------- .../thirdpartyRequests/authorizations.ts | 42 ++- src/domain/thirdpartyRequests/transactions.ts | 18 +- .../thirdpartyRequests/verifications.ts | 42 ++- src/shared/compositeKeyMap.ts | 41 --- src/shared/config.ts | 26 +- test/unit/data/mockData.json | 10 - test/unit/domain/consents.test.ts | 281 ++---------------- .../thirdpartyRequests/authorizations.test.ts | 69 +++-- .../thirdpartyRequests/verifications.test.ts | 51 ++-- 13 files changed, 354 insertions(+), 666 deletions(-) delete mode 100644 src/shared/compositeKeyMap.ts diff --git a/audit-resolve.json b/audit-resolve.json index ea102a0..78b4c2d 100644 --- a/audit-resolve.json +++ b/audit-resolve.json @@ -68,6 +68,126 @@ "decision": "ignore", "madeAt": 1635993834138, "expiresAt": 1638585798965 + }, + "1038419|@mojaloop/central-services-shared>widdershins>urijs": { + "decision": "ignore", + "madeAt": 1646748765308, + "expiresAt": 1649340758801 + }, + "1038437|@mojaloop/central-services-shared>widdershins>urijs": { + "decision": "ignore", + "madeAt": 1646748765308, + "expiresAt": 1649340758801 + }, + "1038442|@mojaloop/central-services-shared>axios>follow-redirects": { + "decision": "ignore", + "madeAt": 1646748766312, + "expiresAt": 1649340758801 + }, + "1038495|@mojaloop/central-services-shared>axios>follow-redirects": { + "decision": "ignore", + "madeAt": 1646748766312, + "expiresAt": 1649340758801 + }, + "1038477|@mojaloop/central-services-shared>widdershins>node-fetch": { + "decision": "ignore", + "madeAt": 1646748767456, + "expiresAt": 1649340758801 + }, + "1038477|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>node-fetch": { + "decision": "ignore", + "madeAt": 1646748767456, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748768483, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>string-width>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748768483, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748768483, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748768483, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748768483, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>string-width>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748768483, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/event-sdk>@grpc/proto-loader>yargs>string-width>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748768483, + "expiresAt": 1649340758801 + }, + "1038492|@mojaloop/central-services-shared>shins>markdown-it": { + "decision": "ignore", + "madeAt": 1646748769513, + "expiresAt": 1649340758801 + }, + "1038575|@mojaloop/central-services-shared>widdershins>openapi-sampler>json-pointer": { + "decision": "ignore", + "madeAt": 1646748770682, + "expiresAt": 1649340758801 + }, + "1038592|@mojaloop/central-services-shared>widdershins>swagger2openapi>better-ajv-errors>jsonpointer": { + "decision": "ignore", + "madeAt": 1646748771784, + "expiresAt": 1649340758801 + }, + "1038592|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>better-ajv-errors>jsonpointer": { + "decision": "ignore", + "madeAt": 1646748771784, + "expiresAt": 1649340758801 + }, + "1038599|hapi-swagger>swagger-parser>z-schema>validator": { + "decision": "ignore", + "madeAt": 1646748772731, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/central-services-shared>widdershins>yargs>string-width>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748773734, + "expiresAt": 1649340758801 + }, + "1038674|@mojaloop/central-services-shared>widdershins>yargs>cliui>string-width>strip-ansi>ansi-regex": { + "decision": "ignore", + "madeAt": 1646748773734, + "expiresAt": 1649340758801 + }, + "1038992|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>ajv": { + "decision": "ignore", + "madeAt": 1646748775145, + "expiresAt": 1649340758801 + }, + "1039200|@mojaloop/central-services-shared>shins>sanitize-html": { + "decision": "ignore", + "madeAt": 1646748776214, + "expiresAt": 1649340758801 + }, + "1039201|@mojaloop/central-services-shared>shins>sanitize-html": { + "decision": "ignore", + "madeAt": 1646748776214, + "expiresAt": 1649340758801 + }, + "1039356|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": { + "decision": "ignore", + "madeAt": 1646748777500, + "expiresAt": 1649340758801 } }, "rules": {}, diff --git a/package-lock.json b/package-lock.json index 0e15b90..f861ed2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1906,9 +1906,9 @@ } }, "@mojaloop/api-snippets": { - "version": "12.6.6", - "resolved": "https://registry.npmjs.org/@mojaloop/api-snippets/-/api-snippets-12.6.6.tgz", - "integrity": "sha512-b8O6P5Z4iCFS1czNAzFOQMapxPS1RaAaqoF7KzxPX2p4IBD3etIlQAXfvo31/0mVObnJIJXCioVUdocDZ/Eqmw==", + "version": "13.0.8", + "resolved": "https://registry.npmjs.org/@mojaloop/api-snippets/-/api-snippets-13.0.8.tgz", + "integrity": "sha512-ri1fQ5iJ0kzywmY5T3vLgeLXrp4CzcYykZLA+SdsgyAu5HlbB8oJkqMlFt1WklXdrNKdO7N1PgihRFUAMJ2N4g==", "requires": { "commander": "^2.19.0", "jest-ts-auto-mock": "^2.0.0", @@ -5476,9 +5476,9 @@ "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" }, "cookiejar": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", - "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" }, "copy-descriptor": { "version": "0.1.1", @@ -7422,9 +7422,9 @@ "integrity": "sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==" }, "formidable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz", - "integrity": "sha512-V8gLm+41I/8kguQ4/o1D3RIHRmhYFG4pnNyonvua+40rqcEmT4+V71yaZ3B457xbbgCsCfjSPi65u/W6vK1U5Q==" + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", + "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==" }, "forwarded": { "version": "0.2.0", @@ -8276,74 +8276,17 @@ } }, "hapi-swagger": { - "version": "14.1.1", - "resolved": "https://registry.npmjs.org/hapi-swagger/-/hapi-swagger-14.1.1.tgz", - "integrity": "sha512-2E1fA5LXORSvKCiuX/3ELakLyDjoawNhqmCgTOxK2tONizLgSloBUSRXD0xZ5UCTI/UxGK1p+3D8PP6vT0sAxw==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/hapi-swagger/-/hapi-swagger-14.2.5.tgz", + "integrity": "sha512-rIxwCT9i+R9E9Z5m9BT15rwYI58IOKTKu7NEx9+pHO5aVeJK703qW3PWk72D7x9MSAnhmlJoEyUiFAU+6zQJ9A==", "requires": { "@hapi/boom": "^9.1.0", "@hapi/hoek": "^9.0.2", - "handlebars": "^4.5.3", + "handlebars": "^4.7.7", "http-status": "^1.0.1", "json-schema-ref-parser": "^6.1.0", "swagger-parser": "4.0.2", - "swagger-ui-dist": "^3.22.1" - }, - "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "optional": true - }, - "core-js": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", - "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==" - }, - "swagger-parser": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/swagger-parser/-/swagger-parser-4.0.2.tgz", - "integrity": "sha512-hKslog8LhsXICJ1sMLsA8b8hQ3oUEX0457aLCFJc4zz6m8drmnCtyjbVqS5HycaKFOKVolJc2wFoe8KDPWfp4g==", - "requires": { - "call-me-maybe": "^1.0.1", - "debug": "^3.1.0", - "json-schema-ref-parser": "^4.1.0", - "ono": "^4.0.3", - "swagger-methods": "^1.0.4", - "swagger-schema-official": "2.0.0-bab6bed", - "z-schema": "^3.19.0" - }, - "dependencies": { - "json-schema-ref-parser": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-4.1.1.tgz", - "integrity": "sha512-lByoCHZ6H2zgb6NtsXIqtzQ+6Ji7iVqnrhWxsXLhF+gXmgu6E8+ErpDxCMR439MUG1nfMjWI2HAoM8l0XgSNhw==", - "requires": { - "call-me-maybe": "^1.0.1", - "debug": "^3.1.0", - "js-yaml": "^3.10.0", - "ono": "^4.0.3" - } - } - } - }, - "validator": { - "version": "10.11.0", - "resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz", - "integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw==" - }, - "z-schema": { - "version": "3.25.1", - "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.25.1.tgz", - "integrity": "sha512-7tDlwhrBG+oYFdXNOjILSurpfQyuVgkRe3hB2q8TEssamDHB7BbLWYkYO98nTn0FibfdFroFKDjndbgufAgS/Q==", - "requires": { - "commander": "^2.7.1", - "core-js": "^2.5.7", - "lodash.get": "^4.0.0", - "lodash.isequal": "^4.0.0", - "validator": "^10.0.0" - } - } + "swagger-ui-dist": "^4.5.0" } }, "har-schema": { @@ -10351,9 +10294,9 @@ } }, "jest-ts-auto-mock": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/jest-ts-auto-mock/-/jest-ts-auto-mock-2.0.0.tgz", - "integrity": "sha512-ybY/VtTWJUGDPhOLdjAXsM10ShO8ri1EorXpfHYg4CH00b/k30c4RJJ0iM7GQ4FakHsIr7/zTRwETd3N9smxoA==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/jest-ts-auto-mock/-/jest-ts-auto-mock-2.1.0.tgz", + "integrity": "sha512-ubL0pweKUHQNY2xCgwXjYllEQMgpKDojcEODpraQVevHqBFBsFDJZkpZp/2JsmujMu4TNJPzmSugXOLfKndmlQ==" }, "jest-util": { "version": "26.6.2", @@ -11672,17 +11615,17 @@ }, "dependencies": { "hosted-git-info": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.0.2.tgz", - "integrity": "sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg==", + "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==", "requires": { "lru-cache": "^6.0.0" } }, "is-core-module": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", - "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", + "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", "requires": { "has": "^1.0.3" } @@ -15816,15 +15759,70 @@ "resolved": "https://registry.npmjs.org/swagger-methods/-/swagger-methods-1.0.8.tgz", "integrity": "sha512-G6baCwuHA+C5jf4FNOrosE4XlmGsdjbOjdBK4yuiDDj/ro9uR4Srj3OR84oQMT8F3qKp00tYNv0YN730oTHPZA==" }, + "swagger-parser": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/swagger-parser/-/swagger-parser-4.0.2.tgz", + "integrity": "sha512-hKslog8LhsXICJ1sMLsA8b8hQ3oUEX0457aLCFJc4zz6m8drmnCtyjbVqS5HycaKFOKVolJc2wFoe8KDPWfp4g==", + "requires": { + "call-me-maybe": "^1.0.1", + "debug": "^3.1.0", + "json-schema-ref-parser": "^4.1.0", + "ono": "^4.0.3", + "swagger-methods": "^1.0.4", + "swagger-schema-official": "2.0.0-bab6bed", + "z-schema": "^3.19.0" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "optional": true + }, + "core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==" + }, + "json-schema-ref-parser": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-4.1.1.tgz", + "integrity": "sha512-lByoCHZ6H2zgb6NtsXIqtzQ+6Ji7iVqnrhWxsXLhF+gXmgu6E8+ErpDxCMR439MUG1nfMjWI2HAoM8l0XgSNhw==", + "requires": { + "call-me-maybe": "^1.0.1", + "debug": "^3.1.0", + "js-yaml": "^3.10.0", + "ono": "^4.0.3" + } + }, + "validator": { + "version": "10.11.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz", + "integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw==" + }, + "z-schema": { + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.25.1.tgz", + "integrity": "sha512-7tDlwhrBG+oYFdXNOjILSurpfQyuVgkRe3hB2q8TEssamDHB7BbLWYkYO98nTn0FibfdFroFKDjndbgufAgS/Q==", + "requires": { + "commander": "^2.7.1", + "core-js": "^2.5.7", + "lodash.get": "^4.0.0", + "lodash.isequal": "^4.0.0", + "validator": "^10.0.0" + } + } + } + }, "swagger-schema-official": { "version": "2.0.0-bab6bed", "resolved": "https://registry.npmjs.org/swagger-schema-official/-/swagger-schema-official-2.0.0-bab6bed.tgz", "integrity": "sha1-cAcEaNbSl3ylI3suUZyn0Gouo/0=" }, "swagger-ui-dist": { - "version": "3.47.1", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.47.1.tgz", - "integrity": "sha512-7b9iHDC/GGC9SJLd3HiV/3EnsJ3wu7xN8Q4MpOPfQO8UG7TQFG2TMTDkvvy0SNeqxQY0tGQY0ppZC9a95tW3kg==" + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-4.6.1.tgz", + "integrity": "sha512-GyP8Hx9qGs7cN6gIK5rTG/NX9CmDDHjq1wzIYlRyJVWZir/D5xarkAroZDYTf4j13ontCQSUZ4Jw83XQoVbB+g==" }, "swagger2openapi": { "version": "6.2.3", @@ -16224,9 +16222,9 @@ "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, "ts-auto-mock": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/ts-auto-mock/-/ts-auto-mock-3.3.5.tgz", - "integrity": "sha512-V1i2DrEjDHEtjlJi6kaMH/n8NGyX3iat8oIUh1rymhULBboWyBqv6cCogej9S2ZXBd1PM8vaPwS3J6ooM7beTw==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/ts-auto-mock/-/ts-auto-mock-3.5.0.tgz", + "integrity": "sha512-E1XjMO6UWK/e+i4Ri7h8xGFCIHAb+dxgojcmPQZabQXIJatddQvqJOypg7nYCD2lPtb43HVa3bQd6uHDYV5PvQ==", "requires": { "lodash-es": "^4.17.21", "micromatch": "^4.0.4", @@ -16243,9 +16241,9 @@ } }, "picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" } } }, @@ -16569,9 +16567,9 @@ } }, "ttypescript": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/ttypescript/-/ttypescript-1.5.12.tgz", - "integrity": "sha512-1ojRyJvpnmgN9kIHmUnQPlEV1gq+VVsxVYjk/NfvMlHSmYxjK5hEvOOU2MQASrbekTUiUM7pR/nXeCc8bzvMOQ==", + "version": "1.5.13", + "resolved": "https://registry.npmjs.org/ttypescript/-/ttypescript-1.5.13.tgz", + "integrity": "sha512-KT/RBfGGlVJFqEI8cVvI3nMsmYcFvPSZh8bU0qX+pAwbi7/ABmYkzn7l/K8skw0xmYjVCoyaV6WLsBQxdadybQ==", "requires": { "resolve": ">=1.9.0" } diff --git a/package.json b/package.json index 3b74e56..8c6203e 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,9 @@ "files": [ "dist" ], + "engines": { + "node": "=14.x" + }, "scripts": { "audit:resolve": "SHELL=sh resolve-audit --production", "audit:check": "SHELL=sh check-audit --production", @@ -114,7 +117,7 @@ "@hapi/hapi": "^20.1.2", "@hapi/inert": "^6.0.3", "@hapi/vision": "^6.0.1", - "@mojaloop/api-snippets": "^12.6.6", + "@mojaloop/api-snippets": "^13.0.7", "@mojaloop/central-services-error-handling": "11.3.0", "@mojaloop/central-services-health": "^13.0.0", "@mojaloop/central-services-logger": "10.6.1", @@ -128,7 +131,7 @@ "canonical-json": "0.0.4", "commander": "5.1.0", "hapi-openapi": "^3.0.0", - "hapi-swagger": "^14.1.1", + "hapi-swagger": "^14.2.5", "module-alias": "^2.2.2", "mustache": "^4.2.0", "parse-strings-in-object": "^2.0.0", diff --git a/src/domain/consents.ts b/src/domain/consents.ts index 2559113..9cc76ca 100644 --- a/src/domain/consents.ts +++ b/src/domain/consents.ts @@ -249,134 +249,3 @@ export async function forwardConsentsRequest ( throw fspiopError } } - -/** - * @function forwardConsentsIdGenerateChallengeError - * @description Generic function to handle sending `PUT .../consents/{ID}/generateChallenge/error` back to the FSPIOP-Source - * @param {string} path Callback endpoint path - * @param {string} consentsId the ID of the consents request - * @param {HapiUtil.Dictionary} headers Headers object of the request - * @param {APIErrorObject} error Error details - * @param {object} span optional request span - * @throws {FSPIOPError} Will throw an error if no endpoint to forward the request is - * found, if there are network errors or if there is a bad response - * @returns {Promise} - */ -export async function forwardConsentsIdGenerateChallengeError ( - path: string, - consentsId: string, - headers: HapiUtil.Dictionary, - error: APIErrorObject, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - span?: any): Promise { - const childSpan = span?.getChild('forwardConsentsIdGenerateChallengeError') - const sourceDfspId = headers[Enum.Http.Headers.FSPIOP.SOURCE] - const destinationDfspId = headers[Enum.Http.Headers.FSPIOP.DESTINATION] - const endpointType = Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_PUT_ERROR - - try { - const url = await Util.Endpoints.getEndpointAndRender( - Config.ENDPOINT_SERVICE_URL, - destinationDfspId, - endpointType, - path, - { ID: consentsId }) - Logger.info(`consents::forwardConsentsIdGenerateChallengeError - Forwarding consents error callback to endpoint: ${url}`) - - await Util.Request.sendRequest( - url, - headers, - sourceDfspId, - destinationDfspId, - Enum.Http.RestMethods.PUT, - error, - Enum.Http.ResponseTypes.JSON, - childSpan - ) - - Logger.info(`consents::forwardConsentsIdGenerateChallengeError - Forwarded consents error callback: from ${sourceDfspId} to ${destinationDfspId}`) - if (childSpan && !childSpan.isFinished) { - childSpan.finish() - } - } catch (err) { - Logger.error(`consents::forwardConsentsIdGenerateChallengeError - Error forwarding consents error to endpoint: ${inspect(err)}`) - const fspiopError: FSPIOPError = ReformatFSPIOPError(err) - if (childSpan && !childSpan.isFinished) { - await finishChildSpan(fspiopError, childSpan) - } - throw fspiopError - } -} - -/** - * @function forwardConsentsIdGenerateChallengeRequest - * @description Forwards a /consents/{ID}/generateChallenge request - * @param {string} path Callback endpoint path - * @param {FspEndpointTypesEnum} path Callback endpoint template - * @param {HapiUtil.Dictionary} headers Headers object of the request - * @param {RestMethodsEnum} method The http method POST - * @param {object} payload Body of the request - * @param {object} span optional request span - * @throws {FSPIOPError} Will throw an error if no endpoint to forward the consents generate challenge requests is - * found, if there are network errors or if there is a bad response - * @returns {Promise} - */ -export async function forwardConsentsIdGenerateChallengeRequest ( - consentsIdGenerateChallengeRequestId: string, - path: string, - endpointType: FspEndpointTypesEnum, - headers: HapiUtil.Dictionary, - method: RestMethodsEnum, - payload: tpAPI.Schemas.ConsentsIDGenerateChallengePostRequest, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - span?: any): Promise { - const childSpan = span?.getChild('forwardConsentsIdGenerateChallengeRequest') - const sourceDfspId = headers[Enum.Http.Headers.FSPIOP.SOURCE] - const destinationDfspId = headers[Enum.Http.Headers.FSPIOP.DESTINATION] - try { - const url = await Util.Endpoints.getEndpointAndRender( - Config.ENDPOINT_SERVICE_URL, - destinationDfspId, - endpointType, - path, - { ID: consentsIdGenerateChallengeRequestId } - ) - Logger.info(`consents::forwardConsentsIdGenerateChallengeRequestError - Forwarding consents error callback to endpoint: ${url}`) - - await Util.Request.sendRequest( - url, - headers, - sourceDfspId, - destinationDfspId, - method, - payload, - Enum.Http.ResponseTypes.JSON, - childSpan - ) - - Logger.info(`consents::forwardConsentsIdGenerateChallengeRequest - Forwarded consents: from ${sourceDfspId} to ${destinationDfspId}`) - if (childSpan && !childSpan.isFinished) { - childSpan.finish() - } - } catch (err) { - Logger.error(`consents::forwardConsentsIdGenerateChallengeRequest - Error forwarding consents to endpoint: ${inspect(err)}`) - const errorHeaders = { - ...headers, - 'fspiop-source': Enum.Http.Headers.FSPIOP.SWITCH.value, - 'fspiop-destination': sourceDfspId - } - const fspiopError: FSPIOPError = ReformatFSPIOPError(err) - await forwardConsentsIdGenerateChallengeError( - Enum.EndPoints.FspEndpointTemplates.TP_CONSENT_GENERATE_CHALLENGE_PUT_ERROR, - consentsIdGenerateChallengeRequestId, - errorHeaders, - fspiopError.toApiErrorObject(Config.ERROR_HANDLING.includeCauseExtension, Config.ERROR_HANDLING.truncateExtensions), - childSpan - ) - - if (childSpan && !childSpan.isFinished) { - await finishChildSpan(fspiopError, childSpan) - } - throw fspiopError - } -} diff --git a/src/domain/thirdpartyRequests/authorizations.ts b/src/domain/thirdpartyRequests/authorizations.ts index 6161854..f390a91 100644 --- a/src/domain/thirdpartyRequests/authorizations.ts +++ b/src/domain/thirdpartyRequests/authorizations.ts @@ -1,20 +1,20 @@ /***** License -------------- - Copyright © 2020 Mojaloop Foundation - The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the 'License') and you may not use these files except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - Contributors + Copyright © 2020 Mojaloop Foundation The Mojaloop files are made available by the Mojaloop Foundation + under the Apache License, Version 2.0 (the 'License') and you may not + use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in + writing, the Mojaloop files are distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific language governing + permissions and limitations under the License. Contributors -------------- - This is the official list of the Mojaloop project contributors for this file. - Names of the original copyright holders (individuals or organizations) - should be listed with a '*' in the first column. People who have - contributed from an organization can be listed under the organization - that actually holds the copyright for their contributions (see the - Gates Foundation organization for an example). Those individuals should have - their names indented and be marked with a '-'. Email address can be added - optionally within square brackets . + This is the official list of the Mojaloop project contributors for this file. Names of the original + copyright holders (individuals or organizations) should be listed with a '*' in the first column. + People who have contributed from an organization can be listed under the organization that actually + holds the copyright for their contributions (see the Gates Foundation organization for an example). + Those individuals should have their names indented and be marked with a '-'. Email address can be + added optionally within square brackets . * Gates Foundation - Name Surname @@ -56,16 +56,16 @@ import { thirdparty as tpAPI } from '@mojaloop/api-snippets' * found, if there are network errors or if there is a bad response * @returns {Promise} */ -export async function forwardAuthorizationRequest( +export async function forwardAuthorizationRequest ( path: string, endpointType: FspEndpointTypesEnum, headers: HapiUtil.Dictionary, method: RestMethodsEnum, authorizationRequestId: string, payload: tpAPI.Schemas.ThirdpartyRequestsAuthorizationsPostRequest - | tpAPI.Schemas.ThirdpartyRequestsAuthorizationsIDPutResponse, + | tpAPI.Schemas.ThirdpartyRequestsAuthorizationsIDPutResponse, + // eslint-disable-next-line @typescript-eslint/no-explicit-any span?: any): Promise { - const childSpan = span?.getChild('forwardAuthorizationRequest') const sourceDfspId = headers[Enum.Http.Headers.FSPIOP.SOURCE] const destinationDfspId = headers[Enum.Http.Headers.FSPIOP.DESTINATION] @@ -115,7 +115,6 @@ export async function forwardAuthorizationRequest( } throw fspiopError } - } /** @@ -130,13 +129,13 @@ export async function forwardAuthorizationRequest( * found, if there are network errors or if there is a bad response * @returns {Promise} */ -export async function forwardAuthorizationRequestError( +export async function forwardAuthorizationRequestError ( path: string, headers: HapiUtil.Dictionary, authorizationRequestId: string, error: APIErrorObject, + // eslint-disable-next-line @typescript-eslint/no-explicit-any span?: any): Promise { - const childSpan = span?.getChild('forwardAuthorizationRequestError') const sourceDfspId = headers[Enum.Http.Headers.FSPIOP.SOURCE] const destinationDfspId = headers[Enum.Http.Headers.FSPIOP.DESTINATION] @@ -150,7 +149,8 @@ export async function forwardAuthorizationRequestError( path, { ID: authorizationRequestId } ) - Logger.info(`authorizations::forwardAuthorizationRequestError - Forwarding thirdpartyTransaction authorization error callback to endpoint: ${url}`) + Logger.info(`authorizations::forwardAuthorizationRequestError - + Forwarding thirdpartyTransaction authorization error callback to endpoint: ${url}`) await Util.Request.sendRequest( url, @@ -167,7 +167,6 @@ export async function forwardAuthorizationRequestError( if (childSpan && !childSpan.isFinished) { childSpan.finish() } - } catch (err) { Logger.error(`authorizations::forwardAuthorizationRequestError - Error forwarding thirdpartyTransaction authorization error to endpoint: ${inspect(err)}`) const fspiopError: FSPIOPError = ReformatFSPIOPError(err) @@ -176,5 +175,4 @@ export async function forwardAuthorizationRequestError( } throw fspiopError } - } diff --git a/src/domain/thirdpartyRequests/transactions.ts b/src/domain/thirdpartyRequests/transactions.ts index 969768e..1288f37 100644 --- a/src/domain/thirdpartyRequests/transactions.ts +++ b/src/domain/thirdpartyRequests/transactions.ts @@ -43,7 +43,6 @@ import Config from '~/shared/config' import inspect from '~/shared/inspect' import { finishChildSpan, getStackOrInspect } from '~/shared/util' - /** * @function forwardTransactionRequest * @description Forwards a POST /thirdpartyRequests/transactions and @@ -65,11 +64,11 @@ async function forwardTransactionRequest ( method: RestMethodsEnum, params: Hapi.Util.Dictionary, payload?: - tpAPI.Schemas.ThirdpartyRequestsTransactionsPostRequest | - tpAPI.Schemas.ThirdpartyRequestsTransactionsIDPutResponse | - tpAPI.Schemas.ThirdpartyRequestsTransactionsIDPatchResponse, + tpAPI.Schemas.ThirdpartyRequestsTransactionsPostRequest | + tpAPI.Schemas.ThirdpartyRequestsTransactionsIDPutResponse | + tpAPI.Schemas.ThirdpartyRequestsTransactionsIDPatchResponse, + // eslint-disable-next-line @typescript-eslint/no-explicit-any span?: any): Promise { - const childSpan = span?.getChild('forwardTransactionRequest') const fspiopSource: string = headers[Enum.Http.Headers.FSPIOP.SOURCE] const fspiopDest: string = headers[Enum.Http.Headers.FSPIOP.DESTINATION] @@ -123,7 +122,6 @@ async function forwardTransactionRequest ( } } - /** * @function forwardTransactionRequestError * @description Generic function to handle sending `PUT .../transactions/error` back to the FSPIOP-Source @@ -142,6 +140,7 @@ async function forwardTransactionRequestError ( method: RestMethodsEnum, transactionRequestId: string, error: APIErrorObject, + // eslint-disable-next-line @typescript-eslint/no-explicit-any span?: any): Promise { const childSpan = span?.getChild('forwardTransactionRequestError') const fspiopSource: string = headers[Enum.Http.Headers.FSPIOP.SOURCE] @@ -200,11 +199,11 @@ async function forwardTransactionRequestNotification ( payload: string, path: string, endpointType: FspEndpointTypesEnum, - method: RestMethodsEnum, + method: RestMethodsEnum ): Promise { - const fspiopSource: string = headers[Enum.Http.Headers.FSPIOP.SOURCE] const fspiopDestination: string = headers[Enum.Http.Headers.FSPIOP.DESTINATION] + // eslint-disable-next-line @typescript-eslint/ban-types const decodedPayload: object = Util.StreamingProtocol.decodePayload(payload, { asParsed: true }) try { @@ -227,7 +226,6 @@ async function forwardTransactionRequestNotification ( decodedPayload, Enum.Http.ResponseTypes.JSON, null) - } catch (err) { // todo: send a PUT /thirdpartyRequests/transactions/{id}/error to PISP Logger.error(`transactions::forwardTransactionRequestNotification - Error forwarding transaction request error to endpoint : ${getStackOrInspect(err)}`) @@ -250,5 +248,5 @@ export { forwardTransactionRequest, forwardTransactionRequestError, forwardTransactionRequestNotification, - isCreateRequest //for testing + isCreateRequest // for testing } diff --git a/src/domain/thirdpartyRequests/verifications.ts b/src/domain/thirdpartyRequests/verifications.ts index d314598..5668643 100644 --- a/src/domain/thirdpartyRequests/verifications.ts +++ b/src/domain/thirdpartyRequests/verifications.ts @@ -1,20 +1,20 @@ /***** License -------------- - Copyright © 2020 Mojaloop Foundation - The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the 'License') and you may not use these files except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - Contributors + Copyright © 2020 Mojaloop Foundation The Mojaloop files are made available by the Mojaloop Foundation + under the Apache License, Version 2.0 (the 'License') and you may not + use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in + writing, the Mojaloop files are distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific language governing + permissions and limitations under the License. Contributors -------------- - This is the official list of the Mojaloop project contributors for this file. - Names of the original copyright holders (individuals or organizations) - should be listed with a '*' in the first column. People who have - contributed from an organization can be listed under the organization - that actually holds the copyright for their contributions (see the - Gates Foundation organization for an example). Those individuals should have - their names indented and be marked with a '-'. Email address can be added - optionally within square brackets . + This is the official list of the Mojaloop project contributors for this file. Names of the original + copyright holders (individuals or organizations) should be listed with a '*' in the first column. + People who have contributed from an organization can be listed under the organization that actually + holds the copyright for their contributions (see the Gates Foundation organization for an example). + Those individuals should have their names indented and be marked with a '-'. Email address can be + added optionally within square brackets . * Gates Foundation - Name Surname @@ -43,18 +43,17 @@ import { inspect } from 'util' import Config from '~/shared/config' import { finishChildSpan } from '~/shared/util' - -export async function forwardVerificationRequest( +export async function forwardVerificationRequest ( path: string, endpointType: FspEndpointTypesEnum, headers: HapiUtil.Dictionary, method: RestMethodsEnum, verificationRequestId: string, payload: - tpAPI.Schemas.ThirdpartyRequestsVerificationsPostRequest | - tpAPI.Schemas.ThirdpartyRequestsVerificationsIDPutResponse, + tpAPI.Schemas.ThirdpartyRequestsVerificationsPostRequest | + tpAPI.Schemas.ThirdpartyRequestsVerificationsIDPutResponse, + // eslint-disable-next-line @typescript-eslint/no-explicit-any span?: any): Promise { - const childSpan = span?.getChild('forwardVerificationRequest') const sourceDfspId = headers[Enum.Http.Headers.FSPIOP.SOURCE] const destinationDfspId = headers[Enum.Http.Headers.FSPIOP.DESTINATION] @@ -104,16 +103,15 @@ export async function forwardVerificationRequest( } throw fspiopError } - } -export async function forwardVerificationRequestError( +export async function forwardVerificationRequestError ( path: string, headers: HapiUtil.Dictionary, verificationRequestId: string, error: APIErrorObject, + // eslint-disable-next-line @typescript-eslint/no-explicit-any span?: any): Promise { - const childSpan = span?.getChild('forwardVerificationRequestError') const sourceDfspId = headers[Enum.Http.Headers.FSPIOP.SOURCE] const destinationDfspId = headers[Enum.Http.Headers.FSPIOP.DESTINATION] @@ -144,7 +142,6 @@ export async function forwardVerificationRequestError( if (childSpan && !childSpan.isFinished) { childSpan.finish() } - } catch (err) { Logger.error(`verifications::forwardVerificationRequestError - Error forwarding thirdpartyTransaction verification error to endpoint: ${inspect(err)}`) const fspiopError: FSPIOPError = ReformatFSPIOPError(err) @@ -153,5 +150,4 @@ export async function forwardVerificationRequestError( } throw fspiopError } - } diff --git a/src/shared/compositeKeyMap.ts b/src/shared/compositeKeyMap.ts deleted file mode 100644 index 1c7821d..0000000 --- a/src/shared/compositeKeyMap.ts +++ /dev/null @@ -1,41 +0,0 @@ -/***** - License - -------------- - Copyright © 2020 Mojaloop Foundation - The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - Contributors - -------------- - This is the official list of the Mojaloop project contributors for this file. - Names of the original copyright holders (individuals or organizations) - should be listed with a '*' in the first column. People who have - contributed from an organization can be listed under the organization - that actually holds the copyright for their contributions (see the - Gates Foundation organization for an example). Those individuals should have - their names indented and be marked with a '-'. Email address can be added - optionally within square brackets . - * Gates Foundation - - Name Surname - - - Lewis Daly - -------------- - ******/ - -import stringify from 'canonical-json' - -/** - * @class CompositeKeyMap - * @description CompositeKeyMap is a special extension of Map, which will stringify the `key` - * value passed in. This allows us to nicely and easily set composite keys. - */ - -export default class CompositeKeyMap extends Map { - public get (key: T): U { - return super.get(stringify(key)) - } - - public set (key: T, value: U): this { - return super.set(stringify(key), value) - } -} diff --git a/src/shared/config.ts b/src/shared/config.ts index e4ef821..c1dc491 100644 --- a/src/shared/config.ts +++ b/src/shared/config.ts @@ -1,20 +1,20 @@ /***** License -------------- - Copyright © 2020 Mojaloop Foundation - The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - Contributors + Copyright © 2020 Mojaloop Foundation The Mojaloop files are made available by the Mojaloop Foundation + under the Apache License, Version 2.0 (the 'License') and you may not + use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in + writing, the Mojaloop files are distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific language governing + permissions and limitations under the License. Contributors -------------- - This is the official list of the Mojaloop project contributors for this file. - Names of the original copyright holders (individuals or organizations) - should be listed with a '*' in the first column. People who have - contributed from an organization can be listed under the organization - that actually holds the copyright for their contributions (see the - Gates Foundation organization for an example). Those individuals should have - their names indented and be marked with a '-'. Email address can be added - optionally within square brackets . + This is the official list of the Mojaloop project contributors for this file. Names of the original + copyright holders (individuals or organizations) should be listed with a '*' in the first column. + People who have contributed from an organization can be listed under the organization that actually + holds the copyright for their contributions (see the Gates Foundation organization for an example). + Those individuals should have their names indented and be marked with a '-'. Email address can be + added optionally within square brackets . * Gates Foundation - Name Surname diff --git a/test/unit/data/mockData.json b/test/unit/data/mockData.json index 30bf903..f3bac0c 100644 --- a/test/unit/data/mockData.json +++ b/test/unit/data/mockData.json @@ -359,16 +359,6 @@ } } }, - "consentsGenerateChallengeRequest": { - "headers": { - "fspiop-source": "pispA", - "fspiop-destination": "auth.dfspa" - }, - "params": {}, - "payload": { - "type": "FIDO" - } - }, "consentsIdPutRequestSigned": { "headers": { "fspiop-source": "pispA", diff --git a/test/unit/domain/consents.test.ts b/test/unit/domain/consents.test.ts index b0b42a5..a3736f5 100644 --- a/test/unit/domain/consents.test.ts +++ b/test/unit/domain/consents.test.ts @@ -27,7 +27,7 @@ import Logger from '@mojaloop/central-services-logger' import { Util, Enum } from '@mojaloop/central-services-shared' import TestData from 'test/unit/data/mockData.json' import Span from 'test/unit/__mocks__/span' -import * as Consents from '~/domain/consents' +import * as Consents from '~/domain/consents' import { ReformatFSPIOPError } from '@mojaloop/central-services-error-handling' const mockGetEndpointAndRender = jest.spyOn(Util.Endpoints, 'getEndpointAndRender') @@ -37,22 +37,21 @@ const mockLoggerError = jest.spyOn(Logger, 'error') const mockData = JSON.parse(JSON.stringify(TestData)) const mockConsentsPostRequestPISP = mockData.consentsPostRequestPISP const mockConsentsIdPutRequest = mockData.consentsIdPutRequestVerified -const mockConsentsPostGenerateChallengeRequest = mockData.consentsGenerateChallengeRequest const mockConsentIdPatchRequestVerified = mockData.patchConsentsByIdRequestVerified const getEndpointForwardConsentsRequestExpected = [ 'http://central-ledger.local:3001', mockConsentsPostRequestPISP.headers['fspiop-destination'], Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_POST, - "/consents", + '/consents' ] const getEndpointForwardConsentsRequestExpectedSecond = [ 'http://central-ledger.local:3001', mockConsentsPostRequestPISP.headers['fspiop-source'], Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_PUT_ERROR, - "/consents/{{ID}}/error", - {"ID": "7b24ea42-6fdd-45f5-999e-0a6981c4198b"} + '/consents/{{ID}}/error', + { ID: '7b24ea42-6fdd-45f5-999e-0a6981c4198b' } ] const expectedForwardConsentsRequestErrorHeaders = { @@ -71,52 +70,20 @@ const sendRequestForwardConsentsRequestExpected = [ expect.objectContaining({ isFinished: false }) ] -const getEndpointforwardConsentsIdGenerateChallengeRequestExpected = [ - 'http://central-ledger.local:3001', - mockConsentsPostGenerateChallengeRequest.headers['fspiop-destination'], - Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_POST, - "/consents/{{ID}}/generateChallenge", - {"ID": "09595320-51e5-4c4e-a910-c56917e4cdc4"} -] - -const getEndpointforwardConsentsIdGenerateChallengeRequestExpectedSecond = [ - 'http://central-ledger.local:3001', - mockConsentsPostGenerateChallengeRequest.headers['fspiop-source'], - Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_PUT_ERROR, - "/consents/{{ID}}/generateChallenge/error", - {"ID": "09595320-51e5-4c4e-a910-c56917e4cdc4"} -] - -const expectedforwardConsentsIdGenerateChallengeRequestErrorHeaders = { - 'fspiop-source': Enum.Http.Headers.FSPIOP.SWITCH.value, - 'fspiop-destination': mockConsentsPostGenerateChallengeRequest.headers['fspiop-source'] -} - -const sendRequestforwardConsentsIdGenerateChallengeRequestExpected = [ - 'http://dfspa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge', - mockConsentsPostGenerateChallengeRequest.headers, - mockConsentsPostGenerateChallengeRequest.headers['fspiop-source'], - mockConsentsPostGenerateChallengeRequest.headers['fspiop-destination'], - Enum.Http.RestMethods.POST, - mockConsentsPostGenerateChallengeRequest.payload, - Enum.Http.ResponseTypes.JSON, - expect.objectContaining({ isFinished: false }) -] - const getEndpointforwardConsentsIdRequestExpected = [ 'http://central-ledger.local:3001', mockConsentsIdPutRequest.headers['fspiop-destination'], Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_PUT, - "/consents/{{ID}}", - {"ID": "09595320-51e5-4c4e-a910-c56917e4cdc4"} + '/consents/{{ID}}', + { ID: '09595320-51e5-4c4e-a910-c56917e4cdc4' } ] const getEndpointforwardConsentsIdRequestExpectedSecond = [ 'http://central-ledger.local:3001', mockConsentsIdPutRequest.headers['fspiop-source'], Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_PUT_ERROR, - "/consents/{{ID}}/error", - {"ID": "09595320-51e5-4c4e-a910-c56917e4cdc4"} + '/consents/{{ID}}/error', + { ID: '09595320-51e5-4c4e-a910-c56917e4cdc4' } ] const expectedforwardConsentsIdRequestErrorHeaders = { @@ -135,13 +102,12 @@ const sendRequestforwardConsentsIdRequestExpected = [ expect.objectContaining({ isFinished: false }) ] - const getEndpointforwardConsentsIdRequestExpectedPatchRequest = [ 'http://central-ledger.local:3001', mockConsentIdPatchRequestVerified.headers['fspiop-destination'], Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_PATCH, - "/consents/{{ID}}", - {"ID": "09595320-51e5-4c4e-a910-c56917e4cdc4"} + '/consents/{{ID}}', + { ID: '09595320-51e5-4c4e-a910-c56917e4cdc4' } ] const sendRequestforwardConsentsIdRequestExpectedPatchRequest = [ @@ -180,7 +146,6 @@ describe('domain/consents', () => { expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestForwardConsentsRequestExpected) }) - it('handles `getEndpoint` failure', async (): Promise => { const mockSpan = new Span() mockGetEndpointAndRender @@ -217,7 +182,7 @@ describe('domain/consents', () => { Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_POST, mockConsentsPostRequestPISP.headers, Enum.Http.RestMethods.POST, - mockConsentsPostRequestPISP.payload, + mockConsentsPostRequestPISP.payload ) await expect(action).rejects.toThrow('Cannot find endpoint second time') @@ -285,7 +250,7 @@ describe('domain/consents', () => { ] mockGetEndpointAndRender .mockResolvedValueOnce('http://dfspa-sdk/consents') - .mockResolvedValue('http://pispa-sdk/consents/' + mockConsentsPostRequestPISP.payload.consentId + '/error',) + .mockResolvedValue('http://pispa-sdk/consents/' + mockConsentsPostRequestPISP.payload.consentId + '/error') mockSendRequest .mockRejectedValueOnce(new Error('Failed to send HTTP request first time')) .mockRejectedValueOnce(new Error('Failed to send HTTP request second time')) @@ -331,7 +296,7 @@ describe('domain/consents/{ID}', () => { ) expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdRequestExpected) - expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestforwardConsentsIdRequestExpected ) + expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestforwardConsentsIdRequestExpected) }) it('forwards PATCH /consents/{ID} request', async (): Promise => { @@ -390,7 +355,7 @@ describe('domain/consents/{ID}', () => { Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_PUT, mockConsentsIdPutRequest.headers, Enum.Http.RestMethods.PUT, - mockConsentsIdPutRequest.payload, + mockConsentsIdPutRequest.payload ) await expect(action).rejects.toThrow('Cannot find endpoint second time') @@ -459,7 +424,7 @@ describe('domain/consents/{ID}', () => { ] mockGetEndpointAndRender .mockResolvedValueOnce('http://dfspa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/') - .mockResolvedValue('http://pispa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4//error',) + .mockResolvedValue('http://pispa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4//error') mockSendRequest .mockRejectedValueOnce(new Error('Failed to send HTTP request first time')) .mockRejectedValueOnce(new Error('Failed to send HTTP request second time')) @@ -477,7 +442,7 @@ describe('domain/consents/{ID}', () => { await expect(action).rejects.toThrow('Failed to send HTTP request second time') expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdRequestExpected) expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdRequestExpectedSecond) - expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestforwardConsentsIdRequestExpected ) + expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestforwardConsentsIdRequestExpected) expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestErrExpected) }) }) @@ -508,8 +473,8 @@ describe('domain/consents/{ID}/error', () => { 'http://central-ledger.local:3001', 'dfspA', Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_PUT_ERROR, - "/consents/{{ID}}/error", - {"ID": "7b24ea42-6fdd-45f5-999e-0a6981c4198b"} + '/consents/{{ID}}/error', + { ID: '7b24ea42-6fdd-45f5-999e-0a6981c4198b' } ] const sendRequestErrorExpected = [ 'http://dfspa-sdk/consents/7b24ea42-6fdd-45f5-999e-0a6981c4198b/error', @@ -533,213 +498,3 @@ describe('domain/consents/{ID}/error', () => { }) }) }) - - -describe('domain/consents/{ID}/generateChallenge', () => { - describe('forwardConsentsIdGenerateChallengeRequest', () => { - beforeEach((): void => { - jest.clearAllMocks() - mockLoggerPush.mockReturnValue(null) - mockLoggerError.mockReturnValue(null) - }) - - it('forwards POST /consents request', async (): Promise => { - const mockSpan = new Span() - mockGetEndpointAndRender.mockResolvedValue('http://dfspa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge') - mockSendRequest.mockResolvedValue({ ok: true, status: 202, statusText: 'Accepted', payload: null }) - await Consents.forwardConsentsIdGenerateChallengeRequest( - '09595320-51e5-4c4e-a910-c56917e4cdc4', - Enum.EndPoints.FspEndpointTemplates.TP_CONSENT_GENERATE_CHALLENGE_POST, - Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_POST, - mockConsentsPostGenerateChallengeRequest.headers, - Enum.Http.RestMethods.POST, - mockConsentsPostGenerateChallengeRequest.payload, - mockSpan - ) - - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpected) - expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestforwardConsentsIdGenerateChallengeRequestExpected ) - }) - - - it('handles `getEndpoint` failure', async (): Promise => { - const mockSpan = new Span() - mockGetEndpointAndRender - .mockRejectedValueOnce(new Error('Cannot find endpoint')) - .mockResolvedValueOnce('http://pispa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge/error') - - const action = async () => await Consents.forwardConsentsIdGenerateChallengeRequest( - '09595320-51e5-4c4e-a910-c56917e4cdc4', - Enum.EndPoints.FspEndpointTemplates.TP_CONSENT_GENERATE_CHALLENGE_POST, - Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_POST, - mockConsentsPostGenerateChallengeRequest.headers, - Enum.Http.RestMethods.POST, - mockConsentsPostGenerateChallengeRequest.payload, - mockSpan - ) - - await expect(action).rejects.toThrow('Cannot find endpoint') - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpected) - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpectedSecond) - // Children's children in `forwardTransactionRequestError()` - expect(mockSpan.child?.child?.finish).toHaveBeenCalledTimes(1) - expect(mockSpan.child?.child?.error).toHaveBeenCalledTimes(0) - // Children in `forwardTransactionRequest()` - expect(mockSpan.child?.finish).toHaveBeenCalledTimes(1) - expect(mockSpan.child?.error).toHaveBeenCalledTimes(1) - }) - - it('handles `getEndpoint` failure twice', async (): Promise => { - mockGetEndpointAndRender - .mockRejectedValue(new Error('Cannot find endpoint first time')) - .mockRejectedValue(new Error('Cannot find endpoint second time')) - - const action = async () => await Consents.forwardConsentsIdGenerateChallengeRequest( - '09595320-51e5-4c4e-a910-c56917e4cdc4', - Enum.EndPoints.FspEndpointTemplates.TP_CONSENT_GENERATE_CHALLENGE_POST, - Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_POST, - mockConsentsPostGenerateChallengeRequest.headers, - Enum.Http.RestMethods.POST, - mockConsentsPostGenerateChallengeRequest.payload, - ) - - await expect(action).rejects.toThrow('Cannot find endpoint second time') - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpected) - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpectedSecond) - expect(mockSendRequest).not.toHaveBeenCalled() - }) - - it('handles `sendRequest` failure', async (): Promise => { - const mockSpan = new Span() - const errorPayload = - ReformatFSPIOPError(new Error('Failed to send HTTP request')).toApiErrorObject(true, true) - const sendRequestErrExpected = [ - 'http://pispa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge/error', - expectedforwardConsentsIdGenerateChallengeRequestErrorHeaders, - expectedforwardConsentsIdGenerateChallengeRequestErrorHeaders['fspiop-source'], - expectedforwardConsentsIdGenerateChallengeRequestErrorHeaders['fspiop-destination'], - Enum.Http.RestMethods.PUT, - errorPayload, - Enum.Http.ResponseTypes.JSON, - expect.objectContaining({ isFinished: false }) - ] - - mockGetEndpointAndRender - .mockResolvedValueOnce('http://dfspa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge') - .mockResolvedValue('http://pispa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge/error') - mockSendRequest - .mockRejectedValueOnce(new Error('Failed to send HTTP request')) - .mockResolvedValue({ ok: true, status: 202, statusText: 'Accepted', payload: null }) - - const action = async () => await Consents.forwardConsentsIdGenerateChallengeRequest( - '09595320-51e5-4c4e-a910-c56917e4cdc4', - Enum.EndPoints.FspEndpointTemplates.TP_CONSENT_GENERATE_CHALLENGE_POST, - Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_POST, - mockConsentsPostGenerateChallengeRequest.headers, - Enum.Http.RestMethods.POST, - mockConsentsPostGenerateChallengeRequest.payload, - mockSpan - ) - await expect(action).rejects.toThrow('Failed to send HTTP request') - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpected) - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpectedSecond) - expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestforwardConsentsIdGenerateChallengeRequestExpected) - expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestErrExpected) - // Children's children in `forwardTransactionRequestError()` - expect(mockSpan.child?.child?.finish).toHaveBeenCalledTimes(1) - expect(mockSpan.child?.child?.error).toHaveBeenCalledTimes(0) - // Children in `forwardTransactionRequest()` - expect(mockSpan.child?.finish).toHaveBeenCalledTimes(1) - expect(mockSpan.child?.error).toHaveBeenCalledTimes(1) - }) - - it('handles `sendRequest` failure twice', async (): Promise => { - const mockSpan = new Span() - const errorPayload = - ReformatFSPIOPError(new Error('Failed to send HTTP request first time')).toApiErrorObject(true, true) - const sendRequestErrExpected = [ - 'http://pispa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge/error', - expectedforwardConsentsIdGenerateChallengeRequestErrorHeaders, - expectedforwardConsentsIdGenerateChallengeRequestErrorHeaders['fspiop-source'], - expectedforwardConsentsIdGenerateChallengeRequestErrorHeaders['fspiop-destination'], - Enum.Http.RestMethods.PUT, - errorPayload, - Enum.Http.ResponseTypes.JSON, - expect.objectContaining({ isFinished: false }) - ] - mockGetEndpointAndRender - .mockResolvedValueOnce('http://dfspa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge') - .mockResolvedValue('http://pispa-sdk/consents/09595320-51e5-4c4e-a910-c56917e4cdc4/generateChallenge/error',) - mockSendRequest - .mockRejectedValueOnce(new Error('Failed to send HTTP request first time')) - .mockRejectedValueOnce(new Error('Failed to send HTTP request second time')) - - const action = async () => await Consents.forwardConsentsIdGenerateChallengeRequest( - '09595320-51e5-4c4e-a910-c56917e4cdc4', - Enum.EndPoints.FspEndpointTemplates.TP_CONSENT_GENERATE_CHALLENGE_POST, - Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_POST, - mockConsentsPostGenerateChallengeRequest.headers, - Enum.Http.RestMethods.POST, - mockConsentsPostGenerateChallengeRequest.payload, - mockSpan - ) - - await expect(action).rejects.toThrow('Failed to send HTTP request second time') - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpected) - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointforwardConsentsIdGenerateChallengeRequestExpectedSecond) - expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestforwardConsentsIdGenerateChallengeRequestExpected ) - expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestErrExpected) - }) - }) -}) - -describe('domain/consents/{ID}/generateChallenge/error', () => { - describe('forwardConsentsIdGenerateChallengeError', () => { - const path = Enum.EndPoints.FspEndpointTemplates.TP_CONSENT_GENERATE_CHALLENGE_PUT_ERROR - - beforeEach((): void => { - jest.clearAllMocks() - mockLoggerPush.mockReturnValue(null) - mockLoggerError.mockReturnValue(null) - }) - - it('forwards the PUT /consents/{ID}/generateChallenge error', async () => { - // Arrange - mockGetEndpointAndRender.mockResolvedValue('http://dfspa-sdk/consents/7b24ea42-6fdd-45f5-999e-0a6981c4198b/generateChallenge/error') - mockSendRequest.mockResolvedValue({ status: 202, payload: null }) - const headers = { - 'fspiop-source': 'switch', - 'fspiop-destination': 'pispA' - } - const id = '7b24ea42-6fdd-45f5-999e-0a6981c4198b' - const fspiopError = ReformatFSPIOPError(new Error('Test Error')) - const payload = fspiopError.toApiErrorObject(true, true) - const getEndpointErrorExpected = [ - 'http://central-ledger.local:3001', - 'pispA', - Enum.EndPoints.FspEndpointTypes.TP_CB_URL_CONSENT_GENERATE_CHALLENGE_PUT_ERROR, - "/consents/{{ID}}/generateChallenge/error", - {"ID": "7b24ea42-6fdd-45f5-999e-0a6981c4198b"} - ] - const sendRequestErrorExpected = [ - 'http://dfspa-sdk/consents/7b24ea42-6fdd-45f5-999e-0a6981c4198b/generateChallenge/error', - headers, - 'switch', - 'pispA', - Enum.Http.RestMethods.PUT, - payload, - Enum.Http.ResponseTypes.JSON, - undefined - ] - - // Act - await Consents.forwardConsentsIdGenerateChallengeError( - path, id, headers, payload - ) - - // Assert - expect(mockGetEndpointAndRender).toHaveBeenCalledWith(...getEndpointErrorExpected) - expect(mockSendRequest).toHaveBeenCalledWith(...sendRequestErrorExpected) - }) - }) -}) diff --git a/test/unit/domain/thirdpartyRequests/authorizations.test.ts b/test/unit/domain/thirdpartyRequests/authorizations.test.ts index 7084ed4..48ef54a 100644 --- a/test/unit/domain/thirdpartyRequests/authorizations.test.ts +++ b/test/unit/domain/thirdpartyRequests/authorizations.test.ts @@ -55,7 +55,7 @@ const validPostPayload: tpAPI.Schemas.ThirdpartyRequestsAuthorizationsPostReques partyIdInfo: { partyIdType: 'MSISDN', partyIdentifier: '+4412345678', - fspId: 'dfspb', + fspId: 'dfspb' } }, payer: { @@ -71,17 +71,20 @@ const validPostPayload: tpAPI.Schemas.ThirdpartyRequestsAuthorizationsPostReques expiration: '2020-06-15T12:00:00.000Z' } -const validPutPayload: tpAPI.Schemas.ThirdpartyRequestsAuthorizationsIDPutResponseFIDO = { - signedPayloadType: 'FIDO', +const validPutPayload: tpAPI.Schemas.ThirdpartyRequestsAuthorizationsIDPutResponseFIDO = { + responseType: 'ACCEPTED', signedPayload: { - id: '45c-TkfkjQovQeAWmOy-RLBHEJ_e4jYzQYgD8VdbkePgM5d98BaAadadNYrknxgH0jQEON8zBydLgh1EqoC9DA', - rawId: '45c+TkfkjQovQeAWmOy+RLBHEJ/e4jYzQYgD8VdbkePgM5d98BaAadadNYrknxgH0jQEON8zBydLgh1EqoC9DA==', - response: { - authenticatorData: 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MBAAAACA==', - clientDataJSON: 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiQUFBQUFBQUFBQUFBQUFBQUFBRUNBdyIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6NDIxODEiLCJjcm9zc09yaWdpbiI6ZmFsc2UsIm90aGVyX2tleXNfY2FuX2JlX2FkZGVkX2hlcmUiOiJkbyBub3QgY29tcGFyZSBjbGllbnREYXRhSlNPTiBhZ2FpbnN0IGEgdGVtcGxhdGUuIFNlZSBodHRwczovL2dvby5nbC95YWJQZXgifQ==', - signature: 'MEUCIDcJRBu5aOLJVc/sPyECmYi23w8xF35n3RNhyUNVwQ2nAiEA+Lnd8dBn06OKkEgAq00BVbmH87ybQHfXlf1Y4RJqwQ8=' - }, - type: 'public-key' + signedPayloadType: 'FIDO', + fidoSignedPayload: { + id: '45c-TkfkjQovQeAWmOy-RLBHEJ_e4jYzQYgD8VdbkePgM5d98BaAadadNYrknxgH0jQEON8zBydLgh1EqoC9DA', + rawId: '45c+TkfkjQovQeAWmOy+RLBHEJ/e4jYzQYgD8VdbkePgM5d98BaAadadNYrknxgH0jQEON8zBydLgh1EqoC9DA==', + response: { + authenticatorData: 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MBAAAACA==', + clientDataJSON: 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiQUFBQUFBQUFBQUFBQUFBQUFBRUNBdyIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6NDIxODEiLCJjcm9zc09yaWdpbiI6ZmFsc2UsIm90aGVyX2tleXNfY2FuX2JlX2FkZGVkX2hlcmUiOiJkbyBub3QgY29tcGFyZSBjbGllbnREYXRhSlNPTiBhZ2FpbnN0IGEgdGVtcGxhdGUuIFNlZSBodHRwczovL2dvby5nbC95YWJQZXgifQ==', + signature: 'MEUCIDcJRBu5aOLJVc/sPyECmYi23w8xF35n3RNhyUNVwQ2nAiEA+Lnd8dBn06OKkEgAq00BVbmH87ybQHfXlf1Y4RJqwQ8=' + }, + type: 'public-key' + } } } @@ -112,8 +115,8 @@ describe('domain/authorizations', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/authorizations", - {"ID": "123456"} + '/thirdpartyRequests/authorizations', + { ID: '123456' } ] const sendRequestExpected = [ 'http://auth-service.local/thirdpartyRequests/authorizations', @@ -151,15 +154,15 @@ describe('domain/authorizations', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/authorizations", - {"ID": "123456"} + '/thirdpartyRequests/authorizations', + { ID: '123456' } ] const getEndpointAndRenderExpectedSecond = [ 'http://central-ledger.local:3001', 'pispA', errorEndpointType, - "/thirdpartyRequests/authorizations/{{ID}}/error", - {"ID": "123456"} + '/thirdpartyRequests/authorizations/{{ID}}/error', + { ID: '123456' } ] // Act @@ -191,15 +194,15 @@ describe('domain/authorizations', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/authorizations", - {"ID": "123456"} + '/thirdpartyRequests/authorizations', + { ID: '123456' } ] const getEndpointAndRenderExpectedSecond = [ 'http://central-ledger.local:3001', 'pispA', errorEndpointType, - "/thirdpartyRequests/authorizations/{{ID}}/error", - {"ID": "123456"} + '/thirdpartyRequests/authorizations/{{ID}}/error', + { ID: '123456' } ] // Act @@ -231,15 +234,15 @@ describe('domain/authorizations', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/authorizations", - {"ID": "123456"} + '/thirdpartyRequests/authorizations', + { ID: '123456' } ] const getEndpointAndRenderExpectedSecond = [ 'http://central-ledger.local:3001', 'pispA', errorEndpointType, - "/thirdpartyRequests/authorizations/{{ID}}/error", - {"ID": "123456"} + '/thirdpartyRequests/authorizations/{{ID}}/error', + { ID: '123456' } ] const sendRequestExpectedFirst = [ 'http://auth-service.local/thirdpartyRequests/authorizations', @@ -298,15 +301,15 @@ describe('domain/authorizations', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/authorizations", - {"ID": "123456"} + '/thirdpartyRequests/authorizations', + { ID: '123456' } ] const getEndpointAndRenderExpectedSecond = [ 'http://central-ledger.local:3001', 'pispA', errorEndpointType, - "/thirdpartyRequests/authorizations/{{ID}}/error", - {"ID": "123456"} + '/thirdpartyRequests/authorizations/{{ID}}/error', + { ID: '123456' } ] const sendRequestExpectedFirst = [ 'http://auth-service.local/thirdpartyRequests/authorizations', @@ -365,8 +368,8 @@ describe('domain/authorizations', () => { 'http://central-ledger.local:3001', 'pispA', Enum.EndPoints.FspEndpointTypes.TP_CB_URL_TRANSACTION_REQUEST_AUTH_PUT_ERROR, - "/thirdpartyRequests/authorizations/{{ID}}/error", - {"ID": "123456"} + '/thirdpartyRequests/authorizations/{{ID}}/error', + { ID: '123456' } ] const sendRequestExpected = [ 'http://pisp.local/thirdpartyRequests/authorizations/123456/error', @@ -413,8 +416,8 @@ describe('domain/authorizations', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/authorizations/{{ID}}", - {"ID": "123456"} + '/thirdpartyRequests/authorizations/{{ID}}', + { ID: '123456' } ] const sendRequestExpected = [ 'http://auth-service.local/thirdpartyRequests/authorizations/123456', diff --git a/test/unit/domain/thirdpartyRequests/verifications.test.ts b/test/unit/domain/thirdpartyRequests/verifications.test.ts index 458442b..56b575a 100644 --- a/test/unit/domain/thirdpartyRequests/verifications.test.ts +++ b/test/unit/domain/thirdpartyRequests/verifications.test.ts @@ -29,7 +29,7 @@ import Logger from '@mojaloop/central-services-logger' import { Enum, Util } from '@mojaloop/central-services-shared' import Span from 'test/unit/__mocks__/span' import { Verifications } from '~/domain/thirdpartyRequests' -import * as types from '~/interface/types'; +import * as types from '~/interface/types' const mockGetEndpointAndRender = jest.spyOn(Util.Endpoints, 'getEndpointAndRender') const mockSendRequest = jest.spyOn(Util.Request, 'sendRequest') @@ -41,19 +41,18 @@ const validPostPayload: tpAPI.Schemas.ThirdpartyRequestsVerificationsPostRequest challenge: '', consentId: '062430f3-69ce-454a-84e3-2b73e953cb4a', signedPayloadType: 'FIDO', - signedPayload: { + fidoSignedPayload: { id: '45c-TkfkjQovQeAWmOy-RLBHEJ_e4jYzQYgD8VdbkePgM5d98BaAadadNYrknxgH0jQEON8zBydLgh1EqoC9DA', rawId: '45c+TkfkjQovQeAWmOy+RLBHEJ/e4jYzQYgD8VdbkePgM5d98BaAadadNYrknxgH0jQEON8zBydLgh1EqoC9DA==', response: { authenticatorData: 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MBAAAACA==', clientDataJSON: 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiQUFBQUFBQUFBQUFBQUFBQUFBRUNBdyIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6NDIxODEiLCJjcm9zc09yaWdpbiI6ZmFsc2UsIm90aGVyX2tleXNfY2FuX2JlX2FkZGVkX2hlcmUiOiJkbyBub3QgY29tcGFyZSBjbGllbnREYXRhSlNPTiBhZ2FpbnN0IGEgdGVtcGxhdGUuIFNlZSBodHRwczovL2dvby5nbC95YWJQZXgifQ==', - signature: 'MEUCIDcJRBu5aOLJVc/sPyECmYi23w8xF35n3RNhyUNVwQ2nAiEA+Lnd8dBn06OKkEgAq00BVbmH87ybQHfXlf1Y4RJqwQ8=', + signature: 'MEUCIDcJRBu5aOLJVc/sPyECmYi23w8xF35n3RNhyUNVwQ2nAiEA+Lnd8dBn06OKkEgAq00BVbmH87ybQHfXlf1Y4RJqwQ8=' }, type: 'public-key' } } - const validPutPayload: tpAPI.Schemas.ThirdpartyRequestsVerificationsIDPutResponse = { authenticationResponse: 'VERIFIED' } @@ -85,8 +84,8 @@ describe('domain/verifications', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/verifications", - { "ID": "123456" } + '/thirdpartyRequests/verifications', + { ID: '123456' } ] const sendRequestExpected = [ 'http://auth-service.local/thirdpartyRequests/verifications', @@ -124,15 +123,15 @@ describe('domain/verifications', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/verifications", - { "ID": "123456" } + '/thirdpartyRequests/verifications', + { ID: '123456' } ] const getEndpointAndRenderExpectedSecond = [ 'http://central-ledger.local:3001', 'pispA', errorEndpointType, - "/thirdpartyRequests/verifications/{{ID}}/error", - { "ID": "123456" } + '/thirdpartyRequests/verifications/{{ID}}/error', + { ID: '123456' } ] // Act @@ -164,15 +163,15 @@ describe('domain/verifications', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/verifications", - { "ID": "123456" } + '/thirdpartyRequests/verifications', + { ID: '123456' } ] const getEndpointAndRenderExpectedSecond = [ 'http://central-ledger.local:3001', 'pispA', errorEndpointType, - "/thirdpartyRequests/verifications/{{ID}}/error", - { "ID": "123456" } + '/thirdpartyRequests/verifications/{{ID}}/error', + { ID: '123456' } ] // Act @@ -204,15 +203,15 @@ describe('domain/verifications', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/verifications", - { "ID": "123456" } + '/thirdpartyRequests/verifications', + { ID: '123456' } ] const getEndpointAndRenderExpectedSecond = [ 'http://central-ledger.local:3001', 'pispA', errorEndpointType, - "/thirdpartyRequests/verifications/{{ID}}/error", - { "ID": "123456" } + '/thirdpartyRequests/verifications/{{ID}}/error', + { ID: '123456' } ] const sendRequestExpectedFirst = [ 'http://auth-service.local/thirdpartyRequests/verifications', @@ -271,15 +270,15 @@ describe('domain/verifications', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/verifications", - { "ID": "123456" } + '/thirdpartyRequests/verifications', + { ID: '123456' } ] const getEndpointAndRenderExpectedSecond = [ 'http://central-ledger.local:3001', 'pispA', errorEndpointType, - "/thirdpartyRequests/verifications/{{ID}}/error", - { "ID": "123456" } + '/thirdpartyRequests/verifications/{{ID}}/error', + { ID: '123456' } ] const sendRequestExpectedFirst = [ 'http://auth-service.local/thirdpartyRequests/verifications', @@ -338,8 +337,8 @@ describe('domain/verifications', () => { 'http://central-ledger.local:3001', 'pispA', Enum.EndPoints.FspEndpointTypes.TP_CB_URL_TRANSACTION_REQUEST_VERIFY_PUT_ERROR, - "/thirdpartyRequests/verifications/{{ID}}/error", - { "ID": "123456" } + '/thirdpartyRequests/verifications/{{ID}}/error', + { ID: '123456' } ] const sendRequestExpected = [ 'http://pisp.local/thirdpartyRequests/verifications/123456/error', @@ -386,8 +385,8 @@ describe('domain/verifications', () => { 'http://central-ledger.local:3001', 'dfspA', endpointType, - "/thirdpartyRequests/verifications/{{ID}}", - { "ID": "123456" } + '/thirdpartyRequests/verifications/{{ID}}', + { ID: '123456' } ] const sendRequestExpected = [ 'http://auth-service.local/thirdpartyRequests/verifications/123456',