Embedded IDV
To successfully integrate Embedded IDV through Yoti's SDK, there are two prerequisites:
- SDK ID
- Application key pair (.PEM file)
These details can be retrieved from the application that was created in the Yoti Hub.
Install the SDK
Yoti SDKs are available for several languages through popular dependency management systems.
To install the SDK:
npm install -S -E yoti
Using Yoti SDKs
The description on how to use the above endpoint from the SDK can be found here:
Please read the above for a full description and understanding, below we have provided examples on how those requests will expose the new functionality.
First, specify the required imports and create a DocScanClient using the SDK ID and the PEM file. Then, define the subject to be returned in the verification report. And set the identity profile requirements to your desired scheme. You will need to set up the SDK configuration and a session specification using the scheme requirements and the SDK config. Finally, use the DocScanClient to create a session by providing the session specification. Retrieve the Session ID and Client Session Token and utilise them to generate the iframe URL.
const path = require('path');
const fs = require('fs');
const {
IDVClient,
SessionSpecificationBuilder,
SdkConfigBuilder,
} = require('yoti');
const YOTI_CLIENT_SDK_ID = 'YOTI_CLIENT_SDK_ID';
const YOTI_PEM = fs.readFileSync(path.join(__dirname, '/path/to/pem'));
const idvClient = new IDVClient(YOTI_CLIENT_SDK_ID, YOTI_PEM);
const subject = {
subject_id: 'subject_id_string',
};
const identityProfileRequirements() = {
trust_framework: 'UK_TFIDA',
scheme: {
type: 'DBS',
objective: 'STANDARD',
},
};
const sdkConfig = new SdkConfigBuilder()
.withAllowHandoff(true)
.withSuccessUrl(`${APP_BASE_URL}/success`)
.withErrorUrl(`${APP_BASE_URL}/error`)
.build();
const sessionSpec = new SessionSpecificationBuilder()
.withSubject(subject)
.withIdentityProfileRequirements(identityProfileRequirements)
.withSdkConfig(sdkConfig)
.build();
const session = await idvClient.createSession(sessionSpec);
const sessionId = session.getSessionId();
const clientSessionToken = session.getClientSessionToken();
const iframeURL = `${config.YOTI_DOC_SCAN_IFRAME_URL}? sessionID=${sessionId}&sessionToken=${clientSessionToken}`;
Subject Explained
Field | Value | Description | Mandatory |
---|---|---|---|
subject | Object | Allows to provide information on the subject. | Optional |
subject_id | String | Allows to track the same user across multiple sessions. Should not contain any personal identifiable information. | Optional |
Identity Profile Requirements Explained
Field | Value | Description | Mandatory |
---|---|---|---|
trust_framework | String | Defines under which trust framework this identity profile should be verified. Enum: UK_TFIDA | Required |
scheme | Object | Defines which scheme this identity profile should satisfy. The scheme must be supported by the specified trust framework otherwise the request is considered invalid. | Required |
type | String | Defines which scheme this identity profile should satisfy. Enum: DBS, RTW, RTR, DBS_RTW | Required |
objective | String | Defines the objective to be achieved for the particular scheme. It must be provided for those schemes where it is mandatory. Example, this is mandatory for DBS and the possible values are: ”BASIC”, “STANDARD”, “ENHANCED”. | Required |
Client side view
Once you have generated the iframe URL, you can send it to the frontend for it to be rendered on the page. Please see example below:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Embedded IDV Integration</title>
</head>
<body>
<div>
<iframe style="border:none;" width="100%" height="750" allow="camera" src="<%= iframeUrl %>" allowfullscreen></iframe>
</div>
</body>
</html>
Retrieve Results
After a session has been created, you can use the Yoti SDK to retrieve the session result (containing all the end-user's uploaded documents and associated metadata).
Result of the session
Session retrieval requires a session ID. This is generated while creating a session as demonstrated above.
// Returns the session result
const sessionResult = await idvClient.getSession(sessionId);
// Returns the session state
const state = sessionResult.getState();
// Returns session resources
const resources = session.getResources();
Retrieve Media
In order to retrieve document images and document fields from the resources container we have to look for the relevant media ID inside of the id document pages.
// Returns a collection of ID Documents
const idDocuments = resources.getIdDocuments();
const media = await idvClient.getMediaContent(sessionId, mediaId);
const buffer = media.getContent();
const base64Content = media.getBase64Content();
const mimeType = media.getMimeType();
Retrieve Identity Profile
Once the session has reached the state of 'Completed', identify profile can be successfully retrieved.
In case of a successful transaction, once the identity profile is received, the identity profile report JSON will be accessible. This contains the media ID which can then be used to get the full JSON response of the report.
const identityProfile = sessionResult.getIdentityProfile();
const identityProfileReport = identityProfile.getIdentityProfileReport();
const mediaID = identityProfileReport.getMedia().getId();
const identityProfileReportMedia = await idvClient.getMediaContent(sessionId, mediaId);
const identityProfileReportMediaBuffer = identityProfileReportMedia.getContent();