@sekyro/web 0.1.0-rc.3 → 0.1.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +44 -0
  3. package/dist/{capture-session-v3-CvIfcwST.d.ts → capture-session-v3-Okq0EQHG.d.ts} +38 -2
  4. package/dist/{capture-session-v3-COIO_F2w.d.cts → capture-session-v3-UQU_WjO2.d.cts} +38 -2
  5. package/dist/{chunk-FIXX2AXC.js → chunk-SGDXLAXR.js} +309 -10
  6. package/dist/chunk-SGDXLAXR.js.map +1 -0
  7. package/dist/{chunk-7TC6TOZ4.js → chunk-TG5IE552.js} +37 -4
  8. package/dist/chunk-TG5IE552.js.map +1 -0
  9. package/dist/client/index.cjs.map +1 -1
  10. package/dist/client/index.d.cts +1 -1
  11. package/dist/client/index.d.ts +1 -1
  12. package/dist/core/index.cjs +36 -3
  13. package/dist/core/index.cjs.map +1 -1
  14. package/dist/core/index.d.cts +2 -2
  15. package/dist/core/index.d.ts +2 -2
  16. package/dist/core/index.js +1 -1
  17. package/dist/{create-verification-CswF2As-.d.ts → create-verification-CA-3szPI.d.cts} +108 -8
  18. package/dist/{create-verification-CP18eq1Q.d.cts → create-verification-c98uAxbl.d.ts} +108 -8
  19. package/dist/{hosted-client-BpvBqu9f.d.cts → hosted-client-DWzCRYJK.d.cts} +14 -1
  20. package/dist/{hosted-client-BpvBqu9f.d.ts → hosted-client-DWzCRYJK.d.ts} +14 -1
  21. package/dist/index.cjs +384 -13
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +25 -3
  24. package/dist/index.d.ts +25 -3
  25. package/dist/index.js +61 -4
  26. package/dist/index.js.map +1 -1
  27. package/dist/internal/index.cjs +261 -11
  28. package/dist/internal/index.cjs.map +1 -1
  29. package/dist/internal/index.d.cts +4 -4
  30. package/dist/internal/index.d.ts +4 -4
  31. package/dist/internal/index.js +12 -2
  32. package/dist/internal/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-7TC6TOZ4.js.map +0 -1
  35. package/dist/chunk-FIXX2AXC.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { C as CameraErrorKind } from '../capture-session-v3-COIO_F2w.cjs';
2
- export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureState, i as ClipError, j as ClipErrorKind, k as ClipRecorder, l as ClipResult, D as DEFAULT_CLIP_MIME, m as DEVICE_PROFILES, n as DeviceClass, o as DeviceProbe, p as DeviceProfile, q as DeviceProfiler, E as EscalationClipArtifact, r as EscalationHook, F as FaceGateV3, G as GateChecks, K as KEYFRAME_CANDIDATES, s as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, t as MIME_CANDIDATES, S as STOP_GRACE_MS, T as TIMESLICE_MS, V as V3ChecksPayload, u as V3GateFactor, v as V3GateQuality, w as V3GateThresholds, x as V3GateTick, y as V3GateTickInput, z as V3TelemetryEvent, A as V3_GATE_DEFAULTS, B as VIDEO_BPS, H as buildLivenessV2FormData, I as cameraPreflight, J as classifyDevice, L as extForMime, N as isClipTooLarge, O as isMediaRecorderSupported, P as mapGetUserMediaError, Q as pickMimeType, R as probeDevice } from '../capture-session-v3-COIO_F2w.cjs';
1
+ import { C as CameraErrorKind } from '../capture-session-v3-UQU_WjO2.cjs';
2
+ export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipResult, D as DEFAULT_CLIP_MIME, o as DEVICE_PROFILES, p as DeviceClass, q as DeviceProbe, r as DeviceProfile, s as DeviceProfiler, E as EscalationClipArtifact, t as EscalationHook, F as FaceGateV3, G as GateChecks, K as KEYFRAME_CANDIDATES, u as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, v as MIME_CANDIDATES, S as STOP_GRACE_MS, T as TIMESLICE_MS, V as V3ChecksPayload, w as V3GateFactor, x as V3GateQuality, y as V3GateThresholds, z as V3GateTick, A as V3GateTickInput, B as V3TelemetryEvent, H as V3_GATE_DEFAULTS, I as VIDEO_BPS, J as buildLivenessV2FormData, L as cameraPreflight, N as classifyDevice, O as extForMime, P as isClipTooLarge, Q as isMediaRecorderSupported, R as mapGetUserMediaError, U as pickMimeType, W as probeDevice } from '../capture-session-v3-UQU_WjO2.cjs';
3
3
  export { C as CENTERED_FACTOR, a as CIRCLE_RADIUS_FACTOR, I as IN_CIRCLE_FACTOR, b as buildCaptureConstraints, d as detectIsMobile } from '../capture-constraints-BujkZcfb.cjs';
4
4
  export { C as CreateDetectorOptions, D as DEFAULT_TIER_ORDER, a as DEFAULT_V3_ASSET_BASE_URL, b as Detector, c as DetectorLadderError, F as FaceObservation, d as createDetector, i as intrinsicSize, t as toStreamPixels } from '../detect-worker-CKXHlXx9.cjs';
5
5
 
