@sekyro/web 0.0.0-stage → 0.1.0-rc.10

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 (89) hide show
  1. package/CHANGELOG.md +220 -0
  2. package/LICENSE +29 -0
  3. package/README.md +136 -2
  4. package/THIRD-PARTY-NOTICES.txt +154 -0
  5. package/dist/background-monitor-A7FKJOAG.js +1 -0
  6. package/dist/capture-constraints-B5omafmk.d.cts +44 -0
  7. package/dist/capture-constraints-B5omafmk.d.ts +44 -0
  8. package/dist/capture-session-doc-GK6G7JOI.js +1 -0
  9. package/dist/capture-session-v3-CmJw_bK0.d.cts +585 -0
  10. package/dist/capture-session-v3-DGG2stO6.d.ts +585 -0
  11. package/dist/chunk-3MSUJYBO.js +1 -0
  12. package/dist/chunk-7ZCZY3ZP.js +1 -0
  13. package/dist/chunk-A3FUGHAH.js +2 -0
  14. package/dist/chunk-BAGSM67V.js +1 -0
  15. package/dist/chunk-BPE5NSQ2.js +1 -0
  16. package/dist/chunk-CJHMFPL6.js +1 -0
  17. package/dist/chunk-DFTCAWMP.js +1 -0
  18. package/dist/chunk-DK5YPBDQ.js +1 -0
  19. package/dist/chunk-ETY6SAAZ.js +1 -0
  20. package/dist/chunk-FFDB6LQN.js +1 -0
  21. package/dist/chunk-FHJ7HO3M.js +1 -0
  22. package/dist/chunk-FPXL63KZ.js +1 -0
  23. package/dist/chunk-FUHDOEBP.js +1 -0
  24. package/dist/chunk-G6LKLN4U.js +1 -0
  25. package/dist/chunk-GI3UFGRQ.js +1 -0
  26. package/dist/chunk-HAO6EQTH.js +1 -0
  27. package/dist/chunk-HWAXEQD5.js +1 -0
  28. package/dist/chunk-MXWLCDFX.js +1 -0
  29. package/dist/chunk-O5WKNZ2C.js +1 -0
  30. package/dist/chunk-OKWG3PVH.js +1 -0
  31. package/dist/chunk-POIQGEZM.js +1 -0
  32. package/dist/chunk-RI3E7GBN.js +1 -0
  33. package/dist/chunk-SEC64KZ3.js +1 -0
  34. package/dist/chunk-SMKCBUJL.js +1 -0
  35. package/dist/chunk-SXZCL5NO.js +1 -0
  36. package/dist/chunk-SZ7YGNUZ.js +1 -0
  37. package/dist/chunk-TDLIXFDT.js +1 -0
  38. package/dist/chunk-UGMHAFEY.js +1 -0
  39. package/dist/chunk-WKJJEPWA.js +1 -0
  40. package/dist/chunk-XR64UFLK.js +1 -0
  41. package/dist/client/index.cjs +1 -0
  42. package/dist/client/index.d.cts +71 -0
  43. package/dist/client/index.d.ts +71 -0
  44. package/dist/client/index.js +1 -0
  45. package/dist/core/index.cjs +1 -0
  46. package/dist/core/index.d.cts +87 -0
  47. package/dist/core/index.d.ts +87 -0
  48. package/dist/core/index.js +1 -0
  49. package/dist/core/ocr/worker.bundle.js +42 -0
  50. package/dist/core/ocr/worker.cjs +42 -0
  51. package/dist/core/ocr/worker.d.cts +84 -0
  52. package/dist/core/ocr/worker.d.ts +84 -0
  53. package/dist/core/ocr/worker.js +41 -0
  54. package/dist/core/v3/detect-worker.cjs +1 -0
  55. package/dist/core/v3/detect-worker.d.cts +1 -0
  56. package/dist/core/v3/detect-worker.d.ts +1 -0
  57. package/dist/core/v3/detect-worker.js +1 -0
  58. package/dist/create-document-capture-IGUQP2NS.js +1 -0
  59. package/dist/create-portrait-capture-RJSFY37D.js +1 -0
  60. package/dist/create-verification-Bb20j6zk.d.ts +2968 -0
  61. package/dist/create-verification-CtqF4A9W.d.cts +2968 -0
  62. package/dist/detect-worker-DclNxkZT.d.cts +111 -0
  63. package/dist/detect-worker-DclNxkZT.d.ts +111 -0
  64. package/dist/detector-scanic-YCDNLCGV.js +1 -0
  65. package/dist/icao-gate-PWBMKRGC.js +1 -0
  66. package/dist/icao-gate-terzKYD7.d.cts +1770 -0
  67. package/dist/icao-gate-terzKYD7.d.ts +1770 -0
  68. package/dist/icao-tuning-4GGVX6B4.js +1 -0
  69. package/dist/index.cjs +1 -0
  70. package/dist/index.d.cts +74 -0
  71. package/dist/index.d.ts +74 -0
  72. package/dist/index.js +1 -0
  73. package/dist/internal/index.cjs +1 -0
  74. package/dist/internal/index.d.cts +462 -0
  75. package/dist/internal/index.d.ts +462 -0
  76. package/dist/internal/index.js +1 -0
  77. package/dist/keyframe-rank-YAJLYJYF.js +1 -0
  78. package/dist/landmarker-KB7LVXAU.js +1 -0
  79. package/dist/mrz-band-VYHOTDHY.js +1 -0
  80. package/dist/plan-runner-QCK2SOGS.js +1 -0
  81. package/dist/popup/index.cjs +1 -0
  82. package/dist/popup/index.d.cts +66 -0
  83. package/dist/popup/index.d.ts +66 -0
  84. package/dist/popup/index.js +1 -0
  85. package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
  86. package/dist/segmenter-USLNBX65.js +1 -0
  87. package/dist/turnstile-FATNZ4AG.js +1 -0
  88. package/package.json +133 -4
  89. package/sbom.cdx.json +195 -0
