Skip to content

Commit dd5561a

Browse files
authored
SDK-2755 Share codes support (#553)
* Added new resources for share code retrieval * Updated /examples/idv-identity-checks to include the `GBR_RTW_SHARECODE` in the advanced identity profile option, and added a second case that focuses only on RTW and the share code fallback
1 parent 7edb81f commit dd5561a

20 files changed

Lines changed: 609 additions & 21 deletions

examples/idv-identity-checks/src/controllers/session.controller.js

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,53 @@ async function createSession(scheme) {
4949
subject_id: 'some_subject_id_string',
5050
};
5151

52-
if (scheme === 'MTF_BASE') {
53-
const advancedIdentityProfileSchemeDBS = new AdvancedIdentityProfileSchemeBuilder()
54-
.withType('DBS')
55-
.withObjective('BASIC')
56-
.withLabel('label-for-DBS-BASIC')
57-
.build();
52+
if (scheme.startsWith('MTF')) {
53+
// Building the requirements for UK_TFIDA
54+
const advancedIdentityProfileUKTFIDABuilder = new AdvancedIdentityProfileBuilder().withTrustFramework('UK_TFIDA');
55+
56+
if (scheme === 'MTF_FULL') {
57+
const advancedIdentityProfileSchemeDBS = new AdvancedIdentityProfileSchemeBuilder()
58+
.withType('DBS')
59+
.withObjective('BASIC')
60+
.withLabel('label-for-DBS-BASIC')
61+
.build();
62+
63+
advancedIdentityProfileUKTFIDABuilder.withScheme(advancedIdentityProfileSchemeDBS);
64+
}
5865

5966
const advancedIdentityProfileSchemeRTW = new AdvancedIdentityProfileSchemeBuilder()
6067
.withType('RTW')
6168
.withLabel('label-for-RTW')
6269
.build();
6370

64-
const advancedIdentityProfileUKTFIDA = new AdvancedIdentityProfileBuilder()
65-
.withTrustFramework('UK_TFIDA')
66-
.withScheme(advancedIdentityProfileSchemeDBS)
67-
.withScheme(advancedIdentityProfileSchemeRTW)
68-
.build();
71+
advancedIdentityProfileUKTFIDABuilder.withScheme(advancedIdentityProfileSchemeRTW);
6972

70-
const advancedIdentityProfileSchemeAL1 = new AdvancedIdentityProfileSchemeBuilder()
71-
.withType('IDENTITY')
72-
.withObjective('AL_L1')
73-
.withLabel('label-for-IDENTITY-AL-L1')
74-
.build();
73+
const advancedIdentityProfileUKTFIDA = advancedIdentityProfileUKTFIDABuilder.build();
7574

76-
const advancedIdentityProfileYotiGlobal = new AdvancedIdentityProfileBuilder()
77-
.withTrustFramework('YOTI_GLOBAL')
78-
.withScheme(advancedIdentityProfileSchemeAL1)
75+
// Building the requirements for YOTI_GLOBAL
76+
const advancedIdentityProfileYotiGlobalBuilder = new AdvancedIdentityProfileBuilder()
77+
.withTrustFramework('YOTI_GLOBAL');
78+
79+
if (scheme === 'MTF_FULL') {
80+
const advancedIdentityProfileSchemeAL1 = new AdvancedIdentityProfileSchemeBuilder()
81+
.withType('IDENTITY')
82+
.withObjective('AL_L1')
83+
.withLabel('label-for-IDENTITY-AL-L1')
84+
.build();
85+
86+
advancedIdentityProfileYotiGlobalBuilder.withScheme(advancedIdentityProfileSchemeAL1);
87+
}
88+
89+
const advancedIdentityProfileSchemeGbrRtwSharecode = new AdvancedIdentityProfileSchemeBuilder()
90+
.withType('GBR_RTW_SHARECODE')
91+
.withLabel('label-for-GBR-RTW-SHARECODE')
7992
.build();
8093

94+
// eslint-disable-next-line max-len
95+
advancedIdentityProfileYotiGlobalBuilder.withScheme(advancedIdentityProfileSchemeGbrRtwSharecode);
96+
97+
const advancedIdentityProfileYotiGlobal = advancedIdentityProfileYotiGlobalBuilder.build();
98+
8199
const advancedIdentityProfileRequirements = new AdvancedIdentityProfileRequirementsBuilder()
82100
.withProfile(advancedIdentityProfileUKTFIDA)
83101
.withProfile(advancedIdentityProfileYotiGlobal)
@@ -104,7 +122,7 @@ async function createSession(scheme) {
104122
.withSuccessUrl(`${config.YOTI_APP_BASE_URL}/success`)
105123
.withErrorUrl(`${config.YOTI_APP_BASE_URL}/error`)
106124
.withAllowHandoff(true)
107-
.withAllowsCameraAndUpload()
125+
// .withAllowsCameraAndUpload()
108126
.build()
109127
)
110128
.build();

examples/idv-identity-checks/views/pages/index.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
<option value="RTW">RTW</option>
1111
<option value="RTR">RTR</option>
1212
<option value="DBS_BASIC_RTW">DBS-BASIC & RTW</option>
13-
<option value="MTF_BASE">Advanced - UK_TFIDA(DBS-BASIC & RTW) + YOTI_GLOBAL(IDENTITY-AL_L1)</option>
13+
<option value="MTF_FULL">Advanced - UK_TFIDA(DBS-BASIC & RTW) + YOTI_GLOBAL(IDENTITY-AL_L1 & GBR_RTW_SHARECODE)</option>
14+
<option value="MTF_RTW_FALLBACK">Advanced - UK_TFIDA(RTW) + YOTI_GLOBAL(GBR_RTW_SHARECODE)</option>
1415
</select>
1516
</div>
1617
<div>

examples/idv-identity-checks/views/pages/success.ejs

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,29 @@
185185
</div>
186186
<% } %>
187187
188+
<% if (sessionResult.getFaceComparisonChecks().length > 0) { %>
189+
<div class="card">
190+
<div class="card-header" id="face-comparison-checks">
191+
<h3 class="mb-0">
192+
<button class="btn btn-link" type="button" data-toggle="collapse"
193+
data-target="#collapse-face-comparison-checks" aria-expanded="true"
194+
aria-controls="collapse-face-comparison-checks">
195+
FaceComparison Checks
196+
</button>
197+
</h3>
198+
199+
</div>
200+
201+
<div id="collapse-face-comparison-checks" class="collapse" aria-labelledby="face-comparison-checks">
202+
<div class="card-body">
203+
<% sessionResult.getFaceComparisonChecks().forEach(function(check){ %>
204+
<%- include('partials/check', { check }); %>
205+
<% }); %>
206+
</div>
207+
</div>
208+
</div>
209+
<% } %>
210+
188211
<% if (sessionResult.getLivenessChecks().length > 0) { %>
189212
<div class="card">
190213
<div class="card-header" id="liveness-checks">
@@ -492,6 +515,169 @@
492515
<% }); %>
493516
<% } %>
494517

