SDK reference, Incode Web SDK 2 Reference / Web SDK 2 Individual Modules

Authentication Module

Warning

This guide is specific to Web SDK 2.x. For Web SDK 1.x, you can find documentation here.

Do not attempt to upgrade or implement without support. Contact your Incode representative to check if you are a candidate for this upgrade.

The Authentication module re-authenticates a returning user by capturing a fresh selfie and matching it against their previously stored biometric record. Used for re-entry into an existing identity (versus the first-time identity verification done by Selfie + Face Match).

This module follows the camera-capture pattern. The lifecycle and capture sub-states are identical to Selfie since both use the same underlying face-capture machinery (BaseFaceCaptureConfig).

Tag

<incode-authentication> is a standard Web Component. Import the UI subpath to register the custom element. Import the CSS to apply the module styles.

import '@incodetech/web/authentication';
import '@incodetech/web/authentication/styles.css';

This is the Web SDK 2.0 equivalent of Web SDK 1.x renderAuthFace for 1:1 authentication. For full UI control, use the headless createAuthenticationManager from @incodetech/core/authentication. See API methods.

Properties

Set these as JavaScript properties on the element, not as HTML attributes.

Property Type Required Description
config AuthenticationConfig & { authHint?: string } ❌ Module configuration. authHint identifies the enrolled identity to match the selfie against. 1:1 authentication needs it. If you omit config, the component loads the AUTHENTICATION configuration from the active Dashboard Flow.
manager AuthenticationManager ❌ Advanced: a pre-built headless manager. If you supply one, the component does not load configuration.
onFinish () => void ❌ Called when the server matches the selfie to the identity. With onDeviceFaceResultsSubmissionEnabled, called when the face results upload succeeds. Confirm the match on your server.
onError (message?: string, errorCode?: number, moduleErrorCode?: string) => void ❌ Called when authentication ends without a match, or when the user closes the module. See Errors.

Keep the Dashboard configuration

By default, a config that you supply replaces the Dashboard configuration. If your config contains only authHint, the module uses SDK defaults for attempts, tutorial, and liveness instead of the Dashboard settings. To merge your config over the Dashboard configuration, call setup() with flow: { mergeConfig: true }. This setting applies to all standalone modules on the page.

Standalone example

This example replaces a Web SDK 1.x renderAuthFace(container, options) call for 1:1 authentication:

import { setup } from '@incodetech/web';
import '@incodetech/web/base.css';
import '@incodetech/web/themes/light.css';
import '@incodetech/web/authentication';
import '@incodetech/web/authentication/styles.css';

await setup({
  apiURL: 'https://demo-api.incodesmile.com',
  token: sessionToken,
  flow: { mergeConfig: true },
  wasm: { pipelines: ['selfie'] },
});

const auth = document.createElement('incode-authentication');
auth.config = { authHint: customerId };
auth.onFinish = () => showAuthenticated();
auth.onError = (message, errorCode, moduleErrorCode) => {
  handleAuthError(moduleErrorCode ?? message);
};

document.querySelector('#auth-container')?.replaceChildren(auth);

Errors

onError receives a stable moduleErrorCode as its third argument. Use the code, not the message, to make decisions.

moduleErrorCode When
NONEXISTENT_CUSTOMER authHint does not match an identity. The module ends after the first attempt.
HINT_NOT_PROVIDED The request did not include authHint. The module ends after the first attempt.
NO_MORE_ATTEMPTS All capture attempts failed, for example because the face did not match the identity on each attempt.
SESSION_EXPIRED The session token expired. errorCode is 401.
CAMERA_PERMISSION_DENIED The browser blocks the camera. The module keeps its screen that shows how to allow the camera, with a refresh button. errorCode is undefined. See Camera permission denied.
(none) The user closed the module. message is undefined.

Other failures, for example a face that does not match, use one capture attempt and let the user try again. They do not call onError until no attempts remain.

Migrating from Web SDK 1.x renderAuthFace