@@ -0,0 +1,1770 @@
1
+ interface Point {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ interface Box {
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ }
11
+ /** The face geometry the gate needs, in SOURCE (stream) pixels. */
12
+ interface FaceGeometry {
13
+ /** Eye centres, ordered by image x (`left` = smaller x). */
14
+ leftEye: Point;
15
+ rightEye: Point;
16
+ /** Inter-ocular distance (px). */
17
+ iod: number;
18
+ /** Bounding box of the landmark mesh (forehead to chin). */
19
+ box: Box;
20
+ /** Nose tip (landmark 1): splits the face into halves for the lighting ratio. */
21
+ nose: Point;
22
+ /** Eye-contour boxes (glare), same order as the eyes. */
23
+ leftEyeBox: Box;
24
+ rightEyeBox: Box;
25
+ }
26
+ /**
27
+ * Normalised Face Landmarker landmarks (0..1) → source-pixel geometry.
28
+ * `null` when the mesh is too short to carry the eyes.
29
+ */
30
+ declare function faceGeometry(landmarks: readonly Point[], width: number, height: number): FaceGeometry | null;
31
+ interface HeadPose {
32
+ yaw: number;
33
+ pitch: number;
34
+ roll: number;
35
+ }
36
+ /**
37
+ * Yaw / pitch / roll (degrees) of the Face Landmarker's facial transformation
38
+ * matrix (4×4, `layout` of `data`; MediaPipe emits column-major). Rotation
39
+ * order R = Rz(roll)·Ry(yaw)·Rx(pitch): yaw turns about the vertical axis,
40
+ * pitch nods, roll tilts. Only magnitudes are gated, so sign conventions never
41
+ * change a verdict. `null` for a malformed matrix.
42
+ */
43
+ declare function poseFromMatrix(data: readonly number[], layout?: "column" | "row"): HeadPose | null;
44
+ /** Roll from the eye line (degrees) — the fallback when no matrix is available. */
45
+ declare function eyeLineRoll(g: Pick<FaceGeometry, "leftEye" | "rightEye">): number;
46
+ /** The ICAO canvas (icao.py): 480×640, eye midpoint at x = 240, eye line at y = 289, IOD 120–160. */
47
+ declare const ICAO_CANVAS: {
48
+ readonly width: 480;
49
+ readonly height: 640;
50
+ readonly eyeX: 240;
51
+ readonly eyeY: 289;
52
+ readonly iodMin: 120;
53
+ readonly iodMax: 160;
54
+ };
55
+ /**
56
+ * The source-pixel window the server's ICAO crop is cut from: scale 1 when the
57
+ * IOD already lies in 120–160, else the scale that brings it to 120 (icao.py:
58
+ * "120 when outside the band"), the eye midpoint at (240, 289) of the window.
59
+ */
60
+ declare function icaoWindow(g: Pick<FaceGeometry, "leftEye" | "rightEye" | "iod">): Box;
61
+ /** How far a window spills outside the frame (0 = inside), as a fraction of its size. */
62
+ declare function windowOverflow(window: Box, frameWidth: number, frameHeight: number): number;
63
+ /**
64
+ * The region of the full-resolution still the SDK uploads: the ICAO window
65
+ * grown by `margin` about its centre (so the server re-crops with its own
66
+ * landmarks), at least `minWidth × minHeight`, 3:4 portrait, then fitted into
67
+ * the frame — the margin shrinks first, then the box slides inside, and only
68
+ * a window larger than the frame is cut to it. Integer pixels.
69
+ */
70
+ declare function portraitCropRegion(g: Pick<FaceGeometry, "leftEye" | "rightEye" | "iod">, frameWidth: number, frameHeight: number, opts: {
71
+ margin: number;
72
+ minWidth: number;
73
+ minHeight: number;
74
+ }): Box;
75
+
76
+ /** Server-tunable thresholds (`capture.icao.backgroundCheck`); defaults below. */
77
+ interface BackgroundCheckTuning {
78
+ /** Run the check at all (ICAO on). Default `true`. */
79
+ enabled: boolean;
80
+ /** Measurements per second (the face gate runs faster). Default 3. */
81
+ hz: number;
82
+ /** The segmenter must load within this window, else the strip fallback. Default 8000 ms. */
83
+ segmenterTimeoutMs: number;
84
+ /** A segmentation slower than this (moving average) switches to the strip fallback. Default 120 ms. */
85
+ segmenterBudgetMs: number;
86
+ /** Person confidence at or above this is the person (excluded). Default 0.5. */
87
+ maskThreshold: number;
88
+ /** Max RMS colour standard deviation (0..255). Default 28. */
89
+ maxColorStd: number;
90
+ /** Max share of textured neighbour pairs (0..1). Default 0.08. */
91
+ maxEdgeDensity: number;
92
+ /** Luma step (0..255) that counts as an edge. Default 24. */
93
+ edgeLuma: number;
94
+ /** Max left/right or top/bottom brightness difference (0..1). Default 0.18. */
95
+ maxGradient: number;
96
+ /** Fewer background pixels than this = not measurable (never blocks). Default 300. */
97
+ minPixels: number;
98
+ /** A non-uniform background holds the shot at most this long, then the shot proceeds. Default 4000 ms. */
99
+ timeoutMs: number;
100
+ }
101
+ /** Person confidence per pixel (0..1 floats, or 0..255 bytes), any resolution (scaled to the frame). */
102
+ interface PersonMask {
103
+ data: Float32Array | Uint8Array | Uint8ClampedArray;
104
+ width: number;
105
+ height: number;
106
+ }
107
+ /** One measurement — numbers only (telemetry and the `gate` block). */
108
+ interface BackgroundUniformity {
109
+ method: "segmenter" | "strip";
110
+ uniform: boolean;
111
+ colorStd: number;
112
+ edgeDensity: number;
113
+ gradient: number;
114
+ /** Background pixels measured (after sampling). */
115
+ pixels: number;
116
+ }
117
+
118
+ /** The device (coaching) limits of each profile — the server limits moved towards strict. */
119
+ declare const ICAO_DEVICE_LIMITS: {
120
+ readonly id_document: {
121
+ readonly pose: {
122
+ readonly yawDeg: 7;
123
+ readonly pitchDeg: 7;
124
+ readonly rollDeg: 5;
125
+ readonly pitchOffsetDeg: 4;
126
+ };
127
+ readonly eyes: {
128
+ readonly relativeMin: 0.62;
129
+ readonly blinkMax: 0.48;
130
+ };
131
+ readonly mouth: {
132
+ readonly jawOpenMax: 0.13;
133
+ readonly smileMax: 0.28;
134
+ readonly puckerMax: 0.28;
135
+ };
136
+ readonly lighting: {
137
+ readonly faceLuma: readonly [95, 185];
138
+ readonly halfRatio: readonly [0.77, 1.31];
139
+ readonly clippedMax: 0.015;
140
+ };
141
+ readonly background: {
142
+ readonly required: true;
143
+ readonly lumaMin: 165;
144
+ readonly lumaSdMax: 20;
145
+ };
146
+ readonly resolution: {
147
+ readonly minIodPx: 110;
148
+ readonly minWidth: 480;
149
+ readonly minHeight: 640;
150
+ };
151
+ };
152
+ readonly selfie: {
153
+ readonly pose: {
154
+ readonly yawDeg: 7;
155
+ readonly pitchDeg: 7;
156
+ readonly rollDeg: 7;
157
+ readonly pitchOffsetDeg: 4;
158
+ };
159
+ readonly eyes: {
160
+ readonly relativeMin: 0.62;
161
+ readonly blinkMax: 0.48;
162
+ };
163
+ readonly mouth: {
164
+ readonly jawOpenMax: 0.13;
165
+ readonly smileMax: 0.28;
166
+ readonly puckerMax: 0.28;
167
+ };
168
+ readonly lighting: {
169
+ readonly faceLuma: readonly [95, 185];
170
+ readonly halfRatio: readonly [0.77, 1.31];
171
+ readonly clippedMax: 0.015;
172
+ };
173
+ readonly background: {
174
+ readonly required: false;
175
+ readonly lumaMin: 165;
176
+ readonly lumaSdMax: 20;
177
+ };
178
+ readonly resolution: {
179
+ readonly minIodPx: 100;
180
+ readonly minWidth: 480;
181
+ readonly minHeight: 640;
182
+ };
183
+ };
184
+ };
185
+
186
+ /** The ICAO threshold set (`id_document`: ID photo; `selfie`: no background rule). */
187
+ type IcaoProfile = keyof typeof ICAO_DEVICE_LIMITS;
188
+ /** `capture.icao` as the server sends it (every field optional on the wire). */
189
+ interface IcaoCaptureTuning {
190
+ /** The threshold set these limits come from (default `id_document`; it also picks the fallbacks). */
191
+ profile?: "id_document" | "selfie";
192
+ yawDeg?: number;
193
+ pitchDeg?: number;
194
+ /**
195
+ * Subtracted from the measured pitch before `pitchDeg` applies (degrees). Where
196
+ * "looking straight" sits relative to the Landmarker's zero; kyc-portrait applies the
197
+ * same `PORTRAIT_POSE_PITCH_OFFSET_DEG`, so keep them equal (D9a, 2026-10-22).
198
+ */
199
+ pitchOffsetDeg?: number;
200
+ rollDeg?: number;
201
+ holdMs?: number;
202
+ /** `alert` policy: the clip starts this long after the face was accepted even if the ICAO gate is not ready (default 3000). */
203
+ alertGraceMs?: number;
204
+ eyes?: {
205
+ relativeMin?: number;
206
+ blinkMax?: number;
207
+ earMin?: number;
208
+ };
209
+ mouth?: {
210
+ jawOpenMax?: number;
211
+ smileMax?: number;
212
+ puckerMax?: number;
213
+ };
214
+ lighting?: {
215
+ faceLuma?: [number, number];
216
+ halfRatio?: [number, number];
217
+ clippedMax?: number;
218
+ };
219
+ /** `required: false` (the `selfie` profile): the background is not evaluated, coached or reported. */
220
+ background?: {
221
+ required?: boolean;
222
+ lumaMin?: number;
223
+ lumaSdMax?: number;
224
+ };
225
+ resolution?: {
226
+ minIodPx?: number;
227
+ minWidth?: number;
228
+ minHeight?: number;
229
+ };
230
+ /** Client-only knobs (no server field today; read when the server adds them). */
231
+ holdFrames?: number;
232
+ cadenceHz?: number;
233
+ baseline?: {
234
+ windowMs?: number;
235
+ minSamples?: number;
236
+ percentile?: number;
237
+ };
238
+ sharpnessMin?: number;
239
+ glare?: {
240
+ specularMax?: number;
241
+ };
242
+ softGraceMs?: number;
243
+ cropMargin?: number;
244
+ camera?: {
245
+ width?: number;
246
+ height?: number;
247
+ };
248
+ /**
249
+ * The client background-uniformity check (ID mode; defaults in
250
+ * core/portrait/background-uniformity.ts `BACKGROUND_CHECK_DEFAULTS`).
251
+ * Skipped entirely when `background.required` is false.
252
+ */
253
+ backgroundCheck?: Partial<BackgroundCheckTuning>;
254
+ }
255
+ /** Fully resolved limits the gate runs on. */
256
+ interface ResolvedIcaoTuning {
257
+ profile: IcaoProfile;
258
+ yawDeg: number;
259
+ pitchDeg: number;
260
+ pitchOffsetDeg: number;
261
+ rollDeg: number;
262
+ holdMs: number;
263
+ alertGraceMs: number;
264
+ eyes: {
265
+ relativeMin: number;
266
+ blinkMax: number;
267
+ };
268
+ mouth: {
269
+ jawOpenMax: number;
270
+ smileMax: number;
271
+ puckerMax: number;
272
+ };
273
+ lighting: {
274
+ faceLuma: [number, number];
275
+ halfRatio: [number, number];
276
+ clippedMax: number;
277
+ };
278
+ background: {
279
+ required: boolean;
280
+ lumaMin: number;
281
+ lumaSdMax: number;
282
+ };
283
+ resolution: {
284
+ minIodPx: number;
285
+ minWidth: number;
286
+ minHeight: number;
287
+ };
288
+ holdFrames: number;
289
+ cadenceHz: number;
290
+ baseline: {
291
+ windowMs: number;
292
+ minSamples: number;
293
+ percentile: number;
294
+ };
295
+ sharpnessMin: number;
296
+ glare: {
297
+ specularMax: number;
298
+ };
299
+ softGraceMs: number;
300
+ cropMargin: number;
301
+ camera: {
302
+ width: number;
303
+ height: number;
304
+ };
305
+ backgroundCheck: BackgroundCheckTuning;
306
+ /** The server's `capture.tuningVersion`, echoed on submit (`null` when absent). */
307
+ tuningVersion: string | null;
308
+ }
309
+ /** Bundled fallbacks: the `id_document` device limits (never looser than the server). */
310
+ declare const ICAO_FALLBACK: Omit<ResolvedIcaoTuning, "tuningVersion">;
311
+ /**
312
+ * Resolve `capture.icao` (any shape, possibly absent) over {@link ICAO_FALLBACK},
313
+ * field by field: an out-of-range or malformed field keeps its fallback.
314
+ */
315
+ declare function resolveIcaoTuning(raw: unknown, tuningVersion?: unknown): ResolvedIcaoTuning;
316
+
317
+ /** Session lifecycle status (spec §4 two-field status/outcome model). */
318
+ type SessionStatus = "created" | "in_progress" | "review_pending" | "completed" | "expired" | "failed";
319
+ /** Terminal verdict, orthogonal to `status`; `null` until terminal/review. */
320
+ type SessionOutcome = "approved" | "review" | "rejected";
321
+ /** Per-check seven-state machine (spec §4.3). */
322
+ type CheckState = "pending" | "input_required" | "processing" | "passed" | "failed" | "review" | "skipped";
323
+ /**
324
+ * The frozen check-type vocabulary (CHECK_TYPES). `phone_otp` joined in Task 13;
325
+ * `nfc_chip` (M-nfc) is read by the native SDKs only; `email_otp` (Plan 8,
326
+ * profile v2 §4.6.5) confirms an email address with a one-time code;
327
+ * `eid_auth` (SDK spec §3.2) is the national eID sign-in (Houwiyeti in MR).
328
+ */
329
+ type CheckType = "liveness" | "face_match" | "doc_ocr" | "population_registry" | "phone_otp" | "nfc_chip" | "email_otp" | "portrait_icao" | "eid_auth";
330
+ type LivenessReason = "no_face" | "media_unreadable" | "clip_too_short" | "spoof_detected" | "review_band" | "liveness_inconclusive" | "device_integrity_failed" | "mobile_required" | "uncalibrated_capture_channel" | "capture_back_camera" | "capture_not_upright";
331
+ type PopulationReason = "nni_not_found" | "nni_invalid" | "registry_unavailable" | "result_from_cache" | "nationality_not_allowed" | "underage" | "age_unverifiable" | "name_mismatch" | "birth_date_mismatch" | "nationality_mismatch" | "nni_recheck";
332
+ type FaceMatchReason = "no_face_source" | "no_face_reference" | "low_quality_reference" | "below_threshold" | "review_band" | "match_inconclusive" | "subject_revoked" | "probe_not_from_liveness";
333
+ type DocReason = "side_missing" | "mrz_checksum_failed" | "unreadable" | "expired_document" | "authenticity_review" | "document_authenticity" | "registry_mismatch" | "document_nni_mismatch" | "nationality_unreadable" | "document_type_not_accepted" | "nationality_not_allowed" | "underage" | "age_unverifiable" | "name_mismatch" | "birth_date_mismatch" | "nationality_mismatch" | "document_number_mismatch";
334
+ /**
335
+ * Profile v2 step 3 matching reasons: a field the partner sent at session
336
+ * create (`subject`) differs from the reference identity (document or
337
+ * registry). All four are final. `document_number_mismatch` is `doc_ocr` only.
338
+ */
339
+ type MatchReason = "name_mismatch" | "birth_date_mismatch" | "nationality_mismatch" | "document_number_mismatch";
340
+ /**
341
+ * Profile v2 step 4 decision-mode reasons (the app decides automatically
342
+ * instead of sending the case to human review). These park the step at
343
+ * `input_required` while attempts remain: `liveness_inconclusive` /
344
+ * `match_inconclusive` (middle score band) and `document_authenticity`
345
+ * (retake the original card). `mobile_required` is kept for compatibility:
346
+ * the backend now answers a non-phone capture with a request-level
347
+ * `409 mobile_required` (continue on a phone; nothing used, not billed).
348
+ */
349
+ type DecisionReason = "liveness_inconclusive" | "match_inconclusive" | "document_authenticity" | "mobile_required";
350
+ /**
351
+ * phone_otp reasons (Task 13). All transient — the caller fixes them by
352
+ * re-entering / resending: `otp_mismatch` (wrong or missing code),
353
+ * `otp_expired` (code lapsed or no active send), `otp_send_failed` (the OTP
354
+ * service was unreachable / a send returned no token).
355
+ */
356
+ type PhoneOtpReason = "otp_mismatch" | "otp_expired" | "otp_send_failed" | "otp_channel_unavailable" | "otp_destination_not_allowed" | "otp_rate_limited" | "otp_destination_unknown";
357
+ /**
358
+ * email_otp reasons (Plan 8, profile v2 §4.6.5). All transient: a wrong or
359
+ * expired code, a send outage, too many sends, an address that cannot receive
360
+ * mail (`email_invalid`), or a disposable address the app blocks
361
+ * (`email_disposable`) — the person enters another address or resends.
362
+ */
363
+ type EmailOtpReason = "otp_mismatch" | "otp_expired" | "otp_send_failed" | "otp_rate_limited" | "email_invalid" | "email_disposable";
364
+ /**
365
+ * nfc_chip reasons (M-nfc, SDK spec §4.3). Native SDKs read the chip; the web
366
+ * never does — on web the step arrives `skipped` (`platform_unsupported`) or
367
+ * the session shows `failureReason: 'platform_unsupported'`.
368
+ */
369
+ type NfcChipReason = "chip_read_failed" | "chip_access_denied" | "chip_parse_failed" | "chip_not_present" | "nfc_unavailable" | "chip_document_mismatch" | "chip_integrity_failed" | "registry_mismatch" | "document_nni_mismatch" | "platform_unsupported";
370
+ /**
371
+ * eid_auth reasons (SDK spec §3.2, generic national eID; Houwiyeti in MR).
372
+ * Retryable: `eid_identifier_invalid` (re-enter the number), `eid_code_invalid`
373
+ * (re-enter the code, see `eid.codeAttemptsRemaining`), `eid_code_expired`
374
+ * (ask for a new code), `eid_unavailable` (the provider is down; try again or
375
+ * use the camera), `eid_resend_too_soon` (wait for `eid.resendAvailableAt`),
376
+ * `eid_resend_limit` (no more codes; type the last code received).
377
+ * Final: `eid_locked` (too many wrong codes), `eid_not_enrolled` (the number
378
+ * has no account in the provider's app).
379
+ * With `eid_not_enrolled`, `eid_unavailable` or `eid_locked` the person may
380
+ * switch to the camera path when the session offers it.
381
+ */
382
+ type EidReason = "eid_identifier_invalid" | "eid_code_invalid" | "eid_code_expired" | "eid_locked" | "eid_not_enrolled" | "eid_unavailable" | "eid_resend_too_soon" | "eid_resend_limit";
383
+ /**
384
+ * Any frozen reason code. The backend declares the field `string`, but the
385
+ * taxonomy is frozen (do-not-drift) — the union IS the contract. NB: liveness
386
+ * and face_match both carry `review_band`.
387
+ */
388
+ type CheckReason = LivenessReason | PopulationReason | FaceMatchReason | DocReason | PhoneOtpReason | EmailOtpReason | NfcChipReason | PortraitIcaoReason | EidReason
389
+ /**
390
+ * Spec 2026-10-27 (Sandbox testers), tester-bound sessions only:
391
+ * `tester_document_mismatch` (doc_ocr, nfc_chip) when the document read is
392
+ * not the bound tester's; `tester_phone_mismatch` (phone_otp) when the
393
+ * number is not the one the tester enrolled with.
394
+ */
395
+ | "tester_document_mismatch" | "tester_phone_mismatch";
396
+ /**
397
+ * Session-level failure reasons: the session was stopped by a policy gate,
398
+ * not by a failed check. All are terminal (no retry on this session):
399
+ * - `location_not_allowed` / `anonymizer_blocked` (profile v2 step 2): the
400
+ * person's IP location is not allowed, or an anonymizer (VPN / proxy / Tor)
401
+ * was detected while the app blocks them;
402
+ * - `capture_tampered` (step 4): the device reported a tampered capture
403
+ * (virtual camera, hooking, emulator…) while the app blocks it;
404
+ * - `device_velocity_exceeded` (step 4): this device already verified too
405
+ * many different people while the app blocks it;
406
+ * - `device_cooldown` (step 4): this device had too many rejected sessions —
407
+ * {@link HostedSessionView.retryAfter} says when it may try again;
408
+ * - `platform_unsupported` (M-nfc): a chip read is required and this client
409
+ * can't read one (web); the session stays open for a native app.
410
+ */
411
+ type SessionFailureReason = "location_not_allowed" | "anonymizer_blocked" | "capture_tampered" | "device_velocity_exceeded" | "device_cooldown" | "platform_unsupported";
412
+ /**
413
+ * The profile-v2 policy reasons a session can end on: the two session-level
414
+ * reasons plus the failed check's policy reasons (`document_type_not_accepted`,
415
+ * `nationality_not_allowed`, `underage`, `age_unverifiable`,
416
+ * `document_nni_mismatch`).
417
+ */
418
+ type PolicyFailureReason = SessionFailureReason | "document_type_not_accepted" | "nationality_not_allowed" | "underage" | "age_unverifiable" | "document_nni_mismatch";
419
+ /**
420
+ * How the person proves their identity when the app makes the document
421
+ * optional for registry nationals (profile v2 step 3): type their national
422
+ * number (NNI) and skip the document, or photograph their document.
423
+ * `document_chip` is offered only to native clients with NFC (M-nfc).
424
+ * `national_eid` (SDK spec §3.2) signs in with the country's national eID
425
+ * (Houwiyeti in MR) instead of the camera path — see
426
+ * {@link MethodChoiceView.nationalEid}.
427
+ */
428
+ type IdentityMethod = "national_number" | "document_photo" | "document_chip" | "national_eid";
429
+ /**
430
+ * The national eID provider a session offers (`MethodChoiceView.nationalEid`).
431
+ * `provider` is `{ISO2}.{provider}` (e.g. `MR.houwiyeti`); `providerName` is
432
+ * the display name ("Houwiyeti").
433
+ */
434
+ interface NationalEidOption {
435
+ provider: string;
436
+ providerName: string;
437
+ /** ISO 3166-1 alpha-2 country of the provider. */
438
+ country: string;
439
+ /**
440
+ * What follows a passed eID (flow model 2026-10-23): `end` (the session ends,
441
+ * the default) or `continue` (the live photo follows). Absent on older APIs = `end`.
442
+ */
443
+ afterPass?: EidAfterPass;
444
+ }
445
+ /** What follows a passed national eID (`nationalEid.afterPass`). */
446
+ type EidAfterPass = "end" | "continue";
447
+ /**
448
+ * The section a step belongs to (flow model 2026-10-23, SDK spec §3.7): Step 1
449
+ * `contact`, Step 2 `identity`, Step 3 `live_photo`. Open: a value this SDK
450
+ * does not know is kept as is, so a client still places the step.
451
+ */
452
+ type StepSection = "contact" | "identity" | "live_photo" | "screening" | (string & {});
453
+ /** A contact channel of a contact choice (`phone_otp` → `phone`, `email_otp` → `email`). */
454
+ type ContactChannel = "phone" | "email";
455
+ /**
456
+ * @deprecated Sekyro flows: the contact choice is `plan.choice` (kind `contact`,
457
+ * {@link PlanChoiceView}); the view no longer carries this shape.
458
+ */
459
+ interface OtpChoiceView {
460
+ options: ContactChannel[];
461
+ selected: ContactChannel | null;
462
+ locked: boolean;
463
+ }
464
+ /** The flow version a session runs (`HostedSessionView.flow`). */
465
+ interface HostedFlowRef {
466
+ id: string;
467
+ slug: string;
468
+ version: number;
469
+ }
470
+ /** The kind of a choice node (Sekyro flows §7.4); a newer server's kind is kept as is. */
471
+ type PlanChoiceKind = "identity_method" | "contact" | "generic" | (string & {});
472
+ /** One option of a choice node, in the server's display order. */
473
+ interface PlanChoiceOption {
474
+ /** The option id sent back with {@link HostedClient.choose} (`document`, `registry`, `phone`, …). */
475
+ id: string;
476
+ /** The service of the option's lane (`document`, `nfc`, `population_registry`, `national_eid`, `phone_otp`, `email_otp`, …). */
477
+ service: string;
478
+ /** Unavailable options are omitted by the server; always `true` when listed. */
479
+ available: boolean;
480
+ /** `national_eid` options: the provider ("Verify with Houwiyeti"); absent or `null` otherwise and on older APIs. */
481
+ nationalEid?: NationalEidOption | null;
482
+ }
483
+ /** `plan.choice`: the choice the person makes now (or may still switch, while `locked` is false). */
484
+ interface PlanChoiceView {
485
+ nodeId: string;
486
+ kind: PlanChoiceKind;
487
+ /** The chosen option id, `null` before a pick. */
488
+ selected: string | null;
489
+ /** The choice can no longer change (a submission into the chosen lane, or the option settled). */
490
+ locked: boolean;
491
+ options: PlanChoiceOption[];
492
+ }
493
+ /** Submissions used on a step and its cap (remaining = `max - used`). */
494
+ interface PlanAttempts {
495
+ used: number;
496
+ max: number;
497
+ }
498
+ /**
499
+ * A step of the plan (a visited node or the current one, never an untaken lane):
500
+ * its node id, service and state plus today's per-type extras (`otp`, `emailOtp`,
501
+ * `eid`, `nfc`, `docCapture`, `nniFromDocument`, `reason`, `icao`, `requiresMobile`, …).
502
+ * A node with two checks yields two steps (`n_live` liveness, `n_live.icao` the ICAO portrait).
503
+ */
504
+ interface PlanStepView extends Omit<HostedStepView, "checkType" | "attemptsRemaining" | "section"> {
505
+ /** The node id (`n_doc`), stable across views; `<node>.icao` for the ICAO portrait of a liveness node. */
506
+ id: string;
507
+ /** The catalog service of the node (`document`, `liveness`, `summary_confirm`, …). */
508
+ service: string;
509
+ /** The check this step submits (`doc_ocr`, `portrait_icao`, `identity_confirm`, …). */
510
+ checkType: CheckType | (string & {});
511
+ section: StepSection;
512
+ attempts: PlanAttempts;
513
+ }
514
+ /** A segment of the progress bar (`plan.sections`): the sections still possible on any remaining path. */
515
+ interface PlanSectionView {
516
+ id: StepSection;
517
+ state: "done" | "current" | "upcoming";
518
+ }
519
+ /** `HostedSessionView.plan` (Sekyro flows §8.1). */
520
+ interface HostedPlanView {
521
+ /** A choice node id (`plan.choice.nodeId`) or a step id; `null` while nothing waits on the person. */
522
+ current: string | null;
523
+ /** Present while `current` is a choice (and, on newer servers, while its lane can still be switched). */
524
+ choice?: PlanChoiceView;
525
+ steps: PlanStepView[];
526
+ sections: PlanSectionView[];
527
+ }
528
+ /** Where the identity summary's data came from. */
529
+ type IdentitySummarySource = "registry" | "document" | "chip";
530
+ /**
531
+ * Step 2b summary and confirm (`HostedSessionView.identitySummary`): the
532
+ * identity data read so far, shown to the person before the live photo. Only
533
+ * on the session-token view and only while the confirmation is pending; masks
534
+ * keep the last 4 characters. Never log or store these values.
535
+ */
536
+ interface IdentitySummaryView {
537
+ /**
538
+ * `full` (document / chip: the record and the photo) or `partial` (the
539
+ * registry from a typed NNI: the short name "Mohamed S.", the birth year,
540
+ * the NNI's last 4, no photo).
541
+ */
542
+ kind: "full" | "partial" | (string & {});
543
+ source: IdentitySummarySource | (string & {});
544
+ /** The full name (`full`), or the short form "Mohamed S." (`partial`). */
545
+ fullName?: string;
546
+ /** `YYYY-MM-DD` (`full`). */
547
+ birthDate?: string;
548
+ /** `YYYY` (`partial`). */
549
+ birthYear?: string;
550
+ /** ISO 3166-1 alpha-2 (or alpha-3) nationality. */
551
+ nationality?: string;
552
+ documentType?: string;
553
+ documentNumberMasked?: string;
554
+ nniMasked?: string;
555
+ /** `YYYY-MM-DD`. */
556
+ expiryDate?: string;
557
+ /** A portrait can be fetched ({@link HostedClient.identityPortrait}). */
558
+ portrait: {
559
+ available: boolean;
560
+ };
561
+ /** A retake is still possible (attempts left, not a `supplied` summary). */
562
+ retakeAvailable: boolean;
563
+ /** What a retake re-opens. */
564
+ retakeTarget?: "document" | "national_number" | (string & {});
565
+ }
566
+ /** The answer to the identity summary ({@link HostedClient.confirmIdentity}). */
567
+ type IdentityConfirmDecision = "confirm" | "retake";
568
+ /**
569
+ * The pending identity-method choice in the 0.1 vocabulary, read from
570
+ * `plan.choice` (`kind: identity_method`): `document` → `document_photo`,
571
+ * `nfc` → `document_chip`, `population_registry` → `national_number`,
572
+ * `national_eid` → `national_eid`. See {@link Verification.methodChoice}.
573
+ */
574
+ interface MethodChoiceView {
575
+ /** The session offers the choice (the app's document mode is `optional`). */
576
+ available: boolean;
577
+ /** The chosen method, or `null` while the person has not chosen. */
578
+ selected: IdentityMethod | null;
579
+ /** The methods to offer, in display order (`national_eid` first when offered). */
580
+ options: IdentityMethod[];
581
+ /**
582
+ * The national eID provider behind the `national_eid` option ("Verify with
583
+ * Houwiyeti"). Absent when the option is not offered (and on older APIs).
584
+ */
585
+ nationalEid?: NationalEidOption;
586
+ }
587
+ /** A document type the backend reads (kyc-docs-v2 vocabulary; `carte_identite` = identity card of any issuer). */
588
+ type AcceptedDocumentType = "carte_identite" | "passport" | "residence_permit";
589
+ /**
590
+ * Accepted document types per issuing country (profile v2 §5.3a): an issuer
591
+ * uses `byIssuer[iso2] ?? default`; `"*"` = every type.
592
+ */
593
+ interface HostedAcceptedDocuments {
594
+ default: "*" | AcceptedDocumentType[];
595
+ byIssuer?: Record<string, AcceptedDocumentType[]>;
596
+ }
597
+ /**
598
+ * phone_otp DISPLAY-SAFE surface (Task 16). The backend stashes the OTP
599
+ * service `verifToken` on the check's persisted outputs (the doc_ocr partial
600
+ * mechanism), but that token is NEVER projected here — only the fields the
601
+ * hosted OTP step renders. `numberSource` (org-authored config) drives the
602
+ * send-phase UI (prefilled display vs entry); the rest appear ONLY once a send
603
+ * has parked the check (`sentToMasked` present ⇒ verify phase).
604
+ */
605
+ interface HostedOtpView {
606
+ /**
607
+ * Per-step `config.numberSource` — drives the send-phase UI (prefilled
608
+ * display vs entry). Narrowed to the frontend contract; the backend field is
609
+ * `string` (dynamic config) but the projection only ever emits these three.
610
+ */
611
+ numberSource?: "prefilled" | "user_entered" | "prefilled_or_entered";
612
+ /** Masked target the last send went to (e.g. `+222 ** ** 34 56`); absent pre-send. */
613
+ sentToMasked?: string;
614
+ /** Delivery channel of the last send. */
615
+ channel?: "sms" | "whatsapp";
616
+ /** ISO-8601 OTP expiry from the last send — drives the verify-phase countdown. */
617
+ expiresAt?: string;
618
+ /**
619
+ * Profile v2 §4.6.4: the channels the person may choose from, in display
620
+ * order (WhatsApp first; a channel the org or app turned off is absent).
621
+ * Absent on a session created before channel choice (no picker; SMS).
622
+ */
623
+ channels?: ("whatsapp" | "sms")[];
624
+ /** ISO-8601 end of the server-side resend cooldown (after a send). */
625
+ resendAvailableAt?: string;
626
+ }
627
+ /**
628
+ * email_otp DISPLAY-SAFE surface (Plan 8, profile v2 §4.6.5): never the
629
+ * provider handle, never the address (only its mask).
630
+ */
631
+ interface HostedEmailOtpView {
632
+ /** Where the address comes from; drives the send-phase UI (notice vs entry). */
633
+ emailSource?: "prefilled" | "user_entered" | "prefilled_or_entered";
634
+ /** Masked target of the last send (e.g. `a•••@e•••.com`); absent pre-send. */
635
+ sentToMasked?: string;
636
+ /** ISO-8601 code expiry from the last send. */
637
+ expiresAt?: string;
638
+ /** ISO-8601 end of the server-side resend cooldown (after a send). */
639
+ resendAvailableAt?: string;
640
+ }
641
+ /**
642
+ * portrait_icao reasons (SDK spec §4.9, ID mode). The first failing ICAO
643
+ * criterion; every one is retryable (re-run only the ICAO gate).
644
+ * `media_unreadable` (no report) is shared with liveness.
645
+ */
646
+ type PortraitIcaoReason = "icao_pose" | "icao_eyes" | "icao_mouth" | "icao_occlusion" | "icao_lighting" | "icao_background" | "icao_resolution" | "portrait_not_from_liveness";
647
+ /** One ICAO criterion of the server's portrait report (SDK spec §4.9). */
648
+ type IcaoCriterion = "pose" | "eyes" | "mouth" | "occlusion" | "glare" | "lighting" | "background" | "resolution";
649
+ /** The ICAO policy of a session's selfie (spec 2026-10-24 selfie ICAO policy §10). */
650
+ interface HostedIcaoPolicy {
651
+ /** `reject`: the gate blocks and the server asks for retakes; `alert`: coaching only, never blocking. */
652
+ policy: "reject" | "alert";
653
+ /** The threshold set: `id_document` (ID photo, uniform background) or `selfie` (no background rule). */
654
+ profile: "id_document" | "selfie";
655
+ }
656
+ /** `HostedSessionView.portrait`. */
657
+ type HostedPortraitView = NonNullable<HostedSessionView["portrait"]>;
658
+ /** One row of the portrait_icao report: the server's measurement — coaching only. */
659
+ interface IcaoReportEntry {
660
+ criterion: IcaoCriterion;
661
+ value: number | null;
662
+ threshold: number | string | null;
663
+ pass: boolean;
664
+ }
665
+ /**
666
+ * eid_auth DISPLAY-SAFE surface (SDK spec §3.2): never the identifier, never
667
+ * the code. `awaiting` drives the screen: `identifier` (type the national
668
+ * number, unless `identifierBound`) → `code` (type the code shown in the
669
+ * provider's app).
670
+ */
671
+ interface HostedEidView {
672
+ /** `{ISO2}.{provider}`, e.g. `MR.houwiyeti`. */
673
+ provider: string;
674
+ /** Display name, e.g. "Houwiyeti". */
675
+ providerName: string;
676
+ /** ISO 3166-1 alpha-2 country of the provider. */
677
+ country: string;
678
+ /** `app_code`: the provider's app shows a code the person types here (the only challenge today). */
679
+ challenge: "app_code";
680
+ awaiting: "identifier" | "code";
681
+ /** The session is bound to the national number — `start` sends no identifier. */
682
+ identifierBound: boolean;
683
+ /** ISO-8601 expiry of the current code. */
684
+ expiresAt?: string;
685
+ /** ISO-8601 time from which a new code may be asked for. */
686
+ resendAvailableAt?: string;
687
+ /** New codes the person may still ask for in this session. */
688
+ resendsRemaining?: number;
689
+ /** Wrong codes left before `eid_locked`. */
690
+ codeAttemptsRemaining?: number;
691
+ /** What follows a pass (flow model 2026-10-23); absent = `end`. */
692
+ afterPass?: EidAfterPass;
693
+ }
694
+ /** `nfc_chip` step hints (M-nfc). `chipHint` is UI copy only, never a gate. */
695
+ interface NfcStepView {
696
+ mode: "preferred" | "mandatory";
697
+ access: ("PACE" | "BAC")[];
698
+ optionalDataGroups: ("DG11" | "DG12" | "DG13")[];
699
+ chipHint: {
700
+ default: Record<string, true | "unknown">;
701
+ byIssuer: Record<string, Record<string, true | "unknown">>;
702
+ };
703
+ /**
704
+ * Sekyro flows §7.7: where the chip key's MRZ comes from — `capture` (an
705
+ * MRZ-only scan before the chip read) or `document` (the earlier document step).
706
+ */
707
+ mrz?: {
708
+ source: "capture" | "document" | (string & {});
709
+ };
710
+ }
711
+ /**
712
+ * Per-check projection in a {@link HostedSessionView} — the spec'd hosted step
713
+ * shape. NEVER carries `calibratedScore` or the raw check `outputs`; the only
714
+ * output-derived data is the phone_otp `HostedOtpView` display subset
715
+ * (masked number/channel/expiry — never the verifToken).
716
+ */
717
+ interface HostedStepView {
718
+ checkType: CheckType;
719
+ state: CheckState;
720
+ /** Frozen-taxonomy reason code explaining a `failed`/`review` state. */
721
+ reason?: CheckReason;
722
+ /**
723
+ * Spec 2026-10-27: a Sandbox check answered by simulation (no provider or
724
+ * model ran). Absent on Live, on real Sandbox checks and on older APIs.
725
+ */
726
+ simulated?: boolean;
727
+ /**
728
+ * Submissions the page may still make for this check (`max(0, cap - attempts)`).
729
+ * Meaningful only while the check is executable — a finalized check may still
730
+ * report more than 0, but re-submitting it 409s regardless.
731
+ */
732
+ attemptsRemaining: number;
733
+ /** doc_ocr only: sides already accepted into the partial accumulator (['recto'] or ['verso']). */
734
+ acceptedSides?: ("recto" | "verso")[];
735
+ /** phone_otp only: the display-safe OTP send/config surface (never the verifToken). */
736
+ otp?: HostedOtpView;
737
+ /** email_otp only: the display-safe email send surface (never the handle or the address). */
738
+ emailOtp?: HostedEmailOtpView;
739
+ /**
740
+ * The check failed after using all of its attempts — no retry is left.
741
+ * Absent on older APIs (treat absent as `false`).
742
+ */
743
+ attemptsExhausted?: boolean;
744
+ /**
745
+ * population_registry only: the session is not bound to an NNI, but the
746
+ * document step already read a valid one — the page submits the registry
747
+ * check with an EMPTY input (no NNI field) and the backend uses the
748
+ * document's number. Absent on older APIs.
749
+ */
750
+ nniFromDocument?: boolean;
751
+ /**
752
+ * liveness / face_match (profile v2 step 4, decision mode `automatic`): the
753
+ * capture must come from a phone — the liveness band is calibrated on
754
+ * mobile captures only. A desktop page hands the person off to their phone
755
+ * instead of capturing (a desktop submission answers `mobile_required`).
756
+ * Absent on older APIs and in `review` mode.
757
+ */
758
+ requiresMobile?: boolean;
759
+ /** nfc_chip only (M-nfc). */
760
+ nfc?: NfcStepView;
761
+ /** portrait_icao only (SDK spec §4.9): the last attempt's per-criterion report. */
762
+ icao?: {
763
+ report: IcaoReportEntry[];
764
+ };
765
+ /** eid_auth only (SDK spec §3.2): the display-safe eID surface. */
766
+ eid?: HostedEidView;
767
+ /**
768
+ * The section of the flow this step belongs to (flow model 2026-10-23).
769
+ * Absent on older APIs (derive it from the check type).
770
+ */
771
+ section?: StepSection;
772
+ /**
773
+ * doc_ocr only, on an open step: the client reads the chip next, so the MRZ is
774
+ * read on device for the chip key (`mrz_for_chip`). Native NFC clients only.
775
+ */
776
+ docCapture?: {
777
+ mode: "mrz_for_chip" | (string & {});
778
+ };
779
+ }
780
+ /** A locale the Sekyro AI-hosted voice clips are recorded in. */
781
+ type HostedVoiceLocale = "ar" | "fr" | "en";
782
+ /**
783
+ * The session's Sekyro AI-hosted voice-guidance clips (the active clip set).
784
+ *
785
+ * `clips[locale]` maps a voice key (`fcv3.*`, the `@sekyro/react` voice-key
786
+ * namespace) to an ABSOLUTE URL on the Sekyro AI assets host
787
+ * (`https://assets.sekyro.ai/voice/<setId>/<locale>/<name>.mp3`; staging:
788
+ * `assets-staging.sekyro.ai`). URLs are immutable per `setId`. A locale or key
789
+ * may be missing — the player falls back to the device voice for it.
790
+ *
791
+ * A page with a Content-Security-Policy must allow the assets origin in
792
+ * `media-src` for the clips to play (see the partner web-SDK guide, CSP note).
793
+ */
794
+ interface HostedVoiceView {
795
+ /** Identifier of the active clip set (part of every clip URL). */
796
+ setId: string;
797
+ /** Per-locale map of voice key (`fcv3.*`) → absolute clip URL. */
798
+ clips: {
799
+ readonly [L in HostedVoiceLocale]?: Readonly<Record<string, string>>;
800
+ };
801
+ }
802
+ /** A branding colour key (each value is `#rrggbb`). */
803
+ type HostedBrandingColorKey = "brand" | "brandFg" | "bg" | "surface" | "fg" | "fgMuted" | "danger" | "success" | "warning";
804
+ /**
805
+ * The org / app branding of a session (`HostedSessionView.branding`): only the
806
+ * fields set in the dashboard, merged per field (app over org). A field the
807
+ * org and app left unset is ABSENT — keep your default for it; the whole
808
+ * object is absent when nothing is set. `logoUrl` is a short-lived signed URL
809
+ * (15 minutes).
810
+ */
811
+ interface HostedBranding {
812
+ /** Signed URL of the logo (PNG or sanitized SVG); absent when none is set. */
813
+ logoUrl?: string;
814
+ /** Colours as `#rrggbb`. */
815
+ colors?: Partial<Record<HostedBrandingColorKey, string>>;
816
+ /** Corner radius step. */
817
+ radius?: "none" | "sm" | "md" | "lg" | "full";
818
+ /** Font choice (system fallbacks when the font is not installed). */
819
+ fontFamily?: "system" | "inter" | "ibm-plex-sans-arabic" | "noto-sans-arabic" | "roboto";
820
+ }
821
+ /**
822
+ * Token-addressed hosted-page bootstrap (`GET /hosted/session`). A separate
823
+ * shape from the partner `SessionView`: `sessionId` instead of `id`,
824
+ * hosted step hints, the consent flag, and the org display name (may be `''`
825
+ * when the org lookup degrades).
826
+ */
827
+ /**
828
+ * Server-delivered capture tuning (`HostedSessionView.capture`, SDK spec §3.5).
829
+ * Coaching values only. `@sekyro/web` does not apply it yet (its built-in v3
830
+ * values stay in force until the adopting minor release); native SDKs apply it
831
+ * field by field over their bundled fallbacks and ignore unknown fields.
832
+ */
833
+ interface HostedCaptureTuning {
834
+ tuningVersion?: string;
835
+ liveness?: Record<string, unknown>;
836
+ document?: Record<string, unknown>;
837
+ /** SDK spec §5.4 ID mode: the strict ICAO gate's coaching limits (present with `portrait`). */
838
+ icao?: IcaoCaptureTuning;
839
+ /**
840
+ * Step 3 one-capture live photo (flow model 2026-10-23): one camera session
841
+ * records the clip AND a full-resolution still (long side at least
842
+ * `still.minLongSidePx`, JPEG `still.jpegQuality`).
843
+ */
844
+ livePhoto?: HostedLivePhotoTuning;
845
+ /**
846
+ * Who films the face, set in the flow (always present on current backends):
847
+ * - `self` — the person films themselves: front camera only, no camera
848
+ * choice, phone held upright;
849
+ * - `assisted` — an agent films the person: back camera by default, the
850
+ * front/back switch allowed, phone held upright.
851
+ * `@sekyro/web` enforces it on a capture bound to the session; an absent
852
+ * value falls back to {@link HostedCaptureTuning.cameraSwitch}, then `self`.
853
+ */
854
+ mode?: CaptureMode;
855
+ /**
856
+ * @deprecated Mirror of `mode === 'assisted'`, kept for older clients. Read
857
+ * {@link HostedCaptureTuning.mode}.
858
+ */
859
+ cameraSwitch?: boolean;
860
+ }
861
+ /**
862
+ * Who films the face (`HostedSessionView.capture.mode`, a flow setting):
863
+ * `self` (the person, front camera) or `assisted` (an agent, back camera).
864
+ */
865
+ type CaptureMode = "self" | "assisted";
866
+ /** `capture.livePhoto` (flow model 2026-10-23, Step 3). */
867
+ interface HostedLivePhotoTuning {
868
+ oneCapture: boolean;
869
+ still: {
870
+ minLongSidePx: number;
871
+ jpegQuality: number;
872
+ };
873
+ }
874
+ /**
875
+ * {@link HostedCaptureTuning} with the native-only document fields typed. The wire shape is
876
+ * the same; `HostedSessionView.capture` stays the open {@link HostedCaptureTuning} so existing
877
+ * consumers keep compiling. Narrow it where the typed fields are read:
878
+ * `const capture = view.capture as HostedNativeCaptureTuning | undefined`.
879
+ */
880
+ interface HostedNativeCaptureTuning extends HostedCaptureTuning {
881
+ document?: HostedDocumentCaptureTuning;
882
+ }
883
+ /**
884
+ * `capture.document`. Only the native-only fields the SDKs share a name for are typed;
885
+ * the rest (gate, aspect, upload, …) stay open. Web ignores the whole block.
886
+ */
887
+ interface HostedDocumentCaptureTuning {
888
+ [field: string]: unknown;
889
+ /** Native document scan machine thresholds (web does not read them). */
890
+ scan?: HostedDocumentScanTuning;
891
+ /** Native on-device OCR tuning (web ignores it; SDK spec §5.2). */
892
+ ocr?: HostedOcrTuning;
893
+ }
894
+ /** `capture.document.scan` — native scan thresholds; only the blur gate is typed here. */
895
+ interface HostedDocumentScanTuning {
896
+ [field: string]: unknown;
897
+ /** Blur gate: a captured photo whose native sharpness is under this is refused and retaken. */
898
+ blurRefuseSharpnessMax?: number;
899
+ }
900
+ /** `capture.document.ocr` — native on-device OCR tuning (web ignores it; SDK spec §5.2). */
901
+ interface HostedOcrTuning {
902
+ enabledOnline?: boolean;
903
+ enabledOffline?: boolean;
904
+ warmup?: boolean;
905
+ maxDeviceLatencyMs?: number;
906
+ deviceTimeoutMs?: number;
907
+ minAvailMemoryMb?: number;
908
+ minConfidenceForRetake?: number;
909
+ minSegmentsForRetake?: number;
910
+ submitGraceMs?: number;
911
+ reportSampleRate?: number;
912
+ readBudgetMs?: number;
913
+ classifyBudgetMs?: number;
914
+ deferArabicOnline?: boolean;
915
+ detectorLimit?: number;
916
+ detectorThreadsMax?: number;
917
+ recognizerThreads?: number;
918
+ recognitionWorkersMax?: number;
919
+ linesInFlight?: number;
920
+ widestLineFirst?: boolean;
921
+ scriptRouting?: boolean;
922
+ arabicColumnFirst?: boolean;
923
+ confidentLatinScore?: number;
924
+ minLatinLetters?: number;
925
+ arabicColumnStart?: number;
926
+ arabicOnlyScore?: number;
927
+ portraitProbeLimit?: number;
928
+ }
929
+ /** Native device attestation parameters (`HostedSessionView.integrity`, SDK spec §6.7). Web ignores it. */
930
+ interface HostedIntegrity {
931
+ mode: "off" | "signal" | "enforce";
932
+ android?: {
933
+ cloudProjectNumber: number;
934
+ };
935
+ ios?: {
936
+ appAttest: true;
937
+ };
938
+ }
939
+ interface HostedSessionView {
940
+ sessionId: string;
941
+ status: SessionStatus;
942
+ outcome: SessionOutcome | null;
943
+ /** ISO-8601 timestamp (Date on the server, string on the wire). */
944
+ expiresAt: string;
945
+ consentRecorded: boolean;
946
+ orgName: string;
947
+ /**
948
+ * The FIRST allowlisted web-SDK origin of the owning org (Task 12), or null
949
+ * when none is registered. The hosted page posts the SDK popup postMessage
950
+ * events (event name + sessionId ONLY) to exactly this origin — never `'*'`.
951
+ * The backend declares it required (`string | null`); optional here so
952
+ * pre-Task-12 consumers/fixtures stay valid (additive field, always on the
953
+ * wire from Task 12 onward).
954
+ */
955
+ sdkOrigin?: string | null;
956
+ /**
957
+ * Cloudflare Turnstile site key the browser must solve an execute-mode
958
+ * challenge against before submitting `liveness` (Plan A Task 5): the org's
959
+ * own widget key when the request origin is one of the org's allowlisted SDK
960
+ * origins, else the hosted widget key, else `null`. `null` means the session
961
+ * cannot be attested from the browser — the SDK sends `{sandbox: true}`,
962
+ * which the backend honours ONLY on sandbox sessions (fails closed on live).
963
+ */
964
+ turnstileSiteKey: string | null;
965
+ /**
966
+ * A Sandbox (test) session: the hosted page marks it as a test session.
967
+ * Optional: absent on an older backend.
968
+ */
969
+ sandbox?: boolean;
970
+ /** Spec 2026-10-27: this session enrolls a Sandbox tester (the hosted page shows the removal link at the end). */
971
+ testerEnrollment?: boolean;
972
+ /**
973
+ * The session was minted with a server-bound NNI (`POST /sessions`
974
+ * `input.nni`, Plan A Task 2): `population_registry` is submitted with an
975
+ * EMPTY input and the backend reads the sealed value. `false` means the
976
+ * person must supply the NNI (hosted population form); the SDK never submits
977
+ * the registry check on an unbound session. The VALUE is never exposed. The
978
+ * backend declares it required; optional here so pre-Task-8 fixtures stay
979
+ * valid (additive field, always on the wire from Task 8 onward).
980
+ */
981
+ nniBound?: boolean;
982
+ /**
983
+ * The Sekyro AI-hosted voice-guidance clips of this session, or `null` when no
984
+ * clip set is active (the device voice is used). Optional: older APIs omit
985
+ * the field — treat absent like `null`.
986
+ */
987
+ voice?: HostedVoiceView | null;
988
+ /**
989
+ * Why the session ended, when a profile-v2 policy stopped it: a
990
+ * {@link SessionFailureReason}, or the failed check's reason when it is a
991
+ * policy reason (eligibility, or `document_nni_mismatch`). Absent otherwise
992
+ * (and on older APIs).
993
+ */
994
+ failureReason?: PolicyFailureReason;
995
+ /**
996
+ * The document types the person may pick, resolved for issuer `MR`,
997
+ * `carte_identite`/`passport` only (older pickers). Absent on older APIs —
998
+ * treat absent as both.
999
+ */
1000
+ acceptedDocumentTypes?: AcceptedDocumentType[];
1001
+ /**
1002
+ * Accepted document types per issuing country — drives the issuer-first
1003
+ * picker. Absent on older APIs (fall back to `acceptedDocumentTypes` for MR).
1004
+ */
1005
+ acceptedDocuments?: HostedAcceptedDocuments;
1006
+ /**
1007
+ * ISO-8601 time from which this device may verify again — set with
1008
+ * `failureReason: 'device_cooldown'` (profile v2 step 4). Absent otherwise
1009
+ * (and on older APIs).
1010
+ */
1011
+ retryAfter?: string;
1012
+ /**
1013
+ * A returning-user session (profile v2 step 5): the person verified before
1014
+ * and this session only confirms it is still them — liveness and a face
1015
+ * match against their stored photo. Hosts read it to say "Confirm it's
1016
+ * you". Absent on full sessions (and on older APIs).
1017
+ */
1018
+ returning?: true;
1019
+ /**
1020
+ * The org / app branding (settings spec §5.1). Absent on older APIs — keep
1021
+ * the default theme. Map it with `brandingToTheme()` from `@sekyro/react`.
1022
+ */
1023
+ branding?: HostedBranding;
1024
+ /** Capture coaching tuning (SDK spec §3.5). Absent on older APIs. */
1025
+ capture?: HostedCaptureTuning;
1026
+ /** Native device attestation parameters; absent for web-only apps and on older APIs. */
1027
+ integrity?: HostedIntegrity;
1028
+ /**
1029
+ * SDK spec §3.5: present when the session runs the ICAO portrait step — the
1030
+ * client runs the ICAO gate (read it with `icaoPolicyOf`). `icao` is absent on
1031
+ * older servers, which send `{ purpose: "id_document" }` alone (= `reject`, `id_document`).
1032
+ */
1033
+ portrait?: {
1034
+ purpose: "id_document";
1035
+ /** Present whenever a `portrait_icao` step runs (absent on older servers): `reject` / `id_document`. */
1036
+ icao?: HostedIcaoPolicy;
1037
+ } | {
1038
+ /** A verification selfie checked against the ICAO selfie rules (selfie ICAO policy). */
1039
+ purpose: "verification";
1040
+ icao: HostedIcaoPolicy;
1041
+ };
1042
+ /** The flow version the session runs (Sekyro flows §9.2). */
1043
+ flow?: HostedFlowRef;
1044
+ /**
1045
+ * What the person does now (Sekyro flows §8.1), the only source of the
1046
+ * steps: render `plan.current`. Absent on an active session only from a
1047
+ * backend older than the flows release (the SDK then asks for an update).
1048
+ */
1049
+ plan?: HostedPlanView;
1050
+ /** Step 2b identity summary, present only while its confirmation is pending. */
1051
+ identitySummary?: IdentitySummaryView;
1052
+ }
1053
+ /** `POST /hosted/consent` result — 201 on first record, 200 `{alreadyRecorded: true}` on replay. */
1054
+ /**
1055
+ * `POST /hosted/consent` answer (Sekyro flows §8.2): the hosted view with
1056
+ * `consentRecorded: true`, plus whether consent was already on record.
1057
+ */
1058
+ type HostedConsentView = HostedSessionView & RecordConsentResult;
1059
+ interface RecordConsentResult {
1060
+ alreadyRecorded: boolean;
1061
+ }
1062
+ /** Consent locale — the page's `[locale]` URL segment echoed back (HostedConsentSchema picklist). */
1063
+ type ConsentLocale = "ar" | "fr" | "en";
1064
+ /** Per-check projection in a {@link SessionView} — enum/id only, never civil data. */
1065
+ interface SessionStepView {
1066
+ checkType: CheckType;
1067
+ state: CheckState;
1068
+ reason?: CheckReason;
1069
+ /**
1070
+ * Spec 2026-10-27: a Sandbox check answered by simulation (no provider or
1071
+ * model ran). Absent on Live, on real Sandbox checks and on older APIs.
1072
+ */
1073
+ simulated?: boolean;
1074
+ calibratedScore?: number;
1075
+ /** The check failed after using all of its attempts. Absent on older APIs. */
1076
+ attemptsExhausted?: boolean;
1077
+ /** portrait_icao only (SDK spec §4.9): the last attempt's per-criterion report. */
1078
+ report?: IcaoReportEntry[];
1079
+ }
1080
+ /**
1081
+ * Client-facing session projection returned by
1082
+ * `POST /sessions/:id/checks/:checkType`. Whitelist-only — never the client token.
1083
+ */
1084
+ interface SessionView {
1085
+ id: string;
1086
+ status: SessionStatus;
1087
+ outcome: SessionOutcome | null;
1088
+ /** Profile-v2 policy stop reason; absent on ordinary failures and older APIs. */
1089
+ failureReason?: PolicyFailureReason;
1090
+ steps: SessionStepView[];
1091
+ /** ISO-8601 timestamp (Date on the server, string on the wire). */
1092
+ expiresAt: string;
1093
+ /** ISO-8601 timestamp (Date on the server, string on the wire). */
1094
+ createdAt?: string;
1095
+ }
1096
+ /** Media class — selects size cap, MIME allowlist and promoted prefix (media.policy.ts). */
1097
+ type MediaKind = "image" | "clip";
1098
+ /**
1099
+ * Body of `POST /sessions/:id/media`. `contentType`/`contentLength` are the
1100
+ * exact values SIGNED into the presigned PUT — the PUT must send them verbatim.
1101
+ * Allowlists (media.policy.ts): image → image/jpeg | image/png (5 MB cap);
1102
+ * clip → video/webm | video/mp4 (15 MB cap). BARE types only — no `;codecs=` params.
1103
+ */
1104
+ interface PresignRequest {
1105
+ kind: MediaKind;
1106
+ contentType: string;
1107
+ contentLength: number;
1108
+ /** D8: the live-camera capture proof (image / clip from the SDK capture flows only). */
1109
+ capture?: CaptureProof;
1110
+ }
1111
+ /**
1112
+ * D8 — the proof a live-camera image / clip presign carries: a single-use nonce
1113
+ * from `POST /sessions/:id/media/capture-nonces`, plus the capture engine and how
1114
+ * long the capture took. A picked file (or a client without the capture flow)
1115
+ * sends none; the backend then flags (or, in `enforce`, refuses) the upload.
1116
+ */
1117
+ interface CaptureProof {
1118
+ nonce: string;
1119
+ engine?: string;
1120
+ captureMs?: number;
1121
+ }
1122
+ /** D8: `POST /sessions/:id/media/capture-nonces` response. */
1123
+ interface CaptureNoncesResult {
1124
+ nonces: string[];
1125
+ /** Seconds each nonce stays usable. */
1126
+ expiresIn: number;
1127
+ }
1128
+ /** D8: what a capture flow knows about its capture when it presigns. */
1129
+ interface CaptureContext {
1130
+ /** Capture engine id (`v1` / `v3` liveness, `document`, `portrait`). */
1131
+ engine?: string;
1132
+ /** How long the camera capture took, ms (→ `captureMs`; informational). */
1133
+ durationMs?: number;
1134
+ }
1135
+ /** Result of a presign — the presigned PUT URL plus the pending object key. */
1136
+ interface PresignUploadResult {
1137
+ key: string;
1138
+ uploadUrl: string;
1139
+ /** Presign TTL in seconds (900 = 15 min). */
1140
+ expiresIn: number;
1141
+ }
1142
+ /** Result of `POST /sessions/:id/media/complete` — the PROMOTED (class-prefixed) key. */
1143
+ interface CompleteMediaResult {
1144
+ ready: true;
1145
+ /** e.g. `clips/{sessionId}/{uuid}` or `doc-images/{sessionId}/{uuid}` — submit THIS key, not the pending one. */
1146
+ key: string;
1147
+ }
1148
+ /**
1149
+ * Liveness attestation bag (attestation-verifier.service.ts). The web SDK sends
1150
+ * `{channel: 'hosted_web', siteKey, turnstileToken}` — `siteKey` echoes the
1151
+ * `HostedSessionView.turnstileSiteKey` the challenge was rendered with, so the
1152
+ * backend picks the matching widget secret deterministically (Turnstile tokens
1153
+ * are single-use: siteverify runs exactly once, never "org then global").
1154
+ * `sandbox: true` and `signature` are honored only on sandbox sessions;
1155
+ * native SDKs will use platform attestation.
1156
+ */
1157
+ interface AttestationInput {
1158
+ sandbox?: boolean;
1159
+ signature?: string;
1160
+ channel?: "hosted_web";
1161
+ turnstileToken?: string;
1162
+ /** The Turnstile site key the token was minted with (selects the verifying secret). */
1163
+ siteKey?: string;
1164
+ }
1165
+ /**
1166
+ * liveness executor input: a promoted `clips/…` key + optional attestation.
1167
+ * `faceMatch` (v2 latency §3.2) carries the already-promoted `doc-images/…`
1168
+ * keyframe so the backend can run face_match IN THE SAME submission when its
1169
+ * bundle flag is on and `face_match` is the next pending step. Backends that
1170
+ * do not bundle ignore it (the input bag is an open record) — the SDK then
1171
+ * submits `face_match` itself with the same key (see liveness-flow.ts).
1172
+ */
1173
+ interface LivenessInput {
1174
+ clipKey: string;
1175
+ attestation?: AttestationInput;
1176
+ /** Declared capture channel — the liveness band is mobile-calibrated, so the
1177
+ * backend clamps non-mobile verdicts to review (uncalibrated_capture_channel).
1178
+ * Client-declared by design (not a security boundary); absent = legacy
1179
+ * clients, treated as mobile server-side during the rollout window. */
1180
+ captureChannel?: 'mobile' | 'desktop';
1181
+ /** Capture metadata (engine, dimensions, clip length, face-capture timing)
1182
+ * — the backend's allowlisted, non-PII `capture` block (session insights). */
1183
+ capture?: LivenessCaptureInput;
1184
+ /** The promoted face_match probe key, for a bundled liveness + face_match run. */
1185
+ faceMatch?: {
1186
+ imageKey: string;
1187
+ };
1188
+ /**
1189
+ * Step 3 one-capture live photo (flow model 2026-10-23): the ICAO still of the
1190
+ * same capture — exactly the `portrait_icao` body. When `portrait_icao` is the
1191
+ * next pending step the server runs it in parallel with liveness.
1192
+ */
1193
+ portraitIcao?: PortraitIcaoInput;
1194
+ }
1195
+ /** `LivenessInput.capture`: what the SDK's `captured` event measured. All ms are whole, ≥ 0. */
1196
+ interface LivenessCaptureInput {
1197
+ engine?: 'v1' | 'v3';
1198
+ width?: number;
1199
+ height?: number;
1200
+ clipMs?: number;
1201
+ cameraReadyMs?: number;
1202
+ faceAcquireMs?: number;
1203
+ captureMs?: number;
1204
+ /** The camera the clip was filmed with (`environment` = back). */
1205
+ facingMode?: 'user' | 'environment';
1206
+ /** The capture mode the SDK applied (the session's `capture.mode`; the server's own value is the authority). */
1207
+ mode?: 'self' | 'assisted';
1208
+ /** The device kind. With `mode` set, the server applies the upright requirement (`capture_not_upright`) to `phone` only. */
1209
+ formFactor?: 'phone' | 'tablet' | 'desktop';
1210
+ }
1211
+ /**
1212
+ * population_registry adapter input. `nni` is the 10-digit NNI for an UNBOUND
1213
+ * session; a session minted with a server-side `input.nni` is BOUND to it
1214
+ * (Plan A Task 2) — the browser submits `{}` and the backend reads the sealed
1215
+ * value. Sending a DIFFERENT nni on a bound session answers 409 `nni_locked`.
1216
+ */
1217
+ interface PopulationInput {
1218
+ nni?: string;
1219
+ }
1220
+ /**
1221
+ * face_match executor input: a promoted `doc-images/…` key (the source selfie frame).
1222
+ * The same key may already have ridden along as {@link LivenessInput.faceMatch}.
1223
+ */
1224
+ interface FaceMatchInput {
1225
+ imageKey: string;
1226
+ }
1227
+ /** Document side (docs.types.ts DocSide). */
1228
+ type DocSide = "recto" | "verso" | "single";
1229
+ /** doc_ocr executor input: a promoted `doc-images/…` key + which side it shows. */
1230
+ interface DocOcrInput {
1231
+ imageKey: string;
1232
+ side: DocSide;
1233
+ /**
1234
+ * Web live MRZ (spec 2026-10-21 D6): the device-read HINT of a live-MRZ capture — where the MRZ is in the uploaded
1235
+ * image and that every hard check digit validated on the device. Geometry, a format, counts and a salted digest
1236
+ * only (never MRZ text); the server re-reads the pixels and decides. Omitted when not ready at POST time.
1237
+ */
1238
+ deviceRead?: DocDeviceRead;
1239
+ }
1240
+ /** The `doc_ocr` device-read hint (identity-backend DeviceReadSchema; strict, text-free). */
1241
+ interface DocDeviceRead {
1242
+ engine: string;
1243
+ source: "live_mrz";
1244
+ format: "TD1" | "TD2" | "TD3";
1245
+ lineCount: number;
1246
+ checkDigitsValid: true;
1247
+ stillConfirmed?: boolean;
1248
+ /** [x, y, w, h] normalized to the uploaded image. */
1249
+ band: [number, number, number, number];
1250
+ /** sha256("sekyro-mrz-1\0" + sessionId + "\0" + canonical MRZ lines), 64 hex. */
1251
+ digest: string;
1252
+ framesToValid: number;
1253
+ msToValid: number;
1254
+ }
1255
+ /**
1256
+ * phone_otp executor input (Task 13): a two-phase check. `send` dispatches (or
1257
+ * resends) an OTP — resolving the number from the trusted server-side prefill
1258
+ * or the user-entered `phone` per the step's `numberSource`; `verify` checks
1259
+ * the entered `code` against the parked token. `phone` is IGNORED for a
1260
+ * `prefilled` step (a client number is never trusted as "prefilled").
1261
+ */
1262
+ interface PhoneOtpInput {
1263
+ /** Phase selector: `send` dispatches/resends, `verify` checks the code. Defaults to `send`. */
1264
+ action: "send" | "verify";
1265
+ /** USER-entered E.164 number (`user_entered` / `prefilled_or_entered` sends only). */
1266
+ phone?: string;
1267
+ /** The code the user typed — `verify` only. */
1268
+ code?: string;
1269
+ /**
1270
+ * The channel the person chose for `send`. Must be one of the step's
1271
+ * `otp.channels` when the view lists them; a session without channels
1272
+ * defaults to `sms`.
1273
+ */
1274
+ channel?: "sms" | "whatsapp";
1275
+ /** OTP message locale override for `send`. */
1276
+ locale?: "ar" | "fr" | "en";
1277
+ }
1278
+ /**
1279
+ * email_otp executor input (Plan 8, profile v2 §4.6.5): `send` emails a code to
1280
+ * the trusted prefill or the user-entered `email` (per `emailOtp.emailSource`;
1281
+ * ignored for `prefilled`), `verify` checks the entered `code`.
1282
+ */
1283
+ interface EmailOtpInput {
1284
+ /** Phase selector: `send` dispatches/resends, `verify` checks the code. */
1285
+ action: "send" | "verify";
1286
+ /** USER-entered address (`user_entered` / `prefilled_or_entered` sends only). */
1287
+ email?: string;
1288
+ /** The code the user typed — `verify` only. */
1289
+ code?: string;
1290
+ /** Email copy locale override for `send`. */
1291
+ locale?: "ar" | "fr" | "en";
1292
+ }
1293
+ /**
1294
+ * portrait_icao executor input (SDK spec §4.9): the ICAO gate's frame
1295
+ * (uploaded as media kind `image`). The server re-runs every criterion; only
1296
+ * `gate.baselineEyeOpenness` (0–1, the user's own eye-openness baseline) is used.
1297
+ */
1298
+ interface PortraitIcaoInput {
1299
+ media: {
1300
+ portrait: string;
1301
+ };
1302
+ gate?: {
1303
+ baselineEyeOpenness?: number;
1304
+ /**
1305
+ * The device verdict on the submitted still, with the server's criterion names
1306
+ * (`framing` folds into `resolution`; unmeasured criteria are omitted, and
1307
+ * `background` when the profile does not require it). Compared with the server
1308
+ * report, never trusted. Values are booleans keyed by {@link IcaoCriterion}
1309
+ * (the 0.1 type is kept: the public API only grows).
1310
+ */
1311
+ criteria?: Record<string, unknown>;
1312
+ /** The client background-uniformity measurement (numbers only; telemetry — the server decides). */
1313
+ backgroundCheck?: Record<string, unknown>;
1314
+ };
1315
+ tuningVersion?: string;
1316
+ }
1317
+ /**
1318
+ * eid_auth executor input (SDK spec §3.2): `start` asks the provider for a
1319
+ * code (with the person's `identifier` — the NNI in MR — unless the session is
1320
+ * bound to it), `verify` checks the typed `code`, `resend` asks for a new code.
1321
+ * On a bound session a different `identifier` answers 409 `nni_locked`.
1322
+ */
1323
+ interface EidAuthInput {
1324
+ action: "start" | "verify" | "resend";
1325
+ /** `start` only: the national number, omitted on a bound session. */
1326
+ identifier?: string;
1327
+ /** `verify` only: the code shown in the provider's app. */
1328
+ code?: string;
1329
+ }
1330
+ /** Per-check-type submission input shapes, keyed by the frozen vocabulary. */
1331
+ interface CheckInputByType {
1332
+ liveness: LivenessInput;
1333
+ face_match: FaceMatchInput;
1334
+ doc_ocr: DocOcrInput;
1335
+ population_registry: PopulationInput;
1336
+ phone_otp: PhoneOtpInput;
1337
+ /** M-nfc: read and submitted by the native SDKs only — the web never submits it. */
1338
+ nfc_chip: never;
1339
+ email_otp: EmailOtpInput;
1340
+ /** SDK spec §4.9: the web ICAO gate ships with M1b; the shape is ready for headless use. */
1341
+ portrait_icao: PortraitIcaoInput;
1342
+ /** SDK spec §3.2: the national eID sign-in. */
1343
+ eid_auth: EidAuthInput;
1344
+ }
1345
+ /**
1346
+ * Body of `POST /sessions/:id/checks/:checkType` (SubmitCheckSchema).
1347
+ * `forceOutcome` is SANDBOX-ONLY (plan D-C) — a live session rejects it with
1348
+ * 403 `force_outcome_forbidden`.
1349
+ */
1350
+ interface SubmitCheckBody {
1351
+ input?: Record<string, unknown>;
1352
+ forceOutcome?: "pass" | "fail";
1353
+ }
1354
+
1355
+ /**
1356
+ * Strip MIME parameters: `video/webm;codecs=vp8,opus` → `video/webm`.
1357
+ *
1358
+ * The capture engine (Task 4) emits `clipMimeType` WITH codec parameters, but
1359
+ * the presign allowlist holds BARE types only (['video/webm','video/mp4'] /
1360
+ * ['image/jpeg','image/png']) and the presigned PUT signs the exact declared
1361
+ * Content-Type. Exported so pages can normalize once and stay byte-consistent
1362
+ * between presign and PUT.
1363
+ */
1364
+ declare function stripMimeParams(contentType: string): string;
1365
+ /** Media-bearing check types → the input field the promoted key goes into. */
1366
+ declare const MEDIA_INPUT_FIELD: {
1367
+ readonly liveness: "clipKey";
1368
+ readonly face_match: "imageKey";
1369
+ readonly doc_ocr: "imageKey";
1370
+ };
1371
+ /** Check types that take an uploaded media key (population_registry does not). */
1372
+ type MediaCheckType = keyof typeof MEDIA_INPUT_FIELD;
1373
+ interface SubmitOptions {
1374
+ /**
1375
+ * Sent as `x-idempotency-key` (the header IdempotencyInterceptor reads).
1376
+ * One key per LOGICAL submit — a flaky-network retry with the same key
1377
+ * replays the first response without burning another attempt.
1378
+ */
1379
+ idempotencyKey?: string;
1380
+ /** SANDBOX-ONLY deterministic override (plan D-C); a live session 403s it. */
1381
+ forceOutcome?: "pass" | "fail";
1382
+ }
1383
+ interface UploadMedia {
1384
+ kind: MediaKind;
1385
+ blob: Blob;
1386
+ /** May carry codec params (engine `clipMimeType`) — stripped before presign AND PUT. */
1387
+ contentType: string;
1388
+ }
1389
+ interface HostedClientOptions {
1390
+ /** API origin, e.g. `https://api.sekyro.ai` — paths are `${apiOrigin}/api/v2/...`. */
1391
+ apiOrigin: string;
1392
+ /** The raw session token from the hosted URL (short code; legacy `cst_` during its TTL) — sent as `x-session-token` on every API call. */
1393
+ sessionToken: string;
1394
+ /** Injection seam (tests / non-window contexts). Defaults to `globalThis.fetch`. */
1395
+ fetch?: typeof globalThis.fetch;
1396
+ /** Per-request timeout for API calls (NOT the Spaces PUT). Default 30 000 ms. */
1397
+ requestTimeoutMs?: number;
1398
+ /**
1399
+ * Tuning for the ONLY automatic retry the client performs: 409
1400
+ * `idempotency_in_progress` (a concurrent identical request is mid-flight
1401
+ * server-side; the real response lands once it finishes). `attempts` counts
1402
+ * retries AFTER the first try. Defaults: 5 × 400 ms.
1403
+ */
1404
+ inProgressRetry?: {
1405
+ attempts?: number;
1406
+ delayMs?: number;
1407
+ };
1408
+ }
1409
+ /**
1410
+ * Hand-authored typed client for the five session-token endpoints:
1411
+ *
1412
+ * GET /api/v2/hosted/session → {@link getSession}
1413
+ * POST /api/v2/hosted/consent → {@link recordConsent}
1414
+ * POST /api/v2/hosted/choice → {@link choose}
1415
+ * POST /api/v2/hosted/identity/confirm → {@link confirmIdentity}
1416
+ * GET /api/v2/hosted/identity/portrait → {@link identityPortrait}
1417
+ * POST /api/v2/sessions/:id/media → {@link presign}
1418
+ * POST /api/v2/sessions/:id/media/complete → {@link completeMedia}
1419
+ * POST /api/v2/sessions/:id/checks/:checkType → {@link submitCheck}
1420
+ *
1421
+ * plus the bare presigned Spaces PUT ({@link uploadToSpaces}) and the
1422
+ * presign→PUT→complete→submit composition ({@link uploadAndSubmit}).
1423
+ *
1424
+ * Envelopes (verified against sessions-docs.e2e-spec.ts):
1425
+ * - success: `{success: true, data}` — unwrapped here, methods return the payload;
1426
+ * - error: flat `{code, message}` → thrown as {@link HostedApiError}.
1427
+ *
1428
+ * The media/checks routes are `:id`-addressed while the token itself is the
1429
+ * only credential the page starts with — the client learns its sessionId from
1430
+ * `GET /hosted/session` (token-addressed) and lazily bootstraps it when a
1431
+ * `:id` route is called first.
1432
+ *
1433
+ * No automatic retry EXCEPT bounded short-delay retry on 409
1434
+ * `idempotency_in_progress`. Everything else — including 429 with its parsed
1435
+ * `retryAfterSeconds` — is surfaced to the page to handle.
1436
+ */
1437
+ declare class HostedClient {
1438
+ private readonly apiOrigin;
1439
+ private readonly sessionToken;
1440
+ private readonly fetchImpl;
1441
+ private readonly requestTimeoutMs;
1442
+ private readonly retryAttempts;
1443
+ private readonly retryDelayMs;
1444
+ private sessionId;
1445
+ private bootstrap;
1446
+ /** D8: prefetched capture nonces (`armCapture`), each with its local expiry. */
1447
+ private captureNonces;
1448
+ private captureFetch;
1449
+ constructor(opts: HostedClientOptions);
1450
+ /** Token-addressed bootstrap — the hosted page's first call. Caches the sessionId. */
1451
+ getSession(): Promise<HostedSessionView>;
1452
+ /**
1453
+ * Record consent once (201; an idempotent replay answers 200 with
1454
+ * `alreadyRecorded: true`). Until recorded, media presign/complete AND check
1455
+ * submission answer 409 `consent_required`.
1456
+ */
1457
+ recordConsent(locale: ConsentLocale): Promise<HostedConsentView>;
1458
+ /**
1459
+ * Pick an option of the current choice (Sekyro flows §7.4): `plan.choice`'s
1460
+ * `nodeId` and one of its option ids. Returns the updated hosted view —
1461
+ * render it. The person may switch while `plan.choice.locked` is false.
1462
+ * Errors: 409 `choice_locked`, 409 `choice_option_unavailable`, 404 `choice_not_found`.
1463
+ */
1464
+ choose(nodeId: string, option: string): Promise<HostedSessionView>;
1465
+ /**
1466
+ * Answer the identity summary (`identitySummary` in the view, Step 2b):
1467
+ * `confirm` lifts the live-photo gate, `retake` re-opens the identity checks
1468
+ * that produced the data. Returns the updated hosted view; 409
1469
+ * `identity_confirm_locked` when nothing is pending or no retake is left.
1470
+ */
1471
+ confirmIdentity(decision: IdentityConfirmDecision): Promise<HostedSessionView>;
1472
+ /**
1473
+ * The summary portrait (`identitySummary.portrait.available`) as a JPEG
1474
+ * `Blob`, fetched with the session-token header (`Cache-Control: no-store`).
1475
+ * Show it from memory (`URL.createObjectURL`, revoked when done) — never
1476
+ * cache or store it.
1477
+ */
1478
+ identityPortrait(): Promise<Blob>;
1479
+ /**
1480
+ * Presign a Spaces PUT for a new pending object. `contentType` is stripped of
1481
+ * MIME parameters defensively (the allowlist holds bare types; the engine's
1482
+ * `clipMimeType` carries codec params) — PUT with the SAME bare type, or the
1483
+ * signed-header check rejects the upload.
1484
+ */
1485
+ presign(kind: MediaKind, contentType: string, contentLength: number): Promise<PresignUploadResult>;
1486
+ /**
1487
+ * D8: prefetch live-camera capture nonces when a camera capture STARTS, so the
1488
+ * presigns that follow (`presignCapture`) need no extra round trip. Never
1489
+ * throws; an older backend without the route simply leaves the pool empty.
1490
+ */
1491
+ armCapture(count?: number): void;
1492
+ /**
1493
+ * D8: presign a LIVE-CAMERA image / clip — like {@link presign}, plus the
1494
+ * capture proof: a fresh single-use nonce (pooled by {@link armCapture}, else
1495
+ * fetched now), the engine and the capture duration. When no nonce can be had
1496
+ * (route absent, network) the presign goes out without a proof — the backend
1497
+ * decides (`signal` flags it, `enforce` refuses it). Only the SDK's own capture
1498
+ * flows call this; a picked file goes through {@link presign}.
1499
+ */
1500
+ presignCapture(kind: MediaKind, contentType: string, contentLength: number, context?: CaptureContext): Promise<PresignUploadResult>;
1501
+ /** D8: one pooled (still fresh) nonce, else one fetched now; undefined when none can be had. */
1502
+ private takeCaptureNonce;
1503
+ /** D8: fetch `count` nonces into the pool (one request in flight at a time). Never throws. */
1504
+ private fillCaptureNonces;
1505
+ /**
1506
+ * Bare PUT to the presigned Spaces URL: EXACTLY the signed headers — the
1507
+ * declared Content-Type and the blob body. NO `x-session-token` (the
1508
+ * signature IS the credential; an extra header breaks nothing but leaks the
1509
+ * token to a third-party host) and no JSON envelope.
1510
+ *
1511
+ * `contentType` is param-stripped here too (idempotent for bare types): the
1512
+ * presign strips internally, so a caller composing manually with the engine's
1513
+ * parameterful `clipMimeType` would otherwise sign `video/webm` but PUT
1514
+ * `video/webm;codecs=…` — a signed-header mismatch S3 rejects at runtime.
1515
+ *
1516
+ * Timeout: 15 min (`AbortSignal.timeout(900_000)`, matching the presign TTL)
1517
+ * rather than the API calls' 30 s — a 15 MB clip on a slow link legitimately
1518
+ * exceeds 30 s, but a stalled in-flight socket must still be bounded (the TTL
1519
+ * alone only bounds when a PUT can START).
1520
+ *
1521
+ * Failures are ALWAYS typed: non-2xx throws {@link HostedApiError} with the
1522
+ * client-synthesized `upload_failed` (message carries a truncated S3 body
1523
+ * snippet — e.g. SignatureDoesNotMatch); a mid-transfer drop → `network_error`;
1524
+ * the timeout → `timeout`.
1525
+ */
1526
+ uploadToSpaces(uploadUrl: string, blob: Blob, contentType: string): Promise<void>;
1527
+ /** Finalize an upload: the backend sniffs + promotes; returns the PROMOTED key to submit. */
1528
+ completeMedia(key: string): Promise<CompleteMediaResult>;
1529
+ /**
1530
+ * Submit one check. Sends `{input, forceOutcome?}` (SubmitCheckSchema) and the
1531
+ * optional `x-idempotency-key` header. Returns the hosted view after the
1532
+ * submission (Sekyro flows §8.2: with its `plan`) — render it.
1533
+ */
1534
+ submitCheck<T extends CheckType>(checkType: T, input: CheckInputByType[T], opts?: SubmitOptions): Promise<HostedSessionView>;
1535
+ /**
1536
+ * Convenience composition: presign → PUT → complete → submit, passing the
1537
+ * PROMOTED key (from complete's response — never the pending presign key)
1538
+ * into the check's media input field (`clipKey` for liveness, `imageKey` for
1539
+ * face_match/doc_ocr). `extraInput` carries the remaining input fields
1540
+ * (liveness `attestation`, doc_ocr `side`). The media content type is
1541
+ * param-stripped ONCE and used for both presign and PUT, so the signed
1542
+ * header always matches.
1543
+ */
1544
+ uploadAndSubmit<T extends MediaCheckType>(checkType: T, media: UploadMedia, extraInput: Omit<CheckInputByType[T], (typeof MEDIA_INPUT_FIELD)[T]>, opts?: SubmitOptions): Promise<HostedSessionView>;
1545
+ /** The token's own sessionId — cached from getSession(), lazily bootstrapped. */
1546
+ private ensureSessionId;
1547
+ /**
1548
+ * One API request: `${apiOrigin}/api/v2${path}`, `x-session-token` always,
1549
+ * AbortSignal timeout (30 s default), `{success, data}` unwrap on 2xx, flat
1550
+ * `{code, message}` → {@link HostedApiError} on non-2xx. EVERY failure is
1551
+ * typed: a rejected fetch → `network_error`, the timeout → `timeout`, an
1552
+ * unparseable 2xx body → `unknown_error` — the page never sees a raw
1553
+ * TypeError/DOMException. The ONLY automatic retry is 409
1554
+ * `idempotency_in_progress` (bounded, short delay).
1555
+ */
1556
+ private api;
1557
+ }
1558
+
1559
+ /** Luma at or above this counts as clipped / specular. */
1560
+ declare const CLIPPED_LUMA = 250;
1561
+ /** Laplacian-variance reference (same as the liveness gate's frame-quality SHARP_REF). */
1562
+ declare const ICAO_SHARP_REF = 180;
1563
+ interface LumaPlane {
1564
+ data: Uint8Array;
1565
+ width: number;
1566
+ height: number;
1567
+ }
1568
+ /** Rec.601 luma of RGBA pixels. */
1569
+ declare function lumaPlane(image: {
1570
+ data: Uint8ClampedArray | Uint8Array;
1571
+ width: number;
1572
+ height: number;
1573
+ }): LumaPlane;
1574
+ interface RegionStats {
1575
+ mean: number;
1576
+ sd: number;
1577
+ /** Fraction of pixels at or above {@link CLIPPED_LUMA}. */
1578
+ clipped: number;
1579
+ count: number;
1580
+ }
1581
+ /** Mean / SD / clipped fraction of a box, optionally excluding a second box. */
1582
+ declare function regionStats(plane: LumaPlane, box: Box, exclude?: Box): RegionStats;
1583
+ interface FaceLighting {
1584
+ faceLuma: number;
1585
+ /** Left-half / right-half mean luma (image halves, split at the nose). */
1586
+ halfRatio: number;
1587
+ clipped: number;
1588
+ }
1589
+ declare function faceLighting(plane: LumaPlane, g: FaceGeometry): FaceLighting | null;
1590
+ /** Specular fraction inside both eye regions (spec §5.4 glasses glare). */
1591
+ declare function eyeSpecular(plane: LumaPlane, g: FaceGeometry): number | null;
1592
+ interface BackgroundStats {
1593
+ luma: number;
1594
+ sd: number;
1595
+ /** Pixels measured — too few means the corners left the frame. */
1596
+ count: number;
1597
+ }
1598
+ /**
1599
+ * Background heuristic: the two top corners of the ICAO window (each 20 % wide,
1600
+ * 25 % tall from 4 % down), minus the head (the face box widened by 40 % and
1601
+ * extended to the top of the window for hair). `null` when nothing is left.
1602
+ */
1603
+ declare function backgroundStats(plane: LumaPlane, g: FaceGeometry): BackgroundStats | null;
1604
+ /** Laplacian variance over the face core on a ≤96×96 grid, normalised 0..1 by {@link ICAO_SHARP_REF}. */
1605
+ declare function faceSharpness(plane: LumaPlane, g: FaceGeometry): number | null;
1606
+ /** Every pixel measure of one frame (`null` fields: not measurable). */
1607
+ interface IcaoPixelStats {
1608
+ lighting: FaceLighting | null;
1609
+ eyeSpecular: number | null;
1610
+ background: BackgroundStats | null;
1611
+ sharpness: number | null;
1612
+ }
1613
+ declare function icaoPixelStats(plane: LumaPlane, g: FaceGeometry): IcaoPixelStats;
1614
+
1615
+ /** The client gate's criteria, in coaching priority order. */
1616
+ declare const ICAO_GATE_CRITERIA: readonly ["face", "framing", "pose", "eyes", "mouth", "glare", "lighting", "background", "resolution", "sharpness"];
1617
+ type IcaoGateCriterion = (typeof ICAO_GATE_CRITERIA)[number];
1618
+ /** Coaching keys (copy `portrait.coach.<key>`). */
1619
+ type IcaoCoachKey = "no_face" | "multiple_faces" | "center" | "too_close" | "pose" | "eyes" | "mouth" | "glare" | "lighting" | "lighting_side" | "background" | "resolution" | "hold_still" | "hold";
1620
+ /** One frame as the gate sees it. Geometry in SOURCE (stream) pixels. */
1621
+ interface IcaoFrameObservation {
1622
+ frameWidth: number;
1623
+ frameHeight: number;
1624
+ /** Faces the landmarker found (the gate wants exactly one). */
1625
+ faces: number;
1626
+ geometry: FaceGeometry | null;
1627
+ /** Facial transformation matrix (4×4, column-major), when produced. */
1628
+ matrix?: readonly number[] | null;
1629
+ /** Blendshape scores by category name (`eyeBlinkLeft`, `jawOpen`, …). */
1630
+ blendshapes?: Readonly<Record<string, number>> | null;
1631
+ /** Pixel heuristics on the analysis frame; `null` when not measured. */
1632
+ stats?: IcaoPixelStats | null;
1633
+ /**
1634
+ * The background-uniformity check (segmenter, or the strip fallback), the
1635
+ * latest measurement — it runs a few times per second, not on every frame.
1636
+ * When present it decides the `background` criterion; `null` = not measurable.
1637
+ */
1638
+ backgroundCheck?: BackgroundUniformity | null;
1639
+ }
1640
+ interface IcaoCriterionState {
1641
+ criterion: IcaoGateCriterion;
1642
+ pass: boolean;
1643
+ /** Passed continuously for `holdMs`. */
1644
+ held: boolean;
1645
+ /** A failing soft criterion the gate stopped waiting for. */
1646
+ waived: boolean;
1647
+ /** The measured value (degrees, ratio, luma, px…) — coaching / telemetry only. */
1648
+ value: number | null;
1649
+ /** Coaching key when failing. */
1650
+ coach: IcaoCoachKey | null;
1651
+ }
1652
+ interface IcaoGateUpdate {
1653
+ criteria: IcaoCriterionState[];
1654
+ /** The one message to show (`hold` when everything passes and the gate is counting down). */
1655
+ coach: IcaoCoachKey;
1656
+ /** The lowest failing criterion (`null` when all pass or are waived). */
1657
+ failing: IcaoGateCriterion | null;
1658
+ /** 0..1 — held criteria, for a progress ring. */
1659
+ progress: number;
1660
+ /** Take the portrait frame now. */
1661
+ ready: boolean;
1662
+ /**
1663
+ * The user's own eye-openness baseline, once known. Unit (D9d, everywhere): openness =
1664
+ * 1 − the Landmarker's `eyeBlink{Left,Right}` blendshape; per frame the mean of the
1665
+ * two eyes; the baseline is the `baseline.percentile` (0.8) quantile over the recent
1666
+ * frontal, single-face frames. kyc-portrait compares the lower eye against it.
1667
+ */
1668
+ baseline: number | null;
1669
+ pose: HeadPose | null;
1670
+ }
1671
+ /** The on-device result submitted with the portrait (`gate`, §4.9): numbers only. */
1672
+ interface IcaoGateSummary {
1673
+ /** In (0, 1]: the gate's eye baseline (1 − blink blendshape; see {@link IcaoGateUpdate.baseline}). */
1674
+ baselineEyeOpenness?: number;
1675
+ criteria: Partial<Record<IcaoGateCriterion, {
1676
+ pass: boolean;
1677
+ value: number | null;
1678
+ waived?: boolean;
1679
+ }>>;
1680
+ /**
1681
+ * The device verdict with the server's criterion names — the submission's
1682
+ * `gate.criteria`: `framing` folds into `resolution`, unmeasured criteria are
1683
+ * omitted (occlusion always; background when the profile does not require it).
1684
+ */
1685
+ verdict?: Partial<Record<IcaoCriterion, boolean>>;
1686
+ /** The background-uniformity measurement behind the `background` criterion (numbers only). */
1687
+ backgroundCheck?: Omit<BackgroundUniformity, "pixels">;
1688
+ }
1689
+ interface Measured {
1690
+ pass: boolean;
1691
+ value: number | null;
1692
+ coach: IcaoCoachKey | null;
1693
+ /** Not measured on this frame (left out of the verdict). */
1694
+ none?: true;
1695
+ }
1696
+ /** The criteria a profile sets limits for (conformance.json `criteria`). */
1697
+ type IcaoJudgedCriterion = "pose" | "eyes" | "mouth" | "lighting" | "background" | "resolution";
1698
+ /**
1699
+ * One frame's measures in the server's units (conformance.json `measures`);
1700
+ * `null` = not measured on this frame.
1701
+ */
1702
+ interface IcaoMeasures {
1703
+ /** Degrees; `pitch` is RAW (before `pitchOffsetDeg`). `null` = no transformation matrix. */
1704
+ pose: HeadPose | null;
1705
+ /** The value shown for a pose without matrix (roll from the eye line). */
1706
+ eyeLineRoll?: number;
1707
+ /** Openness of each eye (1 − the `eyeBlink*` blendshape). */
1708
+ eyes: {
1709
+ left: number;
1710
+ right: number;
1711
+ } | null;
1712
+ /** The person's eye-openness baseline; `null` = the absolute floor only. */
1713
+ baseline: number | null;
1714
+ /** Blendshapes: `jawOpen`, the larger `mouthSmile*`, `mouthPucker`. */
1715
+ mouth: {
1716
+ jawOpen: number;
1717
+ smile: number;
1718
+ pucker: number;
1719
+ } | null;
1720
+ lighting: {
1721
+ faceLuma: number;
1722
+ halfRatio: number;
1723
+ clipped: number;
1724
+ } | null;
1725
+ background: {
1726
+ luma: number;
1727
+ sd: number;
1728
+ } | null;
1729
+ /** The web background-uniformity check; when present (and enabled) it decides the background. */
1730
+ uniformity?: Pick<BackgroundUniformity, "uniform" | "colorStd"> | null;
1731
+ iod: number;
1732
+ frameWidth: number;
1733
+ frameHeight: number;
1734
+ }
1735
+ /**
1736
+ * The per-criterion decision on one frame's measures — pure, the same rule as
1737
+ * kyc-portrait and the native gates (packages/sekyro-contract/icao/conformance.json;
1738
+ * limits are inclusive).
1739
+ */
1740
+ declare function judgeIcao(m: IcaoMeasures, t: ResolvedIcaoTuning): Record<IcaoJudgedCriterion, Measured>;
1741
+ /** Openness of one eye from the Landmarker's blink blendshape (1 − blink). */
1742
+ declare function eyeOpenness(blendshapes: Readonly<Record<string, number>> | null | undefined): {
1743
+ left: number;
1744
+ right: number;
1745
+ blinkLeft: number;
1746
+ blinkRight: number;
1747
+ } | null;
1748
+ /** The `p`-quantile (0..1) of a sample, nearest-rank. */
1749
+ declare function percentile(values: readonly number[], p: number): number | null;
1750
+ /** Score one frame against the limits. Pure; `baseline` is the eye baseline so far. */
1751
+ declare function scoreFrame(frame: IcaoFrameObservation, t: ResolvedIcaoTuning, baseline: number | null): {
1752
+ results: Record<IcaoGateCriterion, Measured>;
1753
+ pose: HeadPose | null;
1754
+ };
1755
+ interface IcaoGate {
1756
+ push(frame: IcaoFrameObservation, nowMs: number): IcaoGateUpdate;
1757
+ /** The last update (`null` before the first frame). */
1758
+ last(): IcaoGateUpdate | null;
1759
+ /** The submission's `gate` block from the last update. */
1760
+ summary(): IcaoGateSummary;
1761
+ /** Start the holds over (a retake). The eye baseline is kept: it describes the person. */
1762
+ reset(): void;
1763
+ }
1764
+ interface IcaoGateOptions {
1765
+ /** `alert`: coaching only — ready `alertGraceMs` after the face was accepted at the latest. Default `reject`. */
1766
+ policy?: "reject" | "alert";
1767
+ }
1768
+ declare function createIcaoGate(t: ResolvedIcaoTuning, options?: IcaoGateOptions): IcaoGate;
1769
+
1770
+ export { type NfcStepView as $, type AcceptedDocumentType as A, type HostedSessionView as B, type CaptureMode as C, type DecisionReason as D, type EidAfterPass as E, type FaceMatchReason as F, type HostedStepView as G, type HeadPose as H, type HostedVoiceLocale as I, type HostedVoiceView as J, type IcaoCaptureTuning as K, type IcaoCoachKey as L, type IcaoCriterion as M, type IcaoCriterionState as N, type IcaoGateCriterion as O, type IcaoGateSummary as P, type IcaoGateUpdate as Q, type IcaoReportEntry as R, type IdentityConfirmDecision as S, type IdentityMethod as T, type IdentitySummarySource as U, type IdentitySummaryView as V, type LivenessReason as W, type MatchReason as X, type MethodChoiceView as Y, type NationalEidOption as Z, type NfcChipReason as _, type CheckReason as a, type ConsentLocale as a$, type OtpChoiceView as a0, type PhoneOtpReason as a1, type PlanAttempts as a2, type PlanChoiceKind as a3, type PlanChoiceOption as a4, type PlanChoiceView as a5, type PlanSectionView as a6, type PlanStepView as a7, type PolicyFailureReason as a8, type PopulationReason as a9, backgroundStats as aA, createIcaoGate as aB, eyeLineRoll as aC, eyeOpenness as aD, eyeSpecular as aE, faceGeometry as aF, faceLighting as aG, faceSharpness as aH, icaoPixelStats as aI, icaoWindow as aJ, judgeIcao as aK, lumaPlane as aL, percentile as aM, portraitCropRegion as aN, poseFromMatrix as aO, regionStats as aP, resolveIcaoTuning as aQ, scoreFrame as aR, windowOverflow as aS, type PersonMask as aT, HostedClient as aU, type AttestationInput as aV, type CaptureContext as aW, type CaptureNoncesResult as aX, type CaptureProof as aY, type CheckInputByType as aZ, type CompleteMediaResult as a_, type PortraitIcaoInput as aa, type PortraitIcaoReason as ab, type SessionFailureReason as ac, type SessionOutcome as ad, type SessionStatus as ae, type StepSection as af, type BackgroundStats as ag, type Box as ah, CLIPPED_LUMA as ai, type FaceGeometry as aj, type FaceLighting as ak, ICAO_CANVAS as al, ICAO_FALLBACK as am, ICAO_GATE_CRITERIA as an, ICAO_SHARP_REF as ao, type IcaoFrameObservation as ap, type IcaoGate as aq, type IcaoGateOptions as ar, type IcaoJudgedCriterion as as, type IcaoMeasures as at, type IcaoPixelStats as au, type IcaoProfile as av, type LumaPlane as aw, type Point as ax, type RegionStats as ay, type ResolvedIcaoTuning as az, type CheckState as b, type DocDeviceRead as b0, type DocOcrInput as b1, type DocSide as b2, type EmailOtpInput as b3, type FaceMatchInput as b4, type HostedClientOptions as b5, type LivenessCaptureInput as b6, type LivenessInput as b7, type MediaCheckType as b8, type MediaKind as b9, type PhoneOtpInput as ba, type PopulationInput as bb, type PresignRequest as bc, type PresignUploadResult as bd, type RecordConsentResult as be, type SessionStepView as bf, type SessionView as bg, type SubmitCheckBody as bh, type SubmitOptions as bi, type UploadMedia as bj, stripMimeParams as bk, type CheckType as c, type ContactChannel as d, type DocReason as e, type EidAuthInput as f, type EidReason as g, type EmailOtpReason as h, type HostedAcceptedDocuments as i, type HostedBranding as j, type HostedBrandingColorKey as k, type HostedCaptureTuning as l, type HostedConsentView as m, type HostedDocumentCaptureTuning as n, type HostedDocumentScanTuning as o, type HostedEidView as p, type HostedEmailOtpView as q, type HostedFlowRef as r, type HostedIcaoPolicy as s, type HostedIntegrity as t, type HostedLivePhotoTuning as u, type HostedNativeCaptureTuning as v, type HostedOcrTuning as w, type HostedOtpView as x, type HostedPlanView as y, type HostedPortraitView as z };