Enrollment
Enrollment is the process of registering a new user by connecting their facial biometrics to a Keyless account. During this process, a full and unobstructed view of the user's face is required.
Enrollment with Web SDK can happen in two ways:
Live Enrollment, through the Keyless Web SDK JS libraries described below.
IDV Bridge SaaS, through the Keyless Authentication Service
On this page we'll explain how to perform only interactive live enrollment on the front-end.
Note Keyless also supports component interoperability, so that users could also be enrolled from IDV Bridge OnPremise or the Mobile SDK and still be authenticated via the Web SDK JS at a later date.
Headless Integration
The @keyless/sdk-web
library lets you integrate the Keyless Web SDK however you want in terms of UI/UX, let's see a basic example of enrollment:
import {
addKeylessEventListeners,
createKeylessMediaStream,
getLastKeylessFrameTriggeredBiometricFilters,
importKeylessWebAssemblyModule,
openKeylessWebSocketConnection,
reduceKeylessBiometricFiltersToTriggered,
removeKeylessEventListeners
} from '@keyless/sdk-web'
function requestTransactionJwtVerification(jwt) {}
function handleImportKeylessWebAssemblyModuleError(error) {}
function handleCreateKeylessMediaStreamError(error) {}
function handleOpenKeylessWebSocketConnectionError(error) {}
/**
* This event is fired when an error occurs during the enrollment process.
* The error object contains a `code` property that indicates the type of error.
*/
function onKeylessError(sym, error) {
/**
* Removing event listeners is advised on terminal events since
* no more than one attempt is allowed per enrollment symbol.
*/
removeKeylessEventListeners(sym)
// will log the error code
console.error(error.message)
}
/**
* This event is fired when the enrollment process is complete.
* It does not fire for failed attempts, only successful ones.
*/
function onKeylessFinished(sym, message) {
/**
* Removing event listeners is advised on terminal events since
* no more than one attempt is allowed per enrollment symbol.
*/
removeKeylessEventListeners(sym)
/**
* The `transactionJwt` is a JSON Web Token (JWT) that contains information
* about the enrollment transaction.
*
* This token is signed by the Keyless Authentication Service and can be used
* to verify the authenticity of the transaction.
*
* This operation is strictly backend-to-backend and should never be performed
* in client-side code.
*/
requestTransactionJwtVerification(message.transactionJwt)
}
/**
* This event is useful for providing real-time feedback to users during
* the enrollment process, such as prompting them to adjust their position
* or lighting conditions to improve biometric recognition.
*/
function onKeylessFrameResults(sym, message) {
let filters
/**
* Returns an array of biometric filters that were triggered in the last frame.
* If no biometric filters were triggered, an empty array is returned.
*/
filters = reduceKeylessBiometricFiltersToTriggered(message.filters)
/**
* Optionally, this function can be used to retrieve the filters that were triggered
* in the last frame.
*
* This can be useful if you need to access the last frame's triggered filters outside
* of the frame results event.
*
* If this function is used then this event is useful for requesting an update to the UI.
*/
filters = getLastKeylessFrameTriggeredBiometricFilters(sym)
}
async function enrollWithKeyless() {
let imprt, enroll, options, stream, open
/**
* Import the Keyless WebAssembly module.
* This is a required step before doing any operation with the Keyless SDK.
*/
imprt = await importKeylessWebAssemblyModule()
if (imprt instanceof Error) return handleImportKeylessWebAssemblyModuleError(imprt)
/**
* Create a Keyless enrollment symbol.
*
* This symbol must be kept in memory for the duration of the enrollment process.
* To perform multiple enrollments, a new symbol must be created for each enrollment.
*/
enroll = createKeylessEnroll()
/**
* Add event listeners through the Keyless enrollment symbol.
* These listeners will handle events during the enrollment process.
*/
addKeylessEventListeners(enroll, [
{ name: 'error', callback: (error) => onKeylessError(enroll, error) },
{ name: 'finished', callback: (message) => onKeylessFinished(enroll, message) },
{ name: 'frame-results', callback: (message) => onKeylessFrameResults(enroll, message) }
])
options = {
customer: { name: 'CUSTOMER_NAME' },
key: { id: 'IMAGE_ENCRYPTION_KEY_ID', value: 'IMAGE_ENCRYPTION_PUBLIC_KEY' },
transaction: {
data: 'DATA_FROM_CUSTOMER_SERVER_TO_BE_SIGNED'
},
username: 'USERNAME',
ws: { url: 'KEYLESS_AUTHENTICATION_SERVICE_URL' }
}
/**
* Create a media stream from the user's video input media device.
* This stream will be used to capture video frames for biometric analysis.
*
* Note: The user must grant permission to access the media device.
*/
stream = await createKeylessMediaStream()
if (stream instanceof Error) return handleCreateKeylessMediaStreamError(stream)
/**
* Open a WebSocket connection to the Keyless Authentication Service.
* This connection will be used to process video frames and receive enrollment results.
*/
open = await openKeylessWebSocketConnection(enroll, options)
if (open instanceof Error) return handleOpenKeylessWebSocketConnectionError(open)
}
enrollWithKeyless()
Web Component Integration
Now that we have explained how to perform enrollment in a headless way with the @keyless/sdk-web package, here is an example of doing so with common setups:
import '@keyless/sdk-web-components'
export function KeylessEnroll() {
function requestTransactionJwtVerification(jwt) {}
onError = (event) => {
// will log the error code
console.log(event.message)
}
onFinished = (event) => {
/**
* The `transactionJwt` is a JSON Web Token (JWT) that contains information
* about the enrollment transaction.
*
* This token is signed by the Keyless Authentication Service and can be used
* to verify the authenticity of the transaction.
*
* This operation is strictly backend-to-backend and should never be performed
* in client-side code.
*/
requestTransactionJwtVerification(message.transactionJwt)
}
return (
<kl-enroll
customer='CUSTOMER_NAME'
enable-camera-instructions
key-id='IMAGE_ENCRYPTION_KEY_ID'
lang='en'
onerror={onError}
onfinished={onfinished}
public-key='IMAGE_ENCRYPTION_PUBLIC_KEY'
size='375'
theme='light'
transaction-data='DATA_FROM_CUSTOMER_SERVER_TO_BE_SIGNED'
username='USERNAME'
ws-url='KEYLESS_AUTHENTICATION_SERVICE_URL'
/>
)
}
Last updated
Was this helpful?