Widget
@arkyc/widget is the framework-agnostic verification flow that runs in the user's browser. It drives the Client / Widget API with the short-lived client token your backend obtained from the SDK.
Install
pnpm add @arkyc/widgetA standalone build is also published at @arkyc/widget/standalone (a minified IIFE that exposes a global Arkyc) for use via a <script> tag.
Modes
import { ArkycWidget } from '@arkyc/widget'
// Overlay (full-screen modal)
ArkycWidget.open({ token, onComplete })
// Inline (mounted into a container)
ArkycWidget.mount({ token, container: '#verify', onComplete })
// Hosted page (reads ?token= and posts results to the parent window)
ArkycWidget.hosted()Options
| Option | Type | Notes |
|---|---|---|
token | string (required) | The client token from arkyc.sessions.create. |
baseUrl | string | Client API base — must include /api (e.g. /api behind a proxy, or https://api.example.com/api). |
branding | ProjectBranding | Colors, logo, radius, theme. Defaults from project config. |
onComplete | (result) => void | result is { status, decision }. |
onError | (error) => void | |
onClose | () => void | |
container | string | HTMLElement (mount only) | Where to render inline. |
Example
const res = await fetch('/verify/start', { method: 'POST' })
const { clientToken } = await res.json()
ArkycWidget.mount({
token: clientToken,
container: '#verify',
baseUrl: '/api', // same-origin proxy to the Arkyc API
onComplete: ({ status, decision }) => {
console.log('done', status, decision)
},
onError: (e) => console.error(e),
})The flow
Welcome → document selection → front capture → back capture → OCR → selfie → passive liveness → face match → processing → result. Back capture is skipped for single-sided documents (e.g. passports); the final processing screen polls the session to a terminal status.
Capture uses getUserMedia + a canvas frame grab, with a file-input fallback. The widget talks only to the Client API with the X-Client-Token header — it never sees your secret key.
Hosted mode + the SDK launcher
If you host the widget page yourself, @arkyc/sdk/browser's ArkycWidget.open opens it in an overlay iframe and relays arkyc:complete / arkyc:error / arkyc:close messages back to your page. See the SDK browser launcher.