@@ -1,5 +1,5 @@
1
- import { C as CameraErrorKind } from '../capture-session-v3-CvIfcwST.js';
2
- export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureState, i as ClipError, j as ClipErrorKind, k as ClipRecorder, l as ClipResult, D as DEFAULT_CLIP_MIME, m as DEVICE_PROFILES, n as DeviceClass, o as DeviceProbe, p as DeviceProfile, q as DeviceProfiler, E as EscalationClipArtifact, r as EscalationHook, F as FaceGateV3, G as GateChecks, K as KEYFRAME_CANDIDATES, s as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, t as MIME_CANDIDATES, S as STOP_GRACE_MS, T as TIMESLICE_MS, V as V3ChecksPayload, u as V3GateFactor, v as V3GateQuality, w as V3GateThresholds, x as V3GateTick, y as V3GateTickInput, z as V3TelemetryEvent, A as V3_GATE_DEFAULTS, B as VIDEO_BPS, H as buildLivenessV2FormData, I as cameraPreflight, J as classifyDevice, L as extForMime, N as isClipTooLarge, O as isMediaRecorderSupported, P as mapGetUserMediaError, Q as pickMimeType, R as probeDevice } from '../capture-session-v3-CvIfcwST.js';
1
+ import { C as CameraErrorKind } from '../capture-session-v3-Okq0EQHG.js';
2
+ export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipResult, D as DEFAULT_CLIP_MIME, o as DEVICE_PROFILES, p as DeviceClass, q as DeviceProbe, r as DeviceProfile, s as DeviceProfiler, E as EscalationClipArtifact, t as EscalationHook, F as FaceGateV3, G as GateChecks, K as KEYFRAME_CANDIDATES, u as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, v as MIME_CANDIDATES, S as STOP_GRACE_MS, T as TIMESLICE_MS, V as V3ChecksPayload, w as V3GateFactor, x as V3GateQuality, y as V3GateThresholds, z as V3GateTick, A as V3GateTickInput, B as V3TelemetryEvent, H as V3_GATE_DEFAULTS, I as VIDEO_BPS, J as buildLivenessV2FormData, L as cameraPreflight, N as classifyDevice, O as extForMime, P as isClipTooLarge, Q as isMediaRecorderSupported, R as mapGetUserMediaError, U as pickMimeType, W as probeDevice } from '../capture-session-v3-Okq0EQHG.js';
3
3
  export { C as CENTERED_FACTOR, a as CIRCLE_RADIUS_FACTOR, I as IN_CIRCLE_FACTOR, b as buildCaptureConstraints, d as detectIsMobile } from '../capture-constraints-BujkZcfb.js';
4
4
  export { C as CreateDetectorOptions, D as DEFAULT_TIER_ORDER, a as DEFAULT_V3_ASSET_BASE_URL, b as Detector, c as DetectorLadderError, F as FaceObservation, d as createDetector, i as intrinsicSize, t as toStreamPixels } from '../detect-worker-CKXHlXx9.js';
5
5
 
@@ -31,7 +31,7 @@ import {
31
31
  mapGetUserMediaError,
32
32
  pickMimeType,
33
33
  probeDevice
34
- } from "../chunk-7TC6TOZ4.js";
34
+ } from "../chunk-TG5IE552.js";
35
35
  import {
36
36
  DEFAULT_TIER_ORDER,
37
37
  DEFAULT_V3_ASSET_BASE_URL,
@@ -1,5 +1,6 @@
1
- import { h as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1 } from './capture-session-v3-CvIfcwST.js';
2
- import { C as CheckReason, c as HostedSessionView, g as HostedClient, A as AttestationInput, h as SessionView, b as CheckType } from './hosted-client-BpvBqu9f.js';
1
+ import { b as Detector } from './detect-worker-CKXHlXx9.cjs';
2
+ import { i as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1 } from './capture-session-v3-UQU_WjO2.cjs';
3
+ import { C as CheckReason, c as HostedSessionView, g as HostedClient, A as AttestationInput, h as SessionView, b as CheckType } from './hosted-client-DWzCRYJK.cjs';
3
4
 
4
5
  /** Gate guidance code. `'hold'` is emitted while the clip records. */
5
6
  type GateHint = "center" | "closer" | "farther" | "light" | "still" | "hold";
@@ -47,7 +48,30 @@ interface CapturedArtifacts {
47
48
  captureChannel: CaptureChannel;
48
49
  /** Set when the browser has no MediaRecorder: a keyframe-only capture. */
49
50
  degraded?: "NO_RECORDER";
51
+ /** The capture engine that produced the artifacts (`'v3'` for this SDK). Always set by the SDK; optional in the type so host-built fixtures stay valid. */
52
+ engine?: CaptureEngineId;
53
+ /**
54
+ * Camera request (`getUserMedia`) → the preview is live, in whole
55
+ * milliseconds measured with `performance.now()`. Part of the face-capture
56
+ * timing the SDK forwards to the backend as `input.capture` on the liveness
57
+ * submission; absent when the phase was not observed.
58
+ */
59
+ cameraReadyMs?: number;
60
+ /**
61
+ * Camera ready → the first face ACCEPTED by the gate (present and with
62
+ * size, centering and quality good enough to make progress — not merely
63
+ * detected), whole ms. Absent when no face was ever accepted.
64
+ */
65
+ faceAcquireMs?: number;
66
+ /**
67
+ * Face-capture duration: FIRST accepted face → gate progress 100 % (capture
68
+ * complete, before the clip window and any upload), whole ms. A face lost
69
+ * and re-acquired keeps the first acceptance as its start.
70
+ */
71
+ captureMs?: number;
50
72
  }
73
+ /** Capture engine identifier carried on {@link CapturedArtifacts.engine}. */
74
+ type CaptureEngineId = "v1" | "v3";
51
75
  /** Camera / engine failure kinds — collapsed to the public six. */
52
76
  type CaptureErrorKind = "permission" | "notfound" | "inuse" | "insecure" | "unsupported" | "generic";
53
77
  /** Camera / engine failure payload (`on('error')`). */
@@ -87,14 +111,28 @@ interface LivenessCaptureEvents {
87
111
  animations: "full" | "reduced";
88
112
  };
89
113
  }
