Skip to content

Commit

Permalink
Merge pull request #281 from getyoti/release/3.17.0
Browse files Browse the repository at this point in the history
Release/3.17.0
  • Loading branch information
laurent-yoti authored Jul 14, 2021
2 parents 5ec2f7e + 888708c commit 3bba7f0
Show file tree
Hide file tree
Showing 33 changed files with 937 additions and 10 deletions.
7 changes: 7 additions & 0 deletions examples/doc-scan/src/controllers/index.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
OrthogonalRestrictionsFilterBuilder,
RequestedIdDocumentComparisonCheckBuilder,
RequestedThirdPartyIdentityCheckBuilder,
RequestedWatchlistScreeningCheckBuilder,
RequiredSupplementaryDocumentBuilder,
ProofOfAddressObjectiveBuilder,
RequestedSupplementaryDocTextExtractionTaskBuilder,
Expand Down Expand Up @@ -53,6 +54,12 @@ async function createSession() {
new RequestedThirdPartyIdentityCheckBuilder()
.build()
)
.withRequestedCheck(
new RequestedWatchlistScreeningCheckBuilder()
.withAdverseMediaCategory()
.withSanctionsCategory()
.build()
)
.withRequestedTask(
new RequestedTextExtractionTaskBuilder()
.withManualCheckAlways()
Expand Down
89 changes: 88 additions & 1 deletion examples/doc-scan/views/pages/partials/check.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% displayGeneratedProfile = typeof hasGeneratedProfile === 'undefined' ? false : hasGeneratedProfile %>
<% displayWatchlistSummary = typeof hasWatchlistSummary === 'undefined' ? false : hasWatchlistSummary %>
<table class="table table-striped">
<tbody>
<tr>
Expand Down Expand Up @@ -91,6 +93,71 @@
</tr>
<% } %>
<% if (displayWatchlistSummary && check.getReport().getWatchlistSummary()) { %>
<tr>
<td>Watchlist Summary</td>
<td>
<table class="table table-bordered">
<tbody>
<tr>
<td>Total hits</td>
<td><%= check.getReport().getWatchlistSummary().getTotalHits(); %></td>
</tr>
<% if (check.getReport().getWatchlistSummary().getAssociatedCountryCodes().length > 0) { %>
<tr>
<td>Associated country codes</td>
<td><%= check.getReport().getWatchlistSummary().getAssociatedCountryCodes().join(', '); %></td>
</tr>
<% } %>
<% if (check.getReport().getWatchlistSummary().getRawResults() && check.getReport().getWatchlistSummary().getRawResults().getMedia()) { %>
<tr>
<td>Raw results</td>
<td>
<table class="table table-striped">
<tbody>
<tr>
<td style="width: auto">Media</td>
<td>
<table class="table table-striped small">
<tbody>
<tr>
<td style="width: auto">ID</td>
<td><a href="/media?mediaId=<%= check.getReport().getWatchlistSummary().getRawResults().getMedia().id %>"><%= check.getReport().getWatchlistSummary().getRawResults().getMedia().id; %></a></td>
</tr>
<tr>
<td style="width: auto">Type</td>
<td><%= check.getReport().getWatchlistSummary().getRawResults().getMedia().type; %></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<% } %>
<% if (check.getReport().getWatchlistSummary().getSearchConfig() && check.getReport().getWatchlistSummary().getSearchConfig().getCategories().length > 0) { %>
<tr>
<td>Search config</td>
<td>
<table class="table table-striped">
<tbody>
<tr>
<td style="width: auto">Categories</td>
<td><%= check.getReport().getWatchlistSummary().getSearchConfig().getCategories().join(', '); %></td>
</tr>
</tbody>
</table>
</td>
</tr>
<% } %>
</tbody>
</table>
</td>
</tr>
<% } %>
<% } %>

<% if (check.getGeneratedMedia().length > 0) { %>
Expand All @@ -115,5 +182,25 @@
</tr>
<% } %>

<% if (displayGeneratedProfile && check.getGeneratedProfile()) { %>
<tr>
<td>Generated Profile</td>
<td>
<table class="table table-striped">
<tbody>
<tr>
<td>ID</td>
<td><a href="/media?mediaId=<%= check.getGeneratedProfile().media.id %>"><%= check.getGeneratedProfile().media.id; %></a></td>
</tr>
<tr>
<td>Type</td>
<td><%= check.getGeneratedProfile().media.type; %></td>
</tr>
</tbody>
</table>
</td>
</tr>
<% } %>

