From 5b7b9a5b8b15c1fa46f37689fe44d8b73de6174c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2020 07:35:23 +0000 Subject: [PATCH 01/33] Bump node-rsa from 1.0.7 to 1.0.8 Bumps [node-rsa](https://github.com/rzcoder/node-rsa) from 1.0.7 to 1.0.8. - [Release notes](https://github.com/rzcoder/node-rsa/releases) - [Commits](https://github.com/rzcoder/node-rsa/commits) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e7a0ab1..7f8c65b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4846,9 +4846,9 @@ } }, "node-rsa": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-1.0.7.tgz", - "integrity": "sha512-idwRXma6scFufZmbaKkHpJoLL93yynRefP6yur13wZ5i9FR35ex451KCoF2OORDeJanyRVahmjjiwmUlCnTqJA==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-1.0.8.tgz", + "integrity": "sha512-q8knkMHEqViIX/fshOltCHTtlt4Nw5wpBpu0//LB1tkxqYZB/001dYMwbPvTPiENwKvPqVDkhxK6J4fV09oa7w==", "requires": { "asn1": "^0.2.4" } From 81a6f23395903b8b212102a73ddfdcd58b920415 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2020 11:15:57 +0000 Subject: [PATCH 02/33] Bump husky from 1.3.1 to 4.2.3 Bumps [husky](https://github.com/typicode/husky) from 1.3.1 to 4.2.3. - [Release notes](https://github.com/typicode/husky/releases) - [Changelog](https://github.com/typicode/husky/blob/master/CHANGELOG.md) - [Commits](https://github.com/typicode/husky/compare/v1.3.1...v4.2.3) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 322 +++++++++++++++++++++++++++++----------------- package.json | 2 +- 2 files changed, 208 insertions(+), 116 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f8c65b6..8f9b0852 100644 --- a/package-lock.json +++ b/package-lock.json @@ -153,6 +153,15 @@ "@babel/helper-plugin-utils": "^7.8.0" } }, + "@babel/runtime": { + "version": "7.8.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.7.tgz", + "integrity": "sha512-+AATMUFppJDw6aiR5NVPHqIQBlV/Pj8wY/EZH+lmvRdUo9xBaz/rF3alAwFJQavvKfeOlPE7oaaDHVbcySbCsg==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, "@babel/template": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", @@ -447,6 +456,12 @@ "@babel/types": "^7.3.0" } }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -472,6 +487,12 @@ "@types/istanbul-lib-report": "*" } }, + "@types/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", + "dev": true + }, "@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", @@ -1023,23 +1044,6 @@ "unset-value": "^1.0.0" } }, - "caller-callsite": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", - "integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=", - "dev": true, - "requires": { - "callsites": "^2.0.0" - }, - "dependencies": { - "callsites": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", - "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", - "dev": true - } - } - }, "caller-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", @@ -1241,6 +1245,12 @@ "delayed-stream": "~1.0.0" } }, + "compare-versions": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", + "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==", + "dev": true + }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -1303,26 +1313,35 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cosmiconfig": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", - "integrity": "sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz", + "integrity": "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==", "dev": true, "requires": { - "import-fresh": "^2.0.0", - "is-directory": "^0.3.1", - "js-yaml": "^3.13.1", - "parse-json": "^4.0.0" + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.1.0", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.7.2" }, "dependencies": { "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", + "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", "dev": true, "requires": { + "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" + "json-parse-better-errors": "^1.0.1", + "lines-and-columns": "^1.1.6" } + }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true } } }, @@ -2244,6 +2263,15 @@ "locate-path": "^2.0.0" } }, + "find-versions": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/find-versions/-/find-versions-3.2.0.tgz", + "integrity": "sha512-P8WRou2S+oe222TOCHitLy8zj+SIsVJh52VP4lvXkaFVnOFFdoWv1H1Jjvel1aI6NCFOAaeAVm8qrI0odiLcww==", + "dev": true, + "requires": { + "semver-regex": "^2.0.0" + } + }, "flat-cache": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", @@ -2885,12 +2913,6 @@ "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, - "get-stdin": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", - "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", - "dev": true - }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -3057,40 +3079,81 @@ } }, "husky": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/husky/-/husky-1.3.1.tgz", - "integrity": "sha512-86U6sVVVf4b5NYSZ0yvv88dRgBSSXXmHaiq5pP4KDj5JVzdwKgBjEtUPOm8hcoytezFwbU+7gotXNhpHdystlg==", - "dev": true, - "requires": { - "cosmiconfig": "^5.0.7", - "execa": "^1.0.0", - "find-up": "^3.0.0", - "get-stdin": "^6.0.0", - "is-ci": "^2.0.0", - "pkg-dir": "^3.0.0", - "please-upgrade-node": "^3.1.1", - "read-pkg": "^4.0.1", - "run-node": "^1.0.0", - "slash": "^2.0.0" + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.3.tgz", + "integrity": "sha512-VxTsSTRwYveKXN4SaH1/FefRJYCtx+wx04sSVcOpD7N2zjoHxa+cEJ07Qg5NmV3HAK+IRKOyNVpi2YBIVccIfQ==", + "dev": true, + "requires": { + "chalk": "^3.0.0", + "ci-info": "^2.0.0", + "compare-versions": "^3.5.1", + "cosmiconfig": "^6.0.0", + "find-versions": "^3.2.0", + "opencollective-postinstall": "^2.0.2", + "pkg-dir": "^4.2.0", + "please-upgrade-node": "^3.2.0", + "slash": "^3.0.0", + "which-pm-runs": "^1.0.0" }, "dependencies": { - "find-up": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", "dev": true, "requires": { - "locate-path": "^3.0.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" } }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" + "p-locate": "^4.1.0" } }, "p-limit": { @@ -3103,12 +3166,12 @@ } }, "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, "requires": { - "p-limit": "^2.0.0" + "p-limit": "^2.2.0" } }, "p-try": { @@ -3117,40 +3180,34 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, - "parse-json": { + "path-exists": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true }, "pkg-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", - "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, "requires": { - "find-up": "^3.0.0" + "find-up": "^4.0.0" } }, - "read-pkg": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-4.0.1.tgz", - "integrity": "sha1-ljYlN48+HE1IyFhytabsfV0JMjc=", + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", "dev": true, "requires": { - "normalize-package-data": "^2.3.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0" + "has-flag": "^4.0.0" } } } @@ -3171,28 +3228,19 @@ "dev": true }, "import-fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz", - "integrity": "sha1-2BNVwVYS04bGH53dOSLUMEgipUY=", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", "dev": true, "requires": { - "caller-path": "^2.0.0", - "resolve-from": "^3.0.0" + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" }, "dependencies": { - "caller-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz", - "integrity": "sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=", - "dev": true, - "requires": { - "caller-callsite": "^2.0.0" - } - }, "resolve-from": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", - "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true } } @@ -3448,12 +3496,6 @@ } } }, - "is-directory": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", - "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", - "dev": true - }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", @@ -4535,6 +4577,12 @@ "type-check": "~0.3.2" } }, + "lines-and-columns": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "dev": true + }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -5024,6 +5072,12 @@ "mimic-fn": "^1.0.0" } }, + "opencollective-postinstall": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz", + "integrity": "sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw==", + "dev": true + }, "optionator": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", @@ -5102,6 +5156,23 @@ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + }, + "dependencies": { + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + } + } + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -5387,6 +5458,12 @@ "util.promisify": "^1.0.0" } }, + "regenerator-runtime": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz", + "integrity": "sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g==", + "dev": true + }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", @@ -5598,12 +5675,6 @@ "is-promise": "^2.1.0" } }, - "run-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz", - "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==", - "dev": true - }, "rx-lite": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", @@ -5673,6 +5744,12 @@ "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", "dev": true }, + "semver-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/semver-regex/-/semver-regex-2.0.0.tgz", + "integrity": "sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw==", + "dev": true + }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -6648,6 +6725,12 @@ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, + "which-pm-runs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", + "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=", + "dev": true + }, "window-size": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", @@ -6719,6 +6802,15 @@ "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true }, + "yaml": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.8.0.tgz", + "integrity": "sha512-6qI/tTx7OVtA4qNqD0OyutbM6Z9EKu4rxWm/2Y3FDEBQ4/2X2XAnyuRXMzAE2+1BPyqzksJZtrIwblOHg0IEzA==", + "dev": true, + "requires": { + "@babel/runtime": "^7.8.7" + } + }, "yargs": { "version": "3.32.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", diff --git a/package.json b/package.json index ee76afa0..e6ef39e5 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "eslint-plugin-import": "^2.18.2", "eslint-plugin-jest": "^21.27.2", "eslint-plugin-node": "8.0.1", - "husky": "^1.3.1", + "husky": "^4.2.3", "jest": "^24.9.0", "nock": "^9.6.1" } From e21eca8f25d8e52f5aed5be1607708688ab8247f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2020 07:14:41 +0000 Subject: [PATCH 03/33] Bump superagent from 3.8.3 to 5.2.2 Bumps [superagent](https://github.com/visionmedia/superagent) from 3.8.3 to 5.2.2. - [Release notes](https://github.com/visionmedia/superagent/releases) - [Changelog](https://github.com/visionmedia/superagent/blob/master/HISTORY.md) - [Commits](https://github.com/visionmedia/superagent/compare/v3.8.3...v5.2.2) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 94 +++++++++++++++++++++++++++++++++-------------- package.json | 2 +- 2 files changed, 67 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8f9b0852..8d1d814d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1310,7 +1310,8 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true }, "cosmiconfig": { "version": "6.0.0", @@ -1421,6 +1422,7 @@ "version": "3.2.6", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, "requires": { "ms": "^2.1.1" } @@ -2073,7 +2075,8 @@ "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true }, "extend-shallow": { "version": "3.0.2", @@ -2196,6 +2199,11 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fast-safe-stringify": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", + "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" + }, "fb-watchman": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.1.tgz", @@ -2297,19 +2305,19 @@ "dev": true }, "form-data": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", "requires": { "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", + "combined-stream": "^1.0.8", "mime-types": "^2.1.12" } }, "formidable": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz", - "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz", + "integrity": "sha512-V8gLm+41I/8kguQ4/o1D3RIHRmhYFG4pnNyonvua+40rqcEmT4+V71yaZ3B457xbbgCsCfjSPi65u/W6vK1U5Q==" }, "fragment-cache": { "version": "0.2.1", @@ -3608,7 +3616,8 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true }, "isexe": { "version": "2.0.0", @@ -4722,9 +4731,9 @@ } }, "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", + "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==" }, "mime-db": { "version": "1.43.0", @@ -5333,7 +5342,8 @@ "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true }, "progress": { "version": "2.0.3", @@ -5432,6 +5442,7 @@ "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -5445,7 +5456,8 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true } } }, @@ -6194,20 +6206,46 @@ "dev": true }, "superagent": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz", - "integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-5.2.2.tgz", + "integrity": "sha512-pMWBUnIllK4ZTw7p/UaobiQPwAO5w/1NRRTDpV0FTVNmECztsxKspj3ZWEordVEaqpZtmOQJJna4yTLyC/q7PQ==", "requires": { - "component-emitter": "^1.2.0", - "cookiejar": "^2.1.0", - "debug": "^3.1.0", - "extend": "^3.0.0", - "form-data": "^2.3.1", - "formidable": "^1.2.0", - "methods": "^1.1.1", - "mime": "^1.4.1", - "qs": "^6.5.1", - "readable-stream": "^2.3.5" + "component-emitter": "^1.3.0", + "cookiejar": "^2.1.2", + "debug": "^4.1.1", + "fast-safe-stringify": "^2.0.7", + "form-data": "^3.0.0", + "formidable": "^1.2.1", + "methods": "^1.1.2", + "mime": "^2.4.4", + "qs": "^6.9.1", + "readable-stream": "^3.4.0", + "semver": "^6.3.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + } } }, "supports-color": { diff --git a/package.json b/package.json index e6ef39e5..621b8879 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "node-rsa": "^1.0.3", "protobufjs": "^5.0.3", "safe-buffer": "^5.1.2", - "superagent": "^3.8.3", + "superagent": "^5.2.2", "uuid": "^3.3.2" }, "devDependencies": { From 2d2e8745c8aa1e127f84b408f3d1598c1164f921 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 3 Apr 2020 07:29:44 +0000 Subject: [PATCH 04/33] Bump eslint-plugin-import from 2.20.1 to 2.20.2 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.20.1 to 2.20.2. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.20.1...v2.20.2) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8d1d814d..83e6e29f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1759,9 +1759,9 @@ } }, "eslint-module-utils": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.5.2.tgz", - "integrity": "sha512-LGScZ/JSlqGKiT8OC+cYRxseMjyqt6QO54nl281CK93unD89ijSeRV6An8Ci/2nvWVKe8K/Tqdm75RQoIOCr+Q==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", + "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", "dev": true, "requires": { "debug": "^2.6.9", @@ -1804,9 +1804,9 @@ } }, "eslint-plugin-import": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.1.tgz", - "integrity": "sha512-qQHgFOTjguR+LnYRoToeZWT62XM55MBVXObHM6SKFd1VzDcX/vqT1kAz8ssqigh5eMj8qXcRoXXGZpPP6RfdCw==", + "version": "2.20.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.2.tgz", + "integrity": "sha512-FObidqpXrR8OnCh4iNsxy+WACztJLXAHBO5hK79T1Hc77PgQZkyDGA5Ag9xAvRpglvLNxhH/zSmZ70/pZ31dHg==", "dev": true, "requires": { "array-includes": "^3.0.3", From 7e68b0bb13efa44adfe834bb665085eb175bf436 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2020 21:33:23 +0000 Subject: [PATCH 05/33] Bump husky from 4.2.3 to 4.2.5 Bumps [husky](https://github.com/typicode/husky) from 4.2.3 to 4.2.5. - [Release notes](https://github.com/typicode/husky/releases) - [Changelog](https://github.com/typicode/husky/blob/master/CHANGELOG.md) - [Commits](https://github.com/typicode/husky/compare/v4.2.3...v4.2.5) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 83e6e29f..9902633b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -154,9 +154,9 @@ } }, "@babel/runtime": { - "version": "7.8.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.7.tgz", - "integrity": "sha512-+AATMUFppJDw6aiR5NVPHqIQBlV/Pj8wY/EZH+lmvRdUo9xBaz/rF3alAwFJQavvKfeOlPE7oaaDHVbcySbCsg==", + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.9.2.tgz", + "integrity": "sha512-NE2DtOdufG7R5vnfQUTehdTfNycfUANEtCa9PssN9O/xmTzP4E08UI797ixaei6hBEVL9BI/PsdJS5x7mWoB9Q==", "dev": true, "requires": { "regenerator-runtime": "^0.13.4" @@ -3087,14 +3087,14 @@ } }, "husky": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.3.tgz", - "integrity": "sha512-VxTsSTRwYveKXN4SaH1/FefRJYCtx+wx04sSVcOpD7N2zjoHxa+cEJ07Qg5NmV3HAK+IRKOyNVpi2YBIVccIfQ==", + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.5.tgz", + "integrity": "sha512-SYZ95AjKcX7goYVZtVZF2i6XiZcHknw50iXvY7b0MiGoj5RwdgRQNEHdb+gPDPCXKlzwrybjFjkL6FOj8uRhZQ==", "dev": true, "requires": { - "chalk": "^3.0.0", + "chalk": "^4.0.0", "ci-info": "^2.0.0", - "compare-versions": "^3.5.1", + "compare-versions": "^3.6.0", "cosmiconfig": "^6.0.0", "find-versions": "^3.2.0", "opencollective-postinstall": "^2.0.2", @@ -3115,9 +3115,9 @@ } }, "chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", + "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -3165,9 +3165,9 @@ } }, "p-limit": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", - "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, "requires": { "p-try": "^2.0.0" @@ -5471,9 +5471,9 @@ } }, "regenerator-runtime": { - "version": "0.13.4", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz", - "integrity": "sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g==", + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", + "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==", "dev": true }, "regex-not": { @@ -6841,9 +6841,9 @@ "dev": true }, "yaml": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.8.0.tgz", - "integrity": "sha512-6qI/tTx7OVtA4qNqD0OyutbM6Z9EKu4rxWm/2Y3FDEBQ4/2X2XAnyuRXMzAE2+1BPyqzksJZtrIwblOHg0IEzA==", + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.8.3.tgz", + "integrity": "sha512-X/v7VDnK+sxbQ2Imq4Jt2PRUsRsP7UcpSl3Llg6+NRRqWLIvxkMFYtH1FmvwNGYRKKPa+EPA4qDBlI9WVG1UKw==", "dev": true, "requires": { "@babel/runtime": "^7.8.7" From 0fa9c32b6e99976565b487baa0765d8ff068f475 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 23 Apr 2020 14:50:36 +0100 Subject: [PATCH 06/33] SDK-1506: Add support for standardised environment variables --- config/yoti.js | 4 +-- tests/config/yoti.spec.js | 58 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tests/config/yoti.spec.js diff --git a/config/yoti.js b/config/yoti.js index 18ff4ed2..dc287481 100644 --- a/config/yoti.js +++ b/config/yoti.js @@ -3,8 +3,8 @@ const constants = require('../src/yoti_common/constants'); const yoti = { - connectApi: process.env.YOTI_CONNECT_API || `${constants.API_BASE_URL}/api/v1`, - docScanApi: process.env.YOTI_DOC_SCAN_API || `${constants.API_BASE_URL}/idverify/v1`, + connectApi: process.env.YOTI_CONNECT_API || process.env.YOTI_API_URL || `${constants.API_BASE_URL}/api/v1`, + docScanApi: process.env.YOTI_DOC_SCAN_API || process.env.YOTI_DOC_SCAN_API_URL || `${constants.API_BASE_URL}/idverify/v1`, }; module.exports = yoti; diff --git a/tests/config/yoti.spec.js b/tests/config/yoti.spec.js new file mode 100644 index 00000000..d9aeeb15 --- /dev/null +++ b/tests/config/yoti.spec.js @@ -0,0 +1,58 @@ + +/** + * Reloads yoti config module with current environment variables. + */ +function getYotiConfig() { + // eslint-disable-next-line global-require + return require('../../config').yoti; +} + +describe('Yoti Config', () => { + let yotiConfig = getYotiConfig(); + const INITIAL_ENV = process.env; + + beforeEach(() => { + jest.resetModules(); + process.env = { ...INITIAL_ENV }; + }); + + afterEach(() => { + process.env = INITIAL_ENV; + }); + + describe('connectApi', () => { + it('should default to production API URL', () => { + expect(yotiConfig.connectApi).toBe('https://api.yoti.com/api/v1'); + }); + + it('should use YOTI_CONNECT_API environment variable', () => { + process.env.YOTI_CONNECT_API = 'some-api-url'; + yotiConfig = getYotiConfig(); + expect(yotiConfig.connectApi).toBe('some-api-url'); + }); + + it('should use YOTI_API_URL environment variable', () => { + process.env.YOTI_API_URL = 'some-other-api-url'; + yotiConfig = getYotiConfig(); + expect(yotiConfig.connectApi).toBe('some-other-api-url'); + }); + }); + + describe('docScanApi', () => { + it('should default to production DOC SCAN API URL', () => { + expect(yotiConfig.docScanApi).toBe('https://api.yoti.com/idverify/v1'); + }); + + it('should use YOTI_DOC_SCAN_API environment variable', () => { + process.env.YOTI_DOC_SCAN_API = 'some-doc-scan-url'; + yotiConfig = getYotiConfig(); + expect(yotiConfig.docScanApi).toBe('some-doc-scan-url'); + }); + + it('should use YOTI_DOC_SCAN_API_URL environment variable', () => { + process.env.YOTI_DOC_SCAN_API_URL = 'some-other-doc-scan-url'; + yotiConfig = getYotiConfig(); + expect(yotiConfig.docScanApi).toBe('some-other-doc-scan-url'); + }); + }); +}); From b322f176f5ed01444efca160cf06571390cfc1dc Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 23 Apr 2020 15:14:35 +0100 Subject: [PATCH 07/33] SDK-1506: Allow config test to run in Node 6 --- tests/config/yoti.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/config/yoti.spec.js b/tests/config/yoti.spec.js index d9aeeb15..79803968 100644 --- a/tests/config/yoti.spec.js +++ b/tests/config/yoti.spec.js @@ -13,7 +13,7 @@ describe('Yoti Config', () => { beforeEach(() => { jest.resetModules(); - process.env = { ...INITIAL_ENV }; + process.env = Object.assign({}, INITIAL_ENV); }); afterEach(() => { From 12ee4d0e1735ec1210dcfa7460e5ac0d054be447 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Tue, 31 Mar 2020 18:25:15 +0100 Subject: [PATCH 08/33] SDK-1460: Implement document filters --- index.js | 14 +++++++- src/client/doc.scan.client.js | 9 ++++++ src/doc_scan_service/doc.scan.constants.js | 5 +++ src/doc_scan_service/doc.scan.service.js | 21 ++++++++++++ src/doc_scan_service/index.js | 12 +++++++ .../document/document.restriction.builder.js | 27 ++++++++++++++++ .../filters/document/document.restriction.js | 20 ++++++++++++ .../document.restrictions.filter.builder.js | 32 +++++++++++++++++++ .../document/document.restrictions.filter.js | 27 ++++++++++++++++ .../orthogonal/country.restriction.builder.js | 31 ++++++++++++++++++ .../filters/orthogonal/country.restriction.js | 21 ++++++++++++ .../orthogonal.restrictions.filter.builder.js | 25 +++++++++++++++ .../orthogonal.restrictions.filter.js | 28 ++++++++++++++++ .../orthogonal/type.restriction.builder.js | 31 ++++++++++++++++++ .../filters/orthogonal/type.restriction.js | 21 ++++++++++++ .../filters/required.document.builder.js | 18 +++++++++++ .../filters/required.document.filter.js | 10 ++++++ .../create/filters/required.document.js | 25 +++++++++++++++ .../required.identity.document.builder.js | 10 ++++++ .../filters/required.identity.document.js | 10 ++++++ .../create/session.specification.builder.js | 18 ++++++++++- .../session/create/session.specification.js | 10 +++++- .../support/supported.country.js | 26 +++++++++++++++ .../support/supported.document.js | 14 ++++++++ .../support/supported.documents.response.js | 18 +++++++++++ .../session.specification.builder.test.js | 1 + 26 files changed, 481 insertions(+), 3 deletions(-) create mode 100644 src/doc_scan_service/session/create/filters/document/document.restriction.builder.js create mode 100644 src/doc_scan_service/session/create/filters/document/document.restriction.js create mode 100644 src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js create mode 100644 src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js create mode 100644 src/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.js create mode 100644 src/doc_scan_service/session/create/filters/orthogonal/country.restriction.js create mode 100644 src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js create mode 100644 src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js create mode 100644 src/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.js create mode 100644 src/doc_scan_service/session/create/filters/orthogonal/type.restriction.js create mode 100644 src/doc_scan_service/session/create/filters/required.document.builder.js create mode 100644 src/doc_scan_service/session/create/filters/required.document.filter.js create mode 100644 src/doc_scan_service/session/create/filters/required.document.js create mode 100644 src/doc_scan_service/session/create/filters/required.identity.document.builder.js create mode 100644 src/doc_scan_service/session/create/filters/required.identity.document.js create mode 100644 src/doc_scan_service/support/supported.country.js create mode 100644 src/doc_scan_service/support/supported.document.js create mode 100644 src/doc_scan_service/support/supported.documents.response.js diff --git a/index.js b/index.js index a9a390d1..cb64ab6a 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,12 @@ const { RequestedLivenessCheckBuilder, RequestedTextExtractionTaskBuilder, DocScanConstants, + RequiredIdentityDocumentBuilder, + DocumentRestrictionsFilterBuilder, + DocumentRestrictionBuilder, + OrthogonalRestrictionsFilterBuilder, + TypeRestrictionBuilder, + CountryRestrictionBuilder, } = require('./src/doc_scan_service'); module.exports = { @@ -50,6 +56,7 @@ module.exports = { RequestBuilder, Payload, YotiDate, + constants, SessionSpecificationBuilder, NotificationConfigBuilder, SdkConfigBuilder, @@ -57,5 +64,10 @@ module.exports = { RequestedFaceMatchCheckBuilder, RequestedLivenessCheckBuilder, RequestedTextExtractionTaskBuilder, - constants, + RequiredIdentityDocumentBuilder, + DocumentRestrictionsFilterBuilder, + DocumentRestrictionBuilder, + OrthogonalRestrictionsFilterBuilder, + TypeRestrictionBuilder, + CountryRestrictionBuilder, }; diff --git a/src/client/doc.scan.client.js b/src/client/doc.scan.client.js index 67a3f85b..71048316 100644 --- a/src/client/doc.scan.client.js +++ b/src/client/doc.scan.client.js @@ -77,6 +77,15 @@ class DocScanClient { deleteMediaContent(sessionId, mediaId) { return this.docScanService.deleteMediaContent(sessionId, mediaId); } + + /** + * Gets a list of supported documents. + * + * @returns {Promise} + */ + getSupportedDocuments() { + return this.docScanService.getSupportedDocuments(); + } } module.exports = DocScanClient; diff --git a/src/doc_scan_service/doc.scan.constants.js b/src/doc_scan_service/doc.scan.constants.js index b9ee023d..98b064ef 100644 --- a/src/doc_scan_service/doc.scan.constants.js +++ b/src/doc_scan_service/doc.scan.constants.js @@ -20,4 +20,9 @@ module.exports = Object.freeze({ ALWAYS: 'ALWAYS', FALLBACK: 'FALLBACK', NEVER: 'NEVER', + ID_DOCUMENT: 'ID_DOCUMENT', + ORTHOGONAL_RESTRICTIONS: 'ORTHOGONAL_RESTRICTIONS', + DOCUMENT_RESTRICTIONS: 'DOCUMENT_RESTRICTIONS', + INCLUSION_WHITELIST: 'WHITELIST', + INCLUSION_BLACKLIST: 'BLACKLIST', }); diff --git a/src/doc_scan_service/doc.scan.service.js b/src/doc_scan_service/doc.scan.service.js index 4c1a2e64..7f831bde 100644 --- a/src/doc_scan_service/doc.scan.service.js +++ b/src/doc_scan_service/doc.scan.service.js @@ -9,6 +9,7 @@ const Validation = require('../yoti_common/validation'); const config = require('../../config'); const Media = require('../data_type/media'); const DocScanError = require('./doc.scan.error'); +const SupportedDocumentsResponse = require('./support/supported.documents.response'); /** * @param {string} sessionId @@ -199,6 +200,26 @@ class DocScanService { .catch(err => reject(new DocScanError(err))); }); } + + /** + * Gets a list of supported documents. + * + * @returns {Promise} + */ + getSupportedDocuments() { + const request = new RequestBuilder() + .withPemString(this.pem) + .withBaseUrl(config.yoti.docScanApi) + .withEndpoint('/supported-documents') + .withGet() + .build(); + + return new Promise((resolve, reject) => { + request.execute() + .then(response => resolve(new SupportedDocumentsResponse(response.getParsedResponse()))) + .catch(err => reject(new DocScanError(err))); + }); + } } module.exports = DocScanService; diff --git a/src/doc_scan_service/index.js b/src/doc_scan_service/index.js index a8fc190b..9b0332d4 100644 --- a/src/doc_scan_service/index.js +++ b/src/doc_scan_service/index.js @@ -9,6 +9,12 @@ const RequestedDocumentAuthenticityCheckBuilder = require('./session/create/chec const RequestedFaceMatchCheckBuilder = require('./session/create/check/requested.face.match.check.builder'); const RequestedLivenessCheckBuilder = require('./session/create/check/requested.liveness.check.builder'); const RequestedTextExtractionTaskBuilder = require('./session/create/task/requested.text.extraction.task.builder'); +const RequiredIdentityDocumentBuilder = require('./session/create/filters/required.identity.document.builder'); +const DocumentRestrictionsFilterBuilder = require('./session/create/filters/document/document.restrictions.filter.builder'); +const DocumentRestrictionBuilder = require('./session/create/filters/document/document.restriction.builder'); +const OrthogonalRestrictionsFilterBuilder = require('./session/create/filters/orthogonal/orthogonal.restrictions.filter.builder'); +const TypeRestrictionBuilder = require('./session/create/filters/orthogonal/type.restriction.builder'); +const CountryRestrictionBuilder = require('./session/create/filters/orthogonal/country.restriction.builder'); module.exports = { DocScanService, @@ -20,4 +26,10 @@ module.exports = { RequestedFaceMatchCheckBuilder, RequestedLivenessCheckBuilder, RequestedTextExtractionTaskBuilder, + RequiredIdentityDocumentBuilder, + DocumentRestrictionsFilterBuilder, + DocumentRestrictionBuilder, + OrthogonalRestrictionsFilterBuilder, + TypeRestrictionBuilder, + CountryRestrictionBuilder, }; diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js new file mode 100644 index 00000000..1c3d5bda --- /dev/null +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js @@ -0,0 +1,27 @@ +const Validation = require('../../../../../yoti_common/validation'); +const DocumentRestriction = require('./document.restriction'); + +class DocumentRestrictionBuilder { + constructor() { + this.countryCodes = []; + this.documentTypes = []; + } + + withDocumentType(documentType) { + Validation.isString(documentType, 'documentType'); + this.countryCodes.push(documentType); + return this; + } + + withCountryCode(countryCode) { + Validation.isString(countryCode, 'countryCode'); + this.countryCodes.push(countryCode); + return this; + } + + build() { + return new DocumentRestriction(this.documentTypes, this.countryCodes); + } +} + +module.exports = DocumentRestrictionBuilder; diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.js b/src/doc_scan_service/session/create/filters/document/document.restriction.js new file mode 100644 index 00000000..038fc98a --- /dev/null +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.js @@ -0,0 +1,20 @@ +const Validation = require('../../../../../yoti_common/validation'); + +class DocumentRestriction { + constructor(documentTypes, countryCodes) { + Validation.isArrayOfStrings(documentTypes, 'documentTypes'); + this.documentTypes = documentTypes; + + Validation.isArrayOfStrings(countryCodes, 'countryCodes'); + this.countryCodes = countryCodes; + } + + toJSON() { + return { + document_types: this.documentTypes, + country_codes: this.countryCodes, + }; + } +} + +module.exports = DocumentRestriction; diff --git a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js new file mode 100644 index 00000000..7c8ed67e --- /dev/null +++ b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js @@ -0,0 +1,32 @@ +const Validation = require('../../../../../yoti_common/validation'); +const DocumentRestrictionsFilter = require('./document.restrictions.filter'); +const DocumentRestriction = require('./document.restriction'); +const DocScanConstants = require('../../../../doc.scan.constants'); + +class DocumentRestrictionsFilterBuilder { + constructor() { + this.documents = []; + } + + forWhitelist() { + this.inclusion = DocScanConstants.INCLUSION_WHITELIST; + return this; + } + + forBlacklist() { + this.inclusion = DocScanConstants.INCLUSION_BLACKLIST; + return this; + } + + withDocumentRestriction(document) { + Validation.instanceOf(document, DocumentRestriction, 'document'); + this.documents.push(document); + return this; + } + + build() { + return new DocumentRestrictionsFilter(this.inclusion, this.documents); + } +} + +module.exports = DocumentRestrictionsFilterBuilder; diff --git a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js new file mode 100644 index 00000000..8392ea81 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js @@ -0,0 +1,27 @@ +const Validation = require('../../../../../yoti_common/validation'); +const RequiredDocumentFilter = require('../required.document.filter'); +const DocumentRestriction = require('./document.restriction'); +const DocScanConstants = require('../../../../doc.scan.constants'); + +class DocumentRestrictionsFilter extends RequiredDocumentFilter { + constructor(inclusion, documents) { + super(DocScanConstants.DOCUMENT_RESTRICTIONS); + + Validation.isString(inclusion, 'inclusion'); + this.inclusion = inclusion; + + Validation.isArrayOfType(documents, DocumentRestriction, 'documents'); + this.documents = documents; + } + + toJSON() { + const json = super.toJSON(); + + json.inclusion = this.inclusion; + json.documents = this.documents; + + return json; + } +} + +module.exports = DocumentRestrictionsFilter; diff --git a/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.js b/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.js new file mode 100644 index 00000000..97038682 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.js @@ -0,0 +1,31 @@ +const Validation = require('../../../../../yoti_common/validation'); +const CountryRestriction = require('./country.restriction'); +const DocScanConstants = require('../../../../doc.scan.constants'); + +class CountryRestrictionBuilder { + constructor() { + this.countryCodes = []; + } + + forWhitelist() { + this.inclusion = DocScanConstants.INCLUSION_WHITELIST; + return this; + } + + forBlacklist() { + this.inclusion = DocScanConstants.INCLUSION_BLACKLIST; + return this; + } + + withCountryCode(countryCode) { + Validation.isString(countryCode, 'countryCode'); + this.countryCodes.push(countryCode); + return this; + } + + build() { + return new CountryRestriction(this.inclusion, this.countryCodes); + } +} + +module.exports = CountryRestrictionBuilder; diff --git a/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.js b/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.js new file mode 100644 index 00000000..0d922e16 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.js @@ -0,0 +1,21 @@ +const Validation = require('../../../../../yoti_common/validation'); + +class CountryRestriction { + constructor(inclusion, countryCodes) { + Validation.notNullOrEmpty(inclusion, 'inclusion'); + Validation.isString(inclusion, 'inclusion'); + this.inclusion = inclusion; + + Validation.isArrayOfStrings(countryCodes, 'countryCodes'); + this.countryCodes = countryCodes; + } + + toJSON() { + return { + inclusion: this.inclusion, + country_codes: this.countryCodes, + }; + } +} + +module.exports = CountryRestriction; diff --git a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js new file mode 100644 index 00000000..88242eec --- /dev/null +++ b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js @@ -0,0 +1,25 @@ +const Validation = require('../../../../../yoti_common/validation'); +const RequiredDocumentFilter = require('../required.document.filter'); +const OrthogonalRestrictionsFilter = require('./orthogonal.restrictions.filter'); +const TypeRestriction = require('./type.restriction'); +const CountryRestriction = require('./country.restriction'); + +class OrthogonalRestrictionsFilterBuilder extends RequiredDocumentFilter { + withCountryRestriction(countryRestriction) { + Validation.instanceOf(countryRestriction, CountryRestriction, 'countryRestriction'); + this.countryRestriction = countryRestriction; + return this; + } + + withTypeRestriction(typeRestriction) { + Validation.instanceOf(typeRestriction, TypeRestriction, 'typeRestriction'); + this.typeRestriction = typeRestriction; + return this; + } + + build() { + return new OrthogonalRestrictionsFilter(this.countryRestriction, this.typeRestriction); + } +} + +module.exports = OrthogonalRestrictionsFilterBuilder; diff --git a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js new file mode 100644 index 00000000..86e7b268 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js @@ -0,0 +1,28 @@ +const Validation = require('../../../../../yoti_common/validation'); +const RequiredDocumentFilter = require('../required.document.filter'); +const DocScanConstants = require('../../../../doc.scan.constants'); +const TypeRestriction = require('./type.restriction'); +const CountryRestriction = require('./country.restriction'); + +class OrthogonalRestrictionsFilter extends RequiredDocumentFilter { + constructor(countryRestriction, typeRestriction) { + super(DocScanConstants.ORTHOGONAL_RESTRICTIONS); + + Validation.instanceOf(countryRestriction, CountryRestriction, 'countryRestriction'); + this.countryRestriction = countryRestriction; + + Validation.instanceOf(typeRestriction, TypeRestriction, 'typeRestriction'); + this.typeRestriction = typeRestriction; + } + + toJSON() { + const json = super.toJSON(); + + json.country_restriction = this.countryRestriction; + json.type_restriction = this.typeRestriction; + + return json; + } +} + +module.exports = OrthogonalRestrictionsFilter; diff --git a/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.js b/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.js new file mode 100644 index 00000000..532c4717 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.js @@ -0,0 +1,31 @@ +const Validation = require('../../../../../yoti_common/validation'); +const TypeRestriction = require('./type.restriction'); +const DocScanConstants = require('../../../../doc.scan.constants'); + +class TypeRestrictionBuilder { + constructor() { + this.documentTypes = []; + } + + forWhitelist() { + this.inclusion = DocScanConstants.INCLUSION_WHITELIST; + return this; + } + + forBlacklist() { + this.inclusion = DocScanConstants.INCLUSION_BLACKLIST; + return this; + } + + withDocumentRestriction(documentType) { + Validation.isString(documentType, 'documentType'); + this.documentTypes.push(documentType); + return this; + } + + build() { + return new TypeRestriction(this.inclusion, this.documentTypes); + } +} + +module.exports = TypeRestrictionBuilder; diff --git a/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.js b/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.js new file mode 100644 index 00000000..2cd60b37 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.js @@ -0,0 +1,21 @@ +const Validation = require('../../../../../yoti_common/validation'); + +class TypeRestriction { + constructor(inclusion, documentTypes) { + Validation.notNullOrEmpty(inclusion, 'inclusion'); + Validation.isString(inclusion, 'inclusion'); + this.inclusion = inclusion; + + Validation.isArrayOfStrings(documentTypes, 'documentTypes'); + this.documentTypes = documentTypes; + } + + toJSON() { + return { + inclusion: this.inclusion, + document_types: this.documentTypes, + }; + } +} + +module.exports = TypeRestriction; diff --git a/src/doc_scan_service/session/create/filters/required.document.builder.js b/src/doc_scan_service/session/create/filters/required.document.builder.js new file mode 100644 index 00000000..afc21d0d --- /dev/null +++ b/src/doc_scan_service/session/create/filters/required.document.builder.js @@ -0,0 +1,18 @@ +const Validation = require('../../../../yoti_common/validation'); +const RequiredDocumentFilter = require('./required.document.filter'); + +class RequiredDocumentBuilder { + constructor() { + if (new.target === RequiredDocumentBuilder) { + throw TypeError('RequiredDocumentBuilder cannot be instantiated'); + } + } + + withFilter(filter) { + Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); + this.filter = filter; + return this; + } +} + +module.exports = RequiredDocumentBuilder; diff --git a/src/doc_scan_service/session/create/filters/required.document.filter.js b/src/doc_scan_service/session/create/filters/required.document.filter.js new file mode 100644 index 00000000..231e5fd3 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/required.document.filter.js @@ -0,0 +1,10 @@ +const Validation = require('../../../../yoti_common/validation'); + +class RequiredDocumentFilter { + constructor(type) { + Validation.isString(type, 'type'); + this.type = type; + } +} + +module.exports = RequiredDocumentFilter; diff --git a/src/doc_scan_service/session/create/filters/required.document.js b/src/doc_scan_service/session/create/filters/required.document.js new file mode 100644 index 00000000..72a1fee0 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/required.document.js @@ -0,0 +1,25 @@ +const Validation = require('../../../../yoti_common/validation'); +const RequiredDocumentFilter = require('./required.document.filter'); + +class RequiredDocument { + constructor(type, filter) { + if (new.target === RequiredDocument) { + throw TypeError('RequiredDocument cannot be instantiated'); + } + + Validation.isString(type, 'type'); + this.type = type; + + Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); + this.filter = filter; + } + + toJSON() { + return { + type: this.type, + filter: this.filter, + }; + } +} + +module.exports = RequiredDocument; diff --git a/src/doc_scan_service/session/create/filters/required.identity.document.builder.js b/src/doc_scan_service/session/create/filters/required.identity.document.builder.js new file mode 100644 index 00000000..8ba7f674 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/required.identity.document.builder.js @@ -0,0 +1,10 @@ +const RequiredIdentityDocument = require('./required.identity.document'); +const RequiredDocumentBuilder = require('./required.document.builder'); + +class RequiredIdentityDocumentBuilder extends RequiredDocumentBuilder { + build() { + return new RequiredIdentityDocument(this.filter); + } +} + +module.exports = RequiredIdentityDocumentBuilder; diff --git a/src/doc_scan_service/session/create/filters/required.identity.document.js b/src/doc_scan_service/session/create/filters/required.identity.document.js new file mode 100644 index 00000000..407e7fe9 --- /dev/null +++ b/src/doc_scan_service/session/create/filters/required.identity.document.js @@ -0,0 +1,10 @@ +const RequiredDocument = require('./required.document'); +const DocScanConstants = require('../../../doc.scan.constants'); + +class RequiredIdentityDocument extends RequiredDocument { + constructor(filter) { + super(DocScanConstants.ID_DOCUMENT, filter); + } +} + +module.exports = RequiredIdentityDocument; diff --git a/src/doc_scan_service/session/create/session.specification.builder.js b/src/doc_scan_service/session/create/session.specification.builder.js index 31e40222..8896ba0b 100644 --- a/src/doc_scan_service/session/create/session.specification.builder.js +++ b/src/doc_scan_service/session/create/session.specification.builder.js @@ -5,6 +5,7 @@ const NotificationConfig = require('./notification.config'); const RequestedTask = require('./task/requested.task'); const RequestedCheck = require('./check/requested.check'); const SdkConfig = require('./sdk.config'); +const RequiredDocument = require('./filters/required.document'); const Validation = require('../../../yoti_common/validation'); /** @@ -16,6 +17,7 @@ class SessionSpecificationBuilder { constructor() { this.requestedChecks = []; this.requestedTasks = []; + this.requiredDocuments = []; } /** @@ -112,6 +114,19 @@ class SessionSpecificationBuilder { return this; } + /** + * Adds a {@link RequiredDocument} to the list documents required from the client + * + * @param {RequiredDocument} requiredDocument + * + * @returns {this} + */ + withRequiredDocument(requiredDocument) { + Validation.instanceOf(requiredDocument, RequiredDocument, 'requiredDocument'); + this.requiredDocuments.push(requiredDocument); + return this; + } + /** * Builds the {@link SessionSpec} based on the values supplied to the builder * @@ -125,7 +140,8 @@ class SessionSpecificationBuilder { this.notifications, this.requestedChecks, this.requestedTasks, - this.sdkConfig + this.sdkConfig, + this.requiredDocuments ); } } diff --git a/src/doc_scan_service/session/create/session.specification.js b/src/doc_scan_service/session/create/session.specification.js index 3a5b28c3..daba8000 100644 --- a/src/doc_scan_service/session/create/session.specification.js +++ b/src/doc_scan_service/session/create/session.specification.js @@ -5,6 +5,7 @@ const NotificationConfig = require('./notification.config'); const SdkConfig = require('./sdk.config'); const RequestedTask = require('./task/requested.task'); const RequestedCheck = require('./check/requested.check'); +const RequiredDocument = require('./filters/required.document'); /** * Definition for the Doc Scan Session to be created @@ -27,6 +28,8 @@ class SessionSpecification { * The Tasks to be performed on each Document * @param {SdkConfig} sdkConfig * The SDK configuration set on the session specification + * @param {RequiredDocument[]} requiredDocuments + * List of RequiredDocument defining the documents required from the client */ constructor( clientSessionTokenTtl, @@ -35,7 +38,8 @@ class SessionSpecification { notifications, requestedChecks, requestedTasks, - sdkConfig + sdkConfig, + requiredDocuments ) { Validation.isInteger(clientSessionTokenTtl, 'clientSessionTokenTtl', true); this.clientSessionTokenTtl = clientSessionTokenTtl; @@ -61,6 +65,9 @@ class SessionSpecification { Validation.isArrayOfType(requestedTasks, RequestedTask, 'requestedTasks'); this.requestedTasks = requestedTasks; + + Validation.isArrayOfType(requiredDocuments, RequiredDocument, 'requiredDocuments'); + this.requiredDocuments = requiredDocuments; } /** @@ -75,6 +82,7 @@ class SessionSpecification { requested_checks: this.requestedChecks, requested_tasks: this.requestedTasks, sdk_config: this.sdkConfig, + required_documents: this.requiredDocuments, }; } } diff --git a/src/doc_scan_service/support/supported.country.js b/src/doc_scan_service/support/supported.country.js new file mode 100644 index 00000000..b8e8996e --- /dev/null +++ b/src/doc_scan_service/support/supported.country.js @@ -0,0 +1,26 @@ +const Validation = require('../../yoti_common/validation'); +const SupportedDocument = require('./supported.document'); + +class SupportedCountry { + constructor(country) { + Validation.isString(country.code, 'code', true); + this.code = country.code; + + if (this.supportedDocuments) { + this.supportedDocuments = country.supported_documents + .map(document => new SupportedDocument(document)); + } else { + this.supportedDocuments = []; + } + } + + getCode() { + return this.code; + } + + getSupportedDocuments() { + return this.supportedDocuments; + } +} + +module.exports = SupportedCountry; diff --git a/src/doc_scan_service/support/supported.document.js b/src/doc_scan_service/support/supported.document.js new file mode 100644 index 00000000..81bea498 --- /dev/null +++ b/src/doc_scan_service/support/supported.document.js @@ -0,0 +1,14 @@ +const Validation = require('../../yoti_common/validation'); + +class SupportedDocument { + constructor(document) { + Validation.isString(document.type, 'type', true); + this.type = document.type; + } + + getType() { + return this.type; + } +} + +module.exports = SupportedDocument; diff --git a/src/doc_scan_service/support/supported.documents.response.js b/src/doc_scan_service/support/supported.documents.response.js new file mode 100644 index 00000000..3fdfb827 --- /dev/null +++ b/src/doc_scan_service/support/supported.documents.response.js @@ -0,0 +1,18 @@ +const SupportedCountry = require('./supported.country'); + +class SupportedDocumentsResponse { + constructor(response) { + if (response.supported_countries) { + this.supportedCountries = response.supported_countries + .map(country => new SupportedCountry(country)); + } else { + this.supportedCountries = []; + } + } + + getSupportedCountries() { + return this.supportedCountries; + } +} + +module.exports = SupportedDocumentsResponse; diff --git a/tests/doc_scan_service/session/create/session.specification.builder.test.js b/tests/doc_scan_service/session/create/session.specification.builder.test.js index 6cf3f26d..ee8dda83 100644 --- a/tests/doc_scan_service/session/create/session.specification.builder.test.js +++ b/tests/doc_scan_service/session/create/session.specification.builder.test.js @@ -83,6 +83,7 @@ describe('SessionSpecificationBuilder', () => { sdk_config: { allowed_capture_methods: 'CAMERA', }, + required_documents: [], }); expect(JSON.stringify(sessionSpec)).toBe(expectedJson); From 8c4d0cca7047efc8fc9bc402e28f44c7baa45c73 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Wed, 1 Apr 2020 16:35:20 +0100 Subject: [PATCH 09/33] SDK-1460: Fix document type and filter type --- .../create/filters/document/document.restriction.builder.js | 2 +- .../session/create/filters/required.document.filter.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js index 1c3d5bda..ad3a7848 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js @@ -9,7 +9,7 @@ class DocumentRestrictionBuilder { withDocumentType(documentType) { Validation.isString(documentType, 'documentType'); - this.countryCodes.push(documentType); + this.documentTypes.push(documentType); return this; } diff --git a/src/doc_scan_service/session/create/filters/required.document.filter.js b/src/doc_scan_service/session/create/filters/required.document.filter.js index 231e5fd3..cd45d19c 100644 --- a/src/doc_scan_service/session/create/filters/required.document.filter.js +++ b/src/doc_scan_service/session/create/filters/required.document.filter.js @@ -5,6 +5,12 @@ class RequiredDocumentFilter { Validation.isString(type, 'type'); this.type = type; } + + toJSON() { + return { + type: this.type, + }; + } } module.exports = RequiredDocumentFilter; From 4cb9a3ba3f7255158cbeb22d3879b4829e05fadf Mon Sep 17 00:00:00 2001 From: David Grayston Date: Wed, 1 Apr 2020 22:17:06 +0100 Subject: [PATCH 10/33] SDK-1460: Fix OrthogonalRestrictionsFilterBuilder --- .../orthogonal/orthogonal.restrictions.filter.builder.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js index 88242eec..713abd26 100644 --- a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js +++ b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js @@ -1,10 +1,9 @@ const Validation = require('../../../../../yoti_common/validation'); -const RequiredDocumentFilter = require('../required.document.filter'); const OrthogonalRestrictionsFilter = require('./orthogonal.restrictions.filter'); const TypeRestriction = require('./type.restriction'); const CountryRestriction = require('./country.restriction'); -class OrthogonalRestrictionsFilterBuilder extends RequiredDocumentFilter { +class OrthogonalRestrictionsFilterBuilder { withCountryRestriction(countryRestriction) { Validation.instanceOf(countryRestriction, CountryRestriction, 'countryRestriction'); this.countryRestriction = countryRestriction; From 3f3ab7eb23cabaec457f1a32626141c01531ec36 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 2 Apr 2020 10:56:54 +0100 Subject: [PATCH 11/33] SDK-1460: Exclude empty country and document type arrays --- .../create/filters/document/document.restriction.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.js b/src/doc_scan_service/session/create/filters/document/document.restriction.js index 038fc98a..41b47ca5 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restriction.js +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.js @@ -2,11 +2,15 @@ const Validation = require('../../../../../yoti_common/validation'); class DocumentRestriction { constructor(documentTypes, countryCodes) { - Validation.isArrayOfStrings(documentTypes, 'documentTypes'); - this.documentTypes = documentTypes; + if (documentTypes && documentTypes.length > 0) { + Validation.isArrayOfStrings(documentTypes, 'documentTypes'); + this.documentTypes = documentTypes; + } - Validation.isArrayOfStrings(countryCodes, 'countryCodes'); - this.countryCodes = countryCodes; + if (countryCodes && countryCodes.length > 0) { + Validation.isArrayOfStrings(countryCodes, 'countryCodes'); + this.countryCodes = countryCodes; + } } toJSON() { From b46c95382989079a5296a41739e24918f533dd3b Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 2 Apr 2020 15:13:14 +0100 Subject: [PATCH 12/33] SDK-1460: Fix supported documents response mapping --- src/doc_scan_service/support/supported.country.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc_scan_service/support/supported.country.js b/src/doc_scan_service/support/supported.country.js index b8e8996e..51ef5369 100644 --- a/src/doc_scan_service/support/supported.country.js +++ b/src/doc_scan_service/support/supported.country.js @@ -6,7 +6,7 @@ class SupportedCountry { Validation.isString(country.code, 'code', true); this.code = country.code; - if (this.supportedDocuments) { + if (country.supported_documents) { this.supportedDocuments = country.supported_documents .map(document => new SupportedDocument(document)); } else { From 24bf0e968c5d8478b20de52c132629bcb20ea685 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 2 Apr 2020 16:53:14 +0100 Subject: [PATCH 13/33] SDK-1460: Add test coverage for document filters --- .../orthogonal.restrictions.filter.js | 12 ++-- tests/client/doc.scan.client.spec.js | 21 ++++++ .../doc_scan_service/doc.scan.service.spec.js | 35 ++++++++++ .../document.restriction.builder.spec.js | 58 ++++++++++++++++ ...cument.restrictions.filter.builder.spec.js | 57 +++++++++++++++ .../country.restriction.builder.spec.js | 49 +++++++++++++ ...ogonal.restrictions.filter.builder.spec.js | 61 ++++++++++++++++ .../type.restriction.builder.spec.js | 49 +++++++++++++ .../filters/required.document.builder.spec.js | 8 +++ .../create/filters/required.document.spec.js | 8 +++ ...required.identity.document.builder.spec.js | 37 ++++++++++ .../session.specification.builder.test.js | 21 +++++- .../supported.documents.response.spec.js | 69 +++++++++++++++++++ 13 files changed, 480 insertions(+), 5 deletions(-) create mode 100644 tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js create mode 100644 tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js create mode 100644 tests/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.spec.js create mode 100644 tests/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.spec.js create mode 100644 tests/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.spec.js create mode 100644 tests/doc_scan_service/session/create/filters/required.document.builder.spec.js create mode 100644 tests/doc_scan_service/session/create/filters/required.document.spec.js create mode 100644 tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js create mode 100644 tests/doc_scan_service/session/support/supported.documents.response.spec.js diff --git a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js index 86e7b268..43eceaed 100644 --- a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js +++ b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js @@ -8,11 +8,15 @@ class OrthogonalRestrictionsFilter extends RequiredDocumentFilter { constructor(countryRestriction, typeRestriction) { super(DocScanConstants.ORTHOGONAL_RESTRICTIONS); - Validation.instanceOf(countryRestriction, CountryRestriction, 'countryRestriction'); - this.countryRestriction = countryRestriction; + if (countryRestriction) { + Validation.instanceOf(countryRestriction, CountryRestriction, 'countryRestriction'); + this.countryRestriction = countryRestriction; + } - Validation.instanceOf(typeRestriction, TypeRestriction, 'typeRestriction'); - this.typeRestriction = typeRestriction; + if (typeRestriction) { + Validation.instanceOf(typeRestriction, TypeRestriction, 'typeRestriction'); + this.typeRestriction = typeRestriction; + } } toJSON() { diff --git a/tests/client/doc.scan.client.spec.js b/tests/client/doc.scan.client.spec.js index 52bbcaf6..131fadbc 100644 --- a/tests/client/doc.scan.client.spec.js +++ b/tests/client/doc.scan.client.spec.js @@ -12,6 +12,7 @@ const { const CreateSessionResult = require('../../src/doc_scan_service/session/create/create.session.result'); const GetSessionResult = require('../../src/doc_scan_service/session/retrieve/get.session.result'); const Media = require('../../src/data_type/media'); +const SupportedDocumentResponse = require('../../src/doc_scan_service/support/supported.documents.response'); const PEM_STRING = fs.readFileSync('./tests/sample-data/keys/node-sdk-test.pem', 'utf8'); const APP_ID = uuid(); @@ -20,6 +21,7 @@ const MEDIA_ID = 'some-media-id'; const SESSION_CREATE_URI = new RegExp(`^/idverify/v1/sessions\\?sdkId=${APP_ID}`); const SESSION_URI = new RegExp(`^/idverify/v1/sessions/${SESSION_ID}\\?sdkId=${APP_ID}`); const MEDIA_URI = new RegExp(`^/idverify/v1/sessions/${SESSION_ID}/media/${MEDIA_ID}/content\\?sdkId=${APP_ID}`); +const SUPPORTED_DOCUMENTS_URI = new RegExp('^/idverify/v1/supported-documents'); describe('DocScanClient', () => { let docScanClient; @@ -117,4 +119,23 @@ describe('DocScanClient', () => { .catch(done); }); }); + + + describe('#getSupportedDocuments', () => { + describe('when a valid response is returned', () => { + it('should return SupportedDocumentResponse', (done) => { + nock(config.yoti.docScanApi) + .get(SUPPORTED_DOCUMENTS_URI) + .reply(200, '{}'); + + docScanClient + .getSupportedDocuments() + .then((result) => { + expect(result).toBeInstanceOf(SupportedDocumentResponse); + done(); + }) + .catch(done); + }); + }); + }); }); diff --git a/tests/doc_scan_service/doc.scan.service.spec.js b/tests/doc_scan_service/doc.scan.service.spec.js index 7827b053..3b428228 100644 --- a/tests/doc_scan_service/doc.scan.service.spec.js +++ b/tests/doc_scan_service/doc.scan.service.spec.js @@ -12,6 +12,7 @@ const { const CreateSessionResult = require('../../src/doc_scan_service/session/create/create.session.result'); const GetSessionResult = require('../../src/doc_scan_service/session/retrieve/get.session.result'); const Media = require('../../src/data_type/media'); +const SupportedDocumentResponse = require('../../src/doc_scan_service/support/supported.documents.response'); const PEM_STRING = fs.readFileSync('./tests/sample-data/keys/node-sdk-test.pem', 'utf8'); const SESSION_ID = 'some-session-id'; @@ -21,6 +22,7 @@ const APP_ID = uuid(); const SESSION_CREATE_URI = new RegExp(`^/idverify/v1/sessions\\?sdkId=${APP_ID}`); const SESSION_URI = new RegExp(`^/idverify/v1/sessions/${SESSION_ID}\\?sdkId=${APP_ID}`); const MEDIA_URI = new RegExp(`^/idverify/v1/sessions/${SESSION_ID}/media/${MEDIA_ID}/content\\?sdkId=${APP_ID}`); +const SUPPORTED_DOCUMENTS_URI = new RegExp('^/idverify/v1/supported-documents'); describe('DocScanService', () => { let docScanService; @@ -301,4 +303,37 @@ describe('DocScanService', () => { }); }); }); + + describe('#getSupportedDocuments', () => { + describe('when a valid response is returned', () => { + it('should return SupportedDocumentResponse', (done) => { + nock(config.yoti.docScanApi) + .get(SUPPORTED_DOCUMENTS_URI) + .reply(200, '{}'); + + docScanService + .getSupportedDocuments() + .then((result) => { + expect(result).toBeInstanceOf(SupportedDocumentResponse); + done(); + }) + .catch(done); + }); + }); + describe('when response is invalid', () => { + it('should reject', (done) => { + nock(config.yoti.docScanApi) + .get(SUPPORTED_DOCUMENTS_URI) + .reply(400, '{}'); + + docScanService + .getSupportedDocuments() + .catch((err) => { + expect(err.message).toBe('Bad Request'); + done(); + }) + .catch(done); + }); + }); + }); }); diff --git a/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js b/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js new file mode 100644 index 00000000..0336548d --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js @@ -0,0 +1,58 @@ +const { DocumentRestrictionBuilder } = require('../../../../../..'); +const DocumentRestriction = require('../../../../../../src/doc_scan_service/session/create/filters/document/document.restriction'); + +const SOME_DOCUMENT_TYPE = 'some-document-type'; +const SOME_OTHER_DOCUMENT_TYPE = 'some-other-document-type'; +const SOME_COUNTRY_CODE = 'some-country-code'; +const SOME_OTHER_COUNTRY_CODE = 'some-other-country-code'; + +describe('DocumentRestrictionBuilder', () => { + it('should build DocumentRestriction', () => { + const documentRestriction = new DocumentRestrictionBuilder().build(); + expect(documentRestriction).toBeInstanceOf(DocumentRestriction); + }); + it('should build DocumentRestriction with document types', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withDocumentType(SOME_DOCUMENT_TYPE) + .withDocumentType(SOME_OTHER_DOCUMENT_TYPE) + .build(); + + expect(JSON.stringify(documentRestriction)) + .toBe(JSON.stringify({ + document_types: [ + SOME_DOCUMENT_TYPE, + SOME_OTHER_DOCUMENT_TYPE, + ], + })); + }); + it('should build DocumentRestriction with country codes', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withCountryCode(SOME_COUNTRY_CODE) + .withCountryCode(SOME_OTHER_COUNTRY_CODE) + .build(); + + expect(JSON.stringify(documentRestriction)) + .toBe(JSON.stringify({ + country_codes: [ + SOME_COUNTRY_CODE, + SOME_OTHER_COUNTRY_CODE, + ], + })); + }); + it('should build DocumentRestriction with document type and country code', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withCountryCode(SOME_COUNTRY_CODE) + .withDocumentType(SOME_DOCUMENT_TYPE) + .build(); + + expect(JSON.stringify(documentRestriction)) + .toBe(JSON.stringify({ + document_types: [ + SOME_DOCUMENT_TYPE, + ], + country_codes: [ + SOME_COUNTRY_CODE, + ], + })); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js b/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js new file mode 100644 index 00000000..72d8fe01 --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js @@ -0,0 +1,57 @@ +const { + DocumentRestrictionsFilterBuilder, + DocumentRestrictionBuilder, +} = require('../../../../../..'); + +const SOME_DOCUMENT_TYPE = 'some-document-type'; + +describe('DocumentRestrictionsFilterBuilder', () => { + it('should build DocumentRestrictionsFilter for whitelist', () => { + const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() + .forWhitelist() + .build(); + + expect(JSON.stringify(documentRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'WHITELIST', + documents: [], + })); + }); + + it('should build DocumentRestrictionsFilter for blacklist', () => { + const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() + .forBlacklist() + .build(); + + expect(JSON.stringify(documentRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'BLACKLIST', + documents: [], + })); + }); + it('should build DocumentRestrictionsFilter with document restriction', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withDocumentType(SOME_DOCUMENT_TYPE) + .build(); + + const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() + .forWhitelist() + .withDocumentRestriction(documentRestriction) + .build(); + + expect(JSON.stringify(documentRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'WHITELIST', + documents: [ + { + document_types: [ + SOME_DOCUMENT_TYPE, + ], + }, + ], + })); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.spec.js b/tests/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.spec.js new file mode 100644 index 00000000..36e5276a --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.spec.js @@ -0,0 +1,49 @@ +const { + CountryRestrictionBuilder, +} = require('../../../../../..'); + +const SOME_COUNTRY_CODE = 'some-country-code'; +const SOME_OTHER_COUNTRY_CODE = 'some-other-country-code'; + +describe('CountryRestrictionBuilder', () => { + it('should build CountryRestriction for whitelist', () => { + const typeRestriction = new CountryRestrictionBuilder() + .forWhitelist() + .build(); + + expect(JSON.stringify(typeRestriction)) + .toBe(JSON.stringify({ + inclusion: 'WHITELIST', + country_codes: [], + })); + }); + + it('should build CountryRestriction for blacklist', () => { + const typeRestriction = new CountryRestrictionBuilder() + .forBlacklist() + .build(); + + expect(JSON.stringify(typeRestriction)) + .toBe(JSON.stringify({ + inclusion: 'BLACKLIST', + country_codes: [], + })); + }); + + it('should build CountryRestriction with country code', () => { + const typeRestriction = new CountryRestrictionBuilder() + .forWhitelist() + .withCountryCode(SOME_COUNTRY_CODE) + .withCountryCode(SOME_OTHER_COUNTRY_CODE) + .build(); + + expect(JSON.stringify(typeRestriction)) + .toBe(JSON.stringify({ + inclusion: 'WHITELIST', + country_codes: [ + SOME_COUNTRY_CODE, + SOME_OTHER_COUNTRY_CODE, + ], + })); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.spec.js b/tests/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.spec.js new file mode 100644 index 00000000..59b532d7 --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.spec.js @@ -0,0 +1,61 @@ +const { + OrthogonalRestrictionsFilterBuilder, + TypeRestrictionBuilder, + CountryRestrictionBuilder, +} = require('../../../../../..'); + +const SOME_COUNTRY_RESTRICTION = new CountryRestrictionBuilder() + .forWhitelist() + .build(); +const SOME_TYPE_RESTRICTION = new TypeRestrictionBuilder() + .forWhitelist() + .build(); + +describe('OrthogonalRestrictionsFilterBuilder', () => { + it('should build OrthogonalRestrictionsFilter', () => { + const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder().build(); + + expect(JSON.stringify(orthogonalRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'ORTHOGONAL_RESTRICTIONS', + })); + }); + + it('should build OrthogonalRestrictionsFilter with country restriction', () => { + const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder() + .withCountryRestriction(SOME_COUNTRY_RESTRICTION) + .build(); + + expect(JSON.stringify(orthogonalRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'ORTHOGONAL_RESTRICTIONS', + country_restriction: SOME_COUNTRY_RESTRICTION, + })); + }); + + it('should build OrthogonalRestrictionsFilter with type restriction', () => { + const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder() + .withTypeRestriction(SOME_TYPE_RESTRICTION) + .build(); + + expect(JSON.stringify(orthogonalRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'ORTHOGONAL_RESTRICTIONS', + type_restriction: SOME_TYPE_RESTRICTION, + })); + }); + + it('should build OrthogonalRestrictionsFilter with type and country restrictions', () => { + const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder() + .withTypeRestriction(SOME_TYPE_RESTRICTION) + .withCountryRestriction(SOME_COUNTRY_RESTRICTION) + .build(); + + expect(JSON.stringify(orthogonalRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'ORTHOGONAL_RESTRICTIONS', + country_restriction: SOME_COUNTRY_RESTRICTION, + type_restriction: SOME_TYPE_RESTRICTION, + })); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.spec.js b/tests/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.spec.js new file mode 100644 index 00000000..3c84bc63 --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.spec.js @@ -0,0 +1,49 @@ +const { + TypeRestrictionBuilder, +} = require('../../../../../..'); + +const SOME_DOCUMENT_TYPE = 'some-document-type'; +const SOME_OTHER_DOCUMENT_TYPE = 'some-other-document-type'; + +describe('TypeRestrictionBuilder', () => { + it('should build TypeRestriction for whitelist', () => { + const typeRestriction = new TypeRestrictionBuilder() + .forWhitelist() + .build(); + + expect(JSON.stringify(typeRestriction)) + .toBe(JSON.stringify({ + inclusion: 'WHITELIST', + document_types: [], + })); + }); + + it('should build TypeRestriction for blacklist', () => { + const typeRestriction = new TypeRestrictionBuilder() + .forBlacklist() + .build(); + + expect(JSON.stringify(typeRestriction)) + .toBe(JSON.stringify({ + inclusion: 'BLACKLIST', + document_types: [], + })); + }); + + it('should build TypeRestriction with type', () => { + const typeRestriction = new TypeRestrictionBuilder() + .forWhitelist() + .withDocumentRestriction(SOME_DOCUMENT_TYPE) + .withDocumentRestriction(SOME_OTHER_DOCUMENT_TYPE) + .build(); + + expect(JSON.stringify(typeRestriction)) + .toBe(JSON.stringify({ + inclusion: 'WHITELIST', + document_types: [ + SOME_DOCUMENT_TYPE, + SOME_OTHER_DOCUMENT_TYPE, + ], + })); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/required.document.builder.spec.js b/tests/doc_scan_service/session/create/filters/required.document.builder.spec.js new file mode 100644 index 00000000..a6127918 --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/required.document.builder.spec.js @@ -0,0 +1,8 @@ +const RequiredDocumentBuilder = require('../../../../../src/doc_scan_service/session/create/filters/required.document.builder'); + +describe('RequiredDocumentBuilder', () => { + it('cannot be instantiated', () => { + expect(() => new RequiredDocumentBuilder()) + .toThrow(new TypeError('RequiredDocumentBuilder cannot be instantiated')); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/required.document.spec.js b/tests/doc_scan_service/session/create/filters/required.document.spec.js new file mode 100644 index 00000000..b14e3813 --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/required.document.spec.js @@ -0,0 +1,8 @@ +const RequiredDocument = require('../../../../../src/doc_scan_service/session/create/filters/required.document'); + +describe('RequiredDocument', () => { + it('cannot be instantiated', () => { + expect(() => new RequiredDocument()) + .toThrow(new TypeError('RequiredDocument cannot be instantiated')); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js b/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js new file mode 100644 index 00000000..1725fc46 --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js @@ -0,0 +1,37 @@ +const { + RequiredIdentityDocumentBuilder, + OrthogonalRestrictionsFilterBuilder, + DocumentRestrictionsFilterBuilder, +} = require('../../../../..'); + +describe('RequiredIdentityDocumentBuilder', () => { + it('builds RequiredIdentityDocument with orthogonal filter', () => { + const requiredIdentityDocument = new RequiredIdentityDocumentBuilder() + .withFilter(new OrthogonalRestrictionsFilterBuilder().build()) + .build(); + + expect(JSON.stringify(requiredIdentityDocument)) + .toBe(JSON.stringify({ + type: 'ID_DOCUMENT', + filter: { + type: 'ORTHOGONAL_RESTRICTIONS', + }, + })); + }); + + it('builds RequiredIdentityDocument with document filter', () => { + const requiredIdentityDocument = new RequiredIdentityDocumentBuilder() + .withFilter(new DocumentRestrictionsFilterBuilder().forWhitelist().build()) + .build(); + + expect(JSON.stringify(requiredIdentityDocument)) + .toBe(JSON.stringify({ + type: 'ID_DOCUMENT', + filter: { + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'WHITELIST', + documents: [], + }, + })); + }); +}); diff --git a/tests/doc_scan_service/session/create/session.specification.builder.test.js b/tests/doc_scan_service/session/create/session.specification.builder.test.js index ee8dda83..75fe48f0 100644 --- a/tests/doc_scan_service/session/create/session.specification.builder.test.js +++ b/tests/doc_scan_service/session/create/session.specification.builder.test.js @@ -6,6 +6,8 @@ const { RequestedDocumentAuthenticityCheckBuilder, NotificationConfigBuilder, SdkConfigBuilder, + RequiredIdentityDocumentBuilder, + DocumentRestrictionsFilterBuilder, } = require('../../../../'); describe('SessionSpecificationBuilder', () => { @@ -33,6 +35,13 @@ describe('SessionSpecificationBuilder', () => { const docAuthenticityCheck = new RequestedDocumentAuthenticityCheckBuilder() .build(); + const documentFilter = new DocumentRestrictionsFilterBuilder() + .forWhitelist() + .build(); + const requiredDocument = new RequiredIdentityDocumentBuilder() + .withFilter(documentFilter) + .build(); + const sessionSpec = new SessionSpecificationBuilder() .withClientSessionTokenTtl(30) .withUserTrackingId('some-tracking-id') @@ -43,6 +52,7 @@ describe('SessionSpecificationBuilder', () => { .withRequestedCheck(livenessCheck) .withRequestedCheck(docAuthenticityCheck) .withRequestedTask(textExtractionTask) + .withRequiredDocument(requiredDocument) .build(); const expectedJson = JSON.stringify({ @@ -83,7 +93,16 @@ describe('SessionSpecificationBuilder', () => { sdk_config: { allowed_capture_methods: 'CAMERA', }, - required_documents: [], + required_documents: [ + { + type: 'ID_DOCUMENT', + filter: { + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'WHITELIST', + documents: [], + }, + }, + ], }); expect(JSON.stringify(sessionSpec)).toBe(expectedJson); diff --git a/tests/doc_scan_service/session/support/supported.documents.response.spec.js b/tests/doc_scan_service/session/support/supported.documents.response.spec.js new file mode 100644 index 00000000..c5b21611 --- /dev/null +++ b/tests/doc_scan_service/session/support/supported.documents.response.spec.js @@ -0,0 +1,69 @@ +const SupportedDocumentsResponse = require('../../../../src/doc_scan_service/support/supported.documents.response'); + +const SOME_DOCUMENT_TYPE = 'some-document-type'; +const SOME_OTHER_DOCUMENT_TYPE = 'some-other-document-type'; +const SOME_COUNTRY_CODE = 'some-country-code'; +const SOME_OTHER_COUNTRY_CODE = 'some-other-country-code'; + +describe('SupportedDocumentsResponse', () => { + it('parses response into list of supported countries', () => { + const supportedDocumentsResponse = new SupportedDocumentsResponse({ + supported_countries: [ + { + code: SOME_COUNTRY_CODE, + supported_documents: [ + { + type: SOME_DOCUMENT_TYPE, + }, + ], + }, + { + code: SOME_OTHER_COUNTRY_CODE, + supported_documents: [ + { + type: SOME_DOCUMENT_TYPE, + }, + { + type: SOME_OTHER_DOCUMENT_TYPE, + }, + ], + }, + { + code: SOME_OTHER_COUNTRY_CODE, + }, + ], + }); + + const supportedCountries = supportedDocumentsResponse.getSupportedCountries(); + + expect(supportedCountries) + .toHaveLength(3); + expect(supportedCountries[0].getCode()) + .toBe(SOME_COUNTRY_CODE); + expect(supportedCountries[0].getSupportedDocuments()) + .toHaveLength(1); + expect(supportedCountries[0].getSupportedDocuments()[0].getType()) + .toBe(SOME_DOCUMENT_TYPE); + + expect(supportedCountries[1].getCode()) + .toBe(SOME_OTHER_COUNTRY_CODE); + expect(supportedCountries[1].getSupportedDocuments()) + .toHaveLength(2); + expect(supportedCountries[1].getSupportedDocuments()[0].getType()) + .toBe(SOME_DOCUMENT_TYPE); + expect(supportedCountries[1].getSupportedDocuments()[1].getType()) + .toBe(SOME_OTHER_DOCUMENT_TYPE); + + expect(supportedCountries[2].getCode()) + .toBe(SOME_OTHER_COUNTRY_CODE); + expect(supportedCountries[2].getSupportedDocuments()) + .toHaveLength(0); + }); + + it('returns empty list when supported countries is not returned', () => { + const supportedDocumentsResponse = new SupportedDocumentsResponse({}); + const supportedCountries = supportedDocumentsResponse.getSupportedCountries(); + + expect(supportedCountries).toHaveLength(0); + }); +}); From fe0df35debebe84ea19ab7856b6b16e1ab00a41a Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 2 Apr 2020 17:20:22 +0100 Subject: [PATCH 14/33] SDK-1460: Prevent RequiredDocumentFilter being instantiated --- .../session/create/filters/required.document.filter.js | 4 ++++ .../create/filters/required.document.filter.spec.js | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/doc_scan_service/session/create/filters/required.document.filter.spec.js diff --git a/src/doc_scan_service/session/create/filters/required.document.filter.js b/src/doc_scan_service/session/create/filters/required.document.filter.js index cd45d19c..c9e877d3 100644 --- a/src/doc_scan_service/session/create/filters/required.document.filter.js +++ b/src/doc_scan_service/session/create/filters/required.document.filter.js @@ -2,6 +2,10 @@ const Validation = require('../../../../yoti_common/validation'); class RequiredDocumentFilter { constructor(type) { + if (new.target === RequiredDocumentFilter) { + throw TypeError('RequiredDocumentFilter cannot be instantiated'); + } + Validation.isString(type, 'type'); this.type = type; } diff --git a/tests/doc_scan_service/session/create/filters/required.document.filter.spec.js b/tests/doc_scan_service/session/create/filters/required.document.filter.spec.js new file mode 100644 index 00000000..d2c49527 --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/required.document.filter.spec.js @@ -0,0 +1,8 @@ +const RequiredDocumentFilter = require('../../../../../src/doc_scan_service/session/create/filters/required.document.filter'); + +describe('RequiredDocumentFilter', () => { + it('cannot be instantiated', () => { + expect(() => new RequiredDocumentFilter()) + .toThrow(new TypeError('RequiredDocumentFilter cannot be instantiated')); + }); +}); From ba0b82575f3f93e769f5d8d9284b52367a2a2f10 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 16 Apr 2020 18:11:01 +0100 Subject: [PATCH 15/33] SDK-1460: Simplify filters --- src/doc_scan_service/index.js | 6 - .../document/document.restriction.builder.js | 27 ----- .../filters/document/document.restriction.js | 12 +- .../document.restrictions.filter.builder.js | 6 +- .../orthogonal/country.restriction.builder.js | 31 ------ .../orthogonal.restrictions.filter.builder.js | 34 ++++-- .../orthogonal/type.restriction.builder.js | 31 ------ .../document.restriction.builder.spec.js | 58 ---------- ...cument.restrictions.filter.builder.spec.js | 103 +++++++++++++++++- .../country.restriction.builder.spec.js | 49 --------- ...ogonal.restrictions.filter.builder.spec.js | 94 ++++++++++++---- .../type.restriction.builder.spec.js | 49 --------- 12 files changed, 208 insertions(+), 292 deletions(-) delete mode 100644 src/doc_scan_service/session/create/filters/document/document.restriction.builder.js delete mode 100644 src/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.js delete mode 100644 src/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.js delete mode 100644 tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js delete mode 100644 tests/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.spec.js delete mode 100644 tests/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.spec.js diff --git a/src/doc_scan_service/index.js b/src/doc_scan_service/index.js index 9b0332d4..529606ee 100644 --- a/src/doc_scan_service/index.js +++ b/src/doc_scan_service/index.js @@ -11,10 +11,7 @@ const RequestedLivenessCheckBuilder = require('./session/create/check/requested. const RequestedTextExtractionTaskBuilder = require('./session/create/task/requested.text.extraction.task.builder'); const RequiredIdentityDocumentBuilder = require('./session/create/filters/required.identity.document.builder'); const DocumentRestrictionsFilterBuilder = require('./session/create/filters/document/document.restrictions.filter.builder'); -const DocumentRestrictionBuilder = require('./session/create/filters/document/document.restriction.builder'); const OrthogonalRestrictionsFilterBuilder = require('./session/create/filters/orthogonal/orthogonal.restrictions.filter.builder'); -const TypeRestrictionBuilder = require('./session/create/filters/orthogonal/type.restriction.builder'); -const CountryRestrictionBuilder = require('./session/create/filters/orthogonal/country.restriction.builder'); module.exports = { DocScanService, @@ -28,8 +25,5 @@ module.exports = { RequestedTextExtractionTaskBuilder, RequiredIdentityDocumentBuilder, DocumentRestrictionsFilterBuilder, - DocumentRestrictionBuilder, OrthogonalRestrictionsFilterBuilder, - TypeRestrictionBuilder, - CountryRestrictionBuilder, }; diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js deleted file mode 100644 index ad3a7848..00000000 --- a/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js +++ /dev/null @@ -1,27 +0,0 @@ -const Validation = require('../../../../../yoti_common/validation'); -const DocumentRestriction = require('./document.restriction'); - -class DocumentRestrictionBuilder { - constructor() { - this.countryCodes = []; - this.documentTypes = []; - } - - withDocumentType(documentType) { - Validation.isString(documentType, 'documentType'); - this.documentTypes.push(documentType); - return this; - } - - withCountryCode(countryCode) { - Validation.isString(countryCode, 'countryCode'); - this.countryCodes.push(countryCode); - return this; - } - - build() { - return new DocumentRestriction(this.documentTypes, this.countryCodes); - } -} - -module.exports = DocumentRestrictionBuilder; diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.js b/src/doc_scan_service/session/create/filters/document/document.restriction.js index 41b47ca5..6309a261 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restriction.js +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.js @@ -1,16 +1,16 @@ const Validation = require('../../../../../yoti_common/validation'); class DocumentRestriction { - constructor(documentTypes, countryCodes) { - if (documentTypes && documentTypes.length > 0) { - Validation.isArrayOfStrings(documentTypes, 'documentTypes'); - this.documentTypes = documentTypes; - } - + constructor(countryCodes, documentTypes) { if (countryCodes && countryCodes.length > 0) { Validation.isArrayOfStrings(countryCodes, 'countryCodes'); this.countryCodes = countryCodes; } + + if (documentTypes && documentTypes.length > 0) { + Validation.isArrayOfStrings(documentTypes, 'documentTypes'); + this.documentTypes = documentTypes; + } } toJSON() { diff --git a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js index 7c8ed67e..a8ffbb25 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js +++ b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js @@ -1,4 +1,3 @@ -const Validation = require('../../../../../yoti_common/validation'); const DocumentRestrictionsFilter = require('./document.restrictions.filter'); const DocumentRestriction = require('./document.restriction'); const DocScanConstants = require('../../../../doc.scan.constants'); @@ -18,9 +17,8 @@ class DocumentRestrictionsFilterBuilder { return this; } - withDocumentRestriction(document) { - Validation.instanceOf(document, DocumentRestriction, 'document'); - this.documents.push(document); + withDocumentRestriction(countryCodes, documentTypes) { + this.documents.push(new DocumentRestriction(countryCodes, documentTypes)); return this; } diff --git a/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.js b/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.js deleted file mode 100644 index 97038682..00000000 --- a/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.js +++ /dev/null @@ -1,31 +0,0 @@ -const Validation = require('../../../../../yoti_common/validation'); -const CountryRestriction = require('./country.restriction'); -const DocScanConstants = require('../../../../doc.scan.constants'); - -class CountryRestrictionBuilder { - constructor() { - this.countryCodes = []; - } - - forWhitelist() { - this.inclusion = DocScanConstants.INCLUSION_WHITELIST; - return this; - } - - forBlacklist() { - this.inclusion = DocScanConstants.INCLUSION_BLACKLIST; - return this; - } - - withCountryCode(countryCode) { - Validation.isString(countryCode, 'countryCode'); - this.countryCodes.push(countryCode); - return this; - } - - build() { - return new CountryRestriction(this.inclusion, this.countryCodes); - } -} - -module.exports = CountryRestrictionBuilder; diff --git a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js index 713abd26..45d6c9f6 100644 --- a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js +++ b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js @@ -1,18 +1,38 @@ -const Validation = require('../../../../../yoti_common/validation'); const OrthogonalRestrictionsFilter = require('./orthogonal.restrictions.filter'); const TypeRestriction = require('./type.restriction'); const CountryRestriction = require('./country.restriction'); +const DocScanConstants = require('../../../../doc.scan.constants'); class OrthogonalRestrictionsFilterBuilder { - withCountryRestriction(countryRestriction) { - Validation.instanceOf(countryRestriction, CountryRestriction, 'countryRestriction'); - this.countryRestriction = countryRestriction; + withWhitelistedCountries(countryCodes) { + this.countryRestriction = new CountryRestriction( + DocScanConstants.INCLUSION_WHITELIST, + countryCodes + ); return this; } - withTypeRestriction(typeRestriction) { - Validation.instanceOf(typeRestriction, TypeRestriction, 'typeRestriction'); - this.typeRestriction = typeRestriction; + withBlacklistedCountries(countryCodes) { + this.countryRestriction = new CountryRestriction( + DocScanConstants.INCLUSION_BLACKLIST, + countryCodes + ); + return this; + } + + withWhitelistedDocumentTypes(documentTypes) { + this.typeRestriction = new TypeRestriction( + DocScanConstants.INCLUSION_WHITELIST, + documentTypes + ); + return this; + } + + withBlacklistedDocumentTypes(documentTypes) { + this.typeRestriction = new TypeRestriction( + DocScanConstants.INCLUSION_BLACKLIST, + documentTypes + ); return this; } diff --git a/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.js b/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.js deleted file mode 100644 index 532c4717..00000000 --- a/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.js +++ /dev/null @@ -1,31 +0,0 @@ -const Validation = require('../../../../../yoti_common/validation'); -const TypeRestriction = require('./type.restriction'); -const DocScanConstants = require('../../../../doc.scan.constants'); - -class TypeRestrictionBuilder { - constructor() { - this.documentTypes = []; - } - - forWhitelist() { - this.inclusion = DocScanConstants.INCLUSION_WHITELIST; - return this; - } - - forBlacklist() { - this.inclusion = DocScanConstants.INCLUSION_BLACKLIST; - return this; - } - - withDocumentRestriction(documentType) { - Validation.isString(documentType, 'documentType'); - this.documentTypes.push(documentType); - return this; - } - - build() { - return new TypeRestriction(this.inclusion, this.documentTypes); - } -} - -module.exports = TypeRestrictionBuilder; diff --git a/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js b/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js deleted file mode 100644 index 0336548d..00000000 --- a/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js +++ /dev/null @@ -1,58 +0,0 @@ -const { DocumentRestrictionBuilder } = require('../../../../../..'); -const DocumentRestriction = require('../../../../../../src/doc_scan_service/session/create/filters/document/document.restriction'); - -const SOME_DOCUMENT_TYPE = 'some-document-type'; -const SOME_OTHER_DOCUMENT_TYPE = 'some-other-document-type'; -const SOME_COUNTRY_CODE = 'some-country-code'; -const SOME_OTHER_COUNTRY_CODE = 'some-other-country-code'; - -describe('DocumentRestrictionBuilder', () => { - it('should build DocumentRestriction', () => { - const documentRestriction = new DocumentRestrictionBuilder().build(); - expect(documentRestriction).toBeInstanceOf(DocumentRestriction); - }); - it('should build DocumentRestriction with document types', () => { - const documentRestriction = new DocumentRestrictionBuilder() - .withDocumentType(SOME_DOCUMENT_TYPE) - .withDocumentType(SOME_OTHER_DOCUMENT_TYPE) - .build(); - - expect(JSON.stringify(documentRestriction)) - .toBe(JSON.stringify({ - document_types: [ - SOME_DOCUMENT_TYPE, - SOME_OTHER_DOCUMENT_TYPE, - ], - })); - }); - it('should build DocumentRestriction with country codes', () => { - const documentRestriction = new DocumentRestrictionBuilder() - .withCountryCode(SOME_COUNTRY_CODE) - .withCountryCode(SOME_OTHER_COUNTRY_CODE) - .build(); - - expect(JSON.stringify(documentRestriction)) - .toBe(JSON.stringify({ - country_codes: [ - SOME_COUNTRY_CODE, - SOME_OTHER_COUNTRY_CODE, - ], - })); - }); - it('should build DocumentRestriction with document type and country code', () => { - const documentRestriction = new DocumentRestrictionBuilder() - .withCountryCode(SOME_COUNTRY_CODE) - .withDocumentType(SOME_DOCUMENT_TYPE) - .build(); - - expect(JSON.stringify(documentRestriction)) - .toBe(JSON.stringify({ - document_types: [ - SOME_DOCUMENT_TYPE, - ], - country_codes: [ - SOME_COUNTRY_CODE, - ], - })); - }); -}); diff --git a/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js b/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js index 72d8fe01..01164168 100644 --- a/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js +++ b/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js @@ -1,9 +1,11 @@ const { DocumentRestrictionsFilterBuilder, - DocumentRestrictionBuilder, } = require('../../../../../..'); const SOME_DOCUMENT_TYPE = 'some-document-type'; +const SOME_OTHER_DOCUMENT_TYPE = 'some-other-document-type'; +const SOME_COUNTRY_CODE = 'some-country-code'; +const SOME_OTHER_COUNTRY_CODE = 'some-other-country-code'; describe('DocumentRestrictionsFilterBuilder', () => { it('should build DocumentRestrictionsFilter for whitelist', () => { @@ -31,14 +33,31 @@ describe('DocumentRestrictionsFilterBuilder', () => { documents: [], })); }); - it('should build DocumentRestrictionsFilter with document restriction', () => { - const documentRestriction = new DocumentRestrictionBuilder() - .withDocumentType(SOME_DOCUMENT_TYPE) + + it('should build DocumentRestrictionsFilter with document type', () => { + const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() + .forWhitelist() + .withDocumentRestriction([], [SOME_DOCUMENT_TYPE]) .build(); + expect(JSON.stringify(documentRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'WHITELIST', + documents: [ + { + document_types: [ + SOME_DOCUMENT_TYPE, + ], + }, + ], + })); + }); + + it('should build DocumentRestrictionsFilter with multiple document types', () => { const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() .forWhitelist() - .withDocumentRestriction(documentRestriction) + .withDocumentRestriction(null, [SOME_DOCUMENT_TYPE, SOME_OTHER_DOCUMENT_TYPE]) .build(); expect(JSON.stringify(documentRestrictionsFilter)) @@ -49,6 +68,80 @@ describe('DocumentRestrictionsFilterBuilder', () => { { document_types: [ SOME_DOCUMENT_TYPE, + SOME_OTHER_DOCUMENT_TYPE, + ], + }, + ], + })); + }); + + it('should build DocumentRestrictionsFilter with country restriction', () => { + const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() + .forWhitelist() + .withDocumentRestriction([SOME_COUNTRY_CODE], []) + .build(); + + expect(JSON.stringify(documentRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'WHITELIST', + documents: [ + { + country_codes: [ + SOME_COUNTRY_CODE, + ], + }, + ], + })); + }); + + it('should build DocumentRestrictionsFilter with multiple countries', () => { + const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() + .forWhitelist() + .withDocumentRestriction([SOME_COUNTRY_CODE, SOME_OTHER_COUNTRY_CODE], []) + .build(); + + expect(JSON.stringify(documentRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'WHITELIST', + documents: [ + { + country_codes: [ + SOME_COUNTRY_CODE, + SOME_OTHER_COUNTRY_CODE, + ], + }, + ], + })); + }); + + it('should build DocumentRestrictionsFilter with multiple document restrictions', () => { + const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() + .forWhitelist() + .withDocumentRestriction([SOME_COUNTRY_CODE], [SOME_DOCUMENT_TYPE]) + .withDocumentRestriction([SOME_OTHER_COUNTRY_CODE], [SOME_OTHER_DOCUMENT_TYPE]) + .build(); + + expect(JSON.stringify(documentRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'DOCUMENT_RESTRICTIONS', + inclusion: 'WHITELIST', + documents: [ + { + document_types: [ + SOME_DOCUMENT_TYPE, + ], + country_codes: [ + SOME_COUNTRY_CODE, + ], + }, + { + document_types: [ + SOME_OTHER_DOCUMENT_TYPE, + ], + country_codes: [ + SOME_OTHER_COUNTRY_CODE, ], }, ], diff --git a/tests/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.spec.js b/tests/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.spec.js deleted file mode 100644 index 36e5276a..00000000 --- a/tests/doc_scan_service/session/create/filters/orthogonal/country.restriction.builder.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -const { - CountryRestrictionBuilder, -} = require('../../../../../..'); - -const SOME_COUNTRY_CODE = 'some-country-code'; -const SOME_OTHER_COUNTRY_CODE = 'some-other-country-code'; - -describe('CountryRestrictionBuilder', () => { - it('should build CountryRestriction for whitelist', () => { - const typeRestriction = new CountryRestrictionBuilder() - .forWhitelist() - .build(); - - expect(JSON.stringify(typeRestriction)) - .toBe(JSON.stringify({ - inclusion: 'WHITELIST', - country_codes: [], - })); - }); - - it('should build CountryRestriction for blacklist', () => { - const typeRestriction = new CountryRestrictionBuilder() - .forBlacklist() - .build(); - - expect(JSON.stringify(typeRestriction)) - .toBe(JSON.stringify({ - inclusion: 'BLACKLIST', - country_codes: [], - })); - }); - - it('should build CountryRestriction with country code', () => { - const typeRestriction = new CountryRestrictionBuilder() - .forWhitelist() - .withCountryCode(SOME_COUNTRY_CODE) - .withCountryCode(SOME_OTHER_COUNTRY_CODE) - .build(); - - expect(JSON.stringify(typeRestriction)) - .toBe(JSON.stringify({ - inclusion: 'WHITELIST', - country_codes: [ - SOME_COUNTRY_CODE, - SOME_OTHER_COUNTRY_CODE, - ], - })); - }); -}); diff --git a/tests/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.spec.js b/tests/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.spec.js index 59b532d7..158c905a 100644 --- a/tests/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.spec.js +++ b/tests/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.spec.js @@ -1,15 +1,11 @@ const { OrthogonalRestrictionsFilterBuilder, - TypeRestrictionBuilder, - CountryRestrictionBuilder, } = require('../../../../../..'); -const SOME_COUNTRY_RESTRICTION = new CountryRestrictionBuilder() - .forWhitelist() - .build(); -const SOME_TYPE_RESTRICTION = new TypeRestrictionBuilder() - .forWhitelist() - .build(); +const SOME_DOCUMENT_TYPE = 'some-document-type'; +const SOME_OTHER_DOCUMENT_TYPE = 'some-other-document-type'; +const SOME_COUNTRY_CODE = 'some-country-code'; +const SOME_OTHER_COUNTRY_CODE = 'some-other-country-code'; describe('OrthogonalRestrictionsFilterBuilder', () => { it('should build OrthogonalRestrictionsFilter', () => { @@ -21,41 +17,101 @@ describe('OrthogonalRestrictionsFilterBuilder', () => { })); }); - it('should build OrthogonalRestrictionsFilter with country restriction', () => { + it('should build OrthogonalRestrictionsFilter with country and type restrictions', () => { const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder() - .withCountryRestriction(SOME_COUNTRY_RESTRICTION) + .withWhitelistedCountries([SOME_COUNTRY_CODE, SOME_OTHER_COUNTRY_CODE]) + .withWhitelistedDocumentTypes([SOME_DOCUMENT_TYPE, SOME_OTHER_DOCUMENT_TYPE]) .build(); expect(JSON.stringify(orthogonalRestrictionsFilter)) .toBe(JSON.stringify({ type: 'ORTHOGONAL_RESTRICTIONS', - country_restriction: SOME_COUNTRY_RESTRICTION, + country_restriction: { + inclusion: 'WHITELIST', + country_codes: [ + SOME_COUNTRY_CODE, + SOME_OTHER_COUNTRY_CODE, + ], + }, + type_restriction: { + inclusion: 'WHITELIST', + document_types: [ + SOME_DOCUMENT_TYPE, + SOME_OTHER_DOCUMENT_TYPE, + ], + }, })); }); - it('should build OrthogonalRestrictionsFilter with type restriction', () => { + it('should build OrthogonalRestrictionsFilter with whitelisted countries', () => { const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder() - .withTypeRestriction(SOME_TYPE_RESTRICTION) + .withWhitelistedCountries([SOME_COUNTRY_CODE, SOME_OTHER_COUNTRY_CODE]) .build(); expect(JSON.stringify(orthogonalRestrictionsFilter)) .toBe(JSON.stringify({ type: 'ORTHOGONAL_RESTRICTIONS', - type_restriction: SOME_TYPE_RESTRICTION, + country_restriction: { + inclusion: 'WHITELIST', + country_codes: [ + SOME_COUNTRY_CODE, + SOME_OTHER_COUNTRY_CODE, + ], + }, })); }); - it('should build OrthogonalRestrictionsFilter with type and country restrictions', () => { + it('should build OrthogonalRestrictionsFilter with blacklisted countries', () => { const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder() - .withTypeRestriction(SOME_TYPE_RESTRICTION) - .withCountryRestriction(SOME_COUNTRY_RESTRICTION) + .withBlacklistedCountries([SOME_COUNTRY_CODE, SOME_OTHER_COUNTRY_CODE]) .build(); expect(JSON.stringify(orthogonalRestrictionsFilter)) .toBe(JSON.stringify({ type: 'ORTHOGONAL_RESTRICTIONS', - country_restriction: SOME_COUNTRY_RESTRICTION, - type_restriction: SOME_TYPE_RESTRICTION, + country_restriction: { + inclusion: 'BLACKLIST', + country_codes: [ + SOME_COUNTRY_CODE, + SOME_OTHER_COUNTRY_CODE, + ], + }, + })); + }); + + it('should build OrthogonalRestrictionsFilter with whitelisted document types', () => { + const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder() + .withWhitelistedDocumentTypes([SOME_DOCUMENT_TYPE, SOME_OTHER_DOCUMENT_TYPE]) + .build(); + + expect(JSON.stringify(orthogonalRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'ORTHOGONAL_RESTRICTIONS', + type_restriction: { + inclusion: 'WHITELIST', + document_types: [ + SOME_DOCUMENT_TYPE, + SOME_OTHER_DOCUMENT_TYPE, + ], + }, + })); + }); + + it('should build OrthogonalRestrictionsFilter with blacklisted document types', () => { + const orthogonalRestrictionsFilter = new OrthogonalRestrictionsFilterBuilder() + .withBlacklistedDocumentTypes([SOME_DOCUMENT_TYPE, SOME_OTHER_DOCUMENT_TYPE]) + .build(); + + expect(JSON.stringify(orthogonalRestrictionsFilter)) + .toBe(JSON.stringify({ + type: 'ORTHOGONAL_RESTRICTIONS', + type_restriction: { + inclusion: 'BLACKLIST', + document_types: [ + SOME_DOCUMENT_TYPE, + SOME_OTHER_DOCUMENT_TYPE, + ], + }, })); }); }); diff --git a/tests/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.spec.js b/tests/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.spec.js deleted file mode 100644 index 3c84bc63..00000000 --- a/tests/doc_scan_service/session/create/filters/orthogonal/type.restriction.builder.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -const { - TypeRestrictionBuilder, -} = require('../../../../../..'); - -const SOME_DOCUMENT_TYPE = 'some-document-type'; -const SOME_OTHER_DOCUMENT_TYPE = 'some-other-document-type'; - -describe('TypeRestrictionBuilder', () => { - it('should build TypeRestriction for whitelist', () => { - const typeRestriction = new TypeRestrictionBuilder() - .forWhitelist() - .build(); - - expect(JSON.stringify(typeRestriction)) - .toBe(JSON.stringify({ - inclusion: 'WHITELIST', - document_types: [], - })); - }); - - it('should build TypeRestriction for blacklist', () => { - const typeRestriction = new TypeRestrictionBuilder() - .forBlacklist() - .build(); - - expect(JSON.stringify(typeRestriction)) - .toBe(JSON.stringify({ - inclusion: 'BLACKLIST', - document_types: [], - })); - }); - - it('should build TypeRestriction with type', () => { - const typeRestriction = new TypeRestrictionBuilder() - .forWhitelist() - .withDocumentRestriction(SOME_DOCUMENT_TYPE) - .withDocumentRestriction(SOME_OTHER_DOCUMENT_TYPE) - .build(); - - expect(JSON.stringify(typeRestriction)) - .toBe(JSON.stringify({ - inclusion: 'WHITELIST', - document_types: [ - SOME_DOCUMENT_TYPE, - SOME_OTHER_DOCUMENT_TYPE, - ], - })); - }); -}); From 145f519731853194ddd834ee9ef1029bf7e26593 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 16 Apr 2020 19:05:46 +0100 Subject: [PATCH 16/33] SDK-1460: Fix default demo app URL --- examples/doc-scan/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/doc-scan/config.js b/examples/doc-scan/config.js index 91966b29..b7911ebf 100644 --- a/examples/doc-scan/config.js +++ b/examples/doc-scan/config.js @@ -4,5 +4,5 @@ module.exports = { YOTI_CLIENT_SDK_ID: process.env.YOTI_CLIENT_SDK_ID, YOTI_PEM: fs.readFileSync(process.env.YOTI_KEY_FILE_PATH), YOTI_DOC_SCAN_IFRAME_URL: process.env.YOTI_DOC_SCAN_IFRAME_URL || 'https://api.yoti.com/idverify/v1/web/index.html', - YOTI_APP_BASE_URL: process.env.YOTI_APP_BASE_URL || 'http://localhost:3000', + YOTI_APP_BASE_URL: process.env.YOTI_APP_BASE_URL || 'https://localhost:3000', }; From 701a0dca8d66a39a91fdcf2c1d98f524719ba4ac Mon Sep 17 00:00:00 2001 From: David Grayston Date: Fri, 17 Apr 2020 11:39:05 +0100 Subject: [PATCH 17/33] SDK-1460: Add JSDocs --- .../filters/document/document.restriction.js | 4 ++++ .../document.restrictions.filter.builder.js | 15 +++++++++++++++ .../document/document.restrictions.filter.js | 4 ++++ .../filters/orthogonal/country.restriction.js | 4 ++++ .../orthogonal.restrictions.filter.builder.js | 15 +++++++++++++++ .../orthogonal/orthogonal.restrictions.filter.js | 4 ++++ .../create/filters/orthogonal/type.restriction.js | 4 ++++ .../create/filters/required.document.builder.js | 5 +++++ .../create/filters/required.document.filter.js | 3 +++ .../session/create/filters/required.document.js | 4 ++++ .../filters/required.identity.document.builder.js | 3 +++ .../create/filters/required.identity.document.js | 3 +++ 12 files changed, 68 insertions(+) diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.js b/src/doc_scan_service/session/create/filters/document/document.restriction.js index 6309a261..e06d7942 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restriction.js +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.js @@ -1,6 +1,10 @@ const Validation = require('../../../../../yoti_common/validation'); class DocumentRestriction { + /** + * @param {string[]} countryCodes + * @param {string[]} documentTypes + */ constructor(countryCodes, documentTypes) { if (countryCodes && countryCodes.length > 0) { Validation.isArrayOfStrings(countryCodes, 'countryCodes'); diff --git a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js index a8ffbb25..8f124208 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js +++ b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js @@ -7,21 +7,36 @@ class DocumentRestrictionsFilterBuilder { this.documents = []; } + /** + * @returns {this} + */ forWhitelist() { this.inclusion = DocScanConstants.INCLUSION_WHITELIST; return this; } + /** + * @returns {this} + */ forBlacklist() { this.inclusion = DocScanConstants.INCLUSION_BLACKLIST; return this; } + /** + * @param {string[]} countryCodes + * @param {string[]} documentTypes + * + * @returns {this} + */ withDocumentRestriction(countryCodes, documentTypes) { this.documents.push(new DocumentRestriction(countryCodes, documentTypes)); return this; } + /** + * @returns {DocumentRestrictionsFilter} + */ build() { return new DocumentRestrictionsFilter(this.inclusion, this.documents); } diff --git a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js index 8392ea81..81ea4786 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js +++ b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js @@ -4,6 +4,10 @@ const DocumentRestriction = require('./document.restriction'); const DocScanConstants = require('../../../../doc.scan.constants'); class DocumentRestrictionsFilter extends RequiredDocumentFilter { + /** + * @param {string} inclusion + * @param {DocumentRestriction[]} documents + */ constructor(inclusion, documents) { super(DocScanConstants.DOCUMENT_RESTRICTIONS); diff --git a/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.js b/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.js index 0d922e16..e18a3cc2 100644 --- a/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.js +++ b/src/doc_scan_service/session/create/filters/orthogonal/country.restriction.js @@ -1,6 +1,10 @@ const Validation = require('../../../../../yoti_common/validation'); class CountryRestriction { + /** + * @param {string} inclusion + * @param {string[]} countryCodes + */ constructor(inclusion, countryCodes) { Validation.notNullOrEmpty(inclusion, 'inclusion'); Validation.isString(inclusion, 'inclusion'); diff --git a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js index 45d6c9f6..7dfe4cac 100644 --- a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js +++ b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.builder.js @@ -4,6 +4,9 @@ const CountryRestriction = require('./country.restriction'); const DocScanConstants = require('../../../../doc.scan.constants'); class OrthogonalRestrictionsFilterBuilder { + /** + * @param {string[]} countryCodes + */ withWhitelistedCountries(countryCodes) { this.countryRestriction = new CountryRestriction( DocScanConstants.INCLUSION_WHITELIST, @@ -12,6 +15,9 @@ class OrthogonalRestrictionsFilterBuilder { return this; } + /** + * @param {string[]} countryCodes + */ withBlacklistedCountries(countryCodes) { this.countryRestriction = new CountryRestriction( DocScanConstants.INCLUSION_BLACKLIST, @@ -20,6 +26,9 @@ class OrthogonalRestrictionsFilterBuilder { return this; } + /** + * @param {string[]} documentTypes + */ withWhitelistedDocumentTypes(documentTypes) { this.typeRestriction = new TypeRestriction( DocScanConstants.INCLUSION_WHITELIST, @@ -28,6 +37,9 @@ class OrthogonalRestrictionsFilterBuilder { return this; } + /** + * @param {string[]} documentTypes + */ withBlacklistedDocumentTypes(documentTypes) { this.typeRestriction = new TypeRestriction( DocScanConstants.INCLUSION_BLACKLIST, @@ -36,6 +48,9 @@ class OrthogonalRestrictionsFilterBuilder { return this; } + /** + * @returns {OrthogonalRestrictionsFilter} + */ build() { return new OrthogonalRestrictionsFilter(this.countryRestriction, this.typeRestriction); } diff --git a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js index 43eceaed..6baa1010 100644 --- a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js +++ b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js @@ -5,6 +5,10 @@ const TypeRestriction = require('./type.restriction'); const CountryRestriction = require('./country.restriction'); class OrthogonalRestrictionsFilter extends RequiredDocumentFilter { + /** + * @param {CountryRestriction} countryRestriction + * @param {TypeRestriction} typeRestriction + */ constructor(countryRestriction, typeRestriction) { super(DocScanConstants.ORTHOGONAL_RESTRICTIONS); diff --git a/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.js b/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.js index 2cd60b37..1668fe67 100644 --- a/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.js +++ b/src/doc_scan_service/session/create/filters/orthogonal/type.restriction.js @@ -1,6 +1,10 @@ const Validation = require('../../../../../yoti_common/validation'); class TypeRestriction { + /** + * @param {string} inclusion + * @param {string[]} documentTypes + */ constructor(inclusion, documentTypes) { Validation.notNullOrEmpty(inclusion, 'inclusion'); Validation.isString(inclusion, 'inclusion'); diff --git a/src/doc_scan_service/session/create/filters/required.document.builder.js b/src/doc_scan_service/session/create/filters/required.document.builder.js index afc21d0d..764ff7aa 100644 --- a/src/doc_scan_service/session/create/filters/required.document.builder.js +++ b/src/doc_scan_service/session/create/filters/required.document.builder.js @@ -8,6 +8,11 @@ class RequiredDocumentBuilder { } } + /** + * @param {RequiredDocumentFilter} filter + * + * @returns {this} + */ withFilter(filter) { Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); this.filter = filter; diff --git a/src/doc_scan_service/session/create/filters/required.document.filter.js b/src/doc_scan_service/session/create/filters/required.document.filter.js index c9e877d3..e7cab48d 100644 --- a/src/doc_scan_service/session/create/filters/required.document.filter.js +++ b/src/doc_scan_service/session/create/filters/required.document.filter.js @@ -1,6 +1,9 @@ const Validation = require('../../../../yoti_common/validation'); class RequiredDocumentFilter { + /** + * @param {string} type + */ constructor(type) { if (new.target === RequiredDocumentFilter) { throw TypeError('RequiredDocumentFilter cannot be instantiated'); diff --git a/src/doc_scan_service/session/create/filters/required.document.js b/src/doc_scan_service/session/create/filters/required.document.js index 72a1fee0..6430dcad 100644 --- a/src/doc_scan_service/session/create/filters/required.document.js +++ b/src/doc_scan_service/session/create/filters/required.document.js @@ -2,6 +2,10 @@ const Validation = require('../../../../yoti_common/validation'); const RequiredDocumentFilter = require('./required.document.filter'); class RequiredDocument { + /** + * @param {string} type + * @param {RequiredDocumentFilter} filter + */ constructor(type, filter) { if (new.target === RequiredDocument) { throw TypeError('RequiredDocument cannot be instantiated'); diff --git a/src/doc_scan_service/session/create/filters/required.identity.document.builder.js b/src/doc_scan_service/session/create/filters/required.identity.document.builder.js index 8ba7f674..1e4fe22c 100644 --- a/src/doc_scan_service/session/create/filters/required.identity.document.builder.js +++ b/src/doc_scan_service/session/create/filters/required.identity.document.builder.js @@ -2,6 +2,9 @@ const RequiredIdentityDocument = require('./required.identity.document'); const RequiredDocumentBuilder = require('./required.document.builder'); class RequiredIdentityDocumentBuilder extends RequiredDocumentBuilder { + /** + * @returns {RequiredIdentityDocument} + */ build() { return new RequiredIdentityDocument(this.filter); } diff --git a/src/doc_scan_service/session/create/filters/required.identity.document.js b/src/doc_scan_service/session/create/filters/required.identity.document.js index 407e7fe9..2680f328 100644 --- a/src/doc_scan_service/session/create/filters/required.identity.document.js +++ b/src/doc_scan_service/session/create/filters/required.identity.document.js @@ -2,6 +2,9 @@ const RequiredDocument = require('./required.document'); const DocScanConstants = require('../../../doc.scan.constants'); class RequiredIdentityDocument extends RequiredDocument { + /** + * @param {RequiredDocumentFilter} filter + */ constructor(filter) { super(DocScanConstants.ID_DOCUMENT, filter); } From dc2fb0a82e5d7ab4a3c14cb93cea2f0f6dacdeeb Mon Sep 17 00:00:00 2001 From: David Grayston Date: Fri, 17 Apr 2020 14:24:08 +0100 Subject: [PATCH 18/33] SDK-1460: Add error route to Doc Scan demo --- examples/doc-scan/index.js | 1 + examples/doc-scan/src/controllers/error.controller.js | 9 +++++++++ examples/doc-scan/src/controllers/index.js | 2 ++ 3 files changed, 12 insertions(+) create mode 100644 examples/doc-scan/src/controllers/error.controller.js diff --git a/examples/doc-scan/index.js b/examples/doc-scan/index.js index 95b368f0..6a4678e5 100644 --- a/examples/doc-scan/index.js +++ b/examples/doc-scan/index.js @@ -26,6 +26,7 @@ const router = express.Router(); router.get('/', controllers.indexController); router.get('/success', controllers.successController); router.get('/media', controllers.mediaController); +router.get('/error', controllers.errorController); app.use('/', router); diff --git a/examples/doc-scan/src/controllers/error.controller.js b/examples/doc-scan/src/controllers/error.controller.js new file mode 100644 index 00000000..b3f4363e --- /dev/null +++ b/examples/doc-scan/src/controllers/error.controller.js @@ -0,0 +1,9 @@ +module.exports = async (req, res) => { + let error = 'An unknown error occured'; + + if (req.query.yotiErrorCode) { + error = `Error Code: ${req.query.yotiErrorCode}`; + } + + res.render('pages/error', { error }); +}; diff --git a/examples/doc-scan/src/controllers/index.js b/examples/doc-scan/src/controllers/index.js index 57694b33..f24dd693 100644 --- a/examples/doc-scan/src/controllers/index.js +++ b/examples/doc-scan/src/controllers/index.js @@ -1,9 +1,11 @@ const indexController = require('./index.controller'); const successController = require('./success.controller'); const mediaController = require('./media.controller'); +const errorController = require('./error.controller'); module.exports = { indexController, successController, mediaController, + errorController, }; From 3c3a7fc5f41cab73559474f6d60af8058e4e5c94 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Mon, 20 Apr 2020 16:30:32 +0100 Subject: [PATCH 19/33] SDK-1460: Allow required documents without filter --- .../session/create/filters/required.document.js | 6 ++++-- .../filters/required.identity.document.builder.spec.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/doc_scan_service/session/create/filters/required.document.js b/src/doc_scan_service/session/create/filters/required.document.js index 6430dcad..91cbebf5 100644 --- a/src/doc_scan_service/session/create/filters/required.document.js +++ b/src/doc_scan_service/session/create/filters/required.document.js @@ -14,8 +14,10 @@ class RequiredDocument { Validation.isString(type, 'type'); this.type = type; - Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); - this.filter = filter; + if (filter) { + Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); + this.filter = filter; + } } toJSON() { diff --git a/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js b/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js index 1725fc46..d85f2159 100644 --- a/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js +++ b/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js @@ -5,6 +5,16 @@ const { } = require('../../../../..'); describe('RequiredIdentityDocumentBuilder', () => { + it('builds RequiredIdentityDocument without filter', () => { + const requiredIdentityDocument = new RequiredIdentityDocumentBuilder() + .build(); + + expect(JSON.stringify(requiredIdentityDocument)) + .toBe(JSON.stringify({ + type: 'ID_DOCUMENT', + })); + }); + it('builds RequiredIdentityDocument with orthogonal filter', () => { const requiredIdentityDocument = new RequiredIdentityDocumentBuilder() .withFilter(new OrthogonalRestrictionsFilterBuilder().build()) From 0127e034d4323f218a8648ef793bffddd4e0d784 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Tue, 21 Apr 2020 11:19:41 +0100 Subject: [PATCH 20/33] SDK-1460: Move filter to ID document --- .../filters/required.document.builder.js | 23 ------------------- .../create/filters/required.document.js | 10 +------- .../required.identity.document.builder.js | 16 +++++++++++-- .../filters/required.identity.document.js | 15 +++++++++++- .../filters/required.document.builder.spec.js | 8 ------- 5 files changed, 29 insertions(+), 43 deletions(-) delete mode 100644 src/doc_scan_service/session/create/filters/required.document.builder.js delete mode 100644 tests/doc_scan_service/session/create/filters/required.document.builder.spec.js diff --git a/src/doc_scan_service/session/create/filters/required.document.builder.js b/src/doc_scan_service/session/create/filters/required.document.builder.js deleted file mode 100644 index 764ff7aa..00000000 --- a/src/doc_scan_service/session/create/filters/required.document.builder.js +++ /dev/null @@ -1,23 +0,0 @@ -const Validation = require('../../../../yoti_common/validation'); -const RequiredDocumentFilter = require('./required.document.filter'); - -class RequiredDocumentBuilder { - constructor() { - if (new.target === RequiredDocumentBuilder) { - throw TypeError('RequiredDocumentBuilder cannot be instantiated'); - } - } - - /** - * @param {RequiredDocumentFilter} filter - * - * @returns {this} - */ - withFilter(filter) { - Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); - this.filter = filter; - return this; - } -} - -module.exports = RequiredDocumentBuilder; diff --git a/src/doc_scan_service/session/create/filters/required.document.js b/src/doc_scan_service/session/create/filters/required.document.js index 91cbebf5..86bfc1c3 100644 --- a/src/doc_scan_service/session/create/filters/required.document.js +++ b/src/doc_scan_service/session/create/filters/required.document.js @@ -1,29 +1,21 @@ const Validation = require('../../../../yoti_common/validation'); -const RequiredDocumentFilter = require('./required.document.filter'); class RequiredDocument { /** * @param {string} type - * @param {RequiredDocumentFilter} filter */ - constructor(type, filter) { + constructor(type) { if (new.target === RequiredDocument) { throw TypeError('RequiredDocument cannot be instantiated'); } Validation.isString(type, 'type'); this.type = type; - - if (filter) { - Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); - this.filter = filter; - } } toJSON() { return { type: this.type, - filter: this.filter, }; } } diff --git a/src/doc_scan_service/session/create/filters/required.identity.document.builder.js b/src/doc_scan_service/session/create/filters/required.identity.document.builder.js index 1e4fe22c..4856de0b 100644 --- a/src/doc_scan_service/session/create/filters/required.identity.document.builder.js +++ b/src/doc_scan_service/session/create/filters/required.identity.document.builder.js @@ -1,7 +1,19 @@ const RequiredIdentityDocument = require('./required.identity.document'); -const RequiredDocumentBuilder = require('./required.document.builder'); +const RequiredDocumentFilter = require('./required.document.filter'); +const Validation = require('../../../../yoti_common/validation'); + +class RequiredIdentityDocumentBuilder { + /** + * @param {RequiredDocumentFilter} filter + * + * @returns {this} + */ + withFilter(filter) { + Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); + this.filter = filter; + return this; + } -class RequiredIdentityDocumentBuilder extends RequiredDocumentBuilder { /** * @returns {RequiredIdentityDocument} */ diff --git a/src/doc_scan_service/session/create/filters/required.identity.document.js b/src/doc_scan_service/session/create/filters/required.identity.document.js index 2680f328..4585cd57 100644 --- a/src/doc_scan_service/session/create/filters/required.identity.document.js +++ b/src/doc_scan_service/session/create/filters/required.identity.document.js @@ -1,12 +1,25 @@ const RequiredDocument = require('./required.document'); +const RequiredDocumentFilter = require('./required.document.filter'); const DocScanConstants = require('../../../doc.scan.constants'); +const Validation = require('../../../../yoti_common/validation'); class RequiredIdentityDocument extends RequiredDocument { /** * @param {RequiredDocumentFilter} filter */ constructor(filter) { - super(DocScanConstants.ID_DOCUMENT, filter); + super(DocScanConstants.ID_DOCUMENT); + + if (filter) { + Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); + this.filter = filter; + } + } + + toJSON() { + const json = super.toJSON(); + json.filter = this.filter; + return json; } } diff --git a/tests/doc_scan_service/session/create/filters/required.document.builder.spec.js b/tests/doc_scan_service/session/create/filters/required.document.builder.spec.js deleted file mode 100644 index a6127918..00000000 --- a/tests/doc_scan_service/session/create/filters/required.document.builder.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -const RequiredDocumentBuilder = require('../../../../../src/doc_scan_service/session/create/filters/required.document.builder'); - -describe('RequiredDocumentBuilder', () => { - it('cannot be instantiated', () => { - expect(() => new RequiredDocumentBuilder()) - .toThrow(new TypeError('RequiredDocumentBuilder cannot be instantiated')); - }); -}); From f3804b40e0ee5fa7d0ecaba98c497001ed3b39a9 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Tue, 21 Apr 2020 15:06:27 +0100 Subject: [PATCH 21/33] SDK-1460: Add document restriction builder --- index.js | 4 - src/doc_scan_service/index.js | 2 + .../document/document.restriction.builder.js | 27 +++++++ .../document.restrictions.filter.builder.js | 9 ++- .../document.restriction.builder.spec.js | 62 +++++++++++++++ ...cument.restrictions.filter.builder.spec.js | 75 ++++--------------- 6 files changed, 110 insertions(+), 69 deletions(-) create mode 100644 src/doc_scan_service/session/create/filters/document/document.restriction.builder.js create mode 100644 tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js diff --git a/index.js b/index.js index cb64ab6a..21e2c86c 100644 --- a/index.js +++ b/index.js @@ -33,8 +33,6 @@ const { DocumentRestrictionsFilterBuilder, DocumentRestrictionBuilder, OrthogonalRestrictionsFilterBuilder, - TypeRestrictionBuilder, - CountryRestrictionBuilder, } = require('./src/doc_scan_service'); module.exports = { @@ -68,6 +66,4 @@ module.exports = { DocumentRestrictionsFilterBuilder, DocumentRestrictionBuilder, OrthogonalRestrictionsFilterBuilder, - TypeRestrictionBuilder, - CountryRestrictionBuilder, }; diff --git a/src/doc_scan_service/index.js b/src/doc_scan_service/index.js index 529606ee..3c69a31b 100644 --- a/src/doc_scan_service/index.js +++ b/src/doc_scan_service/index.js @@ -12,6 +12,7 @@ const RequestedTextExtractionTaskBuilder = require('./session/create/task/reques const RequiredIdentityDocumentBuilder = require('./session/create/filters/required.identity.document.builder'); const DocumentRestrictionsFilterBuilder = require('./session/create/filters/document/document.restrictions.filter.builder'); const OrthogonalRestrictionsFilterBuilder = require('./session/create/filters/orthogonal/orthogonal.restrictions.filter.builder'); +const DocumentRestrictionBuilder = require('./session/create/filters/document/document.restriction.builder'); module.exports = { DocScanService, @@ -25,5 +26,6 @@ module.exports = { RequestedTextExtractionTaskBuilder, RequiredIdentityDocumentBuilder, DocumentRestrictionsFilterBuilder, + DocumentRestrictionBuilder, OrthogonalRestrictionsFilterBuilder, }; diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js new file mode 100644 index 00000000..71e1c56d --- /dev/null +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js @@ -0,0 +1,27 @@ +const Validation = require('../../../../../yoti_common/validation'); +const DocumentRestriction = require('./document.restriction'); + +class DocumentRestrictionBuilder { + constructor() { + this.countryCodes = []; + this.documentTypes = []; + } + + withDocumentTypes(documentTypes) { + Validation.isArrayOfStrings(documentTypes, 'documentType'); + this.documentTypes = documentTypes; + return this; + } + + withCountries(countryCodes) { + Validation.isArrayOfStrings(countryCodes, 'countryCode'); + this.countryCodes = countryCodes; + return this; + } + + build() { + return new DocumentRestriction(this.countryCodes, this.documentTypes); + } +} + +module.exports = DocumentRestrictionBuilder; diff --git a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js index 8f124208..3b14baf8 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js +++ b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.js @@ -1,5 +1,6 @@ const DocumentRestrictionsFilter = require('./document.restrictions.filter'); const DocumentRestriction = require('./document.restriction'); +const Validation = require('../../../../../yoti_common/validation'); const DocScanConstants = require('../../../../doc.scan.constants'); class DocumentRestrictionsFilterBuilder { @@ -24,13 +25,13 @@ class DocumentRestrictionsFilterBuilder { } /** - * @param {string[]} countryCodes - * @param {string[]} documentTypes + * @param {DocumentRestriction} documentRestriction * * @returns {this} */ - withDocumentRestriction(countryCodes, documentTypes) { - this.documents.push(new DocumentRestriction(countryCodes, documentTypes)); + withDocumentRestriction(documentRestriction) { + Validation.instanceOf(documentRestriction, DocumentRestriction, 'documentRestriction'); + this.documents.push(documentRestriction); return this; } diff --git a/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js b/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js new file mode 100644 index 00000000..84e0524a --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js @@ -0,0 +1,62 @@ +const { DocumentRestrictionBuilder } = require('../../../../../..'); +const DocumentRestriction = require('../../../../../../src/doc_scan_service/session/create/filters/document/document.restriction'); + +const SOME_DOCUMENT_TYPE = 'some-document-type'; +const SOME_OTHER_DOCUMENT_TYPE = 'some-other-document-type'; +const SOME_COUNTRY_CODE = 'some-country-code'; +const SOME_OTHER_COUNTRY_CODE = 'some-other-country-code'; + +describe('DocumentRestrictionBuilder', () => { + it('should build DocumentRestriction', () => { + const documentRestriction = new DocumentRestrictionBuilder().build(); + expect(documentRestriction).toBeInstanceOf(DocumentRestriction); + }); + it('should build DocumentRestriction with document types', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withDocumentTypes([ + SOME_DOCUMENT_TYPE, + SOME_OTHER_DOCUMENT_TYPE, + ]) + .build(); + + expect(JSON.stringify(documentRestriction)) + .toBe(JSON.stringify({ + document_types: [ + SOME_DOCUMENT_TYPE, + SOME_OTHER_DOCUMENT_TYPE, + ], + })); + }); + it('should build DocumentRestriction with country codes', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withCountries([ + SOME_COUNTRY_CODE, + SOME_OTHER_COUNTRY_CODE, + ]) + .build(); + + expect(JSON.stringify(documentRestriction)) + .toBe(JSON.stringify({ + country_codes: [ + SOME_COUNTRY_CODE, + SOME_OTHER_COUNTRY_CODE, + ], + })); + }); + it('should build DocumentRestriction with document type and country code', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withCountries([SOME_COUNTRY_CODE]) + .withDocumentTypes([SOME_DOCUMENT_TYPE]) + .build(); + + expect(JSON.stringify(documentRestriction)) + .toBe(JSON.stringify({ + document_types: [ + SOME_DOCUMENT_TYPE, + ], + country_codes: [ + SOME_COUNTRY_CODE, + ], + })); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js b/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js index 01164168..39f06b7f 100644 --- a/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js +++ b/tests/doc_scan_service/session/create/filters/document/document.restrictions.filter.builder.spec.js @@ -1,5 +1,6 @@ const { DocumentRestrictionsFilterBuilder, + DocumentRestrictionBuilder, } = require('../../../../../..'); const SOME_DOCUMENT_TYPE = 'some-document-type'; @@ -34,30 +35,14 @@ describe('DocumentRestrictionsFilterBuilder', () => { })); }); - it('should build DocumentRestrictionsFilter with document type', () => { - const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() - .forWhitelist() - .withDocumentRestriction([], [SOME_DOCUMENT_TYPE]) + it('should build DocumentRestrictionsFilter with document restriction', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withDocumentTypes([SOME_DOCUMENT_TYPE]) .build(); - expect(JSON.stringify(documentRestrictionsFilter)) - .toBe(JSON.stringify({ - type: 'DOCUMENT_RESTRICTIONS', - inclusion: 'WHITELIST', - documents: [ - { - document_types: [ - SOME_DOCUMENT_TYPE, - ], - }, - ], - })); - }); - - it('should build DocumentRestrictionsFilter with multiple document types', () => { const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() .forWhitelist() - .withDocumentRestriction(null, [SOME_DOCUMENT_TYPE, SOME_OTHER_DOCUMENT_TYPE]) + .withDocumentRestriction(documentRestriction) .build(); expect(JSON.stringify(documentRestrictionsFilter)) @@ -68,59 +53,27 @@ describe('DocumentRestrictionsFilterBuilder', () => { { document_types: [ SOME_DOCUMENT_TYPE, - SOME_OTHER_DOCUMENT_TYPE, ], }, ], })); }); - it('should build DocumentRestrictionsFilter with country restriction', () => { - const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() - .forWhitelist() - .withDocumentRestriction([SOME_COUNTRY_CODE], []) + it('should build DocumentRestrictionsFilter with multiple document restrictions', () => { + const someRestriction = new DocumentRestrictionBuilder() + .withCountries([SOME_COUNTRY_CODE]) + .withDocumentTypes([SOME_DOCUMENT_TYPE]) .build(); - expect(JSON.stringify(documentRestrictionsFilter)) - .toBe(JSON.stringify({ - type: 'DOCUMENT_RESTRICTIONS', - inclusion: 'WHITELIST', - documents: [ - { - country_codes: [ - SOME_COUNTRY_CODE, - ], - }, - ], - })); - }); - - it('should build DocumentRestrictionsFilter with multiple countries', () => { - const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() - .forWhitelist() - .withDocumentRestriction([SOME_COUNTRY_CODE, SOME_OTHER_COUNTRY_CODE], []) + const someOtherRestriction = new DocumentRestrictionBuilder() + .withCountries([SOME_OTHER_COUNTRY_CODE]) + .withDocumentTypes([SOME_OTHER_DOCUMENT_TYPE]) .build(); - expect(JSON.stringify(documentRestrictionsFilter)) - .toBe(JSON.stringify({ - type: 'DOCUMENT_RESTRICTIONS', - inclusion: 'WHITELIST', - documents: [ - { - country_codes: [ - SOME_COUNTRY_CODE, - SOME_OTHER_COUNTRY_CODE, - ], - }, - ], - })); - }); - - it('should build DocumentRestrictionsFilter with multiple document restrictions', () => { const documentRestrictionsFilter = new DocumentRestrictionsFilterBuilder() .forWhitelist() - .withDocumentRestriction([SOME_COUNTRY_CODE], [SOME_DOCUMENT_TYPE]) - .withDocumentRestriction([SOME_OTHER_COUNTRY_CODE], [SOME_OTHER_DOCUMENT_TYPE]) + .withDocumentRestriction(someRestriction) + .withDocumentRestriction(someOtherRestriction) .build(); expect(JSON.stringify(documentRestrictionsFilter)) From a09ed6679c89cce7e9f834397f02b7031e4b5924 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Tue, 21 Apr 2020 16:46:48 +0100 Subject: [PATCH 22/33] SDK-1460: Rename RequiredIdentityDocument to RequiredIdDocument --- index.js | 4 ++-- src/doc_scan_service/index.js | 4 ++-- ...ment.builder.js => required.id.document.builder.js} | 10 +++++----- ...ed.identity.document.js => required.id.document.js} | 4 ++-- ...er.spec.js => required.id.document.builder.spec.js} | 10 +++++----- .../create/session.specification.builder.test.js | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) rename src/doc_scan_service/session/create/filters/{required.identity.document.builder.js => required.id.document.builder.js} (60%) rename src/doc_scan_service/session/create/filters/{required.identity.document.js => required.id.document.js} (85%) rename tests/doc_scan_service/session/create/filters/{required.identity.document.builder.spec.js => required.id.document.builder.spec.js} (78%) diff --git a/index.js b/index.js index 21e2c86c..2eb2a73a 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,7 @@ const { RequestedLivenessCheckBuilder, RequestedTextExtractionTaskBuilder, DocScanConstants, - RequiredIdentityDocumentBuilder, + RequiredIdDocumentBuilder, DocumentRestrictionsFilterBuilder, DocumentRestrictionBuilder, OrthogonalRestrictionsFilterBuilder, @@ -62,7 +62,7 @@ module.exports = { RequestedFaceMatchCheckBuilder, RequestedLivenessCheckBuilder, RequestedTextExtractionTaskBuilder, - RequiredIdentityDocumentBuilder, + RequiredIdDocumentBuilder, DocumentRestrictionsFilterBuilder, DocumentRestrictionBuilder, OrthogonalRestrictionsFilterBuilder, diff --git a/src/doc_scan_service/index.js b/src/doc_scan_service/index.js index 3c69a31b..89cf23f9 100644 --- a/src/doc_scan_service/index.js +++ b/src/doc_scan_service/index.js @@ -9,7 +9,7 @@ const RequestedDocumentAuthenticityCheckBuilder = require('./session/create/chec const RequestedFaceMatchCheckBuilder = require('./session/create/check/requested.face.match.check.builder'); const RequestedLivenessCheckBuilder = require('./session/create/check/requested.liveness.check.builder'); const RequestedTextExtractionTaskBuilder = require('./session/create/task/requested.text.extraction.task.builder'); -const RequiredIdentityDocumentBuilder = require('./session/create/filters/required.identity.document.builder'); +const RequiredIdDocumentBuilder = require('./session/create/filters/required.id.document.builder'); const DocumentRestrictionsFilterBuilder = require('./session/create/filters/document/document.restrictions.filter.builder'); const OrthogonalRestrictionsFilterBuilder = require('./session/create/filters/orthogonal/orthogonal.restrictions.filter.builder'); const DocumentRestrictionBuilder = require('./session/create/filters/document/document.restriction.builder'); @@ -24,7 +24,7 @@ module.exports = { RequestedFaceMatchCheckBuilder, RequestedLivenessCheckBuilder, RequestedTextExtractionTaskBuilder, - RequiredIdentityDocumentBuilder, + RequiredIdDocumentBuilder, DocumentRestrictionsFilterBuilder, DocumentRestrictionBuilder, OrthogonalRestrictionsFilterBuilder, diff --git a/src/doc_scan_service/session/create/filters/required.identity.document.builder.js b/src/doc_scan_service/session/create/filters/required.id.document.builder.js similarity index 60% rename from src/doc_scan_service/session/create/filters/required.identity.document.builder.js rename to src/doc_scan_service/session/create/filters/required.id.document.builder.js index 4856de0b..40ce6aef 100644 --- a/src/doc_scan_service/session/create/filters/required.identity.document.builder.js +++ b/src/doc_scan_service/session/create/filters/required.id.document.builder.js @@ -1,8 +1,8 @@ -const RequiredIdentityDocument = require('./required.identity.document'); +const RequiredIdDocument = require('./required.id.document'); const RequiredDocumentFilter = require('./required.document.filter'); const Validation = require('../../../../yoti_common/validation'); -class RequiredIdentityDocumentBuilder { +class RequiredIdDocumentBuilder { /** * @param {RequiredDocumentFilter} filter * @@ -15,11 +15,11 @@ class RequiredIdentityDocumentBuilder { } /** - * @returns {RequiredIdentityDocument} + * @returns {RequiredIdDocument} */ build() { - return new RequiredIdentityDocument(this.filter); + return new RequiredIdDocument(this.filter); } } -module.exports = RequiredIdentityDocumentBuilder; +module.exports = RequiredIdDocumentBuilder; diff --git a/src/doc_scan_service/session/create/filters/required.identity.document.js b/src/doc_scan_service/session/create/filters/required.id.document.js similarity index 85% rename from src/doc_scan_service/session/create/filters/required.identity.document.js rename to src/doc_scan_service/session/create/filters/required.id.document.js index 4585cd57..4fa396c2 100644 --- a/src/doc_scan_service/session/create/filters/required.identity.document.js +++ b/src/doc_scan_service/session/create/filters/required.id.document.js @@ -3,7 +3,7 @@ const RequiredDocumentFilter = require('./required.document.filter'); const DocScanConstants = require('../../../doc.scan.constants'); const Validation = require('../../../../yoti_common/validation'); -class RequiredIdentityDocument extends RequiredDocument { +class RequiredIdDocument extends RequiredDocument { /** * @param {RequiredDocumentFilter} filter */ @@ -23,4 +23,4 @@ class RequiredIdentityDocument extends RequiredDocument { } } -module.exports = RequiredIdentityDocument; +module.exports = RequiredIdDocument; diff --git a/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js b/tests/doc_scan_service/session/create/filters/required.id.document.builder.spec.js similarity index 78% rename from tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js rename to tests/doc_scan_service/session/create/filters/required.id.document.builder.spec.js index d85f2159..e6ad152e 100644 --- a/tests/doc_scan_service/session/create/filters/required.identity.document.builder.spec.js +++ b/tests/doc_scan_service/session/create/filters/required.id.document.builder.spec.js @@ -1,12 +1,12 @@ const { - RequiredIdentityDocumentBuilder, + RequiredIdDocumentBuilder, OrthogonalRestrictionsFilterBuilder, DocumentRestrictionsFilterBuilder, } = require('../../../../..'); -describe('RequiredIdentityDocumentBuilder', () => { +describe('RequiredIdDocumentBuilder', () => { it('builds RequiredIdentityDocument without filter', () => { - const requiredIdentityDocument = new RequiredIdentityDocumentBuilder() + const requiredIdentityDocument = new RequiredIdDocumentBuilder() .build(); expect(JSON.stringify(requiredIdentityDocument)) @@ -16,7 +16,7 @@ describe('RequiredIdentityDocumentBuilder', () => { }); it('builds RequiredIdentityDocument with orthogonal filter', () => { - const requiredIdentityDocument = new RequiredIdentityDocumentBuilder() + const requiredIdentityDocument = new RequiredIdDocumentBuilder() .withFilter(new OrthogonalRestrictionsFilterBuilder().build()) .build(); @@ -30,7 +30,7 @@ describe('RequiredIdentityDocumentBuilder', () => { }); it('builds RequiredIdentityDocument with document filter', () => { - const requiredIdentityDocument = new RequiredIdentityDocumentBuilder() + const requiredIdentityDocument = new RequiredIdDocumentBuilder() .withFilter(new DocumentRestrictionsFilterBuilder().forWhitelist().build()) .build(); diff --git a/tests/doc_scan_service/session/create/session.specification.builder.test.js b/tests/doc_scan_service/session/create/session.specification.builder.test.js index 75fe48f0..4d78b112 100644 --- a/tests/doc_scan_service/session/create/session.specification.builder.test.js +++ b/tests/doc_scan_service/session/create/session.specification.builder.test.js @@ -6,7 +6,7 @@ const { RequestedDocumentAuthenticityCheckBuilder, NotificationConfigBuilder, SdkConfigBuilder, - RequiredIdentityDocumentBuilder, + RequiredIdDocumentBuilder, DocumentRestrictionsFilterBuilder, } = require('../../../../'); @@ -38,7 +38,7 @@ describe('SessionSpecificationBuilder', () => { const documentFilter = new DocumentRestrictionsFilterBuilder() .forWhitelist() .build(); - const requiredDocument = new RequiredIdentityDocumentBuilder() + const requiredDocument = new RequiredIdDocumentBuilder() .withFilter(documentFilter) .build(); From 322adf7e76a9c1309cc17b79aa790194c08b27ba Mon Sep 17 00:00:00 2001 From: David Grayston Date: Tue, 21 Apr 2020 16:55:54 +0100 Subject: [PATCH 23/33] SDK-1460: Rename RequiredDocumentFilter to DocumentFilter --- .../{required.document.filter.js => document.filter.js} | 8 ++++---- .../filters/document/document.restrictions.filter.js | 4 ++-- .../filters/orthogonal/orthogonal.restrictions.filter.js | 4 ++-- .../create/filters/required.id.document.builder.js | 6 +++--- .../session/create/filters/required.id.document.js | 6 +++--- .../session/create/filters/document.filter.spec.js | 8 ++++++++ .../create/filters/required.document.filter.spec.js | 8 -------- 7 files changed, 22 insertions(+), 22 deletions(-) rename src/doc_scan_service/session/create/filters/{required.document.filter.js => document.filter.js} (57%) create mode 100644 tests/doc_scan_service/session/create/filters/document.filter.spec.js delete mode 100644 tests/doc_scan_service/session/create/filters/required.document.filter.spec.js diff --git a/src/doc_scan_service/session/create/filters/required.document.filter.js b/src/doc_scan_service/session/create/filters/document.filter.js similarity index 57% rename from src/doc_scan_service/session/create/filters/required.document.filter.js rename to src/doc_scan_service/session/create/filters/document.filter.js index e7cab48d..375c66b5 100644 --- a/src/doc_scan_service/session/create/filters/required.document.filter.js +++ b/src/doc_scan_service/session/create/filters/document.filter.js @@ -1,12 +1,12 @@ const Validation = require('../../../../yoti_common/validation'); -class RequiredDocumentFilter { +class DocumentFilter { /** * @param {string} type */ constructor(type) { - if (new.target === RequiredDocumentFilter) { - throw TypeError('RequiredDocumentFilter cannot be instantiated'); + if (new.target === DocumentFilter) { + throw TypeError('DocumentFilter cannot be instantiated'); } Validation.isString(type, 'type'); @@ -20,4 +20,4 @@ class RequiredDocumentFilter { } } -module.exports = RequiredDocumentFilter; +module.exports = DocumentFilter; diff --git a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js index 81ea4786..df069370 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js +++ b/src/doc_scan_service/session/create/filters/document/document.restrictions.filter.js @@ -1,9 +1,9 @@ const Validation = require('../../../../../yoti_common/validation'); -const RequiredDocumentFilter = require('../required.document.filter'); +const DocumentFilter = require('../document.filter'); const DocumentRestriction = require('./document.restriction'); const DocScanConstants = require('../../../../doc.scan.constants'); -class DocumentRestrictionsFilter extends RequiredDocumentFilter { +class DocumentRestrictionsFilter extends DocumentFilter { /** * @param {string} inclusion * @param {DocumentRestriction[]} documents diff --git a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js index 6baa1010..d6931c0b 100644 --- a/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js +++ b/src/doc_scan_service/session/create/filters/orthogonal/orthogonal.restrictions.filter.js @@ -1,10 +1,10 @@ const Validation = require('../../../../../yoti_common/validation'); -const RequiredDocumentFilter = require('../required.document.filter'); +const DocumentFilter = require('../document.filter'); const DocScanConstants = require('../../../../doc.scan.constants'); const TypeRestriction = require('./type.restriction'); const CountryRestriction = require('./country.restriction'); -class OrthogonalRestrictionsFilter extends RequiredDocumentFilter { +class OrthogonalRestrictionsFilter extends DocumentFilter { /** * @param {CountryRestriction} countryRestriction * @param {TypeRestriction} typeRestriction diff --git a/src/doc_scan_service/session/create/filters/required.id.document.builder.js b/src/doc_scan_service/session/create/filters/required.id.document.builder.js index 40ce6aef..1d1a8012 100644 --- a/src/doc_scan_service/session/create/filters/required.id.document.builder.js +++ b/src/doc_scan_service/session/create/filters/required.id.document.builder.js @@ -1,15 +1,15 @@ const RequiredIdDocument = require('./required.id.document'); -const RequiredDocumentFilter = require('./required.document.filter'); +const DocumentFilter = require('./document.filter'); const Validation = require('../../../../yoti_common/validation'); class RequiredIdDocumentBuilder { /** - * @param {RequiredDocumentFilter} filter + * @param {DocumentFilter} filter * * @returns {this} */ withFilter(filter) { - Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); + Validation.instanceOf(filter, DocumentFilter, 'filter'); this.filter = filter; return this; } diff --git a/src/doc_scan_service/session/create/filters/required.id.document.js b/src/doc_scan_service/session/create/filters/required.id.document.js index 4fa396c2..0f8d4c6a 100644 --- a/src/doc_scan_service/session/create/filters/required.id.document.js +++ b/src/doc_scan_service/session/create/filters/required.id.document.js @@ -1,17 +1,17 @@ const RequiredDocument = require('./required.document'); -const RequiredDocumentFilter = require('./required.document.filter'); +const DocumentFilter = require('./document.filter'); const DocScanConstants = require('../../../doc.scan.constants'); const Validation = require('../../../../yoti_common/validation'); class RequiredIdDocument extends RequiredDocument { /** - * @param {RequiredDocumentFilter} filter + * @param {DocumentFilter} filter */ constructor(filter) { super(DocScanConstants.ID_DOCUMENT); if (filter) { - Validation.instanceOf(filter, RequiredDocumentFilter, 'filter'); + Validation.instanceOf(filter, DocumentFilter, 'filter'); this.filter = filter; } } diff --git a/tests/doc_scan_service/session/create/filters/document.filter.spec.js b/tests/doc_scan_service/session/create/filters/document.filter.spec.js new file mode 100644 index 00000000..db0e9b43 --- /dev/null +++ b/tests/doc_scan_service/session/create/filters/document.filter.spec.js @@ -0,0 +1,8 @@ +const DocumentFilter = require('../../../../../src/doc_scan_service/session/create/filters/document.filter'); + +describe('DocumentFilter', () => { + it('cannot be instantiated', () => { + expect(() => new DocumentFilter()) + .toThrow(new TypeError('DocumentFilter cannot be instantiated')); + }); +}); diff --git a/tests/doc_scan_service/session/create/filters/required.document.filter.spec.js b/tests/doc_scan_service/session/create/filters/required.document.filter.spec.js deleted file mode 100644 index d2c49527..00000000 --- a/tests/doc_scan_service/session/create/filters/required.document.filter.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -const RequiredDocumentFilter = require('../../../../../src/doc_scan_service/session/create/filters/required.document.filter'); - -describe('RequiredDocumentFilter', () => { - it('cannot be instantiated', () => { - expect(() => new RequiredDocumentFilter()) - .toThrow(new TypeError('RequiredDocumentFilter cannot be instantiated')); - }); -}); From 668c17b8d50d7df9debdc3852c8cfa414578f7c9 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Mon, 27 Apr 2020 18:03:37 +0100 Subject: [PATCH 24/33] SDK-1460: Allow empty lists to be set on filters --- .../document/document.restriction.builder.js | 5 ---- .../filters/document/document.restriction.js | 4 ++-- .../document.restriction.builder.spec.js | 24 +++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js index 71e1c56d..f2d5bb59 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.builder.js @@ -2,11 +2,6 @@ const Validation = require('../../../../../yoti_common/validation'); const DocumentRestriction = require('./document.restriction'); class DocumentRestrictionBuilder { - constructor() { - this.countryCodes = []; - this.documentTypes = []; - } - withDocumentTypes(documentTypes) { Validation.isArrayOfStrings(documentTypes, 'documentType'); this.documentTypes = documentTypes; diff --git a/src/doc_scan_service/session/create/filters/document/document.restriction.js b/src/doc_scan_service/session/create/filters/document/document.restriction.js index e06d7942..bf60c36f 100644 --- a/src/doc_scan_service/session/create/filters/document/document.restriction.js +++ b/src/doc_scan_service/session/create/filters/document/document.restriction.js @@ -6,12 +6,12 @@ class DocumentRestriction { * @param {string[]} documentTypes */ constructor(countryCodes, documentTypes) { - if (countryCodes && countryCodes.length > 0) { + if (countryCodes) { Validation.isArrayOfStrings(countryCodes, 'countryCodes'); this.countryCodes = countryCodes; } - if (documentTypes && documentTypes.length > 0) { + if (documentTypes) { Validation.isArrayOfStrings(documentTypes, 'documentTypes'); this.documentTypes = documentTypes; } diff --git a/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js b/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js index 84e0524a..f08cdff6 100644 --- a/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js +++ b/tests/doc_scan_service/session/create/filters/document/document.restriction.builder.spec.js @@ -11,6 +11,7 @@ describe('DocumentRestrictionBuilder', () => { const documentRestriction = new DocumentRestrictionBuilder().build(); expect(documentRestriction).toBeInstanceOf(DocumentRestriction); }); + it('should build DocumentRestriction with document types', () => { const documentRestriction = new DocumentRestrictionBuilder() .withDocumentTypes([ @@ -27,6 +28,7 @@ describe('DocumentRestrictionBuilder', () => { ], })); }); + it('should build DocumentRestriction with country codes', () => { const documentRestriction = new DocumentRestrictionBuilder() .withCountries([ @@ -59,4 +61,26 @@ describe('DocumentRestrictionBuilder', () => { ], })); }); + + it('should allow empty country list', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withCountries([]) + .build(); + + expect(JSON.stringify(documentRestriction)) + .toBe(JSON.stringify({ + country_codes: [], + })); + }); + + it('should allow empty document type list', () => { + const documentRestriction = new DocumentRestrictionBuilder() + .withDocumentTypes([]) + .build(); + + expect(JSON.stringify(documentRestriction)) + .toBe(JSON.stringify({ + document_types: [], + })); + }); }); From c7cc940ca26c4385945e5540d007af5b3c045609 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Wed, 29 Apr 2020 11:07:58 +0100 Subject: [PATCH 25/33] SDK-1460: Only validate required documents when provided --- .../session/create/session.specification.js | 6 ++-- .../session.specification.builder.test.js | 1 + .../create/session.specification.test.js | 36 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/doc_scan_service/session/create/session.specification.test.js diff --git a/src/doc_scan_service/session/create/session.specification.js b/src/doc_scan_service/session/create/session.specification.js index daba8000..f30d8c14 100644 --- a/src/doc_scan_service/session/create/session.specification.js +++ b/src/doc_scan_service/session/create/session.specification.js @@ -66,8 +66,10 @@ class SessionSpecification { Validation.isArrayOfType(requestedTasks, RequestedTask, 'requestedTasks'); this.requestedTasks = requestedTasks; - Validation.isArrayOfType(requiredDocuments, RequiredDocument, 'requiredDocuments'); - this.requiredDocuments = requiredDocuments; + if (requiredDocuments) { + Validation.isArrayOfType(requiredDocuments, RequiredDocument, 'requiredDocuments'); + this.requiredDocuments = requiredDocuments; + } } /** diff --git a/tests/doc_scan_service/session/create/session.specification.builder.test.js b/tests/doc_scan_service/session/create/session.specification.builder.test.js index 4d78b112..c0be0507 100644 --- a/tests/doc_scan_service/session/create/session.specification.builder.test.js +++ b/tests/doc_scan_service/session/create/session.specification.builder.test.js @@ -38,6 +38,7 @@ describe('SessionSpecificationBuilder', () => { const documentFilter = new DocumentRestrictionsFilterBuilder() .forWhitelist() .build(); + const requiredDocument = new RequiredIdDocumentBuilder() .withFilter(documentFilter) .build(); diff --git a/tests/doc_scan_service/session/create/session.specification.test.js b/tests/doc_scan_service/session/create/session.specification.test.js new file mode 100644 index 00000000..d5cc8b3f --- /dev/null +++ b/tests/doc_scan_service/session/create/session.specification.test.js @@ -0,0 +1,36 @@ +const SessionSpecification = require('../../../../src/doc_scan_service/session/create/session.specification'); + +const { + NotificationConfigBuilder, + SdkConfigBuilder, +} = require('../../../../'); + +const SOME_TRACKING_ID = 'some-tracking-id'; + +describe('SessionSpecification', () => { + it('should serialize to JSON without optional parameters', () => { + const sessionSpec = new SessionSpecification( + 30, + 10, + SOME_TRACKING_ID, + new NotificationConfigBuilder().build(), + [], + [], + new SdkConfigBuilder().build() + ); + + const expectedJson = JSON.stringify({ + client_session_token_ttl: 30, + resources_ttl: 10, + user_tracking_id: SOME_TRACKING_ID, + notifications: { + topics: [], + }, + requested_checks: [], + requested_tasks: [], + sdk_config: {}, + }); + + expect(JSON.stringify(sessionSpec)).toBe(expectedJson); + }); +}); From e35c5612f7cfe99b843264b98153a9e8833a3403 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Wed, 22 Apr 2020 15:54:17 +0100 Subject: [PATCH 26/33] SDK-1549: Add type to check and task responses --- .../session/retrieve/check.response.js | 10 ++++++++++ .../session/retrieve/task.response.js | 10 ++++++++++ .../authenticity.check.response.spec.js | 7 +++++++ .../session/retrieve/check.response.spec.js | 7 +++++++ .../retrieve/face.match.check.response.spec.js | 7 +++++++ .../session/retrieve/get.session.result.spec.js | 17 +++++++++++++---- .../retrieve/liveness.check.response.spec.js | 7 +++++++ .../session/retrieve/task.response.spec.js | 7 ++++--- .../text.extraction.task.response.spec.js | 13 +++++++++---- 9 files changed, 74 insertions(+), 11 deletions(-) diff --git a/src/doc_scan_service/session/retrieve/check.response.js b/src/doc_scan_service/session/retrieve/check.response.js index 47de2bfa..ca792928 100644 --- a/src/doc_scan_service/session/retrieve/check.response.js +++ b/src/doc_scan_service/session/retrieve/check.response.js @@ -7,6 +7,9 @@ const { YotiDate } = require('../../../data_type/date'); class CheckResponse { constructor(check) { + Validation.isString(check.type, 'type', true); + this.type = check.type; + Validation.isString(check.id, 'id', true); this.id = check.id; @@ -42,6 +45,13 @@ class CheckResponse { } } + /** + * @returns {string} + */ + getType() { + return this.type; + } + /** * @returns {string} */ diff --git a/src/doc_scan_service/session/retrieve/task.response.js b/src/doc_scan_service/session/retrieve/task.response.js index 6249533a..a52e3df9 100644 --- a/src/doc_scan_service/session/retrieve/task.response.js +++ b/src/doc_scan_service/session/retrieve/task.response.js @@ -9,6 +9,9 @@ const { YotiDate } = require('../../../data_type/date'); class TaskResponse { constructor(task) { + Validation.isString(task.type, 'type', true); + this.type = task.type; + Validation.isString(task.id, 'id', true); this.id = task.id; @@ -48,6 +51,13 @@ class TaskResponse { } } + /** + * @returns {string} + */ + getType() { + return this.type; + } + /** * @returns {string} */ diff --git a/tests/doc_scan_service/session/retrieve/authenticity.check.response.spec.js b/tests/doc_scan_service/session/retrieve/authenticity.check.response.spec.js index d4b6634c..e1006831 100644 --- a/tests/doc_scan_service/session/retrieve/authenticity.check.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/authenticity.check.response.spec.js @@ -9,6 +9,7 @@ describe('AuthenticityCheckResponse', () => { beforeEach(() => { checkResponse = new AuthenticityCheckResponse({ + type: 'some-type', id: 'some-id', state: 'some-state', created: '2006-01-02T22:04:05.123Z', @@ -29,6 +30,12 @@ describe('AuthenticityCheckResponse', () => { expect(checkResponse).toBeInstanceOf(CheckResponse); }); + describe('#getType', () => { + it('should return Type', () => { + expect(checkResponse.getType()).toBe('some-type'); + }); + }); + describe('#getId', () => { it('should return ID', () => { expect(checkResponse.getId()).toBe('some-id'); diff --git a/tests/doc_scan_service/session/retrieve/check.response.spec.js b/tests/doc_scan_service/session/retrieve/check.response.spec.js index 5b523adc..e392ab21 100644 --- a/tests/doc_scan_service/session/retrieve/check.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/check.response.spec.js @@ -8,6 +8,7 @@ describe('CheckResponse', () => { beforeEach(() => { checkResponse = new CheckResponse({ + type: 'some-type', id: 'some-id', state: 'some-state', created: '2006-01-02T22:04:05.123Z', @@ -24,6 +25,12 @@ describe('CheckResponse', () => { }); }); + describe('#getType', () => { + it('should return type', () => { + expect(checkResponse.getType()).toBe('some-type'); + }); + }); + describe('#getId', () => { it('should return ID', () => { expect(checkResponse.getId()).toBe('some-id'); diff --git a/tests/doc_scan_service/session/retrieve/face.match.check.response.spec.js b/tests/doc_scan_service/session/retrieve/face.match.check.response.spec.js index 7bfc6937..da171c0a 100644 --- a/tests/doc_scan_service/session/retrieve/face.match.check.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/face.match.check.response.spec.js @@ -9,6 +9,7 @@ describe('FaceMatchCheckResponse', () => { beforeEach(() => { checkResponse = new FaceMatchCheckResponse({ + type: 'some-type', id: 'some-id', state: 'some-state', created: '2006-01-02T22:04:05.123Z', @@ -29,6 +30,12 @@ describe('FaceMatchCheckResponse', () => { expect(checkResponse).toBeInstanceOf(CheckResponse); }); + describe('#getType', () => { + it('should return Type', () => { + expect(checkResponse.getType()).toBe('some-type'); + }); + }); + describe('#getId', () => { it('should return ID', () => { expect(checkResponse.getId()).toBe('some-id'); diff --git a/tests/doc_scan_service/session/retrieve/get.session.result.spec.js b/tests/doc_scan_service/session/retrieve/get.session.result.spec.js index 21071c1d..f6cdaf10 100644 --- a/tests/doc_scan_service/session/retrieve/get.session.result.spec.js +++ b/tests/doc_scan_service/session/retrieve/get.session.result.spec.js @@ -6,6 +6,11 @@ const TextDataCheckResponse = require('../../../../src/doc_scan_service/session/ const ZoomLivenessCheckResponse = require('../../../../src/doc_scan_service/session/retrieve/liveness.check.response'); const ResourceContainer = require('../../../../src/doc_scan_service/session/retrieve/resource.container'); +const ID_DOCUMENT_AUTHENTICITY = 'ID_DOCUMENT_AUTHENTICITY'; +const ID_DOCUMENT_FACE_MATCH = 'ID_DOCUMENT_FACE_MATCH'; +const ID_DOCUMENT_TEXT_DATA_CHECK = 'ID_DOCUMENT_TEXT_DATA_CHECK'; +const LIVENESS = 'LIVENESS'; + describe('GetSessionResult', () => { let session; @@ -22,16 +27,16 @@ describe('GetSessionResult', () => { }, checks: [ { - type: 'ID_DOCUMENT_AUTHENTICITY', + type: ID_DOCUMENT_AUTHENTICITY, }, { - type: 'LIVENESS', + type: LIVENESS, }, { - type: 'ID_DOCUMENT_FACE_MATCH', + type: ID_DOCUMENT_FACE_MATCH, }, { - type: 'ID_DOCUMENT_TEXT_DATA_CHECK', + type: ID_DOCUMENT_TEXT_DATA_CHECK, }, ], }); @@ -94,6 +99,7 @@ describe('GetSessionResult', () => { const checks = session.getAuthenticityChecks(); expect(checks.length).toBe(1); expect(checks[0]).toBeInstanceOf(AuthenticityCheckResponse); + expect(checks[0].getType()).toBe(ID_DOCUMENT_AUTHENTICITY); }); }); @@ -102,6 +108,7 @@ describe('GetSessionResult', () => { const checks = session.getLivenessChecks(); expect(checks.length).toBe(1); expect(checks[0]).toBeInstanceOf(ZoomLivenessCheckResponse); + expect(checks[0].getType()).toBe(LIVENESS); }); }); @@ -110,6 +117,7 @@ describe('GetSessionResult', () => { const checks = session.getTextDataChecks(); expect(checks.length).toBe(1); expect(checks[0]).toBeInstanceOf(TextDataCheckResponse); + expect(checks[0].getType()).toBe(ID_DOCUMENT_TEXT_DATA_CHECK); }); }); @@ -118,6 +126,7 @@ describe('GetSessionResult', () => { const checks = session.getFaceMatchChecks(); expect(checks.length).toBe(1); expect(checks[0]).toBeInstanceOf(FaceMatchCheckResponse); + expect(checks[0].getType()).toBe(ID_DOCUMENT_FACE_MATCH); }); }); diff --git a/tests/doc_scan_service/session/retrieve/liveness.check.response.spec.js b/tests/doc_scan_service/session/retrieve/liveness.check.response.spec.js index 559ad40c..0c7f83c3 100644 --- a/tests/doc_scan_service/session/retrieve/liveness.check.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/liveness.check.response.spec.js @@ -9,6 +9,7 @@ describe('LivenessCheckResponse', () => { beforeEach(() => { checkResponse = new LivenessCheckResponse({ + type: 'some-type', id: 'some-id', state: 'some-state', created: '2006-01-02T22:04:05.123Z', @@ -29,6 +30,12 @@ describe('LivenessCheckResponse', () => { expect(checkResponse).toBeInstanceOf(CheckResponse); }); + describe('#getType', () => { + it('should return Type', () => { + expect(checkResponse.getType()).toBe('some-type'); + }); + }); + describe('#getId', () => { it('should return ID', () => { expect(checkResponse.getId()).toBe('some-id'); diff --git a/tests/doc_scan_service/session/retrieve/task.response.spec.js b/tests/doc_scan_service/session/retrieve/task.response.spec.js index aa0b380e..b3087233 100644 --- a/tests/doc_scan_service/session/retrieve/task.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/task.response.spec.js @@ -9,6 +9,7 @@ describe('TaskResponse', () => { beforeEach(() => { taskResponse = new TaskResponse({ + type: 'some-type', id: 'some-id', state: 'some-state', created: '2006-01-02T22:04:05.123Z', @@ -29,9 +30,9 @@ describe('TaskResponse', () => { }); }); - describe('#getId', () => { - it('should be instance of TaskResponse', () => { - expect(taskResponse).toBeInstanceOf(TaskResponse); + describe('#getType', () => { + it('should return Type', () => { + expect(taskResponse.getType()).toBe('some-type'); }); }); diff --git a/tests/doc_scan_service/session/retrieve/text.extraction.task.response.spec.js b/tests/doc_scan_service/session/retrieve/text.extraction.task.response.spec.js index a30f3dfa..2224244d 100644 --- a/tests/doc_scan_service/session/retrieve/text.extraction.task.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/text.extraction.task.response.spec.js @@ -9,6 +9,7 @@ describe('TextExtractionTaskResponse', () => { beforeEach(() => { taskResponse = new TextExtractionTaskResponse({ + type: 'some-type', id: 'some-id', state: 'some-state', created: '2006-01-02T22:04:05.123Z', @@ -26,10 +27,8 @@ describe('TextExtractionTaskResponse', () => { }); }); - describe('#getId', () => { - it('should be instance of TaskResponse', () => { - expect(taskResponse).toBeInstanceOf(TaskResponse); - }); + it('should be instance of TaskResponse', () => { + expect(taskResponse).toBeInstanceOf(TaskResponse); }); describe('#getId', () => { @@ -38,6 +37,12 @@ describe('TextExtractionTaskResponse', () => { }); }); + describe('#getType', () => { + it('should return type', () => { + expect(taskResponse.getType()).toBe('some-type'); + }); + }); + describe('#getState', () => { it('should return state', () => { expect(taskResponse.getState()).toBe('some-state'); From 89970977d8ef2bd124141c8bc0253e5e9c82e33f Mon Sep 17 00:00:00 2001 From: David Grayston Date: Wed, 22 Apr 2020 16:09:43 +0100 Subject: [PATCH 27/33] SDK-1549: Add test coverage for unknown check/task types --- .../session/retrieve/get.session.result.spec.js | 4 +++- .../retrieve/id.document.resource.response.spec.js | 10 ++++++++++ .../session/retrieve/resource.response.spec.js | 10 ++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/doc_scan_service/session/retrieve/get.session.result.spec.js b/tests/doc_scan_service/session/retrieve/get.session.result.spec.js index f6cdaf10..25c0962e 100644 --- a/tests/doc_scan_service/session/retrieve/get.session.result.spec.js +++ b/tests/doc_scan_service/session/retrieve/get.session.result.spec.js @@ -10,6 +10,7 @@ const ID_DOCUMENT_AUTHENTICITY = 'ID_DOCUMENT_AUTHENTICITY'; const ID_DOCUMENT_FACE_MATCH = 'ID_DOCUMENT_FACE_MATCH'; const ID_DOCUMENT_TEXT_DATA_CHECK = 'ID_DOCUMENT_TEXT_DATA_CHECK'; const LIVENESS = 'LIVENESS'; +const SOME_UNKNOWN_CHECK = 'SOME_UNKNOWN_CHECK'; describe('GetSessionResult', () => { let session; @@ -142,7 +143,7 @@ describe('GetSessionResult', () => { session = new GetSessionResult({ checks: [ { - type: 'SOME_UNKNOWN_CHECK', + type: SOME_UNKNOWN_CHECK, }, ], }); @@ -150,6 +151,7 @@ describe('GetSessionResult', () => { const checks = session.getChecks(); expect(checks.length).toBe(1); expect(checks[0]).toBeInstanceOf(CheckResponse); + expect(checks[0].getType()).toBe(SOME_UNKNOWN_CHECK); }); }); }); diff --git a/tests/doc_scan_service/session/retrieve/id.document.resource.response.spec.js b/tests/doc_scan_service/session/retrieve/id.document.resource.response.spec.js index 6c339019..ec9d4329 100644 --- a/tests/doc_scan_service/session/retrieve/id.document.resource.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/id.document.resource.response.spec.js @@ -2,6 +2,7 @@ const IdDocumentResourceResponse = require('../../../../src/doc_scan_service/session/retrieve/id.document.resource.response'); const PageResponse = require('../../../../src/doc_scan_service/session/retrieve/page.response'); const DocumentFieldsResponse = require('../../../../src/doc_scan_service/session/retrieve/document.fields.response'); +const TaskResponse = require('../../../../src/doc_scan_service/session/retrieve/task.response'); const TextExtractionTaskResponse = require('../../../../src/doc_scan_service/session/retrieve/text.extraction.task.response'); describe('IdDocumentResourceResponse', () => { @@ -53,6 +54,15 @@ describe('IdDocumentResourceResponse', () => { }); }); + describe('#getTasks', () => { + it('should return a list of TaskResponse', () => { + const tasks = documentResourceResponse.getTasks(); + tasks.forEach((task) => { + expect(task).toBeInstanceOf(TaskResponse); + }); + }); + }); + describe('#getTextExtractionTasks', () => { it('should return a list of TextExtractionTaskResponse', () => { const tasks = documentResourceResponse.getTextExtractionTasks(); diff --git a/tests/doc_scan_service/session/retrieve/resource.response.spec.js b/tests/doc_scan_service/session/retrieve/resource.response.spec.js index 9fdb7e0e..69238581 100644 --- a/tests/doc_scan_service/session/retrieve/resource.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/resource.response.spec.js @@ -3,6 +3,9 @@ const ResourceResponse = require('../../../../src/doc_scan_service/session/retri const TaskResponse = require('../../../../src/doc_scan_service/session/retrieve/task.response'); const TextExtractionTaskResponse = require('../../../../src/doc_scan_service/session/retrieve/text.extraction.task.response'); +const ID_DOCUMENT_TEXT_DATA_EXTRACTION = 'ID_DOCUMENT_TEXT_DATA_EXTRACTION'; +const SOME_UNKNOWN_TASK = 'SOME_UNKNOWN_TASK'; + describe('ResourceResponse', () => { let resourceResponse; @@ -11,10 +14,10 @@ describe('ResourceResponse', () => { id: 'some-id', tasks: [ { - type: 'ID_DOCUMENT_TEXT_DATA_EXTRACTION', + type: ID_DOCUMENT_TEXT_DATA_EXTRACTION, }, { - type: 'SOME_UNKNOWN_TYPE', + type: SOME_UNKNOWN_TASK, }, ], }); @@ -38,6 +41,9 @@ describe('ResourceResponse', () => { }); expect(tasks[0]).toBeInstanceOf(TextExtractionTaskResponse); + expect(tasks[0].getType()).toBe(ID_DOCUMENT_TEXT_DATA_EXTRACTION); + + expect(tasks[1].getType()).toBe(SOME_UNKNOWN_TASK); }); }); describe('when tasks are not available', () => { From 6e99edc2ff4b1d449155547eb2966c9acf8fc748 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 23 Apr 2020 12:30:03 +0100 Subject: [PATCH 28/33] SDK-1549: Add type to GeneratedCheckResponse and LivenessResourceResponse --- .../session/retrieve/generated.check.response.js | 10 ++++++++++ .../retrieve/liveness.resource.response.js | 14 ++++++++++++++ .../retrieve/generated.check.response.spec.js | 7 +++++++ .../generated.text.data.check.response.spec.js | 7 +++++++ .../retrieve/liveness.resource.response.spec.js | 7 +++++++ .../session/retrieve/task.response.spec.js | 15 +++++++++------ .../zoom.liveness.resource.response.spec.js | 14 ++++++++++++++ 7 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/doc_scan_service/session/retrieve/generated.check.response.js b/src/doc_scan_service/session/retrieve/generated.check.response.js index a9f47bc9..1749b034 100644 --- a/src/doc_scan_service/session/retrieve/generated.check.response.js +++ b/src/doc_scan_service/session/retrieve/generated.check.response.js @@ -6,6 +6,9 @@ class GeneratedCheckResponse { constructor(check) { Validation.isString(check.id, 'id', true); this.id = check.id; + + Validation.isString(check.type, 'type', true); + this.type = check.type; } /** @@ -14,6 +17,13 @@ class GeneratedCheckResponse { getId() { return this.id; } + + /** + * @returns {string} + */ + getType() { + return this.type; + } } module.exports = GeneratedCheckResponse; diff --git a/src/doc_scan_service/session/retrieve/liveness.resource.response.js b/src/doc_scan_service/session/retrieve/liveness.resource.response.js index 9940b0d2..94817cb1 100644 --- a/src/doc_scan_service/session/retrieve/liveness.resource.response.js +++ b/src/doc_scan_service/session/retrieve/liveness.resource.response.js @@ -1,8 +1,22 @@ 'use strict'; const ResourceResponse = require('./resource.response'); +const Validation = require('../../../yoti_common/validation'); class LivenessResourceResponse extends ResourceResponse { + constructor(resource) { + super(resource); + + Validation.isString(resource.liveness_type, 'liveness_type', true); + this.livenessType = resource.liveness_type; + } + + /** + * @returns {string} + */ + getLivenessType() { + return this.livenessType; + } } module.exports = LivenessResourceResponse; diff --git a/tests/doc_scan_service/session/retrieve/generated.check.response.spec.js b/tests/doc_scan_service/session/retrieve/generated.check.response.spec.js index 583f2d24..f561daa2 100644 --- a/tests/doc_scan_service/session/retrieve/generated.check.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/generated.check.response.spec.js @@ -7,6 +7,7 @@ describe('GeneratedCheckResponse', () => { beforeEach(() => { generatedCheckResponse = new GeneratedCheckResponse({ id: 'some-id', + type: 'some-type', }); }); @@ -15,4 +16,10 @@ describe('GeneratedCheckResponse', () => { expect(generatedCheckResponse.getId()).toBe('some-id'); }); }); + + describe('#getType', () => { + it('should return type', () => { + expect(generatedCheckResponse.getType()).toBe('some-type'); + }); + }); }); diff --git a/tests/doc_scan_service/session/retrieve/generated.text.data.check.response.spec.js b/tests/doc_scan_service/session/retrieve/generated.text.data.check.response.spec.js index 4da86946..09b88175 100644 --- a/tests/doc_scan_service/session/retrieve/generated.text.data.check.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/generated.text.data.check.response.spec.js @@ -7,6 +7,7 @@ describe('GeneratedTextDataCheckResponse', () => { beforeEach(() => { generatedCheckResponse = new GeneratedTextDataCheckResponse({ id: 'some-id', + type: 'some-type', }); }); @@ -15,4 +16,10 @@ describe('GeneratedTextDataCheckResponse', () => { expect(generatedCheckResponse.getId()).toBe('some-id'); }); }); + + describe('#getType', () => { + it('should return type', () => { + expect(generatedCheckResponse.getType()).toBe('some-type'); + }); + }); }); diff --git a/tests/doc_scan_service/session/retrieve/liveness.resource.response.spec.js b/tests/doc_scan_service/session/retrieve/liveness.resource.response.spec.js index 00c96e70..fbec859b 100644 --- a/tests/doc_scan_service/session/retrieve/liveness.resource.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/liveness.resource.response.spec.js @@ -8,6 +8,7 @@ describe('LivenessResourceResponse', () => { beforeEach(() => { resourceResponse = new LivenessResourceResponse({ + liveness_type: 'some-liveness-type', id: 'some-id', tasks: [ { @@ -26,6 +27,12 @@ describe('LivenessResourceResponse', () => { }); }); + describe('#getType', () => { + it('should return type', () => { + expect(resourceResponse.getLivenessType()).toBe('some-liveness-type'); + }); + }); + describe('#getTasks', () => { it('should return a list of tasks', () => { const tasks = resourceResponse.getTasks(); diff --git a/tests/doc_scan_service/session/retrieve/task.response.spec.js b/tests/doc_scan_service/session/retrieve/task.response.spec.js index b3087233..f20d6a08 100644 --- a/tests/doc_scan_service/session/retrieve/task.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/task.response.spec.js @@ -4,6 +4,9 @@ const GeneratedCheckResponse = require('../../../../src/doc_scan_service/session const GeneratedTextDataCheckResponse = require('../../../../src/doc_scan_service/session/retrieve/generated.text.data.check.response'); const GeneratedMedia = require('../../../../src/doc_scan_service/session/retrieve/generated.media'); +const ID_DOCUMENT_TEXT_DATA_CHECK = 'ID_DOCUMENT_TEXT_DATA_CHECK'; +const SOME_UNKNOWN_TYPE = 'SOME_UNKNOWN_TYPE'; + describe('TaskResponse', () => { let taskResponse; @@ -16,11 +19,11 @@ describe('TaskResponse', () => { last_updated: '2006-02-02T22:04:05.123Z', generated_checks: [ { - type: 'ID_DOCUMENT_TEXT_DATA_CHECK', + type: ID_DOCUMENT_TEXT_DATA_CHECK, id: 'some-id', }, { - type: 'SOME_UNKNOWN_TYPE', + type: SOME_UNKNOWN_TYPE, }, ], generated_media: [ @@ -69,11 +72,11 @@ describe('TaskResponse', () => { expect(checks.length).toBe(2); - checks.forEach((check) => { - expect(check).toBeInstanceOf(GeneratedCheckResponse); - }); - expect(checks[0]).toBeInstanceOf(GeneratedTextDataCheckResponse); + expect(checks[0].getType()).toBe(ID_DOCUMENT_TEXT_DATA_CHECK); + + expect(checks[1]).toBeInstanceOf(GeneratedCheckResponse); + expect(checks[1].getType()).toBe(SOME_UNKNOWN_TYPE); }); }); describe('when checks are not available', () => { diff --git a/tests/doc_scan_service/session/retrieve/zoom.liveness.resource.response.spec.js b/tests/doc_scan_service/session/retrieve/zoom.liveness.resource.response.spec.js index 3c58bc92..e989b50e 100644 --- a/tests/doc_scan_service/session/retrieve/zoom.liveness.resource.response.spec.js +++ b/tests/doc_scan_service/session/retrieve/zoom.liveness.resource.response.spec.js @@ -8,6 +8,8 @@ describe('ZoomLivenessResourceResponse', () => { beforeEach(() => { zoomLivenessResourceResponse = new ZoomLivenessResourceResponse({ + liveness_type: 'some-liveness-type', + id: 'some-id', facemap: {}, frames: [ {}, @@ -16,6 +18,18 @@ describe('ZoomLivenessResourceResponse', () => { }); }); + describe('#getId', () => { + it('should return ID', () => { + expect(zoomLivenessResourceResponse.getId()).toBe('some-id'); + }); + }); + + describe('#getType', () => { + it('should return type', () => { + expect(zoomLivenessResourceResponse.getLivenessType()).toBe('some-liveness-type'); + }); + }); + describe('#getFaceMap', () => { it('should return FaceMap', () => { expect(zoomLivenessResourceResponse.getFaceMap()).toBeInstanceOf(FaceMapResponse); From 702db57a903ac278690f0cf3dc4fdf532342089b Mon Sep 17 00:00:00 2001 From: David Grayston Date: Thu, 23 Apr 2020 12:39:47 +0100 Subject: [PATCH 29/33] SDK-1549: Add coverage for liveness type mapping --- .../session/retrieve/resource.container.spec.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/doc_scan_service/session/retrieve/resource.container.spec.js b/tests/doc_scan_service/session/retrieve/resource.container.spec.js index c266125f..33564f48 100644 --- a/tests/doc_scan_service/session/retrieve/resource.container.spec.js +++ b/tests/doc_scan_service/session/retrieve/resource.container.spec.js @@ -3,6 +3,9 @@ const IdDocumentResourceResponse = require('../../../../src/doc_scan_service/ses const ZoomLivenessResourceResponse = require('../../../../src/doc_scan_service/session/retrieve/zoom.liveness.resource.response'); const LivenessResourceResponse = require('../../../../src/doc_scan_service/session/retrieve/liveness.resource.response'); +const ZOOM = 'ZOOM'; +const SOME_UNKNOWN_LIVENESS_TYPE = 'SOME_UNKNOWN_LIVENESS_TYPE'; + describe('ResourceContainer', () => { let resourceContainer; @@ -14,9 +17,11 @@ describe('ResourceContainer', () => { ], liveness_capture: [ { - liveness_type: 'ZOOM', + liveness_type: ZOOM, + }, + { + liveness_type: SOME_UNKNOWN_LIVENESS_TYPE, }, - {}, ], }); }); @@ -54,6 +59,13 @@ describe('ResourceContainer', () => { it('should return zoom liveness resource response', () => { const livenessCapture = resourceContainer.getLivenessCapture(); expect(livenessCapture[0]).toBeInstanceOf(ZoomLivenessResourceResponse); + expect(livenessCapture[0].getLivenessType()).toBe(ZOOM); + }); + + it('should return unknown liveness resource response', () => { + const livenessCapture = resourceContainer.getLivenessCapture(); + expect(livenessCapture[1]).toBeInstanceOf(LivenessResourceResponse); + expect(livenessCapture[1].getLivenessType()).toBe(SOME_UNKNOWN_LIVENESS_TYPE); }); }); describe('when liveness capture is not available', () => { @@ -71,6 +83,7 @@ describe('ResourceContainer', () => { const livenessCapture = resourceContainer.getZoomLivenessResources(); livenessCapture.forEach((item) => { expect(item).toBeInstanceOf(ZoomLivenessResourceResponse); + expect(item.getLivenessType()).toBe(ZOOM); }); }); }); From 5b898c9eea90d50cac59f2e75c30b9862d4f5e5c Mon Sep 17 00:00:00 2001 From: David Grayston Date: Mon, 4 May 2020 20:55:05 +0100 Subject: [PATCH 30/33] SDK-1301: Correct demo error message --- examples/doc-scan/src/controllers/error.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/doc-scan/src/controllers/error.controller.js b/examples/doc-scan/src/controllers/error.controller.js index b3f4363e..222374a2 100644 --- a/examples/doc-scan/src/controllers/error.controller.js +++ b/examples/doc-scan/src/controllers/error.controller.js @@ -1,5 +1,5 @@ module.exports = async (req, res) => { - let error = 'An unknown error occured'; + let error = 'An unknown error occurred'; if (req.query.yotiErrorCode) { error = `Error Code: ${req.query.yotiErrorCode}`; From b93a0a96abe82c75f3c3a2373e7adb29a4e057b8 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Tue, 5 May 2020 12:33:45 +0100 Subject: [PATCH 31/33] SDK-1301: Use API URL as iframe base URL --- examples/doc-scan/.env.example | 3 +-- examples/doc-scan/config.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/doc-scan/.env.example b/examples/doc-scan/.env.example index f954f115..a70f4667 100644 --- a/examples/doc-scan/.env.example +++ b/examples/doc-scan/.env.example @@ -4,5 +4,4 @@ YOTI_CLIENT_SDK_ID= YOTI_KEY_FILE_PATH= # Optional configuration. -YOTI_DOC_SCAN_IFRAME_URL= -YOTI_DOC_SCAN_API= +YOTI_DOC_SCAN_API_URL= diff --git a/examples/doc-scan/config.js b/examples/doc-scan/config.js index b7911ebf..28d97902 100644 --- a/examples/doc-scan/config.js +++ b/examples/doc-scan/config.js @@ -1,8 +1,10 @@ const fs = require('fs'); +const yotiConfig = require('yoti/config').yoti; + module.exports = { YOTI_CLIENT_SDK_ID: process.env.YOTI_CLIENT_SDK_ID, YOTI_PEM: fs.readFileSync(process.env.YOTI_KEY_FILE_PATH), - YOTI_DOC_SCAN_IFRAME_URL: process.env.YOTI_DOC_SCAN_IFRAME_URL || 'https://api.yoti.com/idverify/v1/web/index.html', + YOTI_DOC_SCAN_IFRAME_URL: `${yotiConfig.docScanApi}/web/index.html`, YOTI_APP_BASE_URL: process.env.YOTI_APP_BASE_URL || 'https://localhost:3000', }; From f828c11fa79cf084a154b01a87ce23c01b389f8f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 10 May 2020 16:47:04 +0000 Subject: [PATCH 32/33] Bump safe-buffer from 5.2.0 to 5.2.1 Bumps [safe-buffer](https://github.com/feross/safe-buffer) from 5.2.0 to 5.2.1. - [Release notes](https://github.com/feross/safe-buffer/releases) - [Commits](https://github.com/feross/safe-buffer/compare/v5.2.0...v5.2.1) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9902633b..29b1f8c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5703,9 +5703,9 @@ } }, "safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, "safe-regex": { "version": "1.1.0", From 9e7d003b9de1c74e8ca9649b02b424b683a867b3 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Tue, 5 May 2020 18:08:57 +0100 Subject: [PATCH 33/33] Bump minor version --- package-lock.json | 2 +- package.json | 2 +- sonar-project.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 29b1f8c9..cefcc310 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yoti", - "version": "3.9.0", + "version": "3.10.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 621b8879..414842ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yoti", - "version": "3.9.0", + "version": "3.10.0", "description": "Yoti NodeJS SDK for back-end integration", "author": "Yoti LTD (https://www.yoti.com/developers)", "license": "MIT", diff --git a/sonar-project.properties b/sonar-project.properties index e647f20c..b4a9b40f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey = yoti-web-sdk:node sonar.projectName = node-sdk -sonar.projectVersion = 3.9.0 +sonar.projectVersion = 3.10.0 sonar.exclusions=tests/**,examples/**,node_modules/**,coverage/** sonar.javascript.lcov.reportPaths=coverage/lcov.info sonar.verbose = true