-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
ae0ff82
commit ca41d9e
Showing
80 changed files
with
2,301 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 3 additions & 59 deletions
62
examples/idv-identity-checks/src/controllers/index.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', { | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
examples/idv-identity-checks/src/controllers/session.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> |
Oops, something went wrong.