</tbody>
</table>
</table>
26 changes: 24 additions & 2 deletions examples/doc-scan/views/pages/success.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,29 @@
<div id="collapse-third-party-identity-checks" class="collapse" aria-labelledby="collapse-third-party-identity-checks">
<div class="card-body">
<% sessionResult.getThirdPartyIdentityChecks().forEach(function(check){ %>
<%- include('partials/check', { check }); %>
<%- include('partials/check', { check, hasGeneratedProfile: true }); %>
<% }); %>
</div>
</div>
</div>
<% } %>
<% if (sessionResult.getWatchlistScreeningChecks().length > 0) { %>
<div class="card">
<div class="card-header" id="watch-list-screening-checks">
<h3 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#collapse-watch-list-screening-checks" aria-expanded="true"
aria-controls="collapse-watch-list-screening-checks">
Watchlist Screening Checks
</button>
</h3>
</div>
<div id="collapse-watch-list-screening-checks" class="collapse" aria-labelledby="collapse-watch-list-screening-checks">
<div class="card-body">
<% sessionResult.getWatchlistScreeningChecks().forEach(function(check){ %>
<%- include('partials/check', { check, hasGeneratedProfile: true, hasWatchlistSummary: true }); %>
<% }); %>
</div>
</div>
Expand Down Expand Up @@ -225,7 +247,7 @@
</div>
</div>
<%
<%
let docNum = 0;
sessionResult.getResources().getIdDocuments().forEach(function(document) {
docNum++;
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {
RequestedDocumentAuthenticityCheckBuilder,
RequestedIdDocumentComparisonCheckBuilder,
RequestedThirdPartyIdentityCheckBuilder,
RequestedWatchlistScreeningCheckBuilder,
RequestedFaceMatchCheckBuilder,
RequestedLivenessCheckBuilder,
RequestedTextExtractionTaskBuilder,
Expand Down Expand Up @@ -66,6 +67,7 @@ module.exports = {
RequestedDocumentAuthenticityCheckBuilder,
RequestedIdDocumentComparisonCheckBuilder,
RequestedThirdPartyIdentityCheckBuilder,
RequestedWatchlistScreeningCheckBuilder,
RequestedFaceMatchCheckBuilder,
RequestedLivenessCheckBuilder,
RequestedTextExtractionTaskBuilder,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yoti",
"version": "3.16.0",
"version": "3.17.0",
"description": "Yoti NodeJS SDK for back-end integration",
"author": "Yoti LTD <[email protected]> (https://www.yoti.com/developers)",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sonar.organization = getyoti

sonar.projectKey = getyoti:node
sonar.projectName = Node SDK
sonar.projectVersion = 3.16.0
sonar.projectVersion = 3.17.0
sonar.exclusions=tests/**,examples/**,node_modules/**,coverage/**
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.verbose = true
Expand Down
3 changes: 3 additions & 0 deletions src/doc_scan_service/doc.scan.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module.exports = Object.freeze({
ID_DOCUMENT_FACE_MATCH: 'ID_DOCUMENT_FACE_MATCH',
ID_DOCUMENT_COMPARISON: 'ID_DOCUMENT_COMPARISON',
THIRD_PARTY_IDENTITY: 'THIRD_PARTY_IDENTITY',
WATCHLIST_SCREENING: 'WATCHLIST_SCREENING',
ADVERSE_MEDIA: 'ADVERSE-MEDIA',
SANCTIONS: 'SANCTIONS',
LIVENESS: 'LIVENESS',
ZOOM: 'ZOOM',
CAMERA: 'CAMERA',
Expand Down
2 changes: 2 additions & 0 deletions src/doc_scan_service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const SdkConfigBuilder = require('./session/create/sdk.config.builder');
const RequestedDocumentAuthenticityCheckBuilder = require('./session/create/check/requested.document.authenticity.check.builder');
const RequestedIdDocumentComparisonCheckBuilder = require('./session/create/check/requested.id.document.comparison.check.builder');
const RequestedThirdPartyIdentityCheckBuilder = require('./session/create/check/requested.third.party.identity.check.builder');
const RequestedWatchlistScreeningCheckBuilder = require('./session/create/check/requested.watchlist.screening.check.builder');
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');
Expand All @@ -28,6 +29,7 @@ module.exports = {
RequestedDocumentAuthenticityCheckBuilder,
RequestedIdDocumentComparisonCheckBuilder,
RequestedThirdPartyIdentityCheckBuilder,
RequestedWatchlistScreeningCheckBuilder,
RequestedFaceMatchCheckBuilder,
RequestedLivenessCheckBuilder,
RequestedTextExtractionTaskBuilder,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict';

const RequestedWatchlistScreeningCheck = require('./requested.watchlist.screening.check');
const RequestedWatchlistScreeningConfig = require('./requested.watchlist.screening.config');
const DocScanConstants = require('../../../doc.scan.constants');
const Validation = require('../../../../yoti_common/validation');

/**
* Builder to assist the creation of {@link RequestedWatchlistScreeningCheck}.
*
* @class RequestedWatchlistScreeningCheckBuilder
*/
/* eslint class-methods-use-this: ["error", { "exceptMethods": ["build"] }] */
class RequestedWatchlistScreeningCheckBuilder {
constructor() {
this.categories = [];
}

/**
* Adds ADVERSE_MEDIA to the list of categories used for watchlist screening
*
* @returns {this}
*/
withAdverseMediaCategory() {
return this.withCategory(DocScanConstants.ADVERSE_MEDIA);
}

/**
* Adds SANCTIONS to the list of categories used for watchlist screening
*
* @returns {this}
*/
withSanctionsCategory() {
return this.withCategory(DocScanConstants.SANCTIONS);
}

/**
* Adds a category to the list of categories used for watchlist screening
*
* @param {string} category
*
* @returns {this}
*/
withCategory(category) {
Validation.isString(category, 'category');
Validation.notNullOrEmpty(category, 'category');
this.categories.push(category);
return this;
}

build() {
const config = new RequestedWatchlistScreeningConfig(this.categories);
return new RequestedWatchlistScreeningCheck(config);
}
}

module.exports = RequestedWatchlistScreeningCheckBuilder;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const RequestedCheck = require('./requested.check');
const DocScanConstants = require('../../../doc.scan.constants');
const Validation = require('../../../../yoti_common/validation');
const RequestedWatchlistScreeningConfig = require('./requested.watchlist.screening.config');

/**
* @class RequestedWatchlistScreeningCheck
*/
class RequestedWatchlistScreeningCheck extends RequestedCheck {
/**
* @param {RequestedWatchlistScreeningConfig} config
*/
constructor(config) {
Validation.instanceOf(config, RequestedWatchlistScreeningConfig, 'config');
super(DocScanConstants.WATCHLIST_SCREENING, config);
}
}

module.exports = RequestedWatchlistScreeningCheck;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

const Validation = require('../../../../yoti_common/validation');
/**
* The configuration applied when creating a RequestedWatchlistScreeningCheck
*
* @class RequestedWatchlistScreeningConfig
*/
class RequestedWatchlistScreeningConfig {
/**
* @param {string[]} categories
* The list of categories corresponding to each watchlist screening conducted
*/
constructor(categories) {
if (categories) {
Validation.isArrayOfStrings(categories, 'categories');
this.categories = categories.filter((elem, pos) => categories.indexOf(elem) === pos);
}
}

/**
* @returns {Object} data for JSON.stringify()
*/
toJSON() {
return {
categories: this.categories,
};
}
}

module.exports = RequestedWatchlistScreeningConfig;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const MediaResponse = require('./media.response');

class GeneratedProfileResponse {
constructor(generatedProfile) {
if (generatedProfile.media) {
this.media = new MediaResponse(generatedProfile.media);
}
}

/**
* @returns {MediaResponse}
*/
getMedia() {
return this.media;
}
}

module.exports = GeneratedProfileResponse;
10 changes: 10 additions & 0 deletions src/doc_scan_service/session/retrieve/get.session.result.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const SupplementaryDocumentTextDataCheckResponse = require('./supplementary.docu
const LivenessCheckResponse = require('./liveness.check.response');
const IdDocumentComparisonCheckResponse = require('./id.document.comparison.check.response');
const ThirdPartyIdentityCheckResponse = require('./third.party.identity.check.response');
const WatchlistScreeningCheckResponse = require('./watchlist.screening.check.response');
const DocScanConstants = require('../../doc.scan.constants');
const { YotiDate } = require('../../../data_type/date');

Expand Down Expand Up @@ -42,6 +43,8 @@ class GetSessionResult {
return new IdDocumentComparisonCheckResponse(check);
case DocScanConstants.THIRD_PARTY_IDENTITY:
return new ThirdPartyIdentityCheckResponse(check);
case DocScanConstants.WATCHLIST_SCREENING:
return new WatchlistScreeningCheckResponse(check);
case DocScanConstants.ID_DOCUMENT_FACE_MATCH:
return new FaceMatchCheckResponse(check);
case DocScanConstants.ID_DOCUMENT_TEXT_DATA_CHECK:
Expand Down Expand Up @@ -163,6 +166,13 @@ class GetSessionResult {
return this.getChecks().filter((check) => check instanceof ThirdPartyIdentityCheckResponse);
}

/**
* @returns {WatchlistScreeningCheckResponse[]}
*/
getWatchlistScreeningChecks() {
return this.getChecks().filter((check) => check instanceof WatchlistScreeningCheckResponse);
}

/**
* @returns {ResourceContainer}
*/
Expand Down
Loading

0 comments on commit 3bba7f0

Please sign in to comment.