Skip to content

Commit

Permalink
SDK-2465 support advanced identity profile in IDV (#478)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
laurent-yoti authored Jun 24, 2024
1 parent ae0ff82 commit ca41d9e
Show file tree
Hide file tree
Showing 80 changed files with 2,301 additions and 211 deletions.
2 changes: 1 addition & 1 deletion examples/idv-identity-checks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
1. Start the server `npm start`
1. Visit `https://localhost:3003`

* _The [default controller](./src/controllers/index.controller.js) demonstrates how to create an IDV session_
* _The [default controller](./src/controllers/session.controller.js) demonstrates how to create an IDV session_
* _The [success controller](./src/controllers/success.controller.js) demonstrates how to retrieve an IDV session_
1 change: 1 addition & 0 deletions examples/idv-identity-checks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ app.use(session({
const router = express.Router();

router.get('/', controllers.indexController);
router.post('/session', controllers.sessionController);
router.get('/success', controllers.successController);
router.get('/media', controllers.mediaController);
router.get('/error', controllers.errorController);
Expand Down
62 changes: 3 additions & 59 deletions examples/idv-identity-checks/src/controllers/index.controller.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,4 @@
const {
IDVClient,
SessionSpecificationBuilder,
SdkConfigBuilder,
} = require('yoti');
const config = require('../../config');

/**
* Create an IDV session.
*/
async function createSession() {
const idvClient = new IDVClient(config.YOTI_CLIENT_SDK_ID, config.YOTI_PEM);

const subject = {
subject_id: 'subject_id_string',
};

const identityProfileRequirements = {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'DBS',
objective: 'BASIC',
},
};

const sessionSpec = new SessionSpecificationBuilder()
.withClientSessionTokenTtl(600) // 10 minutes
.withResourcesTtl(90000) // session TTL(10 minutes) + 24 hours(minimum required)
.withUserTrackingId('some-user-tracking-id')
.withSubject(subject)
.withIdentityProfileRequirements(identityProfileRequirements)
.withSdkConfig(
new SdkConfigBuilder()
.withPrimaryColour('#2d9fff')
.withLocale('en-GB')
.withPresetIssuingCountry('GBR')
.withSuccessUrl(`${config.YOTI_APP_BASE_URL}/success`)
.withErrorUrl(`${config.YOTI_APP_BASE_URL}/error`)
.withAllowHandoff(true)
.build()
)
.build();

return idvClient.createSession(sessionSpec);
}

module.exports = async (req, res) => {
try {
const session = await createSession();

req.session.IDV_SESSION_ID = session.getSessionId();
req.session.IDV_SESSION_TOKEN = session.getClientSessionToken();

res.render('pages/index', {
iframeUrl: `${config.YOTI_IDV_IFRAME_URL}?sessionID=${req.session.IDV_SESSION_ID}&sessionToken=${req.session.IDV_SESSION_TOKEN}`,
});
} catch (error) {
res.render('pages/error', { error });
}
module.exports = (req, res) => {
res.render('pages/index', {
});
};
2 changes: 2 additions & 0 deletions examples/idv-identity-checks/src/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const indexController = require('./index.controller');
const sessionController = require('./session.controller');
const successController = require('./success.controller');
const mediaController = require('./media.controller');
const errorController = require('./error.controller');

module.exports = {
indexController,
sessionController,
successController,
mediaController,
errorController,
Expand Down
128 changes: 128 additions & 0 deletions examples/idv-identity-checks/src/controllers/session.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
const {
IDVClient,
SessionSpecificationBuilder,
SdkConfigBuilder,
AdvancedIdentityProfileBuilder,
AdvancedIdentityProfileRequirementsBuilder,
AdvancedIdentityProfileSchemeBuilder,
} = require('yoti');
const config = require('../../config');

const identityProfileRequirementsDescriptors = {
RTW: {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'RTW',
},
},
RTR: {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'RTR',
},
},
DBS_BASIC: {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'DBS',
objective: 'BASIC',
},
},
DBS_BASIC_RTW: {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'DBS_RTW',
objective: 'BASIC',
},
},
};

/**
* Create an IDV session.
*/
async function createSession(scheme) {
const idvClient = new IDVClient(config.YOTI_CLIENT_SDK_ID, config.YOTI_PEM);

const sessionSpecificationBuilder = new SessionSpecificationBuilder();

const subject = {
subject_id: 'some_subject_id_string',
};

if (scheme === 'MTF_BASE') {
const advancedIdentityProfileSchemeDBS = new AdvancedIdentityProfileSchemeBuilder()
.withType('DBS')
.withObjective('BASIC')
.withLabel('label-for-DBS-BASIC')
.build();

const advancedIdentityProfileSchemeRTW = new AdvancedIdentityProfileSchemeBuilder()
.withType('RTW')
.withLabel('label-for-RTW')
.build();

const advancedIdentityProfileUKTFIDA = new AdvancedIdentityProfileBuilder()
.withTrustFramework('UK_TFIDA')
.withScheme(advancedIdentityProfileSchemeDBS)
.withScheme(advancedIdentityProfileSchemeRTW)
.build();

const advancedIdentityProfileSchemeAL1 = new AdvancedIdentityProfileSchemeBuilder()
.withType('IDENTITY')
.withObjective('AL_L1')
.withLabel('label-for-IDENTITY-AL-L1')
.build();

const advancedIdentityProfileYotiGlobal = new AdvancedIdentityProfileBuilder()
.withTrustFramework('YOTI_GLOBAL')
.withScheme(advancedIdentityProfileSchemeAL1)
.build();

const advancedIdentityProfileRequirements = new AdvancedIdentityProfileRequirementsBuilder()
.withProfile(advancedIdentityProfileUKTFIDA)
.withProfile(advancedIdentityProfileYotiGlobal)
.build();

sessionSpecificationBuilder
.withAdvancedIdentityProfileRequirements(advancedIdentityProfileRequirements);
} else {
const identityProfileRequirements = identityProfileRequirementsDescriptors[scheme];
sessionSpecificationBuilder
.withIdentityProfileRequirements(identityProfileRequirements);
}

const sessionSpec = sessionSpecificationBuilder
.withClientSessionTokenTtl(600) // 10 minutes
.withResourcesTtl(90000) // session TTL(10 minutes) + 24 hours(minimum required)
.withUserTrackingId('some-user-tracking-id')
.withSubject(subject)
.withSdkConfig(
new SdkConfigBuilder()
.withPrimaryColour('#2d9fff')
.withLocale('en-GB')
.withPresetIssuingCountry('GBR')
.withSuccessUrl(`${config.YOTI_APP_BASE_URL}/success`)
.withErrorUrl(`${config.YOTI_APP_BASE_URL}/error`)
.withAllowHandoff(true)
.withAllowsCameraAndUpload()
.build()
)
.build();

return idvClient.createSession(sessionSpec);
}

module.exports = async (req, res) => {
const { scheme } = req.body;
try {
const session = await createSession(scheme);

req.session.IDV_SESSION_ID = session.getSessionId();
req.session.IDV_SESSION_TOKEN = session.getClientSessionToken();
res.render('pages/session', {
iframeUrl: `${config.YOTI_IDV_IFRAME_URL}?sessionID=${req.session.IDV_SESSION_ID}&sessionToken=${req.session.IDV_SESSION_TOKEN}`,
});
} catch (error) {
res.render('pages/error', { error });
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion examples/idv-identity-checks/static/images/logo.svg

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 63 additions & 4 deletions examples/idv-identity-checks/static/style.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,67 @@

body {
padding-top: 4.5rem;
.yoti-body {
margin: 0;
}

table td:first-child {
width: 30%;
}
}

.yoti-html {
height: 100%;
}

.yoti-top-section {
display: flex;
flex-direction: column;
padding: 20px 0;
align-items: center;
}

.yoti-logo-section {
margin-bottom: 10px;
}

.yoti-logo-image {
display: block;
}

.yoti-main-title {
text-align:center;
font-size:25px;
color:#2875bc;
}

.yoti-checks-section {
display: flex;
flex-direction: column;
margin-top: 150px;
align-items: center;
}

.yoti-checks-scheme {
font-weight: bold;
font-size: large;
}

.yoti-error-container {
color: #664d03;
background-color: #fff3cd;
border-color: #ffecb5;
position: relative;
padding: 1rem 1rem;
margin: 20px;
border-radius: 0.25rem;
}

.yoti-submit-button {
margin: 30px;
font-family: GT Eesti Display, sans-serif;
font-size: 15px;
font-weight: bold;
box-sizing: border-box;
width: 200px;
height: 50px;
border-radius: 12px;
color: #fff;
background-color: #2875bc;
}
21 changes: 20 additions & 1 deletion examples/idv-identity-checks/views/pages/index.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<%- include('layout/header'); -%>
<iframe style="border:none;" width="100%" height="750" allow="camera" src="<%= iframeUrl %>" allowfullscreen></iframe>
<main>
<h1 class="yoti-main-title">Identity check example</h1>
<form action="/session" method="post">
<div class="yoti-checks-section">
<div>
<label for="selectedScheme" class="yoti-checks-scheme">Select identity check scheme: </label>
<select name="scheme" id="selectedScheme">
<option value="DBS_BASIC">DBS-BASIC</option>
<option value="RTW">RTW</option>
<option value="RTR">RTR</option>
<option value="DBS_BASIC_RTW">DBS-BASIC & RTW</option>
<option value="MTF_BASE">Advanced - UK_TFIDA(DBS-BASIC & RTW) + YOTI_GLOBAL(IDENTITY-AL_L1)</option>
</select>
</div>
<div>
<button class="yoti-submit-button" type="submit" id="submitButton">Create session</button>
</div>
</div>
</form>
</main>
<%- include('layout/footer'); -%>
19 changes: 12 additions & 7 deletions examples/idv-identity-checks/views/pages/layout/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
<link rel="icon" type="image/png" href="/static/images/favicon.png" />
</head>

<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<a href="/" class="navbar-brand">
<img src="/static/images/logo.svg" height="30" class="d-inline-block align-top mr-2">
IDV
</a>
</nav>
<body class="yoti-body">
<section class="yoti-top-section">
<div class="yoti-logo-section">
<a href="/">
<img
class="yoti-logo-image"
src="/static/images/logo.png"
srcset="/static/images/[email protected] 2x"
alt="Yoti"/>
</a>
</div>
</section>
Loading

0 comments on commit ca41d9e

Please sign in to comment.