Skip to content

Commit 30e3b55

Browse files
committed
SDK-2465 support advanced identity profile in IDV (#478)
* Added all files to create and retrieve Advanced Identity Profile * Added unit-tests for idv_service/session/create/identity_profile/advanced * Added unit-tests for idv_service/session/retrieve/identity_profile/advanced * Added idv_service/session/retrieve/get.session.result * Updated session.specification.builder and session.specification * Export of AdvancedIdentityProfile builders from idv_service, then from top level. * Updated examples /examples/idv-identity-checks to use advanced identity profile (to be reviewed) * Fixed create advanced.identity.profile.scheme * Removed logs * Added in IDV retrieve/identity.profile.scheme.response Removed label * Move single identity profile to folder * Added/cleaned-up JSDoc and remove @type (as not compatible for both JS and TS completion) * Eslint in examples (temporary) * Updated example for adding Advanced identity profile check in the IDV flow.
1 parent b06562b commit 30e3b55

File tree

80 files changed

+2301
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2301
-211
lines changed

examples/idv-identity-checks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
1. Start the server `npm start`
88
1. Visit `https://localhost:3003`
99

10-
* _The [default controller](./src/controllers/index.controller.js) demonstrates how to create an IDV session_
10+
* _The [default controller](./src/controllers/session.controller.js) demonstrates how to create an IDV session_
1111
* _The [success controller](./src/controllers/success.controller.js) demonstrates how to retrieve an IDV session_

examples/idv-identity-checks/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ app.use(session({
2424
const router = express.Router();
2525

2626
router.get('/', controllers.indexController);
27+
router.post('/session', controllers.sessionController);
2728
router.get('/success', controllers.successController);
2829
router.get('/media', controllers.mediaController);
2930
router.get('/error', controllers.errorController);
Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,4 @@
1-
const {
2-
IDVClient,
3-
SessionSpecificationBuilder,
4-
SdkConfigBuilder,
5-
} = require('yoti');
6-
const config = require('../../config');
7-
8-
/**
9-
* Create an IDV session.
10-
*/
11-
async function createSession() {
12-
const idvClient = new IDVClient(config.YOTI_CLIENT_SDK_ID, config.YOTI_PEM);
13-
14-
const subject = {
15-
subject_id: 'subject_id_string',
16-
};
17-
18-
const identityProfileRequirements = {
19-
trust_framework: 'UK_TFIDA',
20-
scheme: {
21-
type: 'DBS',
22-
objective: 'BASIC',
23-
},
24-
};
25-
26-
const sessionSpec = new SessionSpecificationBuilder()
27-
.withClientSessionTokenTtl(600) // 10 minutes
28-
.withResourcesTtl(90000) // session TTL(10 minutes) + 24 hours(minimum required)
29-
.withUserTrackingId('some-user-tracking-id')
30-
.withSubject(subject)
31-
.withIdentityProfileRequirements(identityProfileRequirements)
32-
.withSdkConfig(
33-
new SdkConfigBuilder()
34-
.withPrimaryColour('#2d9fff')
35-
.withLocale('en-GB')
36-
.withPresetIssuingCountry('GBR')
37-
.withSuccessUrl(`${config.YOTI_APP_BASE_URL}/success`)
38-
.withErrorUrl(`${config.YOTI_APP_BASE_URL}/error`)
39-
.withAllowHandoff(true)
40-
.build()
41-
)
42-
.build();
43-
44-
return idvClient.createSession(sessionSpec);
45-
}
46-
47-
module.exports = async (req, res) => {
48-
try {
49-
const session = await createSession();
50-
51-
req.session.IDV_SESSION_ID = session.getSessionId();
52-
req.session.IDV_SESSION_TOKEN = session.getClientSessionToken();
53-
54-
res.render('pages/index', {
55-
iframeUrl: `${config.YOTI_IDV_IFRAME_URL}?sessionID=${req.session.IDV_SESSION_ID}&sessionToken=${req.session.IDV_SESSION_TOKEN}`,
56-
});
57-
} catch (error) {
58-
res.render('pages/error', { error });
59-
}
1+
module.exports = (req, res) => {
2+
res.render('pages/index', {
3+
});
604
};

examples/idv-identity-checks/src/controllers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const indexController = require('./index.controller');
2+
const sessionController = require('./session.controller');
23
const successController = require('./success.controller');
34
const mediaController = require('./media.controller');
45
const errorController = require('./error.controller');
56

67
module.exports = {
78
indexController,
9+
sessionController,
810
successController,
911
mediaController,
1012
errorController,
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
const {
2+
IDVClient,
3+
SessionSpecificationBuilder,
4+
SdkConfigBuilder,
5+
AdvancedIdentityProfileBuilder,
6+
AdvancedIdentityProfileRequirementsBuilder,
7+
AdvancedIdentityProfileSchemeBuilder,
8+
} = require('yoti');
9+
const config = require('../../config');
10+
11+
const identityProfileRequirementsDescriptors = {
12+
RTW: {
13+
trust_framework: 'UK_TFIDA',
14+
scheme: {
15+
type: 'RTW',
16+
},
17+
},
18+
RTR: {
19+
trust_framework: 'UK_TFIDA',
20+
scheme: {
21+
type: 'RTR',
22+
},
23+
},
24+
DBS_BASIC: {
25+
trust_framework: 'UK_TFIDA',
26+
scheme: {
27+
type: 'DBS',
28+
objective: 'BASIC',
29+
},
30+
},
31+
DBS_BASIC_RTW: {
32+
trust_framework: 'UK_TFIDA',
33+
scheme: {
34+
type: 'DBS_RTW',
35+
objective: 'BASIC',
36+
},
37+
},
38+
};
39+
40+
/**
41+
* Create an IDV session.
42+
*/
43+
async function createSession(scheme) {
44+
const idvClient = new IDVClient(config.YOTI_CLIENT_SDK_ID, config.YOTI_PEM);
45+
46+
const sessionSpecificationBuilder = new SessionSpecificationBuilder();
47+
48+
const subject = {
49+
subject_id: 'some_subject_id_string',
50+
};
51+
52+
if (scheme === 'MTF_BASE') {
53+
const advancedIdentityProfileSchemeDBS = new AdvancedIdentityProfileSchemeBuilder()
54+
.withType('DBS')
55+
.withObjective('BASIC')
56+
.withLabel('label-for-DBS-BASIC')
57+
.build();
58+
59+
const advancedIdentityProfileSchemeRTW = new AdvancedIdentityProfileSchemeBuilder()
60+
.withType('RTW')
61+
.withLabel('label-for-RTW')
62+
.build();
63+
64+
const advancedIdentityProfileUKTFIDA = new AdvancedIdentityProfileBuilder()
65+
.withTrustFramework('UK_TFIDA')
66+
.withScheme(advancedIdentityProfileSchemeDBS)
67+
.withScheme(advancedIdentityProfileSchemeRTW)
68+
.build();
69+
70+
const advancedIdentityProfileSchemeAL1 = new AdvancedIdentityProfileSchemeBuilder()
71+
.withType('IDENTITY')
72+
.withObjective('AL_L1')
73+
.withLabel('label-for-IDENTITY-AL-L1')
74+
.build();
75+
76+
const advancedIdentityProfileYotiGlobal = new AdvancedIdentityProfileBuilder()
77+
.withTrustFramework('YOTI_GLOBAL')
78+
.withScheme(advancedIdentityProfileSchemeAL1)
79+
.build();
80+
81+
const advancedIdentityProfileRequirements = new AdvancedIdentityProfileRequirementsBuilder()
82+
.withProfile(advancedIdentityProfileUKTFIDA)
83+
.withProfile(advancedIdentityProfileYotiGlobal)
84+
.build();
85+
86+
sessionSpecificationBuilder
87+
.withAdvancedIdentityProfileRequirements(advancedIdentityProfileRequirements);
88+
} else {
89+
const identityProfileRequirements = identityProfileRequirementsDescriptors[scheme];
90+
sessionSpecificationBuilder
91+
.withIdentityProfileRequirements(identityProfileRequirements);
92+
}
93+
94+
const sessionSpec = sessionSpecificationBuilder
95+
.withClientSessionTokenTtl(600) // 10 minutes
96+
.withResourcesTtl(90000) // session TTL(10 minutes) + 24 hours(minimum required)
97+
.withUserTrackingId('some-user-tracking-id')
98+
.withSubject(subject)
99+
.withSdkConfig(
100+
new SdkConfigBuilder()
101+
.withPrimaryColour('#2d9fff')
102+
.withLocale('en-GB')
103+
.withPresetIssuingCountry('GBR')
104+
.withSuccessUrl(`${config.YOTI_APP_BASE_URL}/success`)
105+
.withErrorUrl(`${config.YOTI_APP_BASE_URL}/error`)
106+
.withAllowHandoff(true)
107+
.withAllowsCameraAndUpload()
108+
.build()
109+
)
110+
.build();
111+
112+
return idvClient.createSession(sessionSpec);
113+
}
114+
115+
module.exports = async (req, res) => {
116+
const { scheme } = req.body;
117+
try {
118+
const session = await createSession(scheme);
119+
120+
req.session.IDV_SESSION_ID = session.getSessionId();
121+
req.session.IDV_SESSION_TOKEN = session.getClientSessionToken();
122+
res.render('pages/session', {
123+
iframeUrl: `${config.YOTI_IDV_IFRAME_URL}?sessionID=${req.session.IDV_SESSION_ID}&sessionToken=${req.session.IDV_SESSION_TOKEN}`,
124+
});
125+
} catch (error) {
126+
res.render('pages/error', { error });
127+
}
128+
};
2.92 KB
Loading

examples/idv-identity-checks/static/images/logo.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.
5.48 KB
Loading
Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,67 @@
1-
2-
body {
3-
padding-top: 4.5rem;
1+
.yoti-body {
2+
margin: 0;
43
}
54

65
table td:first-child {
76
width: 30%;
8-
}
7+
}
8+
9+
.yoti-html {
10+
height: 100%;
11+
}
12+
13+
.yoti-top-section {
14+
display: flex;
15+
flex-direction: column;
16+
padding: 20px 0;
17+
align-items: center;
18+
}
19+
20+
.yoti-logo-section {
21+
margin-bottom: 10px;
22+
}
23+
24+
.yoti-logo-image {
25+
display: block;
26+
}
27+
28+
.yoti-main-title {
29+
text-align:center;
30+
font-size:25px;
31+
color:#2875bc;
32+
}
33+
34+
.yoti-checks-section {
35+
display: flex;
36+
flex-direction: column;
37+
margin-top: 150px;
38+
align-items: center;
39+
}
40+
41+
.yoti-checks-scheme {
42+
font-weight: bold;
43+
font-size: large;
44+
}
45+
46+
.yoti-error-container {
47+
color: #664d03;
48+
background-color: #fff3cd;
49+
border-color: #ffecb5;
50+
position: relative;
51+
padding: 1rem 1rem;
52+
margin: 20px;
53+
border-radius: 0.25rem;
54+
}
55+
56+
.yoti-submit-button {
57+
margin: 30px;
58+
font-family: GT Eesti Display, sans-serif;
59+
font-size: 15px;
60+
font-weight: bold;
61+
box-sizing: border-box;
62+
width: 200px;
63+
height: 50px;
64+
border-radius: 12px;
65+
color: #fff;
66+
background-color: #2875bc;
67+
}
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
<%- include('layout/header'); -%>
2-
<iframe style="border:none;" width="100%" height="750" allow="camera" src="<%= iframeUrl %>" allowfullscreen></iframe>
2+
<main>
3+
<h1 class="yoti-main-title">Identity check example</h1>
4+
<form action="/session" method="post">
5+
<div class="yoti-checks-section">
6+
<div>
7+
<label for="selectedScheme" class="yoti-checks-scheme">Select identity check scheme: </label>
8+
<select name="scheme" id="selectedScheme">
9+
<option value="DBS_BASIC">DBS-BASIC</option>
10+
<option value="RTW">RTW</option>
11+
<option value="RTR">RTR</option>
12+
<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>
14+
</select>
15+
</div>
16+
<div>
17+
<button class="yoti-submit-button" type="submit" id="submitButton">Create session</button>
18+
</div>
19+
</div>
20+
</form>
21+
</main>
322
<%- include('layout/footer'); -%>

0 commit comments

Comments
 (0)