Skip to content

Commit 1085653

Browse files
authored
SDK-2617 IDV session SDK configuration with suppressed screens (#538)
* Added optional 'suppressed_screens' in the IDV session SDK configuration. * Fix JSDOC description * Added example for the suppressed screens option.
1 parent 042e9de commit 1085653

File tree

10 files changed

+133
-5
lines changed

10 files changed

+133
-5
lines changed

examples/idv/src/controllers/use-cases/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const allowExpiredDocumentCheckController = require('./allow.expired.document.ch
55
const faceComparisonCheckController = require('./face.comparison.check.controller');
66
const faceMatchCheckController = require('./face.match.check.controller');
77
const watchlistCheckController = require('./watchlist.check.controller');
8+
const suppressedScreensCheckController = require('./suppressed.screens.check.controller');
89

910
module.exports = {
1011
authenticityAndIdentityCheckController,
@@ -14,4 +15,5 @@ module.exports = {
1415
faceComparisonCheckController,
1516
faceMatchCheckController,
1617
watchlistCheckController,
18+
suppressedScreensCheckController,
1719
};
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const {
2+
IDVClient,
3+
SessionSpecificationBuilder,
4+
SdkConfigBuilder,
5+
RequiredIdDocumentBuilder,
6+
RequestedDocumentAuthenticityCheckBuilder,
7+
RequestedTextExtractionTaskBuilder,
8+
} = require('yoti');
9+
const config = require('../../../config');
10+
11+
/**
12+
* Create an IDV session.
13+
*/
14+
async function createSession() {
15+
const idvClient = new IDVClient(
16+
config.YOTI_CLIENT_SDK_ID,
17+
config.YOTI_PEM
18+
);
19+
20+
const sessionSpec = new SessionSpecificationBuilder()
21+
.withClientSessionTokenTtl(600) // 10 minutes
22+
.withResourcesTtl(90000) // session TTL(10 minutes) + 24 hours(minimum required)
23+
.withUserTrackingId('some-user-tracking-id')
24+
.withRequestedCheck(
25+
new RequestedDocumentAuthenticityCheckBuilder()
26+
.withManualCheckFallback()
27+
.build()
28+
)
29+
.withRequestedTask(
30+
new RequestedTextExtractionTaskBuilder()
31+
.withManualCheckFallback()
32+
.withChipDataDesired()
33+
.withCreateExpandedDocumentFields(true) // default is false
34+
.build()
35+
)
36+
.withSdkConfig(
37+
new SdkConfigBuilder()
38+
.withAllowsCameraAndUpload()
39+
.withPrimaryColour('#2d9fff')
40+
.withSecondaryColour('#FFFFFF')
41+
.withFontColour('#FFFFFF')
42+
.withLocale('en-GB')
43+
.withPresetIssuingCountry('GBR')
44+
.withSuccessUrl(`${config.YOTI_APP_BASE_URL}/success`)
45+
.withErrorUrl(`${config.YOTI_APP_BASE_URL}/error`)
46+
.withAllowHandoff(true)
47+
.withIdDocumentTextExtractionGenericRetries(3)
48+
.withIdDocumentTextExtractionReclassificationRetries(3)
49+
.withSuppressedScreens([
50+
'ID_DOCUMENT_EDUCATION',
51+
'ID_DOCUMENT_REQUIREMENTS',
52+
])
53+
.build()
54+
)
55+
.withRequiredDocument(
56+
(new RequiredIdDocumentBuilder()).build()
57+
)
58+
.build();
59+
60+
return idvClient.createSession(sessionSpec);
61+
}
62+
63+
module.exports = async (req, res) => {
64+
try {
65+
const session = await createSession();
66+
67+
req.session.IDV_SESSION_ID = session.getSessionId();
68+
req.session.IDV_SESSION_TOKEN = session.getClientSessionToken();
69+
70+
res.render('pages/session', {
71+
sessionId: req.session.IDV_SESSION_ID,
72+
iframeUrl: `${config.YOTI_IDV_IFRAME_URL}?sessionID=${req.session.IDV_SESSION_ID}&sessionToken=${req.session.IDV_SESSION_TOKEN}`,
73+
});
74+
} catch (error) {
75+
res.render('pages/error', { error });
76+
}
77+
};

examples/idv/src/routes/use-cases-router.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
faceComparisonCheckController,
1515
faceMatchCheckController,
1616
watchlistCheckController,
17+
suppressedScreensCheckController,
1718
} = controllers.useCasesControllers;
1819

1920
const caseIdToControllerMapping = {
@@ -24,6 +25,7 @@ const caseIdToControllerMapping = {
2425
[Cases.FACE_COMPARISON]: faceComparisonCheckController,
2526
[Cases.FACE_MATCH]: faceMatchCheckController,
2627
[Cases.WATCHLIST]: watchlistCheckController,
28+
[Cases.SUPPRESSED_SCREENS]: suppressedScreensCheckController,
2729
};
2830

2931
const casesEntries = [...CasesMap.entries()];

examples/idv/src/useCases.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const Cases = {
66
FACE_COMPARISON: 'faceComparison',
77
FACE_MATCH: 'faceMatch',
88
WATCHLIST: 'watchlist',
9+
SUPPRESSED_SCREENS: 'suppressedScreens',
910
};
1011

1112
const CasesMap = new Map([
@@ -37,6 +38,10 @@ const CasesMap = new Map([
3738
name: 'Watchlist check',
3839
path: '/watchlist-check',
3940
}],
41+
[Cases.SUPPRESSED_SCREENS, {
42+
name: 'Suppressed screens check',
43+
path: '/suppressed-screens-check',
44+
}],
4045
]);
4146

4247
module.exports = {

src/idv_service/session/create/sdk.config.builder.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,20 @@ class SdkConfigBuilder {
264264
return this;
265265
}
266266

267+
/**
268+
* Sets the suppressed screens on the builder
269+
*
270+
* @param {string[]} screens
271+
*
272+
* @returns {this}
273+
*/
274+
withSuppressedScreens(screens) {
275+
Validation.notNullOrEmpty(screens, 'suppressedScreens');
276+
Validation.isArrayOfStrings(screens, 'suppressedScreens');
277+
this.suppressedScreens = screens;
278+
return this;
279+
}
280+
267281
/**
268282
* Builds the {@link SdkConfig} using the values supplied to the builder
269283
*
@@ -283,7 +297,8 @@ class SdkConfigBuilder {
283297
this.biometricConsentFlow,
284298
this.allowHandoff,
285299
this.attemptsConfiguration,
286-
this.brandId
300+
this.brandId,
301+
this.suppressedScreens
287302
);
288303
}
289304
}

src/idv_service/session/create/sdk.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class SdkConfig {
3030
* The attempts configuration
3131
* @param {string} brandId
3232
* The brandID for the client
33+
* @param {string[]} suppressedScreens
34+
* The list of suppressed screens
3335
*/
3436
constructor(
3537
allowedCaptureMethods,
@@ -44,7 +46,8 @@ class SdkConfig {
4446
biometricConsentFlow,
4547
allowHandoff,
4648
attemptsConfiguration,
47-
brandId
49+
brandId,
50+
suppressedScreens
4851
) {
4952
Validation.isString(allowedCaptureMethods, 'allowedCaptureMethods', true);
5053
/** @private */
@@ -99,6 +102,13 @@ class SdkConfig {
99102
Validation.isString(brandId, 'brandId', true);
100103
/** @private */
101104
this.brandId = brandId;
105+
106+
if (suppressedScreens) {
107+
Validation.notNullOrEmpty(suppressedScreens, 'suppressedScreens');
108+
Validation.isArrayOfStrings(suppressedScreens, 'suppressedScreens');
109+
/** @private */
110+
this.suppressedScreens = suppressedScreens;
111+
}
102112
}
103113

104114
/**
@@ -119,6 +129,7 @@ class SdkConfig {
119129
allow_handoff: this.allowHandoff,
120130
attempts_configuration: this.attemptsConfiguration,
121131
brand_id: this.brandId,
132+
suppressed_screens: this.suppressedScreens,
122133
};
123134
}
124135
}

tests/idv_service/session/create/sdk.config.builder.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('SdkConfigBuilder', () => {
1717
.withBiometricConsentFlow('some-flow')
1818
.withAllowHandoff(true)
1919
.withBrandId('some-brand-identifier')
20+
.withSuppressedScreens(['SCREEN_1', 'SCREEN_3'])
2021
.build();
2122

2223
const expectedJson = JSON.stringify({
@@ -32,6 +33,7 @@ describe('SdkConfigBuilder', () => {
3233
biometric_consent_flow: 'some-flow',
3334
allow_handoff: true,
3435
brand_id: 'some-brand-identifier',
36+
suppressed_screens: ['SCREEN_1', 'SCREEN_3'],
3537
});
3638

3739
expect(JSON.stringify(sdkConfig)).toBe(expectedJson);

types/src/idv_service/session/create/sdk.config.builder.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ declare class SdkConfigBuilder {
172172
*/
173173
withBrandId(brandId: string): this;
174174
brandId: string;
175+
/**
176+
* Sets the suppressed screens on the builder
177+
*
178+
* @param {string[]} screens
179+
*
180+
* @returns {this}
181+
*/
182+
withSuppressedScreens(screens: string[]): this;
183+
suppressedScreens: string[];
175184
/**
176185
* Builds the {@link SdkConfig} using the values supplied to the builder
177186
*

types/src/idv_service/session/create/sdk.config.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ declare class SdkConfig {
2727
* The attempts configuration
2828
* @param {string} brandId
2929
* The brandID for the client
30+
* @param {string[]} suppressedScreens
31+
* The list of suppressed screens
3032
*/
31-
constructor(allowedCaptureMethods: string, primaryColour: string, secondaryColour: string, fontColour: string, locale: string, presetIssuingCountry: string, successUrl: string, errorUrl: string, privacyPolicyUrl: string, biometricConsentFlow: string, allowHandoff: boolean, attemptsConfiguration: object, brandId: string);
33+
constructor(allowedCaptureMethods: string, primaryColour: string, secondaryColour: string, fontColour: string, locale: string, presetIssuingCountry: string, successUrl: string, errorUrl: string, privacyPolicyUrl: string, biometricConsentFlow: string, allowHandoff: boolean, attemptsConfiguration: object, brandId: string, suppressedScreens: string[]);
3234
/** @private */
3335
private allowedCaptureMethods;
3436
/** @private */
@@ -55,6 +57,8 @@ declare class SdkConfig {
5557
private attemptsConfiguration;
5658
/** @private */
5759
private brandId;
60+
/** @private */
61+
private suppressedScreens;
5862
/**
5963
* Returns serialized data for JSON.stringify()
6064
*/
@@ -72,5 +76,6 @@ declare class SdkConfig {
7276
allow_handoff: boolean;
7377
attempts_configuration: any;
7478
brand_id: string;
79+
suppressed_screens: string[];
7580
};
7681
}

types/src/idv_service/session/retrieve/breakdown.response.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ declare class BreakdownResponse {
1818
*/
1919
getResult(): string;
2020
/**
21-
* @returns {string} Likely 'AUTOMATED' or 'EXPERT_REVIEW'
21+
* @returns {string|undefined} Likely 'AUTOMATED' or 'EXPERT_REVIEW'
2222
*/
23-
getProcess(): string;
23+
getProcess(): string | undefined;
2424
/**
2525
* @returns {DetailsResponse[]}
2626
*/

0 commit comments

Comments
 (0)