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

Identity Reuse 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 Identity Reuse module offers a returning user the identity documents they already verified with partner organizations, so they can reuse one instead of capturing a fresh ID.

The built-in UI lists each document as a card, with the first one tagged Recommended, followed by a Scan a new document card. Tapping a card submits that choice immediately. The screen also opens a What data will be shared? sheet and links to Incode's Privacy Policy. The copy names the organization receiving the document only when a headless integration supplies the name through a fetchCompanyName override; otherwise it uses copy without the name.

This module follows the form-based pattern with a selection state. Picking a document submits it in one step. See the patterns page for the shared lifecycle.

Tag

<incode-identity-reuse> is a standard Web Component. Importing the UI subpath registers the custom element; importing the CSS applies the module's styles.

import '@incodetech/web/identity-reuse';
import '@incodetech/web/identity-reuse/styles.css';

Properties

Property Type Required Description
config IdentityReuseConfig ❌ No options
onFinish (output?: unknown) => void ❌ Called when the module finishes, with output set to { identityShared: boolean }
onError (error: string) => void ❌ Called when an error occurs

Configuration

The module takes no configuration:

type IdentityReuseConfig = {};

Which prior documents are offered is configured server-side.

State machine

IdentityReuseState is a discriminated union over status. The selection state (documentsFound) is unique to this module:

Status Description
idle Initial state, waiting for load().
loading Fetching reusable documents. A fetchCompanyName override, when a host supplies one, runs in parallel and can't keep this state going past one second after loading starts.
documentsFound Documents are available; picking one submits it.
submitting Submitting the chosen document for reuse.
finished Terminal. Carries output: { identityShared }, which is true only when the person picked a document and the backend imported it.
error Recoverable error; the user can retry or skip. Carries error.

When status === 'documentsFound':

Property Type Description
documents ReusableDocument[] Ordered documents; index 0 is the best match. Render the first entry as recommended — position is the only signal.
selectedDocumentId SelectedDocumentId | undefined The current selection, or 'scanNew' when the user chose to scan a new document. Populated with documents[0].id on entry.
companyName string (optional) Name of the organization receiving the reused document. The back end doesn't provide it, so it's absent unless a headless integration supplies it by overriding the machine's fetchCompanyName actor. Use it in your own copy.

Each ReusableDocument carries id, documentType (camelCase, for example driversLicense), maskedNumber (for example 00*****29), countryCode (ISO 3166-1 alpha-3), and verifiedAt (Unix epoch in seconds). Format countryCode and verifiedAt in your own UI — the module passes both through unchanged.

API methods

Method Purpose
load() Fetch reusable documents. Moves idle → loading.
chooseDocument(documentId) Select a document by id or pass the SCAN_NEW_DOCUMENT sentinel ('scanNew') without submitting. Only needed for two-step UIs. Ids that aren't among documents are ignored.
submit(documentId?) Submit a document for reuse. Pass an id or SCAN_NEW_DOCUMENT to select and submit in one call. Omit it to submit the current selection. Ids that aren't among documents are ignored.
skip() Skip identity reuse entirely and finish the module.
retry() Reload documents after an error.

Plus the universal lifecycle: subscribe, getState, reset, stop.

SCAN_NEW_DOCUMENT, the SelectedDocumentId type, and ReusableDocument are exported from @incodetech/core/identity-reuse:

import {
  createIdentityReuseManager,
  SCAN_NEW_DOCUMENT,
} from '@incodetech/core/identity-reuse';

const manager = createIdentityReuseManager({ config: {} });

manager.subscribe((state) => {
  if (state.status === 'documentsFound') {
    // Reuse the recommended document in one step.
    manager.submit(state.documents[0].id);
    // Or scan a new document instead: manager.submit(SCAN_NEW_DOCUMENT);
  }
});

manager.load();

Result

The module reports whether a document was shared, as IdentityReuseOutput (exported from @incodetech/core/identity-reuse):

type IdentityReuseOutput = {
  identityShared: boolean;
};

identityShared is false in every other way the module ends: the person scans a new document or skips, or there is no document to offer.

In a Flow

In a Flow, identity reuse runs after three steps: an email or phone (or a search hint sent at session start), a face authentication that finds no customer in your organization, and an identity search. When the person shares a document, the Flow skips the ID capture and validates the shared document instead. The face match runs either way, against the shared document or the newly captured ID.

  • <incode-flow> renders the module and forwards its result for you. When the module reports an error, <incode-flow> calls your onError and keeps the module's own Retry and Skip screen on display.
  • In a headless integration, register identityReuseMachine with the Orchestrated Flow Manager, and pass state.output from the finished state to flowManager.completeModule(). See Headless Mode → Identity reuse step keys.

See also

Was this page helpful?