@sekyro/web 0.1.0-rc.6 → 0.1.0-rc.8

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 (118) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/LICENSE +25 -16
  3. package/README.md +6 -8
  4. package/THIRD-PARTY-NOTICES.txt +154 -0
  5. package/dist/background-monitor-A7FKJOAG.js +1 -0
  6. package/dist/capture-session-doc-YBE3UMJJ.js +1 -0
  7. package/dist/{capture-session-v3-Okq0EQHG.d.ts → capture-session-v3-CQK-G-qX.d.ts} +72 -3
  8. package/dist/{capture-session-v3-UQU_WjO2.d.cts → capture-session-v3-Dvob-uH2.d.cts} +72 -3
  9. package/dist/chunk-4RS2YIL4.js +1 -0
  10. package/dist/chunk-7V2M6Y2W.js +1 -0
  11. package/dist/chunk-7ZCZY3ZP.js +1 -0
  12. package/dist/chunk-A3FUGHAH.js +2 -0
  13. package/dist/chunk-BPE5NSQ2.js +1 -0
  14. package/dist/chunk-CJHMFPL6.js +1 -0
  15. package/dist/chunk-DFTCAWMP.js +1 -0
  16. package/dist/chunk-DK5YPBDQ.js +1 -0
  17. package/dist/chunk-DQWW4OCK.js +1 -0
  18. package/dist/chunk-FHJ7HO3M.js +1 -0
  19. package/dist/chunk-FPXL63KZ.js +1 -0
  20. package/dist/chunk-G6LKLN4U.js +1 -0
  21. package/dist/chunk-GI3UFGRQ.js +1 -0
  22. package/dist/chunk-LQ7C44JG.js +1 -0
  23. package/dist/chunk-M43ET4NJ.js +1 -0
  24. package/dist/chunk-MXWLCDFX.js +1 -0
  25. package/dist/chunk-MY6EXEL2.js +1 -0
  26. package/dist/chunk-O5WKNZ2C.js +1 -0
  27. package/dist/chunk-OKWG3PVH.js +1 -0
  28. package/dist/chunk-POIQGEZM.js +1 -0
  29. package/dist/chunk-RI3E7GBN.js +1 -0
  30. package/dist/chunk-RNRFHUJA.js +1 -0
  31. package/dist/chunk-RVHAKRAI.js +1 -0
  32. package/dist/chunk-SMKCBUJL.js +1 -0
  33. package/dist/chunk-SXZCL5NO.js +1 -0
  34. package/dist/chunk-TDLIXFDT.js +1 -0
  35. package/dist/chunk-XLN5OT25.js +1 -0
  36. package/dist/chunk-YDQBVWXG.js +1 -0
  37. package/dist/chunk-YPG7CB4O.js +1 -0
  38. package/dist/client/index.cjs +1 -357
  39. package/dist/client/index.d.cts +13 -3
  40. package/dist/client/index.d.ts +13 -3
  41. package/dist/client/index.js +1 -15
  42. package/dist/core/index.cjs +1 -1639
  43. package/dist/core/index.d.cts +3 -3
  44. package/dist/core/index.d.ts +3 -3
  45. package/dist/core/index.js +1 -139
  46. package/dist/core/ocr/worker.bundle.js +42 -0
  47. package/dist/core/ocr/worker.cjs +42 -0
  48. package/dist/core/ocr/worker.d.cts +84 -0
  49. package/dist/core/ocr/worker.d.ts +84 -0
  50. package/dist/core/ocr/worker.js +41 -0
  51. package/dist/core/v3/detect-worker.cjs +1 -392
  52. package/dist/core/v3/detect-worker.d.cts +1 -1
  53. package/dist/core/v3/detect-worker.d.ts +1 -1
  54. package/dist/core/v3/detect-worker.js +1 -13
  55. package/dist/create-document-capture-T4APHJMY.js +1 -0
  56. package/dist/create-portrait-capture-B57GE5FU.js +1 -0
  57. package/dist/create-verification-C0AVIcVW.d.ts +2787 -0
  58. package/dist/create-verification-DoFpgzok.d.cts +2787 -0
  59. package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
  60. package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
  61. package/dist/detector-scanic-YCDNLCGV.js +1 -0
  62. package/dist/icao-gate-D8qm1O2t.d.cts +1655 -0
  63. package/dist/icao-gate-D8qm1O2t.d.ts +1655 -0
  64. package/dist/icao-gate-PWBMKRGC.js +1 -0
  65. package/dist/icao-tuning-4GGVX6B4.js +1 -0
  66. package/dist/index.cjs +1 -3030
  67. package/dist/index.d.cts +52 -6
  68. package/dist/index.d.ts +52 -6
  69. package/dist/index.js +1 -85
  70. package/dist/internal/index.cjs +1 -4439
  71. package/dist/internal/index.d.cts +352 -312
  72. package/dist/internal/index.d.ts +352 -312
  73. package/dist/internal/index.js +1 -657
  74. package/dist/keyframe-rank-YAJLYJYF.js +1 -0
  75. package/dist/landmarker-KB7LVXAU.js +1 -0
  76. package/dist/mrz-band-VYHOTDHY.js +1 -0
  77. package/dist/plan-runner-UBK4B4CG.js +1 -0
  78. package/dist/popup/index.cjs +1 -76
  79. package/dist/popup/index.js +1 -11
  80. package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
  81. package/dist/segmenter-USLNBX65.js +1 -0
  82. package/dist/turnstile-FATNZ4AG.js +1 -0
  83. package/package.json +25 -10
  84. package/sbom.cdx.json +195 -0
  85. package/dist/chunk-MWNFSNMP.js +0 -52
  86. package/dist/chunk-MWNFSNMP.js.map +0 -1
  87. package/dist/chunk-NILNKLK6.js +0 -50
  88. package/dist/chunk-NILNKLK6.js.map +0 -1
  89. package/dist/chunk-NWF46H7K.js +0 -359
  90. package/dist/chunk-NWF46H7K.js.map +0 -1
  91. package/dist/chunk-R3SJQHYU.js +0 -1173
  92. package/dist/chunk-R3SJQHYU.js.map +0 -1
  93. package/dist/chunk-TG5IE552.js +0 -1128
  94. package/dist/chunk-TG5IE552.js.map +0 -1
  95. package/dist/chunk-WY6U7AIK.js +0 -193
  96. package/dist/chunk-WY6U7AIK.js.map +0 -1
  97. package/dist/chunk-YVFF4Q4G.js +0 -327
  98. package/dist/chunk-YVFF4Q4G.js.map +0 -1
  99. package/dist/client/index.cjs.map +0 -1
  100. package/dist/client/index.js.map +0 -1
  101. package/dist/core/index.cjs.map +0 -1
  102. package/dist/core/index.js.map +0 -1
  103. package/dist/core/v3/detect-worker.cjs.map +0 -1
  104. package/dist/core/v3/detect-worker.js.map +0 -1
  105. package/dist/create-verification-BKc9NFQj.d.cts +0 -455
  106. package/dist/create-verification-DjcMZHAQ.d.ts +0 -455
  107. package/dist/detector-scanic-4C6IEW2K.js +0 -787
  108. package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
  109. package/dist/hosted-client-DJXq_CB9.d.cts +0 -449
  110. package/dist/hosted-client-DJXq_CB9.d.ts +0 -449
  111. package/dist/index.cjs.map +0 -1
  112. package/dist/index.js.map +0 -1
  113. package/dist/internal/index.cjs.map +0 -1
  114. package/dist/internal/index.js.map +0 -1
  115. package/dist/popup/index.cjs.map +0 -1
  116. package/dist/popup/index.js.map +0 -1
  117. package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
  118. package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