518+
<% if (sessionResult.getResources().getShareCodeResources().length > 0) { %>
519+
<div class="row pt-4">
520+
<div class="col">
521+
<h2>Share Codes</h2>
522+
</div>
523+
</div>
524+
525+
<%
526+
let shareCodeNum = 0;
527+
sessionResult.getResources().getShareCodeResources().forEach(function(shareCode) {
528+
shareCodeNum++;
529+
%>
530+
<div class="row pt-4">
531+
<div class="col">
532+
533+
<h3>Share Code<%= shareCodeNum; %> (<small>Task state: <span class="badge badge-info"><%= shareCode.getTasks()[0].getState(); %></span></small>)</h3>
534+
535+
<div class="accordion mt-3">
536+
537+
<% if (shareCode.getLookupProfile()) { %>
538+
<div class="card">
539+
<div class="card-header" id="share-code-lookup-profile-<%= shareCodeNum %>">
540+
<h4 class="mb-0">
541+
<button class="btn btn-link" type="button" data-toggle="collapse"
542+
data-target="#collapse-share-code-lookup-profile-<%= shareCodeNum %>" aria-expanded="true"
543+
aria-controls="collapse-share-code-lookup-profile-<%= shareCodeNum %>">
544+
Lookup profile
545+
</button>
546+
</h4>
547+
</div>
548+
<div id="collapse-share-code-lookup-profile-<%= shareCodeNum %>" class="collapse" aria-labelledby="share-code-lookup-profile-<%= shareCodeNum %>">
549+
<div class="card-body">
550+
<% if (shareCode.getLookupProfile().getMedia()) { %>
551+
<h5>Media</h5>
552+
<table class="table table-striped table-light">
553+
<tbody>
554+
<tr>
555+
<td>ID</td>
556+
<td>
557+
<a
558+
href="/media?mediaId=<%= shareCode.getLookupProfile().getMedia().getId() %>">
559+
<%= shareCode.getLookupProfile().getMedia().getId() %>
560+
</a>
561+
</td>
562+
</tr>
563+
</tbody>
564+
</table>
565+
<% } %>
566+
</div>
567+
</div>
568+
</div>
569+
<% } %>
570+
571+
<% if (shareCode.getReturnedProfile()) { %>
572+
<div class="card">
573+
<div class="card-header" id="share-code-returned-profile-<%= shareCodeNum %>">
574+
<h4 class="mb-0">
575+
<button class="btn btn-link" type="button" data-toggle="collapse"
576+
data-target="#collapse-share-code-returned-profile-<%= shareCodeNum %>" aria-expanded="true"
577+
aria-controls="collapse-share-code-returned-profile-<%= shareCodeNum %>">
578+
Returned profile
579+
</button>
580+
</h4>
581+
</div>
582+
<div id="collapse-share-code-returned-profile-<%= shareCodeNum %>" class="collapse" aria-labelledby="share-code-returned-profile-<%= shareCodeNum %>">
583+
<div class="card-body">
584+
<% if (shareCode.getReturnedProfile().getMedia()) { %>
585+
<h5>Media</h5>
586+
<table class="table table-striped table-light">
587+
<tbody>
588+
<tr>
589+
<td>ID</td>
590+
<td>
591+
<a
592+
href="/media?mediaId=<%= shareCode.getReturnedProfile().getMedia().getId() %>">
593+
<%= shareCode.getReturnedProfile().getMedia().getId() %>
594+
</a>
595+
</td>
596+
</tr>
597+
</tbody>
598+
</table>
599+
<% } %>
600+
</div>
601+
</div>
602+
</div>
603+
<% } %>
604+
605+
<% if (shareCode.getIdPhoto()) { %>
606+
<div class="card">
607+
<div class="card-header" id="share-code-id-photo-<%= shareCodeNum %>">
608+
<h4 class="mb-0">
609+
<button class="btn btn-link" type="button" data-toggle="collapse"
610+
data-target="#collapse-share-code-id-photo-<%= shareCodeNum %>" aria-expanded="true"
611+
aria-controls="collapse-share-code-id-photo-<%= shareCodeNum %>">
612+
ID Photo
613+
</button>
614+
</h4>
615+
</div>
616+
<div id="collapse-share-code-id-photo-<%= shareCodeNum %>" class="collapse" aria-labelledby="share-code-id-photo-<%= shareCodeNum %>">
617+
<div class="card-body">
618+
<% if (shareCode.getIdPhoto().getMedia()) { %>
619+
<h5>Media</h5>
620+
<table class="table table-striped table-light">
621+
<tbody>
622+
<tr>
623+
<td>ID</td>
624+
<td>
625+
<a
626+
href="/media?mediaId=<%= shareCode.getIdPhoto().getMedia().getId() %>">
627+
<%= shareCode.getIdPhoto().getMedia().getId() %>
628+
</a>
629+
</td>
630+
</tr>
631+
</tbody>
632+
</table>
633+
<% } %>
634+
</div>
635+
</div>
636+
</div>
637+
<% } %>
638+
639+
<% if (shareCode.getFile()) { %>
640+
<div class="card">
641+
<div class="card-header" id="share-code-file-<%= shareCodeNum %>">
642+
<h4 class="mb-0">
643+
<button class="btn btn-link" type="button" data-toggle="collapse"
644+
data-target="#collapse-share-code-file-<%= shareCodeNum %>" aria-expanded="true"
645+
aria-controls="collapse-share-code-file-<%= shareCodeNum %>">
646+
File
647+
</button>
648+
</h4>
649+
</div>
650+
<div id="collapse-share-code-file-<%= shareCodeNum %>" class="collapse" aria-labelledby="share-code-file-<%= shareCodeNum %>">
651+
<div class="card-body">
652+
<% if (shareCode.getFile().getMedia()) { %>
653+
<h5>Media</h5>
654+
<table class="table table-striped table-light">
655+
<tbody>
656+
<tr>
657+
<td>ID</td>
658+
<td>
659+
<a
660+
href="/media?mediaId=<%= shareCode.getFile().getMedia().getId() %>">
661+
<%= shareCode.getFile().getMedia().getId() %>
662+
</a>
663+
</td>
664+
</tr>
665+
</tbody>
666+
</table>
667+
<% } %>
668+
</div>
669+
</div>
670+
</div>
671+
<% } %>
672+
673+
</div>
674+
675+
</div>
676+
</div>
677+
678+
<% }); %>
679+
<% } %>
680+
495681
<% if (sessionResult.getResources().getSupplementaryDocuments().length > 0) { %>
496682
<div class="row pt-4">
497683
<div class="col">

src/idv_service/session/retrieve/resource.container.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const ZoomLivenessResourceResponse = require('./zoom.liveness.resource.response'
55
const StaticLivenessResourceResponse = require('./static.liveness.resource.response');
66
const LivenessResourceResponse = require('./liveness.resource.response');
77
const FaceCaptureResourceResponse = require('./face.capture.resource.response');
8+
const ShareCodeResourceResponse = require('./share.code.resource.response');
89
const IDVConstants = require('../../idv.constants');
910
const Validation = require('../../../yoti_common/validation');
1011
const SupplementaryDocumentResourceResponse = require('./supplementary.document.resource.response');
@@ -64,6 +65,18 @@ class ResourceContainer {
6465
/** @private */
6566
this.faceCapture = [];
6667
}
68+
69+
if (resources.share_codes) {
70+
Validation.isArray(resources.share_codes, 'share_codes');
71+
72+
/** @private */
73+
this.shareCodes = resources.share_codes.map(
74+
(resource) => new ShareCodeResourceResponse(resource)
75+
);
76+
} else {
77+
/** @private */
78+
this.shareCodes = [];
79+
}
6780
}
6881

6982
/**
@@ -125,6 +138,16 @@ class ResourceContainer {
125138
getFaceCaptureResources() {
126139
return this.faceCapture;
127140
}
141+
142+
/**
143+
* Returns share-code resources
144+
*
145+
* @returns {ShareCodeResourceResponse[]}
146+
* The list of share-code resources
147+
*/
148+
getShareCodeResources() {
149+
return this.shareCodes;
150+
}
128151
}
129152

130153
module.exports = ResourceContainer;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const Validation = require('../../../yoti_common/validation');
4+
const MediaResponse = require('./media.response');
5+
6+
class ShareCodeFileResponse {
7+
constructor(file) {
8+
if (file.media) {
9+
Validation.isPlainObject(file.media, 'media');
10+
/** @private */
11+
this.media = new MediaResponse(file.media);
12+
}
13+
}
14+
15+
/**
16+
* @return MediaResponse
17+
*/
18+
getMedia() {
19+
return this.media;
20+
}
21+
}
22+
23+
module.exports = ShareCodeFileResponse;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const Validation = require('../../../yoti_common/validation');
4+
const MediaResponse = require('./media.response');
5+
6+
class ShareCodeIdPhotoResponse {
7+
constructor(idPhoto) {
8+
if (idPhoto.media) {
9+
Validation.isPlainObject(idPhoto.media, 'media');
10+
/** @private */
11+
this.media = new MediaResponse(idPhoto.media);
12+
}
13+
}
14+
15+
/**
16+
* @return MediaResponse
17+
*/
18+
getMedia() {
19+
return this.media;
20+
}
21+
}
22+
23+
module.exports = ShareCodeIdPhotoResponse;

0 commit comments

Comments
 (0)