Error handling
The PingOne Recognize Web SDK can generate a variety of errors when processing authentication (KeylessAuth) and enrollment (KeylessEnroll) requests.
Error types
The PingOne Recognize Web SDK generates the following error types:
-
General
errorevents common to web applications -
WebSocket specific (
ws-error) errors
Registering event listeners
To handle errors, register an error event listener, as shown in the following example:
import { createKeylessAuth } from '@keyless/sdk-web'
function onKeylessError(error) {
// will log the error code
console.log(error.message)
}
const auth = createKeylessAuth()
// register the error event listener
addKeylessEventListener(auth, 'error', onKeylessError)
// opening a connection without the required options will always emit an error
openKeylessWebSocketConnection(auth, {})
Enrollment components, such as KeylessEnroll, also support error event listeners.
Handling errors
When errors occur, the error object passed to the event listener contains an error code defined in the KeylessError enumeration exported by the @keyless/sdk-web package:
Details
enum KeylessError {
FRAME_RESULTS_SET_UNSET = 'FRAME_RESULTS_SET_UNSET',
OPTIONS_UNSET = 'OPTIONS_UNSET',
VIDEO_ELEMENT_UNSET = 'VIDEO_ELEMENT_UNSET',
VIDEO_ELEMENT_EVENT_LISTENERS_UNSET = 'VIDEO_ELEMENT_EVENT_LISTENERS_UNSET',
WEB_SOCKET_MESSAGE_SET_UNSET = 'WEB_SOCKET_MESSAGE_SET_UNSET',
MEDIA_DEVICES_EMPTY_VIDEO_INPUT_LABEL = 'MEDIA_DEVICES_EMPTY_VIDEO_INPUT_LABEL',
MEDIA_DEVICES_NO_VIDEO_INPUTS = 'MEDIA_DEVICES_NO_VIDEO_INPUTS',
MEDIA_STREAM_ABORT = 'MEDIA_STREAM_ABORT',
MEDIA_STREAM_INVALID_STATE = 'MEDIA_STREAM_INVALID_STATE',
MEDIA_STREAM_NOT_ALLOWED = 'MEDIA_STREAM_NOT_ALLOWED',
MEDIA_STREAM_NOT_FOUND = 'MEDIA_STREAM_NOT_FOUND',
MEDIA_STREAM_NOT_READABLE = 'MEDIA_STREAM_NOT_READABLE',
MEDIA_STREAM_OVERCONSTRAINED = 'MEDIA_STREAM_OVERCONSTRAINED',
MEDIA_STREAM_SECURITY = 'MEDIA_STREAM_SECURITY',
MEDIA_STREAM_TYPE = 'MEDIA_STREAM_TYPE',
MEDIA_STREAM_UNSET = 'MEDIA_STREAM_UNSET',
SERVER_CUSTOMER_NOT_FOUND = 'SERVER_CUSTOMER_NOT_FOUND',
SERVER_FACE_DOES_NOT_MATCH = 'SERVER_FACE_DOES_NOT_MATCH',
SERVER_FORBIDDEN = 'SERVER_FORBIDDEN',
SERVER_IMAGE_ENCRYPT_FAILED = 'SERVER_IMAGE_ENCRYPT_FAILED',
SERVER_INTERNAL_ERROR = 'SERVER_INTERNAL_ERROR',
SERVER_NO_ATTEMPTS_LEFT = 'SERVER_NO_ATTEMPTS_LEFT',
SERVER_RECOGNITION_FAILED = 'SERVER_RECOGNITION_FAILED',
SERVER_TIMEOUT = 'SERVER_TIMEOUT',
SERVER_UNAVAILABLE_SERVICE = 'SERVER_UNAVAILABLE_SERVICE',
SERVER_UNPROCESSABLE_EVENT = 'SERVER_UNPROCESSABLE_EVENT',
SERVER_USER_ALREADY_ENROLLED = 'SERVER_USER_ALREADY_ENROLLED',
SERVER_USER_NOT_FOUND = 'SERVER_USER_NOT_FOUND',
SERVER_USER_LOCKED_OUT = 'SERVER_USER_LOCKED_OUT',
SERVER_VALIDATION_FAILED = 'SERVER_VALIDATION_FAILED',
SESSION_MANAGER_NOT_NULL = 'SESSION_MANAGER_NOT_NULL',
SESSION_MANAGER_NULL = 'SESSION_MANAGER_NULL',
CREATE_MEDIA_STREAM_ARGS_UNSET = 'CREATE_MEDIA_STREAM_ARGS_UNSET',
EXCEPTION = 'EXCEPTION',
RUNTIME_VIOLATION = 'RUNTIME_VIOLATION',
SYMBOL_DESCRIPTION_UNSET = 'SYMBOL_DESCRIPTION_UNSET',
SESSION_ID_UNSET = 'SESSION_ID_UNSET',
CUSTOMER_UNSET = 'CUSTOMER_UNSET',
KEY_DECODE_FAILED = 'KEY_DECODE_FAILED',
KEY_UNSET = 'KEY_UNSET',
KEY_ID_UNSET = 'KEY_ID_UNSET',
USERNAME_UNSET = 'USERNAME_UNSET',
WEB_SOCKET_URL_PARSE_FAILED = 'WEB_SOCKET_URL_PARSE_FAILED',
WEB_SOCKET_URL_UNSET = 'WEB_SOCKET_URL_UNSET',
WEB_ASSEMBLY_ABORTED = 'WEB_ASSEMBLY_ABORTED',
WEB_ASSEMBLY_FACTORY_FAILED = 'WEB_ASSEMBLY_FACTORY_FAILED',
WEB_ASSEMBLY_IMPORT_FAILED = 'WEB_ASSEMBLY_IMPORT_FAILED',
WEB_ASSEMBLY_NOT_READY = 'WEB_ASSEMBLY_NOT_READY',
WEB_ASSEMBLY_MODULE_NOT_FOUND = 'WEB_ASSEMBLY_MODULE_NOT_FOUND',
WEB_SOCKET_ERROR = 'WEB_SOCKET_ERROR',
WEB_SOCKET_OPEN = 'WEB_SOCKET_OPEN',
WEB_SOCKET_TIMEOUT = 'WEB_SOCKET_TIMEOUT',
WEB_SOCKET_UNEXPECTED_CLOSE = 'WEB_SOCKET_UNEXPECTED_CLOSE'
}
Error reference
Error |
Description |
|
Internal error; contact Support |
|
Internal error; contact Support |
|
Invalid state error, |
|
Internal error; contact Support |
|
Internal error; contact Support |
|
The user is locked out on their client device |
|
The user did not grant permission to use the camera |
|
The user’s device does not have a camera |
|
An |
|
An |
|
A |
|
A |
|
A |
|
An |
|
A |
|
A |
|
Integration error. The |
|
The customer does not exist. Contact Support. |
|
The face captured during the stream does not match the one enrolled |
|
The authorization token is invalid |
|
Internal error; contact Support |
|
Internal error; contact Support |
|
The user used all available circuits, authentication cannot proceed without a new enrollment |
|
Biometric error. Contact Support |
|
The client took too long to reply to the server or an internal request timed out |
|
The server failed to establish a connection to another service |
|
Internal error; contact Support |
|
The user is attempting to enroll a username that is already enrolled |
|
The user is attempting to authenticate with a user that is not enrolled |
|
The user is locked out of the server. |
|
Internal error; contact Support |
|
Integration error. The attempt must complete or be disposed using |
|
Integration error. The This error also occurs when you don’t have the proper security headers to run Web Assembly in your server. Learn more in Security headers. |
|
Internal error; contact Support |
|
Generic web assembly error. Contact Support. |
|
Tampering detected. Contact Support. |
|
Internal error; contact Support |
|
Internal error; contact Support |
|
Integration error. The |
|
Integration error. The |
|
Integration error. The |
|
Integration error. The |
|
Integration error. The |
|
Integration error. The |
|
Integration error. The |
|
The web assembly runtime aborted on an unexpected condition. Contact Support. |
|
The web assembly initialization failed. Contact Support. |
|
The web assembly import failed. Contact Support. |
|
Integration error. The |
|
Internal error; contact Support |
|
Connection error. Contact Support. |
|
Connection error. Contact Support. |
|
The server took too long to reply to the client |
|
Either a connection or internal error. Contact Support. |
Web component error handling
Web components inherit errors from the @keyless/sdk-web library. Use the Error reference to diagnose errors in web components.
The following example shows how to handle an error event within a <kl-auth> web component:
Details
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Auth</title>
<style>
* {
box-sizing: border-box;
}
body {
align-items: center;
display: flex;
justify-content: center;
margin: 0;
min-height: 100vh;
padding: 8px;
}
kl-auth {
border: 1px solid lightgray;
}
</style>
</head>
<body>
<kl-auth
authorization-token="USER_AUTHORIZATION_FROM_CUSTOMER"
customer="CUSTOMER_NAME"
enable-camera-instructions
key="IMAGE_ENCRYPTION_PUBLIC_KEY"
key-id="IMAGE_ENCRYPTION_KEY_ID"
lang="en"
size="375"
theme="light"
transaction-data='DATA_FROM_CUSTOMER_SERVER_TO_BE_SIGNED'
username="USERNAME"
ws-url="KEYLESS_AUTHENTICATION_SERVICE_URL"
></kl-auth>
<script src="@keyless/sdk-web-components/index.js" type="module"></script>
<script>
const auth = document.querySelector('kl-auth')
auth.addEventListener('error', (event) => {
// will print the error code
console.error(event.message)
})
</script>
</body>
</html>
The SDK extends the ErrorEvent to provide the error code inside the error message and to include additional errors:
enum KeylessComponentsError {
QUEUE_UNSET = 'QUEUE_UNSET',
SYMBOL_UNSET = 'SYMBOL_UNSET',
NONCANCELABLE = 'NONCANCELABLE'
}
Each KeylessComponentsError error represents an internal error. Contact Support.