@@ -1,455 +0,0 @@
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, f as HostedVoiceView, c as HostedSessionView, i as HostedClient, A as AttestationInput, j as SessionView, b as CheckType } from './hosted-client-DJXq_CB9.js';
4
-
5
- /** Gate guidance code. `'hold'` is emitted while the clip records. */
6
- type GateHint = "center" | "closer" | "farther" | "light" | "still" | "hold";
7
- /**
8
- * Capture + verification state, as seen by the partner:
9
- * - `idle → starting → gating → recording → captured` is the engine's run;
10
- * - `uploading → checking → done` follows ONLY when the handle was obtained via
11
- * {@link Verification.liveness} (the SDK uploads and submits after `captured`);
12
- * - `error` on a camera / engine failure (see {@link CaptureError}).
13
- */
14
- type CaptureState = "idle" | "starting" | "gating" | "recording" | "captured" | "uploading" | "checking" | "done" | "error";
15
- /** Declared capture channel — the liveness band is mobile-calibrated. */
16
- type CaptureChannel = "mobile" | "desktop";
17
- /** Gate ring update: integrator progress 0..1 and the current guidance code. */
18
- interface GateUpdate {
19
- /** Gate integrator 0..1 — drive the ring off this directly. */
20
- progress: number;
21
- /** Current guidance code, `null` when no hint applies. */
22
- hint: GateHint | null;
23
- /**
24
- * The detector currently sees a face (a non-zero engine presence factor). `false`
25
- * with `hint: 'center'` means "no face in frame" rather than "off-center" —
26
- * hosts use it to tell seeking from aligning, and for the no-face copy.
27
- */
28
- faceDetected: boolean;
29
- }
30
- /**
31
- * What the engine captured. Fires BEFORE any upload. `clip` is absent only in
32
- * the `degraded: 'NO_RECORDER'` case (no MediaRecorder on this browser).
33
- */
34
- interface CapturedArtifacts {
35
- /** Mirrored JPEG keyframe (the face_match probe). */
36
- keyframe: Blob;
37
- /** The 2.5 s liveness clip (MP4-first mime ladder). */
38
- clip?: Blob;
39
- /** Container mime the clip finalized with — may carry codec params. */
40
- clipMime?: string;
41
- /** Intrinsic video width at capture time. */
42
- width: number;
43
- /** Intrinsic video height at capture time. */
44
- height: number;
45
- /** Recording-start → recording-stop, when known. */
46
- clipMs?: number;
47
- /** `'mobile'` on phones/tablets (the calibrated channel), else `'desktop'`. */
48
- captureChannel: CaptureChannel;
49
- /** Set when the browser has no MediaRecorder: a keyframe-only capture. */
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;
72
- }
73
- /** Capture engine identifier carried on {@link CapturedArtifacts.engine}. */
74
- type CaptureEngineId = "v1" | "v3";
75
- /** Camera / engine failure kinds — collapsed to the public six. */
76
- type CaptureErrorKind = "permission" | "notfound" | "inuse" | "insecure" | "unsupported" | "generic";
77
- /** Camera / engine failure payload (`on('error')`). */
78
- interface CaptureError {
79
- kind: CaptureErrorKind;
80
- /**
81
- * A fresh attempt (`retry()`) can succeed — false for `insecure` (needs
82
- * HTTPS) and `unsupported` (the browser cannot capture at all).
83
- */
84
- retryable: boolean;
85
- }
86
- /** Event map of a {@link LivenessCaptureHandle}. */
87
- interface LivenessCaptureEvents {
88
- /** Every state transition. */
89
- state: CaptureState;
90
- /** Gate ring updates while gating/recording. */
91
- gate: GateUpdate;
92
- /** The capture result — fires BEFORE any upload. */
93
- captured: CapturedArtifacts;
94
- /** Camera / engine failure. */
95
- error: CaptureError;
96
- /**
97
- * Clip mode only: the recording window just ended and the keyframe is already
98
- * available, BEFORE the clip finalizes (iOS can lag ~1.5 s). Hosts freeze the
99
- * display on `previewDataUrl` (a mirrored JPEG data URL) instead of leaving
100
- * the live feed running; `captured` follows once the clip lands.
101
- */
102
- frozen: {
103
- previewDataUrl: string;
104
- };
105
- /**
106
- * Device-profile hint, emitted when it changes: `'reduced'` asks the host to
107
- * drop decorative animations (a LOW device class needs the frames for
108
- * detection). Chrome only — never gate input.
109
- */
110
- profile: {
111
- animations: "full" | "reduced";
112
- };
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
- }
125
- /** Live capture handle returned by {@link createLivenessCapture} / {@link Verification.liveness}. */
126
- interface LivenessCaptureHandle {
127
- /** Current {@link CaptureState}. */
128
- readonly state: CaptureState;
129
- /** Subscribe; returns the unsubscribe function. */
130
- on<K extends keyof LivenessCaptureEvents>(event: K, handler: (payload: LivenessCaptureEvents[K]) => void): () => 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>;
136
- /** Fresh attempt: resets the engine and restarts the camera. */
137
- retry(): void;
138
- /** Toggle user/environment camera (gate restarts from zero). */
139
- switchCamera(): void;
140
- /** Stop the camera, release the detector, drop all listeners. */
141
- destroy(): void;
142
- }
143
- /** Options of {@link createLivenessCapture} / {@link Verification.liveness}. */
144
- interface LivenessCaptureOptions {
145
- /** Host-owned `<video playsInline muted>` element. */
146
- video: HTMLVideoElement;
147
- /** Initial camera; default `'user'`. `start({ facing })` overrides it. */
148
- facing?: CameraFacing;
149
- /** Base URL of the detector assets (tasks-vision wasm + tflite); default `/models-v3`. */
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;
159
- }
160
- /**
161
- * SDK-side failure reasons (status `'unavailable'`):
162
- * - `no_recorder` — no MediaRecorder / unsupported clip container;
163
- * - `attestation` — Turnstile failed client-side or `attestation_invalid` after one retry;
164
- * - `network` — transport / API failure after the bounded replays;
165
- * - `nni_unbound` — `population_registry` is the frontier but the session was
166
- * minted WITHOUT a server-bound NNI (`POST /sessions` `input.nni`), so the
167
- * SDK cannot submit it. Mint the session with the NNI (or complete the
168
- * population step yourself) before starting the capture.
169
- */
170
- type SdkFailureReason = "no_recorder" | "attestation" | "network" | "nni_unbound";
171
- /** Backend reason taxonomy ∪ the SDK-side failure reasons. */
172
- type ReasonCode = CheckReason | SdkFailureReason;
173
- /**
174
- * - `approved` / `rejected` / `review` — the session's verdict;
175
- * - `retry` — a retryable reason with attempts remaining (`autoRetry` on); the
176
- * capture re-arms by itself;
177
- * - `unavailable` — v2 could not run this capture (no MediaRecorder,
178
- * attestation failed, network/API failure). Treat as "not completed".
179
- */
180
- type VerificationStatus = "approved" | "rejected" | "review" | "retry" | "unavailable";
181
- /** The verdict for this session / capture (`on('result')`). */
182
- interface VerificationResult {
183
- sessionId: string;
184
- status: VerificationStatus;
185
- /** Backend reason, or the SDK-side failure reason for `unavailable`. */
186
- reason?: ReasonCode;
187
- /**
188
- * `retry` (and a `rejected` on a still-parked step): submissions left for
189
- * the parked check after this one, for the host's coaching copy.
190
- */
191
- attemptsRemaining?: number;
192
- }
193
- /** Consent locale picklist (mirrors the backend HostedConsentSchema). */
194
- type VerificationLocale = "ar" | "fr" | "en";
195
- /** Options of {@link createVerification}. */
196
- interface VerificationOptions {
197
- /** The session's client token (from `POST /api/v2/sessions` → `client_token`). */
198
- clientToken: string;
199
- /** API origin; default `https://api.sekyro.ai`. */
200
- apiOrigin?: string;
201
- /** Consent locale (echoed into the auditable consent record). */
202
- locale: VerificationLocale;
203
- /** Re-arm the capture on retryable reasons while attempts remain. Default `true`. */
204
- autoRetry?: boolean;
205
- /**
206
- * How a `retry` verdict re-arms the capture (`autoRetry` on):
207
- * - `'auto'` (default) — the camera restarts immediately;
208
- * - `'manual'` — the handle settles at `done`; the host shows its coaching
209
- * and calls `retry()` on the handle when the user is ready.
210
- */
211
- rearm?: "auto" | "manual";
212
- /** Injection seam for `fetch` (tests / non-window contexts). */
213
- fetch?: typeof globalThis.fetch;
214
- }
215
- /** Event map of a {@link Verification}. */
216
- interface VerificationEvents {
217
- /** Verdict per capture (and once when the registry settles the session early). */
218
- result: VerificationResult;
219
- /** Every hosted-view update the SDK observes (bootstrap, consent, submits). */
220
- view: HostedSessionView;
221
- }
222
- /** One session's verification, from {@link createVerification}. */
223
- interface Verification {
224
- /** Record consent once (no-op when the session already has it). */
225
- consent(): Promise<void>;
226
- /**
227
- * Submit `population_registry` early with the SERVER-bound NNI (empty input)
228
- * when it is the pending frontier. Retries once on `registry_unavailable`.
229
- * Never rejects — failures surface through `result`. Idempotent.
230
- */
231
- startRegistry(): Promise<void>;
232
- /** Start a liveness capture bound to this verification; the SDK uploads + submits on `captured`. */
233
- liveness(options: LivenessCaptureOptions): LivenessCaptureHandle;
234
- /**
235
- * The session's Sekyro-hosted voice clips (`view.voice`), bootstrapping the
236
- * hosted view when it has not been fetched yet. Resolves `null` when the
237
- * session has no active clip set, the API predates the field, the bootstrap
238
- * fails, or the verification was destroyed. Never rejects.
239
- */
240
- voiceClips(): Promise<HostedVoiceView | null>;
241
- /** Subscribe; returns the unsubscribe function. */
242
- on<K extends keyof VerificationEvents>(event: K, handler: (payload: VerificationEvents[K]) => void): () => void;
243
- /** Destroy the active capture and drop all listeners. */
244
- destroy(): void;
245
- }
246
-
247
- /** The engine surface the handle binds — CaptureSessionV3 or a test double. */
248
- interface CaptureEngine {
249
- readonly state: CaptureState$1;
250
- on<K extends keyof CaptureSessionV3Events>(event: K, handler: (payload: CaptureSessionV3Events[K]) => void): () => void;
251
- /** `facingMode` sets the camera for this attempt and later retries. */
252
- start(options?: {
253
- facingMode?: "user" | "environment";
254
- }): Promise<void>;
255
- retry(): void;
256
- switchCamera(): void;
257
- destroy(): void;
258
- /** Device-profile chrome hint (LOW class → `'reduced'`); absent on doubles. */
259
- readonly animations?: "full" | "reduced";
260
- }
261
- /** Internal construction seams (tests; Sekyro's own hosted page). */
262
- interface LivenessCaptureInternals {
263
- /** Replace the engine constructor (default: `new CaptureSessionV3(options)`). */
264
- createEngine?: (options: CaptureSessionV3Options) => CaptureEngine;
265
- /** Extra engine options merged in (worker offload, warmed detector, telemetry). */
266
- engineOptions?: Partial<Pick<CaptureSessionV3Options, "createDetector" | "createWorker" | "telemetry" | "deviceClass">>;
267
- /** Clock (default `performance.now`). */
268
- now?: () => number;
269
- }
270
- /** fcv3.* guidance key → public gate hint code. */
271
- declare function mapGuidanceHint(key: string): GateHint | null;
272
- /** Engine state → public state (`preflight|acquiring → starting`, `positioning → gating`). */
273
- declare function mapEngineState(state: CaptureState$1): CaptureState;
274
- /** Engine error kinds → the public six (`models|cliptoolarge|recorder|overconstrained → generic`). */
275
- declare function mapErrorKind(kind: CaptureErrorKind$1): CaptureErrorKind;
276
- /** Handle + the hooks the verification layer uses to drive the flow states. */
277
- interface LivenessCaptureInternalHandle {
278
- handle: LivenessCaptureHandle;
279
- /** Push a post-capture state (`uploading | checking | done`). */
280
- setFlowState(state: Extract<CaptureState, "uploading" | "checking" | "done">): void;
281
- }
282
- declare function createLivenessCaptureInternal(options: LivenessCaptureOptions, internals?: LivenessCaptureInternals): LivenessCaptureInternalHandle;
283
- /**
284
- * Create a standalone liveness capture (no upload — pair it with your own
285
- * submission, or use {@link Verification.liveness} for the full flow).
286
- */
287
- declare function createLivenessCapture(options: LivenessCaptureOptions): LivenessCaptureHandle;
288
-
289
- /** Preload state per asset base URL. */
290
- type LivenessAssetsStatus = "idle" | "loading" | "ready" | "failed";
291
- /** Options of {@link preloadLivenessAssets}. */
292
- interface PreloadLivenessAssetsOptions {
293
- /** Same value as the capture's `assetBaseUrl`; default `/models-v3`. */
294
- assetBaseUrl?: string;
295
- /** Defer the load to browser idle time (`requestIdleCallback`, 1.2 s timeout fallback). Default `false`. */
296
- idle?: boolean;
297
- /** Skip when the browser asks to save data (`navigator.connection.saveData`). Default `false`. */
298
- respectSaveData?: boolean;
299
- }
300
- /** Blaze init deadline for the preload — generous: a slow ~11 MB wasm download must finish. */
301
- declare const PRELOAD_BLAZE_INIT_TIMEOUT_MS = 120000;
302
- /** Outer budget reclaiming only a genuinely hung load (≥ the init deadline + slack). */
303
- declare const PRELOAD_BUDGET_MS = 130000;
304
- type Loader = (base: string) => Promise<Detector>;
305
- /** @internal Test seam: replace the detector loader (null restores the real one). */
306
- declare function setPreloadLoaderForTests(next: Loader | null): void;
307
- /** @internal Test seam: drop every entry (destroying warmed detectors). */
308
- declare function resetLivenessAssetsForTests(): void;
309
- /**
310
- * Warm the face detector for `assetBaseUrl` so the capture starts instantly.
311
- * Idempotent per base URL and never rejects: resolves the settled status.
312
- * `'idle'` means nothing was preloaded here (SSR, no camera API, Data-Saver
313
- * skip) — start normally. Calling again after `'failed'` retries the load.
314
- * With `idle: true` the load is deferred (status stays `'idle'` until it
315
- * starts); a later non-idle call — or a capture mounting meanwhile — starts it
316
- * at once, and {@link releaseLivenessAssets} cancels it.
317
- */
318
- declare function preloadLivenessAssets(options?: PreloadLivenessAssetsOptions): Promise<LivenessAssetsStatus>;
319
- /** Current preload status for `assetBaseUrl` (default `/models-v3`). */
320
- declare function getLivenessAssetsStatus(assetBaseUrl?: string): LivenessAssetsStatus;
321
- /**
322
- * Subscribe to status changes for `assetBaseUrl`; returns the unsubscribe
323
- * function. Does NOT emit the current status on subscribe (read it with
324
- * {@link getLivenessAssetsStatus}) — the
325
- * `useSyncExternalStore(subscribe, getSnapshot)` contract, so it plugs into
326
- * that hook directly.
327
- */
328
- declare function subscribeLivenessAssets(listener: (status: LivenessAssetsStatus) => void, assetBaseUrl?: string): () => void;
329
- /** Free the warmed detector (an SPA leaving the flow). Never call while a capture is mounted. */
330
- declare function releaseLivenessAssets(assetBaseUrl?: string): void;
331
- /**
332
- * @internal The capture engine's detector source when a preload exists for
333
- * `assetBaseUrl`: a non-owning view of the warm instance (waiting for an
334
- * in-flight load), or — once that load failed — a cold detector OWNED by the
335
- * session (default ladder + deadline). `undefined` when nothing was preloaded.
336
- * Invoking it on an idle-scheduled preload starts that load now and joins it.
337
- */
338
- declare function preloadedDetectorFactory(assetBaseUrl?: string): (() => Promise<Detector>) | undefined;
339
-
340
- /** The client surface the flow needs — `HostedClient` or a test fake. */
341
- type HostedClientLike = Pick<HostedClient, "getSession" | "recordConsent" | "presign" | "uploadToSpaces" | "completeMedia" | "submitCheck">;
342
- /** The presign policy allowlist for `kind: 'clip'` (media.policy.ts mirror). */
343
- declare const CLIP_MIME_ALLOWLIST: readonly string[];
344
- /** Same-key transport replays AFTER the first try, and the pause between them. */
345
- declare const TRANSPORT_REPLAY_ATTEMPTS = 2;
346
- declare const TRANSPORT_REPLAY_DELAY_MS = 1000;
347
- /** A Turnstile challenge failed client-side (load / render / error-callback / timeout). */
348
- declare class AttestationError extends Error {
349
- constructor(message: string);
350
- }
351
- /** One logical submission: receives the client and ITS idempotency key. */
352
- type SubmitExecutor = (client: HostedClientLike, idempotencyKey: string) => Promise<SessionView>;
353
- interface SubmitRuntime {
354
- client: HostedClientLike;
355
- /** Force-record consent (the server just said it is missing). */
356
- ensureConsent(opts: {
357
- force: true;
358
- }): Promise<void>;
359
- sleep(ms: number): Promise<void>;
360
- uuid(): string;
361
- }
362
- /**
363
- * Run one logical submission (ported use-submit semantics):
364
- * - a fresh `crypto.randomUUID()` key per logical submission;
365
- * - a transport-class failure replays the SAME executor under the SAME key
366
- * (bounded) — the backend's IdempotencyInterceptor returns the first
367
- * response instead of burning another attempt;
368
- * - ONE `consent_required` recovery: force-record consent and re-run under a
369
- * FRESH key (the 409 envelope is idempotency-cached under the old one);
370
- * - ONE attestation retry (client-side Turnstile failure or a server
371
- * `attestation_invalid`): `onAttestationInvalid` drops the cached token and
372
- * the executor re-runs under a fresh key.
373
- * Throws the final error otherwise.
374
- */
375
- declare function runSubmission(rt: SubmitRuntime, executor: SubmitExecutor, hooks?: {
376
- onAttestationInvalid?: () => void;
377
- }): Promise<SessionView>;
378
- interface LivenessFlowDeps extends SubmitRuntime {
379
- artifacts: CapturedArtifacts;
380
- /** Fresh attestation per call (Turnstile execute, or `{sandbox: true}`). */
381
- getAttestation(): Promise<AttestationInput>;
382
- /** Latest hosted view (frontier decisions). */
383
- getView(): HostedSessionView;
384
- /** Re-GET the view from the server (after a RESYNC code) and fold it in. */
385
- refreshView(): Promise<HostedSessionView>;
386
- /** Fold a submit response into the view. */
387
- applySubmit(view: SessionView, submitted: CheckType): void;
388
- /** Flow-state hook for the capture handle. */
389
- onPhase(phase: "uploading" | "checking"): void;
390
- /** The verification was destroyed (the only thing that cancels a chain). */
391
- isCancelled(): boolean;
392
- }
393
- type LivenessFlowOutcome = {
394
- kind: "settled";
395
- } | {
396
- kind: "resync";
397
- } | {
398
- kind: "unavailable";
399
- reason: SdkFailureReason;
400
- } | {
401
- kind: "cancelled";
402
- };
403
- /**
404
- * Run the biometric submissions the CURRENT frontier allows, re-evaluating
405
- * after every submit and after every RESYNC re-GET:
406
- * - frontier `liveness` → clip upload + attestation + `liveness` (once per capture);
407
- * - frontier `face_match` → keyframe upload + `face_match` (once per capture),
408
- * allowed when liveness was NOT part of this capture (it had already
409
- * settled — any state, incl. `failed`: the selfie-fallback case, where this
410
- * capture only feeds face_match) or settled chainable from this capture
411
- * (passed / review / processing / skipped — or absent);
412
- * - anything else (terminal view, a non-biometric frontier, a check this
413
- * capture already submitted) → `settled` for the caller to map the view.
414
- * A RESYNC code re-GETs the view and re-enters (at most {@link RESYNC_REENTRY_MAX}
415
- * times); the final RESYNC surfaces as `resync` for the caller to map.
416
- */
417
- declare function runLivenessFlow(deps: LivenessFlowDeps): Promise<LivenessFlowOutcome>;
418
-
419
- /** Production API origin — the `apiOrigin` default. */
420
- declare const DEFAULT_API_ORIGIN = "https://api.sekyro.ai";
421
- /** Pause before the single `registry_unavailable` re-submit. */
422
- declare const REGISTRY_RETRY_DELAY_MS = 5000;
423
- /** Bounded poll while a biometric verdict is still `processing` after the submits. */
424
- declare const PROCESSING_POLL_DELAY_MS = 1500;
425
- declare const PROCESSING_POLL_MAX = 10;
426
- /**
427
- * Construction seams — tests and Sekyro's own hosted page (`@sekyro/web/internal`).
428
- * Not part of the partner contract.
429
- */
430
- interface VerificationInternals {
431
- /** Replace the HTTP client (default: `new HostedClient({...})`). */
432
- client?: HostedClientLike;
433
- /**
434
- * Replace the Turnstile challenge (default: {@link executeTurnstile}). The
435
- * `signal` aborts when the verification is destroyed (M1).
436
- */
437
- getTurnstileToken?: (siteKey: string, opts: {
438
- signal: AbortSignal;
439
- }) => Promise<string>;
440
- /** Capture-engine seams forwarded to {@link createLivenessCaptureInternal}. */
441
- capture?: LivenessCaptureInternals;
442
- sleep?: (ms: number) => Promise<void>;
443
- uuid?: () => string;
444
- }
445
- /** `crypto.randomUUID()` with a v4 fallback for hosts that lack it. */
446
- declare function randomUuid(): string;
447
- /**
448
- * Create a verification bound to one session (spec §3.1):
449
- * `consent()` → `startRegistry()` → `liveness({video})` → `on('result')`.
450
- */
451
- declare function createVerification(options: VerificationOptions): Verification;
452
- /** {@link createVerification} with construction seams (tests / Sekyro-internal hosts). */
453
- declare function createVerificationInternal(options: VerificationOptions, internals: VerificationInternals): Verification;
454
-
455
- 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 };