Web SDK 1.x renderAuthFace Web SDK 2.0 <incode-authentication>
container Mount or append <incode-authentication> in that container.
session.token setup({ token })
authHint auth.config = { authHint }. Also set setup({ flow: { mergeConfig: true } }) to keep the Dashboard configuration. See Keep the Dashboard configuration.
onSuccess(response) auth.onFinish(). It does not receive the server response. It is called only when the server returns a match. Confirm the result on your server.
onError({ code }) auth.onError(message, errorCode, moduleErrorCode). The 1.x code values NO_MORE_ATTEMPTS, NONEXISTENT_CUSTOMER, and HINT_NOT_PROVIDED are in moduleErrorCode.
uiConfig setup({ uiConfig })
parentSize Size the element or its container with CSS.
throwOnCameraPermissionDenied Not needed. When the user denies camera access, the module shows recovery steps and a refresh button. It also calls onError with moduleErrorCode set to CAMERA_PERMISSION_DENIED.
Return value close() Remove the element from the page. This stops the camera and the module.

Both versions read the AUTHENTICATION module settings from the Dashboard Flow, and both send the same authentication request. Inside <incode-flow>, set authHint on the flow config. The orchestrator mounts and configures this component automatically.

Configuration

AuthenticationConfig is the intersection of the dashboard-driven FlowModuleConfig['AUTHENTICATION'] and the shared BaseFaceCaptureConfig:

type AuthenticationConfig = FlowModuleConfig['AUTHENTICATION'] &
  BaseFaceCaptureConfig;

The dashboard fields are similar to Selfie's: showTutorial, autoCaptureTimeout, numberOfAttempts, type (always 'ONE_TO_ONE' for re-auth), deepsightLiveness, plus the validate-* booleans (validateClosedEyes, validateFaceMask, validateHeadCover, validateLenses).

This page inherits the Selfie capture-config table. AuthenticationConfig intersects BaseFaceCaptureConfig, the same type Selfie uses, so every shared capture field is valid here too — showPreview, assistedOnboarding, enableFaceRecording, captureAttempts, validateBrightness, cameraResolution, and ageAssurance among them. See Module: Selfie → Configuration Options for their types and defaults rather than a second copy here.

The table below covers only the fields worth calling out for re-authentication; it is not the complete list.

Option Type Required Description
onDeviceFaceResultsSubmissionEnabled boolean ❌ Opt-in. When true, face analysis runs entirely on-device and only the results are submitted to the server. Has E2EE and WASM-pipeline prerequisites — see On-Device Face Capture for the full walkthrough. Leave off to keep the legacy server-side path.
selfieConcealmentOption 'OPTION_NONE' | 'OPTION_SILHOUETTE' | 'OPTION_2D' | 'OPTION_3D' ❌ Conceals the on-screen camera preview with a cosmetic avatar. Display-only — detection, quality, liveness, and upload run on the real frames. See Module: Selfie → Face concealment. Default OPTION_NONE.
avatarAssets AvatarAssetsOverrides ❌ Where to load the avatar runtime from when selfieConcealmentOption selects an avatar. See Module: Selfie → Self-hosting the avatar runtime.

State machine

For read-only onDeviceMode, obfuscateWithAvatar, avatarCanvas, and avatarVariant presentation fields, plus the error-state moduleErrorCode, see Selfie capture state properties. Privacy Lens is the OPTION_SILHOUETTE concealment option.

AuthenticationState follows the same shape as SelfieState — see Module: Selfie → States Reference for the full list. The states are:

idle, loading, tutorial, permissions, capture, processing, finished, closed, error.

API methods

Identical to the Selfie manager API: load, nextStep, requestPermission, goToLearnMore, back, capture, retryCapture, close, plus the universal lifecycle (subscribe, getState, reset, stop).

See Module: Selfie → API Methods for the full reference.

WASM requirement

Authentication uses the same selfie ML pipeline as the Selfie module. Preload via setup({ wasm: { pipelines: ['selfie'] } }).

See also

Was this page helpful?