114
+ /** Which camera to open: the selfie camera (`'user'`) or the rear one (`'environment'`). */
115
+ type CameraFacing = "user" | "environment";
116
+ /** Options of {@link LivenessCaptureHandle.start}. */
117
+ interface LivenessStartOptions {
118
+ /**
119
+ * Camera for this attempt and its retries; default: the current one
120
+ * ({@link LivenessCaptureOptions.facing}, else `'user'`). Use `switchCamera()`
121
+ * to change camera mid-capture.
122
+ */
123
+ facing?: CameraFacing;
124
+ }
90
125
  /** Live capture handle returned by {@link createLivenessCapture} / {@link Verification.liveness}. */
91
126
  interface LivenessCaptureHandle {
92
127
  /** Current {@link CaptureState}. */
93
128
  readonly state: CaptureState;
94
129
  /** Subscribe; returns the unsubscribe function. */
95
130
  on<K extends keyof LivenessCaptureEvents>(event: K, handler: (payload: LivenessCaptureEvents[K]) => void): () => void;
96
- /** Ask for the camera and start gating. Resolves once the attempt is running or failed. */
97
- start(): Promise<void>;
131
+ /**
132
+ * Ask for the camera and start gating. Resolves once the attempt is running or failed.
133
+ * `options.facing` picks the camera for this attempt and later retries.
134
+ */
135
+ start(options?: LivenessStartOptions): Promise<void>;
98
136
  /** Fresh attempt: resets the engine and restarts the camera. */
99
137
  retry(): void;
100
138
  /** Toggle user/environment camera (gate restarts from zero). */
@@ -106,10 +144,18 @@ interface LivenessCaptureHandle {
106
144
  interface LivenessCaptureOptions {
107
145
  /** Host-owned `<video playsInline muted>` element. */
108
146
  video: HTMLVideoElement;
109
- /** Initial camera; default `'user'`. */
110
- facing?: "user" | "environment";
147
+ /** Initial camera; default `'user'`. `start({ facing })` overrides it. */
148
+ facing?: CameraFacing;
111
149
  /** Base URL of the detector assets (tasks-vision wasm + tflite); default `/models-v3`. */
112
150
  assetBaseUrl?: string;
151
+ /**
152
+ * Hold a Screen Wake Lock while the camera is live (`starting` / `gating` /
153
+ * `recording`) so the phone does not dim or lock mid-capture; re-taken when
154
+ * the page becomes visible again. Best-effort: unsupported browsers or a
155
+ * refused request (e.g. an iframe without `allow="screen-wake-lock"`) never
156
+ * affect the capture. Default `true`; `false` never requests the lock.
157
+ */
158
+ keepScreenAwake?: boolean;
113
159
  }
114
160
  /**
115
161
  * SDK-side failure reasons (status `'unavailable'`):
@@ -195,7 +241,10 @@ interface Verification {
195
241
  interface CaptureEngine {
196
242
  readonly state: CaptureState$1;
197
243
  on<K extends keyof CaptureSessionV3Events>(event: K, handler: (payload: CaptureSessionV3Events[K]) => void): () => void;
198
- start(): Promise<void>;
244
+ /** `facingMode` sets the camera for this attempt and later retries. */
245
+ start(options?: {
246
+ facingMode?: "user" | "environment";
247
+ }): Promise<void>;
199
248
  retry(): void;
200
249
  switchCamera(): void;
201
250
  destroy(): void;
@@ -230,6 +279,57 @@ declare function createLivenessCaptureInternal(options: LivenessCaptureOptions,
230
279
  */
231
280
  declare function createLivenessCapture(options: LivenessCaptureOptions): LivenessCaptureHandle;
232
281
 
282
+ /** Preload state per asset base URL. */
283
+ type LivenessAssetsStatus = "idle" | "loading" | "ready" | "failed";
284
+ /** Options of {@link preloadLivenessAssets}. */
285
+ interface PreloadLivenessAssetsOptions {
286
+ /** Same value as the capture's `assetBaseUrl`; default `/models-v3`. */
287
+ assetBaseUrl?: string;
288
+ /** Defer the load to browser idle time (`requestIdleCallback`, 1.2 s timeout fallback). Default `false`. */
289
+ idle?: boolean;
290
+ /** Skip when the browser asks to save data (`navigator.connection.saveData`). Default `false`. */
291
+ respectSaveData?: boolean;
292
+ }
293
+ /** Blaze init deadline for the preload — generous: a slow ~11 MB wasm download must finish. */
294
+ declare const PRELOAD_BLAZE_INIT_TIMEOUT_MS = 120000;
295
+ /** Outer budget reclaiming only a genuinely hung load (≥ the init deadline + slack). */
296
+ declare const PRELOAD_BUDGET_MS = 130000;
297
+ type Loader = (base: string) => Promise<Detector>;
298
+ /** @internal Test seam: replace the detector loader (null restores the real one). */
299
+ declare function setPreloadLoaderForTests(next: Loader | null): void;
300
+ /** @internal Test seam: drop every entry (destroying warmed detectors). */
301
+ declare function resetLivenessAssetsForTests(): void;
302
+ /**
303
+ * Warm the face detector for `assetBaseUrl` so the capture starts instantly.
304
+ * Idempotent per base URL and never rejects: resolves the settled status.
305
+ * `'idle'` means nothing was preloaded here (SSR, no camera API, Data-Saver
306
+ * skip) — start normally. Calling again after `'failed'` retries the load.
307
+ * With `idle: true` the load is deferred (status stays `'idle'` until it
308
+ * starts); a later non-idle call — or a capture mounting meanwhile — starts it
309
+ * at once, and {@link releaseLivenessAssets} cancels it.
310
+ */
311
+ declare function preloadLivenessAssets(options?: PreloadLivenessAssetsOptions): Promise<LivenessAssetsStatus>;
312
+ /** Current preload status for `assetBaseUrl` (default `/models-v3`). */
313
+ declare function getLivenessAssetsStatus(assetBaseUrl?: string): LivenessAssetsStatus;
314
+ /**
315
+ * Subscribe to status changes for `assetBaseUrl`; returns the unsubscribe
316
+ * function. Does NOT emit the current status on subscribe (read it with
317
+ * {@link getLivenessAssetsStatus}) — the
318
+ * `useSyncExternalStore(subscribe, getSnapshot)` contract, so it plugs into
319
+ * that hook directly.
320
+ */
321
+ declare function subscribeLivenessAssets(listener: (status: LivenessAssetsStatus) => void, assetBaseUrl?: string): () => void;
322
+ /** Free the warmed detector (an SPA leaving the flow). Never call while a capture is mounted. */
323
+ declare function releaseLivenessAssets(assetBaseUrl?: string): void;
324
+ /**
325
+ * @internal The capture engine's detector source when a preload exists for
326
+ * `assetBaseUrl`: a non-owning view of the warm instance (waiting for an
327
+ * in-flight load), or — once that load failed — a cold detector OWNED by the
328
+ * session (default ladder + deadline). `undefined` when nothing was preloaded.
329
+ * Invoking it on an idle-scheduled preload starts that load now and joins it.
330
+ */
331
+ declare function preloadedDetectorFactory(assetBaseUrl?: string): (() => Promise<Detector>) | undefined;
332
+
233
333
  /** The client surface the flow needs — `HostedClient` or a test fake. */
234
334
  type HostedClientLike = Pick<HostedClient, "getSession" | "recordConsent" | "presign" | "uploadToSpaces" | "completeMedia" | "submitCheck">;
235
335
  /** The presign policy allowlist for `kind: 'clip'` (media.policy.ts mirror). */
@@ -345,4 +445,4 @@ declare function createVerification(options: VerificationOptions): Verification;
345
445
  /** {@link createVerification} with construction seams (tests / Sekyro-internal hosts). */
346
446
  declare function createVerificationInternal(options: VerificationOptions, internals: VerificationInternals): Verification;
347
447
 
348
- export { AttestationError as A, createLivenessCaptureInternal as B, type CaptureChannel as C, DEFAULT_API_ORIGIN as D, createVerificationInternal as E, mapEngineState as F, type GateHint as G, type HostedClientLike as H, mapErrorKind as I, mapGuidanceHint as J, randomUuid as K, type LivenessCaptureEvents as L, runLivenessFlow as M, runSubmission as N, PROCESSING_POLL_DELAY_MS as P, type ReasonCode as R, type SdkFailureReason as S, TRANSPORT_REPLAY_ATTEMPTS as T, type Verification as V, type CaptureError as a, type CaptureErrorKind as b, type CaptureState as c, type CapturedArtifacts as d, type GateUpdate as e, type LivenessCaptureHandle as f, type LivenessCaptureOptions as g, type VerificationEvents as h, type VerificationLocale as i, type VerificationOptions as j, type VerificationResult as k, type VerificationStatus as l, createLivenessCapture as m, createVerification as n, CLIP_MIME_ALLOWLIST as o, type CaptureEngine as p, type LivenessCaptureInternalHandle as q, type LivenessCaptureInternals as r, type LivenessFlowDeps as s, type LivenessFlowOutcome as t, PROCESSING_POLL_MAX as u, REGISTRY_RETRY_DELAY_MS as v, type SubmitExecutor as w, type SubmitRuntime as x, TRANSPORT_REPLAY_DELAY_MS as y, type VerificationInternals as z };
448
+ export { preloadedDetectorFactory as $, AttestationError as A, type LivenessFlowDeps as B, type CameraFacing as C, DEFAULT_API_ORIGIN as D, type LivenessFlowOutcome as E, PRELOAD_BLAZE_INIT_TIMEOUT_MS as F, type GateHint as G, type HostedClientLike as H, PRELOAD_BUDGET_MS as I, PROCESSING_POLL_DELAY_MS as J, PROCESSING_POLL_MAX as K, type LivenessAssetsStatus as L, REGISTRY_RETRY_DELAY_MS as M, type SubmitExecutor as N, type SubmitRuntime as O, type PreloadLivenessAssetsOptions as P, TRANSPORT_REPLAY_DELAY_MS as Q, type ReasonCode as R, type SdkFailureReason as S, TRANSPORT_REPLAY_ATTEMPTS as T, type VerificationInternals as U, type Verification as V, createLivenessCaptureInternal as W, createVerificationInternal as X, mapEngineState as Y, mapErrorKind as Z, mapGuidanceHint as _, type CaptureChannel as a, randomUuid as a0, resetLivenessAssetsForTests as a1, runLivenessFlow as a2, runSubmission as a3, setPreloadLoaderForTests as a4, type CaptureEngineId as b, type CaptureError as c, type CaptureErrorKind as d, type CaptureState as e, type CapturedArtifacts as f, type GateUpdate as g, type LivenessCaptureEvents as h, type LivenessCaptureHandle as i, type LivenessCaptureOptions as j, type LivenessStartOptions as k, type VerificationEvents as l, type VerificationLocale as m, type VerificationOptions as n, type VerificationResult as o, type VerificationStatus as p, createLivenessCapture as q, createVerification as r, getLivenessAssetsStatus as s, preloadLivenessAssets as t, releaseLivenessAssets as u, subscribeLivenessAssets as v, CLIP_MIME_ALLOWLIST as w, type CaptureEngine as x, type LivenessCaptureInternalHandle as y, type LivenessCaptureInternals as z };
@@ -1,5 +1,6 @@
1
- import { h as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1 } from './capture-session-v3-COIO_F2w.cjs';
2
- import { C as CheckReason, c as HostedSessionView, g as HostedClient, A as AttestationInput, h as SessionView, b as CheckType } from './hosted-client-BpvBqu9f.cjs';
1
+ import { b as Detector } from './detect-worker-CKXHlXx9.js';
2
+ import { i as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1 } from './capture-session-v3-Okq0EQHG.js';
3
+ import { C as CheckReason, c as HostedSessionView, g as HostedClient, A as AttestationInput, h as SessionView, b as CheckType } from './hosted-client-DWzCRYJK.js';
3
4
 
4
5
  /** Gate guidance code. `'hold'` is emitted while the clip records. */
5
6
  type GateHint = "center" | "closer" | "farther" | "light" | "still" | "hold";
@@ -47,7 +48,30 @@ interface CapturedArtifacts {
47
48
  captureChannel: CaptureChannel;
48
49
  /** Set when the browser has no MediaRecorder: a keyframe-only capture. */
49
50
  degraded?: "NO_RECORDER";
51
+ /** The capture engine that produced the artifacts (`'v3'` for this SDK). Always set by the SDK; optional in the type so host-built fixtures stay valid. */
52
+ engine?: CaptureEngineId;
53
+ /**
54
+ * Camera request (`getUserMedia`) → the preview is live, in whole
55
+ * milliseconds measured with `performance.now()`. Part of the face-capture
56
+ * timing the SDK forwards to the backend as `input.capture` on the liveness
57
+ * submission; absent when the phase was not observed.
58
+ */
59
+ cameraReadyMs?: number;
60
+ /**
61
+ * Camera ready → the first face ACCEPTED by the gate (present and with
62
+ * size, centering and quality good enough to make progress — not merely
63
+ * detected), whole ms. Absent when no face was ever accepted.
64
+ */
65
+ faceAcquireMs?: number;
66
+ /**
67
+ * Face-capture duration: FIRST accepted face → gate progress 100 % (capture
68
+ * complete, before the clip window and any upload), whole ms. A face lost
69
+ * and re-acquired keeps the first acceptance as its start.
70
+ */
71
+ captureMs?: number;
50
72
  }
73
+ /** Capture engine identifier carried on {@link CapturedArtifacts.engine}. */
74
+ type CaptureEngineId = "v1" | "v3";
51
75
  /** Camera / engine failure kinds — collapsed to the public six. */
52
76
  type CaptureErrorKind = "permission" | "notfound" | "inuse" | "insecure" | "unsupported" | "generic";
53
77
  /** Camera / engine failure payload (`on('error')`). */
@@ -87,14 +111,28 @@ interface LivenessCaptureEvents {
87
111
  animations: "full" | "reduced";
88
112
  };
89
113
  }
114
+ /** Which camera to open: the selfie camera (`'user'`) or the rear one (`'environment'`). */
115
+ type CameraFacing = "user" | "environment";
116
+ /** Options of {@link LivenessCaptureHandle.start}. */
117
+ interface LivenessStartOptions {
118
+ /**
119
+ * Camera for this attempt and its retries; default: the current one
120
+ * ({@link LivenessCaptureOptions.facing}, else `'user'`). Use `switchCamera()`
121
+ * to change camera mid-capture.
122
+ */
123
+ facing?: CameraFacing;
124
+ }
90
125
  /** Live capture handle returned by {@link createLivenessCapture} / {@link Verification.liveness}. */
91
126
  interface LivenessCaptureHandle {
92
127
  /** Current {@link CaptureState}. */
93
128
  readonly state: CaptureState;
94
129
  /** Subscribe; returns the unsubscribe function. */
95
130
  on<K extends keyof LivenessCaptureEvents>(event: K, handler: (payload: LivenessCaptureEvents[K]) => void): () => void;
96
- /** Ask for the camera and start gating. Resolves once the attempt is running or failed. */
97
- start(): Promise<void>;
131
+ /**
132
+ * Ask for the camera and start gating. Resolves once the attempt is running or failed.
133
+ * `options.facing` picks the camera for this attempt and later retries.
134
+ */
135
+ start(options?: LivenessStartOptions): Promise<void>;
98
136
  /** Fresh attempt: resets the engine and restarts the camera. */
99
137
  retry(): void;
100
138
  /** Toggle user/environment camera (gate restarts from zero). */
@@ -106,10 +144,18 @@ interface LivenessCaptureHandle {
106
144
  interface LivenessCaptureOptions {
107
145
  /** Host-owned `<video playsInline muted>` element. */
108
146
  video: HTMLVideoElement;
109
- /** Initial camera; default `'user'`. */
110
- facing?: "user" | "environment";
147
+ /** Initial camera; default `'user'`. `start({ facing })` overrides it. */
148
+ facing?: CameraFacing;
111
149
  /** Base URL of the detector assets (tasks-vision wasm + tflite); default `/models-v3`. */
112
150
  assetBaseUrl?: string;
151
+ /**
152
+ * Hold a Screen Wake Lock while the camera is live (`starting` / `gating` /
153
+ * `recording`) so the phone does not dim or lock mid-capture; re-taken when
154
+ * the page becomes visible again. Best-effort: unsupported browsers or a
155
+ * refused request (e.g. an iframe without `allow="screen-wake-lock"`) never
156
+ * affect the capture. Default `true`; `false` never requests the lock.
157
+ */
158
+ keepScreenAwake?: boolean;
113
159
  }
114
160
  /**
115
161
  * SDK-side failure reasons (status `'unavailable'`):
@@ -195,7 +241,10 @@ interface Verification {
195
241
  interface CaptureEngine {
196
242
  readonly state: CaptureState$1;
197
243
  on<K extends keyof CaptureSessionV3Events>(event: K, handler: (payload: CaptureSessionV3Events[K]) => void): () => void;
198
- start(): Promise<void>;
244
+ /** `facingMode` sets the camera for this attempt and later retries. */
245
+ start(options?: {
246
+ facingMode?: "user" | "environment";
247
+ }): Promise<void>;
199
248
  retry(): void;
200
249
  switchCamera(): void;
201
250
  destroy(): void;
@@ -230,6 +279,57 @@ declare function createLivenessCaptureInternal(options: LivenessCaptureOptions,
230
279
  */
231
280
  declare function createLivenessCapture(options: LivenessCaptureOptions): LivenessCaptureHandle;
232
281
 
282
+ /** Preload state per asset base URL. */
283
+ type LivenessAssetsStatus = "idle" | "loading" | "ready" | "failed";
284
+ /** Options of {@link preloadLivenessAssets}. */
285
+ interface PreloadLivenessAssetsOptions {
286
+ /** Same value as the capture's `assetBaseUrl`; default `/models-v3`. */
287
+ assetBaseUrl?: string;
288
+ /** Defer the load to browser idle time (`requestIdleCallback`, 1.2 s timeout fallback). Default `false`. */
289
+ idle?: boolean;
290
+ /** Skip when the browser asks to save data (`navigator.connection.saveData`). Default `false`. */
291
+ respectSaveData?: boolean;
292
+ }
293
+ /** Blaze init deadline for the preload — generous: a slow ~11 MB wasm download must finish. */
294
+ declare const PRELOAD_BLAZE_INIT_TIMEOUT_MS = 120000;
295
+ /** Outer budget reclaiming only a genuinely hung load (≥ the init deadline + slack). */
296
+ declare const PRELOAD_BUDGET_MS = 130000;
297
+ type Loader = (base: string) => Promise<Detector>;
298
+ /** @internal Test seam: replace the detector loader (null restores the real one). */
299
+ declare function setPreloadLoaderForTests(next: Loader | null): void;
300
+ /** @internal Test seam: drop every entry (destroying warmed detectors). */
301
+ declare function resetLivenessAssetsForTests(): void;
302
+ /**
303
+ * Warm the face detector for `assetBaseUrl` so the capture starts instantly.
304
+ * Idempotent per base URL and never rejects: resolves the settled status.
305
+ * `'idle'` means nothing was preloaded here (SSR, no camera API, Data-Saver
306
+ * skip) — start normally. Calling again after `'failed'` retries the load.
307
+ * With `idle: true` the load is deferred (status stays `'idle'` until it
308
+ * starts); a later non-idle call — or a capture mounting meanwhile — starts it
309
+ * at once, and {@link releaseLivenessAssets} cancels it.
310
+ */
311
+ declare function preloadLivenessAssets(options?: PreloadLivenessAssetsOptions): Promise<LivenessAssetsStatus>;
312
+ /** Current preload status for `assetBaseUrl` (default `/models-v3`). */
313
+ declare function getLivenessAssetsStatus(assetBaseUrl?: string): LivenessAssetsStatus;
314
+ /**
315
+ * Subscribe to status changes for `assetBaseUrl`; returns the unsubscribe
316
+ * function. Does NOT emit the current status on subscribe (read it with
317
+ * {@link getLivenessAssetsStatus}) — the
318
+ * `useSyncExternalStore(subscribe, getSnapshot)` contract, so it plugs into
319
+ * that hook directly.
320
+ */
321
+ declare function subscribeLivenessAssets(listener: (status: LivenessAssetsStatus) => void, assetBaseUrl?: string): () => void;
322
+ /** Free the warmed detector (an SPA leaving the flow). Never call while a capture is mounted. */
323
+ declare function releaseLivenessAssets(assetBaseUrl?: string): void;
324
+ /**
325
+ * @internal The capture engine's detector source when a preload exists for
326
+ * `assetBaseUrl`: a non-owning view of the warm instance (waiting for an
327
+ * in-flight load), or — once that load failed — a cold detector OWNED by the
328
+ * session (default ladder + deadline). `undefined` when nothing was preloaded.
329
+ * Invoking it on an idle-scheduled preload starts that load now and joins it.
330
+ */
331
+ declare function preloadedDetectorFactory(assetBaseUrl?: string): (() => Promise<Detector>) | undefined;
332
+
233
333
  /** The client surface the flow needs — `HostedClient` or a test fake. */
234
334
  type HostedClientLike = Pick<HostedClient, "getSession" | "recordConsent" | "presign" | "uploadToSpaces" | "completeMedia" | "submitCheck">;
235
335
  /** The presign policy allowlist for `kind: 'clip'` (media.policy.ts mirror). */
@@ -345,4 +445,4 @@ declare function createVerification(options: VerificationOptions): Verification;
345
445
  /** {@link createVerification} with construction seams (tests / Sekyro-internal hosts). */
346
446
  declare function createVerificationInternal(options: VerificationOptions, internals: VerificationInternals): Verification;
347
447
 
348
- export { AttestationError as A, createLivenessCaptureInternal as B, type CaptureChannel as C, DEFAULT_API_ORIGIN as D, createVerificationInternal as E, mapEngineState as F, type GateHint as G, type HostedClientLike as H, mapErrorKind as I, mapGuidanceHint as J, randomUuid as K, type LivenessCaptureEvents as L, runLivenessFlow as M, runSubmission as N, PROCESSING_POLL_DELAY_MS as P, type ReasonCode as R, type SdkFailureReason as S, TRANSPORT_REPLAY_ATTEMPTS as T, type Verification as V, type CaptureError as a, type CaptureErrorKind as b, type CaptureState as c, type CapturedArtifacts as d, type GateUpdate as e, type LivenessCaptureHandle as f, type LivenessCaptureOptions as g, type VerificationEvents as h, type VerificationLocale as i, type VerificationOptions as j, type VerificationResult as k, type VerificationStatus as l, createLivenessCapture as m, createVerification as n, CLIP_MIME_ALLOWLIST as o, type CaptureEngine as p, type LivenessCaptureInternalHandle as q, type LivenessCaptureInternals as r, type LivenessFlowDeps as s, type LivenessFlowOutcome as t, PROCESSING_POLL_MAX as u, REGISTRY_RETRY_DELAY_MS as v, type SubmitExecutor as w, type SubmitRuntime as x, TRANSPORT_REPLAY_DELAY_MS as y, type VerificationInternals as z };
448
+ export { preloadedDetectorFactory as $, AttestationError as A, type LivenessFlowDeps as B, type CameraFacing as C, DEFAULT_API_ORIGIN as D, type LivenessFlowOutcome as E, PRELOAD_BLAZE_INIT_TIMEOUT_MS as F, type GateHint as G, type HostedClientLike as H, PRELOAD_BUDGET_MS as I, PROCESSING_POLL_DELAY_MS as J, PROCESSING_POLL_MAX as K, type LivenessAssetsStatus as L, REGISTRY_RETRY_DELAY_MS as M, type SubmitExecutor as N, type SubmitRuntime as O, type PreloadLivenessAssetsOptions as P, TRANSPORT_REPLAY_DELAY_MS as Q, type ReasonCode as R, type SdkFailureReason as S, TRANSPORT_REPLAY_ATTEMPTS as T, type VerificationInternals as U, type Verification as V, createLivenessCaptureInternal as W, createVerificationInternal as X, mapEngineState as Y, mapErrorKind as Z, mapGuidanceHint as _, type CaptureChannel as a, randomUuid as a0, resetLivenessAssetsForTests as a1, runLivenessFlow as a2, runSubmission as a3, setPreloadLoaderForTests as a4, type CaptureEngineId as b, type CaptureError as c, type CaptureErrorKind as d, type CaptureState as e, type CapturedArtifacts as f, type GateUpdate as g, type LivenessCaptureEvents as h, type LivenessCaptureHandle as i, type LivenessCaptureOptions as j, type LivenessStartOptions as k, type VerificationEvents as l, type VerificationLocale as m, type VerificationOptions as n, type VerificationResult as o, type VerificationStatus as p, createLivenessCapture as q, createVerification as r, getLivenessAssetsStatus as s, preloadLivenessAssets as t, releaseLivenessAssets as u, subscribeLivenessAssets as v, CLIP_MIME_ALLOWLIST as w, type CaptureEngine as x, type LivenessCaptureInternalHandle as y, type LivenessCaptureInternals as z };
@@ -190,6 +190,19 @@ interface LivenessInput {
190
190
  * Client-declared by design (not a security boundary); absent = legacy
191
191
  * clients, treated as mobile server-side during the rollout window. */
192
192
  captureChannel?: 'mobile' | 'desktop';
193
+ /** Capture metadata (engine, dimensions, clip length, face-capture timing)
194
+ * — the backend's allowlisted, non-PII `capture` block (session insights). */
195
+ capture?: LivenessCaptureInput;
196
+ }
197
+ /** `LivenessInput.capture`: what the SDK's `captured` event measured. All ms are whole, ≥ 0. */
198
+ interface LivenessCaptureInput {
199
+ engine?: 'v1' | 'v3';
200
+ width?: number;
201
+ height?: number;
202
+ clipMs?: number;
203
+ cameraReadyMs?: number;
204
+ faceAcquireMs?: number;
205
+ captureMs?: number;
193
206
  }
194
207
  /**
195
208
  * population_registry adapter input. `nni` is the 10-digit NNI for an UNBOUND
@@ -405,4 +418,4 @@ declare class HostedClient {
405
418
  private api;
406
419
  }
407
420
 
408
- export { type AttestationInput as A, type CheckReason as C, type DocReason as D, type FaceMatchReason as F, type HostedOtpView as H, type LivenessReason as L, type MediaCheckType as M, type PhoneOtpReason as P, type RecordConsentResult as R, type SessionOutcome as S, type UploadMedia as U, type CheckState as a, type CheckType as b, type HostedSessionView as c, type HostedStepView as d, type PopulationReason as e, type SessionStatus as f, HostedClient as g, type SessionView as h, type CheckInputByType as i, type CompleteMediaResult as j, type ConsentLocale as k, type DocOcrInput as l, type DocSide as m, type FaceMatchInput as n, type HostedClientOptions as o, type LivenessInput as p, type MediaKind as q, type PhoneOtpInput as r, type PopulationInput as s, type PresignRequest as t, type PresignUploadResult as u, type SessionStepView as v, type SubmitCheckBody as w, type SubmitOptions as x, stripMimeParams as y };
421
+ export { type AttestationInput as A, type CheckReason as C, type DocReason as D, type FaceMatchReason as F, type HostedOtpView as H, type LivenessReason as L, type MediaCheckType as M, type PhoneOtpReason as P, type RecordConsentResult as R, type SessionOutcome as S, type UploadMedia as U, type CheckState as a, type CheckType as b, type HostedSessionView as c, type HostedStepView as d, type PopulationReason as e, type SessionStatus as f, HostedClient as g, type SessionView as h, type CheckInputByType as i, type CompleteMediaResult as j, type ConsentLocale as k, type DocOcrInput as l, type DocSide as m, type FaceMatchInput as n, type HostedClientOptions as o, type LivenessCaptureInput as p, type LivenessInput as q, type MediaKind as r, type PhoneOtpInput as s, type PopulationInput as t, type PresignRequest as u, type PresignUploadResult as v, type SessionStepView as w, type SubmitCheckBody as x, type SubmitOptions as y, stripMimeParams as z };
@@ -190,6 +190,19 @@ interface LivenessInput {
190
190
  * Client-declared by design (not a security boundary); absent = legacy
191
191
  * clients, treated as mobile server-side during the rollout window. */
192
192
  captureChannel?: 'mobile' | 'desktop';
193
+ /** Capture metadata (engine, dimensions, clip length, face-capture timing)
194
+ * — the backend's allowlisted, non-PII `capture` block (session insights). */
195
+ capture?: LivenessCaptureInput;
196
+ }
197
+ /** `LivenessInput.capture`: what the SDK's `captured` event measured. All ms are whole, ≥ 0. */
198
+ interface LivenessCaptureInput {
199
+ engine?: 'v1' | 'v3';
200
+ width?: number;
201
+ height?: number;
202
+ clipMs?: number;
203
+ cameraReadyMs?: number;
204
+ faceAcquireMs?: number;
205
+ captureMs?: number;
193
206
  }
194
207
  /**
195
208
  * population_registry adapter input. `nni` is the 10-digit NNI for an UNBOUND
@@ -405,4 +418,4 @@ declare class HostedClient {
405
418
  private api;
406
419
  }
407
420
 
408
- export { type AttestationInput as A, type CheckReason as C, type DocReason as D, type FaceMatchReason as F, type HostedOtpView as H, type LivenessReason as L, type MediaCheckType as M, type PhoneOtpReason as P, type RecordConsentResult as R, type SessionOutcome as S, type UploadMedia as U, type CheckState as a, type CheckType as b, type HostedSessionView as c, type HostedStepView as d, type PopulationReason as e, type SessionStatus as f, HostedClient as g, type SessionView as h, type CheckInputByType as i, type CompleteMediaResult as j, type ConsentLocale as k, type DocOcrInput as l, type DocSide as m, type FaceMatchInput as n, type HostedClientOptions as o, type LivenessInput as p, type MediaKind as q, type PhoneOtpInput as r, type PopulationInput as s, type PresignRequest as t, type PresignUploadResult as u, type SessionStepView as v, type SubmitCheckBody as w, type SubmitOptions as x, stripMimeParams as y };
421
+ export { type AttestationInput as A, type CheckReason as C, type DocReason as D, type FaceMatchReason as F, type HostedOtpView as H, type LivenessReason as L, type MediaCheckType as M, type PhoneOtpReason as P, type RecordConsentResult as R, type SessionOutcome as S, type UploadMedia as U, type CheckState as a, type CheckType as b, type HostedSessionView as c, type HostedStepView as d, type PopulationReason as e, type SessionStatus as f, HostedClient as g, type SessionView as h, type CheckInputByType as i, type CompleteMediaResult as j, type ConsentLocale as k, type DocOcrInput as l, type DocSide as m, type FaceMatchInput as n, type HostedClientOptions as o, type LivenessCaptureInput as p, type LivenessInput as q, type MediaKind as r, type PhoneOtpInput as s, type PopulationInput as t, type PresignRequest as u, type PresignUploadResult as v, type SessionStepView as w, type SubmitCheckBody as x, type SubmitOptions as y, stripMimeParams as z };