Skip to content

Web SDK Overview ​

The eKYC Web SDK is a TypeScript bundle that runs the capture, quality-check and verification flow in the browser. It scans the NID front and back, the QR code, and the user's face, then verifies them against the API. Current version 1.3.20.

Platform ​

WhatDescription
BrowserRuns in modern browsers and inside WebViews. Requires HTTPS and camera permission.
WebViewOn iOS WebViews, enable inline media playback — allowsInlineMediaPlayback in Flutter and React Native.
Node Engine>= 20 to build the bundle.

Build dependencies ​

WhatDescription
@tensorflow/tfjs-core 4.20.0Core operators and data structures.
@tensorflow/tfjs-backend-cpu 4.20.0Runs models on the device CPU.
@tensorflow/tfjs-tflite 0.0.1-alpha.8Runs TensorFlow Lite models in JavaScript.
@vladmandic/human 3.2.2Face detection and facial attribute analysis.
@types/w3c-image-capture 1.0.10Types for the W3C Image Capture API.
javascript-obfuscator 4.1.1Obfuscates the built bundle.
esbuild 0.24.0Bundler and compiler.

What the SDK Does For You ​

scanStart runs a pipeline rather than a single action, the same way the Mobile SDK's takeNID and takeFaces do.

WhatDescription
scanStart(['front','back'])Captures the card → uploads → checks sanity → extracts card info.
scanStart(['face'])Captures the selfie → uploads → checks face sanity → checks liveness.
scanStart(['qrcode'])Scans and decodes the QR code on the card.

Quality checks run on the device before upload, so the user sees a blurred-image warning immediately rather than after a network round trip.

The class-based API (CakeEkycSDK) also exposes the individual steps — scanNID, scanFace, verifyNID, verifyFaces, verifyPair, verifyFaceAuthentication — when you need to drive them yourself.

WARNING

The SDK's result object is for driving the UI only. Base the onboarding decision on results your backend fetches from the eKYC server (or on responses whose X-Signature your backend has verified) — never on verdicts reported by the app or browser, which a modified client can change.

Common Configuration ​

ParamTypeRequiredDefaultDescription
baseUrlstringYes—Base URL for API requests.
tokenstringYes—Authentication token. Fetch it from your backend at runtime.
resourcePathstringNo—Path to SDK resources.
headersRecord<string, string>No—Additional HTTP headers.

WARNING

The token is a per-tenant credential. Fetch it from your backend — never hardcode it in the page or commit it to source. The Access Key itself must never reach the browser.

Journey ​

The standard flow runs front to back to face, with a review step after each capture:

text
Start
  → Scan Front NID → Preview Front NID
  → Scan Back NID  → Preview Back NID
  → Verify (Front + Back)
  → Scan Face
  → Verify (Front + Back + Face)
End
WhatDescription
Scan Front NIDCapture the front side of the National ID.
Preview Front NIDShow the capture to the user for review.
Scan Back NIDCapture the back side.
Preview Back NIDShow the capture to the user for review.
Verify (Front + Back)Check that front and back are consistent and valid.
Scan FaceCapture the user's face.
Verify (Front + Back + Face)Compare the face against the photo and data on the ID.

Packaging ​

The build bundles with esbuild, then obfuscates and strips console calls.

javascript
function createBuildSettings(options) {
  return {
    entryPoints: ['./demo/adapter.ts'],
    outfile: 'dist/adapter.js',
    sourcemap: false,
    bundle: true,
    plugins: [
      esbuildPluginTsc({ force: false }),
      ObfuscatorPlugin({
        compact: true,
        controlFlowFlattening: true,
        filter: [],
      }),
    ],
    ...options,
  }
}

const settings = createBuildSettings({
  minify: true,
  minifyWhitespace: true,
  minifyIdentifiers: true,
  minifySyntax: true,
  treeShaking: true,
  drop: ['console'],
  ignoreAnnotations: true,
})

await esbuild.build(settings)

SDK Error Codes ​

Raised by the SDK itself, separate from the numeric API error codes. The values match the Mobile SDK.

FieldTypeDescription
60000NID_SANITY_FAILEDNID sanity check failed.
60001NID_TAMPERING_FAILEDNID tampering detection failed.
60002FACE_SANITY_FAILEDFace sanity check failed.
60003FACE_LIVENESS_FAILEDFace liveness check failed.

QR scanning has its own codes:

FieldTypeDescription
DOP-675_001Scan timeout"Hết thời gian quét mã. Vui lòng thử lại."
DOP-675_002Scan error"Không thể quét được mã QR, vui lòng thử lại!"

Unlike the Mobile SDK, the Web SDK has no 40000–40003 range — timeouts, cancellation and permission failures surface as thrown exceptions or as sdkError on the response.

APIs Used ​

WhatDescription
Upload ImageEvery captured image is uploaded before any check runs.
Verify ID Card SanityChecks the authenticity and validity of the card.
Read ID Card InfoOCR, MRZ and QR extraction.
Verify Face Sanity · Verify Face LivenessSelfie quality and liveness.
Compare FacesMatches the selfie against the card portrait.
FaceAuthenVerifies identity against a stored reference. Documented in the FaceAuthen.

Next Steps ​

Developers