@sekyro/web 0.1.0-rc.2 → 0.1.0-rc.21

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 (133) hide show
  1. package/CHANGELOG.md +313 -0
  2. package/LICENSE +25 -16
  3. package/README.md +111 -60
  4. package/THIRD-PARTY-NOTICES.txt +154 -0
  5. package/dist/background-monitor-A7FKJOAG.js +1 -0
  6. package/dist/camera-trait-45MJTW4K.js +1 -0
  7. package/dist/capture-constraints-B5omafmk.d.cts +44 -0
  8. package/dist/capture-constraints-B5omafmk.d.ts +44 -0
  9. package/dist/capture-session-doc-XBZGXWOP.js +1 -0
  10. package/dist/{capture-session-v3-CAoWM8iT.d.cts → capture-session-v3-26FgzBIl.d.cts} +185 -15
  11. package/dist/{capture-session-v3-BJ8ciaWl.d.ts → capture-session-v3-ZO0QOeQH.d.ts} +185 -15
  12. package/dist/chunk-234OZEDB.js +1 -0
  13. package/dist/chunk-33KKMPJ5.js +1 -0
  14. package/dist/chunk-53POX7U4.js +1 -0
  15. package/dist/chunk-7Q4YPMAF.js +1 -0
  16. package/dist/chunk-A3FUGHAH.js +2 -0
  17. package/dist/chunk-B2X33ZW2.js +1 -0
  18. package/dist/chunk-CJHMFPL6.js +1 -0
  19. package/dist/chunk-CQ7SKLMC.js +1 -0
  20. package/dist/chunk-DFTCAWMP.js +1 -0
  21. package/dist/chunk-DK5YPBDQ.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-GT2ZLGF7.js +1 -0
  27. package/dist/chunk-H3HVCWLF.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-P3H3D33O.js +1 -0
  32. package/dist/chunk-P6UP4UQY.js +1 -0
  33. package/dist/chunk-POIQGEZM.js +1 -0
  34. package/dist/chunk-QYYJLXKA.js +1 -0
  35. package/dist/chunk-RI3E7GBN.js +1 -0
  36. package/dist/chunk-SMKCBUJL.js +1 -0
  37. package/dist/chunk-SNACCYTL.js +1 -0
  38. package/dist/chunk-TDLIXFDT.js +1 -0
  39. package/dist/chunk-TQB3URP2.js +1 -0
  40. package/dist/chunk-VIAT4DEA.js +1 -0
  41. package/dist/chunk-ZADZTM3M.js +1 -0
  42. package/dist/chunk-ZNIZACXD.js +1 -0
  43. package/dist/client/index.cjs +1 -357
  44. package/dist/client/index.d.cts +6 -37
  45. package/dist/client/index.d.ts +6 -37
  46. package/dist/client/index.js +1 -15
  47. package/dist/core/index.cjs +1 -1605
  48. package/dist/core/index.d.cts +5 -4
  49. package/dist/core/index.d.ts +5 -4
  50. package/dist/core/index.js +1 -139
  51. package/dist/core/ocr/worker.bundle.js +42 -0
  52. package/dist/core/ocr/worker.cjs +42 -0
  53. package/dist/core/ocr/worker.d.cts +84 -0
  54. package/dist/core/ocr/worker.d.ts +84 -0
  55. package/dist/core/ocr/worker.js +41 -0
  56. package/dist/core/v3/detect-worker.cjs +1 -392
  57. package/dist/core/v3/detect-worker.d.cts +1 -1
  58. package/dist/core/v3/detect-worker.d.ts +1 -1
  59. package/dist/core/v3/detect-worker.js +1 -13
  60. package/dist/create-document-capture-23R2F47A.js +1 -0
  61. package/dist/create-portrait-capture-AGFHECK7.js +1 -0
  62. package/dist/create-verification-CXhXxknV.d.cts +3313 -0
  63. package/dist/create-verification-KlHIU4Fy.d.ts +3313 -0
  64. package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
  65. package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
  66. package/dist/detector-scanic-YCDNLCGV.js +1 -0
  67. package/dist/icao-gate-DI8VePWd.d.ts +566 -0
  68. package/dist/icao-gate-DvzOzHq6.d.cts +566 -0
  69. package/dist/icao-gate-T3BTOKFJ.js +1 -0
  70. package/dist/icao-policy-DztbA50-.d.ts +71 -0
  71. package/dist/icao-policy-MRB8NMAu.d.cts +71 -0
  72. package/dist/icao-tuning-4ETMF53W.js +1 -0
  73. package/dist/index.cjs +1 -2636
  74. package/dist/index.d.cts +110 -5
  75. package/dist/index.d.ts +110 -5
  76. package/dist/index.js +1 -28
  77. package/dist/internal/index.cjs +1 -4166
  78. package/dist/internal/index.d.cts +369 -324
  79. package/dist/internal/index.d.ts +369 -324
  80. package/dist/internal/index.js +1 -647
  81. package/dist/keyframe-rank-YAJLYJYF.js +1 -0
  82. package/dist/landmarker-KB7LVXAU.js +1 -0
  83. package/dist/mrz-band-VYHOTDHY.js +1 -0
  84. package/dist/plan-runner-NUWONT7F.js +1 -0
  85. package/dist/popup/index.cjs +1 -76
  86. package/dist/popup/index.d.cts +8 -2
  87. package/dist/popup/index.d.ts +8 -2
  88. package/dist/popup/index.js +1 -11
  89. package/dist/print-AYSCRSZB.js +1 -0
  90. package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
  91. package/dist/segmenter-USLNBX65.js +1 -0
  92. package/dist/turnstile-FATNZ4AG.js +1 -0
  93. package/dist/types-C_XP92JQ.d.cts +1732 -0
  94. package/dist/types-C_XP92JQ.d.ts +1732 -0
  95. package/dist/upload-file-UYXOHCRG.js +1 -0
  96. package/package.json +27 -11
  97. package/sbom.cdx.json +234 -0
  98. package/dist/capture-constraints-BujkZcfb.d.cts +0 -21
  99. package/dist/capture-constraints-BujkZcfb.d.ts +0 -21
  100. package/dist/chunk-BPYVZUJA.js +0 -852
  101. package/dist/chunk-BPYVZUJA.js.map +0 -1
  102. package/dist/chunk-LOTAJDRE.js +0 -1094
  103. package/dist/chunk-LOTAJDRE.js.map +0 -1
  104. package/dist/chunk-MWNFSNMP.js +0 -52
  105. package/dist/chunk-MWNFSNMP.js.map +0 -1
  106. package/dist/chunk-NILNKLK6.js +0 -50
  107. package/dist/chunk-NILNKLK6.js.map +0 -1
  108. package/dist/chunk-NWF46H7K.js +0 -359
  109. package/dist/chunk-NWF46H7K.js.map +0 -1
  110. package/dist/chunk-WY6U7AIK.js +0 -193
  111. package/dist/chunk-WY6U7AIK.js.map +0 -1
  112. package/dist/chunk-YVFF4Q4G.js +0 -327
  113. package/dist/chunk-YVFF4Q4G.js.map +0 -1
  114. package/dist/client/index.cjs.map +0 -1
  115. package/dist/client/index.js.map +0 -1
  116. package/dist/core/index.cjs.map +0 -1
  117. package/dist/core/index.js.map +0 -1
  118. package/dist/core/v3/detect-worker.cjs.map +0 -1
  119. package/dist/core/v3/detect-worker.js.map +0 -1
  120. package/dist/create-verification-CjLnJ0w6.d.ts +0 -348
  121. package/dist/create-verification-EnZ13uY4.d.cts +0 -348
  122. package/dist/detector-scanic-4C6IEW2K.js +0 -787
  123. package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
  124. package/dist/hosted-client-BpvBqu9f.d.cts +0 -408
  125. package/dist/hosted-client-BpvBqu9f.d.ts +0 -408
  126. package/dist/index.cjs.map +0 -1
  127. package/dist/index.js.map +0 -1
  128. package/dist/internal/index.cjs.map +0 -1
  129. package/dist/internal/index.js.map +0 -1
  130. package/dist/popup/index.cjs.map +0 -1
  131. package/dist/popup/index.js.map +0 -1
  132. package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
  133. package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
@@ -0,0 +1,566 @@
1
+ import { R as HostedSessionView, j as ConsentLocale, v as HostedConsentView, aK as CameraUnavailableCause, aL as CaptureIssueReport, Y as IdentityConfirmDecision, a4 as MediaKind, av as PresignUploadResult, C as CaptureContext, i as CompleteMediaResult, h as CheckType, e as CheckInputByType, W as IcaoCriterion, a_ as BackgroundUniformity, aX as ResolvedIcaoTuning } from './types-C_XP92JQ.cjs';
2
+
3
+ interface Point {
4
+ x: number;
5
+ y: number;
6
+ }
7
+ interface Box {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ }
13
+ /** The face geometry the gate needs, in SOURCE (stream) pixels. */
14
+ interface FaceGeometry {
15
+ /** Eye centres, ordered by image x (`left` = smaller x). */
16
+ leftEye: Point;
17
+ rightEye: Point;
18
+ /** Inter-ocular distance (px). */
19
+ iod: number;
20
+ /** Bounding box of the landmark mesh (forehead to chin). */
21
+ box: Box;
22
+ /** Nose tip (landmark 1): splits the face into halves for the lighting ratio. */
23
+ nose: Point;
24
+ /** Eye-contour boxes (glare), same order as the eyes. */
25
+ leftEyeBox: Box;
26
+ rightEyeBox: Box;
27
+ }
28
+ /**
29
+ * Normalised Face Landmarker landmarks (0..1) → source-pixel geometry.
30
+ * `null` when the mesh is too short to carry the eyes.
31
+ */
32
+ declare function faceGeometry(landmarks: readonly Point[], width: number, height: number): FaceGeometry | null;
33
+ interface HeadPose {
34
+ yaw: number;
35
+ pitch: number;
36
+ roll: number;
37
+ }
38
+ /**
39
+ * Yaw / pitch / roll (degrees) of the Face Landmarker's facial transformation
40
+ * matrix (4×4, `layout` of `data`; MediaPipe emits column-major). Rotation
41
+ * order R = Rz(roll)·Ry(yaw)·Rx(pitch): yaw turns about the vertical axis,
42
+ * pitch nods, roll tilts. Only magnitudes are gated, so sign conventions never
43
+ * change a verdict. `null` for a malformed matrix.
44
+ */
45
+ declare function poseFromMatrix(data: readonly number[], layout?: "column" | "row"): HeadPose | null;
46
+ /** Roll from the eye line (degrees) — the fallback when no matrix is available. */
47
+ declare function eyeLineRoll(g: Pick<FaceGeometry, "leftEye" | "rightEye">): number;
48
+ /** The ICAO canvas (icao.py): 480×640, eye midpoint at x = 240, eye line at y = 289, IOD 120–160. */
49
+ declare const ICAO_CANVAS: {
50
+ readonly width: 480;
51
+ readonly height: 640;
52
+ readonly eyeX: 240;
53
+ readonly eyeY: 289;
54
+ readonly iodMin: 120;
55
+ readonly iodMax: 160;
56
+ };
57
+ /**
58
+ * The source-pixel window the server's ICAO crop is cut from: scale 1 when the
59
+ * IOD already lies in 120–160, else the scale that brings it to 120 (icao.py:
60
+ * "120 when outside the band"), the eye midpoint at (240, 289) of the window.
61
+ */
62
+ declare function icaoWindow(g: Pick<FaceGeometry, "leftEye" | "rightEye" | "iod">): Box;
63
+ /** How far a window spills outside the frame (0 = inside), as a fraction of its size. */
64
+ declare function windowOverflow(window: Box, frameWidth: number, frameHeight: number): number;
65
+ /**
66
+ * The region of the full-resolution still the SDK uploads: the ICAO window
67
+ * grown by `margin` about its centre (so the server re-crops with its own
68
+ * landmarks), at least `minWidth × minHeight`, 3:4 portrait, then fitted into
69
+ * the frame — the margin shrinks first, then the box slides inside, and only
70
+ * a window larger than the frame is cut to it. Integer pixels.
71
+ */
72
+ declare function portraitCropRegion(g: Pick<FaceGeometry, "leftEye" | "rightEye" | "iod">, frameWidth: number, frameHeight: number, opts: {
73
+ margin: number;
74
+ minWidth: number;
75
+ minHeight: number;
76
+ }): Box;
77
+
78
+ /**
79
+ * Strip MIME parameters: `video/webm;codecs=vp8,opus` → `video/webm`.
80
+ *
81
+ * The capture engine (Task 4) emits `clipMimeType` WITH codec parameters, but
82
+ * the presign allowlist holds BARE types only (['video/webm','video/mp4'] /
83
+ * ['image/jpeg','image/png']) and the presigned PUT signs the exact declared
84
+ * Content-Type. Exported so pages can normalize once and stay byte-consistent
85
+ * between presign and PUT.
86
+ */
87
+ declare function stripMimeParams(contentType: string): string;
88
+ /** Media-bearing check types → the input field the promoted key goes into. */
89
+ declare const MEDIA_INPUT_FIELD: {
90
+ readonly liveness: "clipKey";
91
+ readonly face_match: "imageKey";
92
+ readonly doc_ocr: "imageKey";
93
+ };
94
+ /** Check types that take an uploaded media key (population_registry does not). */
95
+ type MediaCheckType = keyof typeof MEDIA_INPUT_FIELD;
96
+ interface SubmitOptions {
97
+ /**
98
+ * Sent as `x-idempotency-key` (the header IdempotencyInterceptor reads).
99
+ * One key per LOGICAL submit — a flaky-network retry with the same key
100
+ * replays the first response without burning another attempt.
101
+ */
102
+ idempotencyKey?: string;
103
+ /**
104
+ * SANDBOX-ONLY deterministic override (plan D-C); a live session 403s it. The `age_*` values ride the liveness
105
+ * submit and pick what the age check (selfie) step decides.
106
+ */
107
+ forceOutcome?: "pass" | "fail" | "age_over" | "age_uncertain" | "age_under" | "age_unavailable";
108
+ }
109
+ interface UploadMedia {
110
+ kind: MediaKind;
111
+ blob: Blob;
112
+ /** May carry codec params (engine `clipMimeType`) — stripped before presign AND PUT. */
113
+ contentType: string;
114
+ }
115
+ interface HostedClientOptions {
116
+ /** API origin, e.g. `https://api.sekyro.ai` — paths are `${apiOrigin}/api/v2/...`. */
117
+ apiOrigin: string;
118
+ /** The raw session token from the hosted URL (short code) — sent as `x-session-token` on every API call. */
119
+ sessionToken: string;
120
+ /** Injection seam (tests / non-window contexts). Defaults to `globalThis.fetch`. */
121
+ fetch?: typeof globalThis.fetch;
122
+ /** Per-request timeout for API calls (NOT the Spaces PUT). Default 30 000 ms. */
123
+ requestTimeoutMs?: number;
124
+ /**
125
+ * Tuning for the automatic retry on 409 `idempotency_in_progress` (a
126
+ * concurrent identical request is mid-flight server-side; the real response
127
+ * lands once it finishes). `attempts` counts retries AFTER the first try.
128
+ * Defaults: 5 × 400 ms. (The other automatic retry, once on a 503
129
+ * `server_busy` / `request_timeout`, is not tunable.)
130
+ */
131
+ inProgressRetry?: {
132
+ attempts?: number;
133
+ delayMs?: number;
134
+ };
135
+ /**
136
+ * Injection seam (tests): the source of the busy-retry jitter, returning a value in [0, 1).
137
+ * Defaults to `Math.random`.
138
+ */
139
+ random?: () => number;
140
+ }
141
+ /**
142
+ * Hand-authored typed client for the five session-token endpoints:
143
+ *
144
+ * GET /api/v2/hosted/session → {@link getSession}
145
+ * POST /api/v2/hosted/consent → {@link recordConsent}
146
+ * POST /api/v2/hosted/choice → {@link choose}
147
+ * POST /api/v2/hosted/identity/confirm → {@link confirmIdentity}
148
+ * GET /api/v2/hosted/identity/portrait → {@link identityPortrait}
149
+ * POST /api/v2/sessions/:id/media → {@link presign}
150
+ * POST /api/v2/sessions/:id/media/complete → {@link completeMedia}
151
+ * POST /api/v2/sessions/:id/checks/:checkType → {@link submitCheck}
152
+ *
153
+ * plus the bare presigned Spaces PUT ({@link uploadToSpaces}) and the
154
+ * presign→PUT→complete→submit composition ({@link uploadAndSubmit}).
155
+ *
156
+ * Envelopes (verified against sessions-docs.e2e-spec.ts):
157
+ * - success: `{success: true, data}` — unwrapped here, methods return the payload;
158
+ * - error: flat `{code, message}` → thrown as {@link HostedApiError}.
159
+ *
160
+ * The media/checks routes are `:id`-addressed while the token itself is the
161
+ * only credential the page starts with — the client learns its sessionId from
162
+ * `GET /hosted/session` (token-addressed) and lazily bootstraps it when a
163
+ * `:id` route is called first.
164
+ *
165
+ * Two automatic retries only: bounded short-delay retry on 409
166
+ * `idempotency_in_progress`, and ONE retry after `Retry-After` (capped at 20 s,
167
+ * ±25 % jitter) on a 503 `server_busy` / `request_timeout` for the calls that are safe to
168
+ * repeat: the reads (`getSession`, `identityPortrait`), the naturally
169
+ * idempotent writes (`recordConsent`, `choose`) and `submitCheck` with an
170
+ * idempotency key. Everything else — including 429 with its parsed
171
+ * `retryAfterSeconds` — is surfaced to the page to handle.
172
+ */
173
+ /**
174
+ * The `x-sekyro-sdk` value of this SDK (`@sekyro/web/<version>`, person data spec §5.6): every hosted
175
+ * call sends it. A page that calls a hosted session-token route itself sends it too.
176
+ */
177
+ declare const SEKYRO_SDK_HEADER: string;
178
+ declare class HostedClient {
179
+ private readonly apiOrigin;
180
+ private readonly sessionToken;
181
+ private readonly fetchImpl;
182
+ private readonly requestTimeoutMs;
183
+ private readonly retryAttempts;
184
+ private readonly retryDelayMs;
185
+ private readonly random;
186
+ private sessionId;
187
+ private bootstrap;
188
+ /** D8: prefetched capture nonces (`armCapture`), each with its local expiry. */
189
+ private captureNonces;
190
+ private captureFetch;
191
+ /** Capture issues already reported, with their send (see reportCaptureIssue): a repeat awaits the first. */
192
+ private readonly reportedIssues;
193
+ constructor(opts: HostedClientOptions);
194
+ /** Token-addressed bootstrap — the hosted page's first call. Caches the sessionId. */
195
+ getSession(): Promise<HostedSessionView>;
196
+ /**
197
+ * Record consent once (201; an idempotent replay answers 200 with
198
+ * `alreadyRecorded: true`). Until recorded, media presign/complete AND check
199
+ * submission answer 409 `consent_required`.
200
+ */
201
+ recordConsent(locale: ConsentLocale): Promise<HostedConsentView>;
202
+ /**
203
+ * Spec 2026-10-29 §3.4: the device has no usable camera. The server fails the frontier liveness step with
204
+ * `camera_unavailable` (no attempt, nothing billed) and lets the flow decide: a fallback step, else the session
205
+ * ends at level 0. Returns the hosted view; 409 `check_out_of_order` when the frontier is not a liveness step.
206
+ * `cause` (2026-10-30) says why (`denied` | `no_camera`); omitted, the body stays `{}` and nothing is recorded.
207
+ */
208
+ reportCameraUnavailable(cause?: CameraUnavailableCause): Promise<HostedSessionView>;
209
+ /**
210
+ * 2026-11-04: record a capture failure the page showed (`POST /hosted/capture-issue`, 204) so it can be diagnosed
211
+ * later. Fire-and-forget: never rejects, and every failure is swallowed. At most one report per distinct
212
+ * (check, attempt, kind, name, phase); a repeat makes no call and resolves when the first send settles (a failed send
213
+ * is forgotten, so a later repeat sends again). `name` is re-sanitised (letters only, at most
214
+ * 40 characters) and `engineKind` kept only when it is a lower-case code of at most 32 characters.
215
+ */
216
+ reportCaptureIssue(issue: CaptureIssueReport): Promise<void>;
217
+ /**
218
+ * Pick an option of the current choice (Sekyro flows §7.4): `plan.choice`'s
219
+ * `nodeId` and one of its option ids. Returns the updated hosted view —
220
+ * render it. The person may switch while `plan.choice.locked` is false.
221
+ * Errors: 409 `choice_locked`, 409 `choice_option_unavailable`, 404 `choice_not_found`.
222
+ */
223
+ choose(nodeId: string, option: string): Promise<HostedSessionView>;
224
+ /**
225
+ * Answer the identity summary (`identitySummary` in the view, Step 2b):
226
+ * `confirm` lifts the live-photo gate, `retake` re-opens the identity checks
227
+ * that produced the data. Returns the updated hosted view; 409
228
+ * `identity_confirm_locked` when nothing is pending or no retake is left.
229
+ */
230
+ confirmIdentity(decision: IdentityConfirmDecision): Promise<HostedSessionView>;
231
+ /**
232
+ * The summary portrait (`identitySummary.portrait.available`) as a JPEG
233
+ * `Blob`, fetched with the session-token header (`Cache-Control: no-store`).
234
+ * Show it from memory (`URL.createObjectURL`, revoked when done) — never
235
+ * cache or store it.
236
+ */
237
+ identityPortrait(): Promise<Blob>;
238
+ /**
239
+ * Presign a Spaces PUT for a new pending object. `contentType` is stripped of
240
+ * MIME parameters defensively (the allowlist holds bare types; the engine's
241
+ * `clipMimeType` carries codec params) — PUT with the SAME bare type, or the
242
+ * signed-header check rejects the upload.
243
+ */
244
+ presign(kind: MediaKind, contentType: string, contentLength: number, options?: {
245
+ source?: "upload";
246
+ }): Promise<PresignUploadResult>;
247
+ /**
248
+ * D8: prefetch live-camera capture nonces when a camera capture STARTS, so the
249
+ * presigns that follow (`presignCapture`) need no extra round trip. Never
250
+ * throws; an older backend without the route simply leaves the pool empty.
251
+ */
252
+ armCapture(count?: number): void;
253
+ /**
254
+ * D8: presign a LIVE-CAMERA image / clip — like {@link presign}, plus the
255
+ * capture proof: a fresh single-use nonce (pooled by {@link armCapture}, else
256
+ * fetched now), the engine and the capture duration. When no nonce can be had
257
+ * (route absent, network) the presign goes out without a proof — the backend
258
+ * decides (`signal` flags it, `enforce` refuses it). Only the SDK's own capture
259
+ * flows call this; a picked file goes through {@link presign}.
260
+ */
261
+ presignCapture(kind: MediaKind, contentType: string, contentLength: number, context?: CaptureContext): Promise<PresignUploadResult>;
262
+ /** D8: one pooled (still fresh) nonce, else one fetched now; undefined when none can be had. */
263
+ private takeCaptureNonce;
264
+ /** D8: fetch `count` nonces into the pool (one request in flight at a time). Never throws. */
265
+ private fillCaptureNonces;
266
+ /**
267
+ * Bare PUT to the presigned Spaces URL: EXACTLY the signed headers — the
268
+ * declared Content-Type and the blob body. NO `x-session-token` (the
269
+ * signature IS the credential; an extra header breaks nothing but leaks the
270
+ * token to a third-party host) and no JSON envelope.
271
+ *
272
+ * `contentType` is param-stripped here too (idempotent for bare types): the
273
+ * presign strips internally, so a caller composing manually with the engine's
274
+ * parameterful `clipMimeType` would otherwise sign `video/webm` but PUT
275
+ * `video/webm;codecs=…` — a signed-header mismatch S3 rejects at runtime.
276
+ *
277
+ * Timeout: 15 min (`AbortSignal.timeout(900_000)`, matching the presign TTL)
278
+ * rather than the API calls' 30 s — a 15 MB clip on a slow link legitimately
279
+ * exceeds 30 s, but a stalled in-flight socket must still be bounded (the TTL
280
+ * alone only bounds when a PUT can START).
281
+ *
282
+ * Failures are ALWAYS typed: non-2xx throws {@link HostedApiError} with the
283
+ * client-synthesized `upload_failed` (message carries a truncated S3 body
284
+ * snippet — e.g. SignatureDoesNotMatch); a mid-transfer drop → `network_error`;
285
+ * the timeout → `timeout`.
286
+ */
287
+ uploadToSpaces(uploadUrl: string, blob: Blob, contentType: string): Promise<void>;
288
+ /** Finalize an upload: the backend sniffs + promotes; returns the PROMOTED key to submit. */
289
+ completeMedia(key: string): Promise<CompleteMediaResult>;
290
+ /**
291
+ * Submit one check. Sends `{input, forceOutcome?}` (SubmitCheckSchema) and the
292
+ * optional `x-idempotency-key` header. Returns the hosted view after the
293
+ * submission (Sekyro flows §8.2: with its `plan`) — render it.
294
+ */
295
+ submitCheck<T extends CheckType>(checkType: T, input: CheckInputByType[T], opts?: SubmitOptions): Promise<HostedSessionView>;
296
+ /**
297
+ * Convenience composition: presign → PUT → complete → submit, passing the
298
+ * PROMOTED key (from complete's response — never the pending presign key)
299
+ * into the check's media input field (`clipKey` for liveness, `imageKey` for
300
+ * face_match/doc_ocr). `extraInput` carries the remaining input fields
301
+ * (liveness `attestation`, doc_ocr `side`). The media content type is
302
+ * param-stripped ONCE and used for both presign and PUT, so the signed
303
+ * header always matches.
304
+ */
305
+ uploadAndSubmit<T extends MediaCheckType>(checkType: T, media: UploadMedia, extraInput: Omit<CheckInputByType[T], (typeof MEDIA_INPUT_FIELD)[T]>, opts?: SubmitOptions): Promise<HostedSessionView>;
306
+ /** The token's own sessionId — cached from getSession(), lazily bootstrapped. */
307
+ private ensureSessionId;
308
+ /**
309
+ * One API request: `${apiOrigin}/api/v2${path}`, `x-session-token` always,
310
+ * AbortSignal timeout (30 s default), `{success, data}` unwrap on 2xx, flat
311
+ * `{code, message}` → {@link HostedApiError} on non-2xx. EVERY failure is
312
+ * typed: a rejected fetch → `network_error`, the timeout → `timeout`, an
313
+ * unparseable 2xx body → `unknown_error` — the page never sees a raw
314
+ * TypeError/DOMException. Automatic retries: 409 `idempotency_in_progress`
315
+ * (bounded, short delay), and ONE retry of a 503 `server_busy` /
316
+ * `request_timeout` after its `Retry-After` (default 2 s, capped at 20 s, ±25 %
317
+ * jitter) when the call is safe to repeat: every GET, and a POST that sets
318
+ * `busyRetry`. The wait runs between requests, outside each request's timeout.
319
+ */
320
+ private api;
321
+ }
322
+
323
+ /** Luma at or above this counts as clipped / specular. */
324
+ declare const CLIPPED_LUMA = 250;
325
+ /** Laplacian-variance reference (same as the liveness gate's frame-quality SHARP_REF). */
326
+ declare const ICAO_SHARP_REF = 180;
327
+ interface LumaPlane {
328
+ data: Uint8Array;
329
+ width: number;
330
+ height: number;
331
+ }
332
+ /** Rec.601 luma of RGBA pixels. */
333
+ declare function lumaPlane(image: {
334
+ data: Uint8ClampedArray | Uint8Array;
335
+ width: number;
336
+ height: number;
337
+ }): LumaPlane;
338
+ interface RegionStats {
339
+ mean: number;
340
+ sd: number;
341
+ /** Fraction of pixels at or above {@link CLIPPED_LUMA}. */
342
+ clipped: number;
343
+ count: number;
344
+ }
345
+ /** Mean / SD / clipped fraction of a box, optionally excluding a second box. */
346
+ declare function regionStats(plane: LumaPlane, box: Box, exclude?: Box): RegionStats;
347
+ interface FaceLighting {
348
+ faceLuma: number;
349
+ /** Left-half / right-half mean luma (image halves, split at the nose). */
350
+ halfRatio: number;
351
+ clipped: number;
352
+ }
353
+ declare function faceLighting(plane: LumaPlane, g: FaceGeometry): FaceLighting | null;
354
+ /** Specular fraction inside both eye regions (spec §5.4 glasses glare). */
355
+ declare function eyeSpecular(plane: LumaPlane, g: FaceGeometry): number | null;
356
+ interface BackgroundStats {
357
+ luma: number;
358
+ sd: number;
359
+ /** Pixels measured — too few means the corners left the frame. */
360
+ count: number;
361
+ }
362
+ /**
363
+ * Background heuristic: the two top corners of the ICAO window (each 20 % wide,
364
+ * 25 % tall from 4 % down), minus the head (the face box widened by 40 % and
365
+ * extended to the top of the window for hair). `null` when nothing is left.
366
+ */
367
+ declare function backgroundStats(plane: LumaPlane, g: FaceGeometry): BackgroundStats | null;
368
+ /** Laplacian variance over the face core on a ≤96×96 grid, normalised 0..1 by {@link ICAO_SHARP_REF}. */
369
+ declare function faceSharpness(plane: LumaPlane, g: FaceGeometry): number | null;
370
+ /** Every pixel measure of one frame (`null` fields: not measurable). */
371
+ interface IcaoPixelStats {
372
+ lighting: FaceLighting | null;
373
+ eyeSpecular: number | null;
374
+ background: BackgroundStats | null;
375
+ sharpness: number | null;
376
+ }
377
+ declare function icaoPixelStats(plane: LumaPlane, g: FaceGeometry): IcaoPixelStats;
378
+
379
+ /** The client gate's criteria, in coaching priority order. */
380
+ declare const ICAO_GATE_CRITERIA: readonly ["face", "framing", "pose", "eyes", "mouth", "glare", "lighting", "background", "resolution", "sharpness"];
381
+ type IcaoGateCriterion = (typeof ICAO_GATE_CRITERIA)[number];
382
+ /** Coaching keys (copy `portrait.coach.<key>`). */
383
+ type IcaoCoachKey = "no_face" | "multiple_faces" | "center" | "too_close" | "pose" | "eyes" | "mouth" | "glare" | "lighting" | "lighting_side" | "background" | "resolution" | "hold_still" | "hold";
384
+ /** One frame as the gate sees it. Geometry in SOURCE (stream) pixels. */
385
+ interface IcaoFrameObservation {
386
+ frameWidth: number;
387
+ frameHeight: number;
388
+ /** Faces the landmarker found (the gate wants exactly one). */
389
+ faces: number;
390
+ geometry: FaceGeometry | null;
391
+ /** Facial transformation matrix (4×4, column-major), when produced. */
392
+ matrix?: readonly number[] | null;
393
+ /** Blendshape scores by category name (`eyeBlinkLeft`, `jawOpen`, …). */
394
+ blendshapes?: Readonly<Record<string, number>> | null;
395
+ /** Pixel heuristics on the analysis frame; `null` when not measured. */
396
+ stats?: IcaoPixelStats | null;
397
+ /**
398
+ * The background-uniformity check (segmenter, or the strip fallback), the
399
+ * latest measurement — it runs a few times per second, not on every frame.
400
+ * When present it decides the `background` criterion; `null` = not measurable.
401
+ */
402
+ backgroundCheck?: BackgroundUniformity | null;
403
+ }
404
+ interface IcaoCriterionState {
405
+ criterion: IcaoGateCriterion;
406
+ pass: boolean;
407
+ /** Passed continuously for `holdMs`. */
408
+ held: boolean;
409
+ /** A failing soft criterion the gate stopped waiting for. */
410
+ waived: boolean;
411
+ /** The measured value (degrees, ratio, luma, px…) — coaching / telemetry only. */
412
+ value: number | null;
413
+ /** Coaching key when failing. */
414
+ coach: IcaoCoachKey | null;
415
+ }
416
+ interface IcaoGateUpdate {
417
+ criteria: IcaoCriterionState[];
418
+ /** The one message to show (`hold` when everything passes and the gate is counting down). */
419
+ coach: IcaoCoachKey;
420
+ /** The lowest failing criterion (`null` when all pass or are waived). */
421
+ failing: IcaoGateCriterion | null;
422
+ /** 0..1 — held criteria, for a progress ring. */
423
+ progress: number;
424
+ /** Take the portrait frame now. */
425
+ ready: boolean;
426
+ /**
427
+ * The user's own eye-openness baseline, once known. Unit (D9d, everywhere): openness =
428
+ * 1 − the Landmarker's `eyeBlink{Left,Right}` blendshape; per frame the mean of the
429
+ * two eyes; the baseline is the `baseline.percentile` (0.8) quantile over the recent
430
+ * frontal, single-face frames. kyc-portrait compares the lower eye against it.
431
+ */
432
+ baseline: number | null;
433
+ /** The same quantile of each eye alone (2026-11-06): what each eye is judged against; `null` until known. */
434
+ baselines: {
435
+ left: number;
436
+ right: number;
437
+ } | null;
438
+ pose: HeadPose | null;
439
+ }
440
+ /** The on-device result submitted with the portrait (`gate`, §4.9): numbers only. */
441
+ interface IcaoGateSummary {
442
+ /** In (0, 1]: the gate's eye baseline (1 − blink blendshape; see {@link IcaoGateUpdate.baseline}). */
443
+ baselineEyeOpenness?: number;
444
+ /** In (0, 1], both or neither: the baseline of each eye, which selects kyc-portrait's per-eye rule. */
445
+ baselineEyeOpennessLeft?: number;
446
+ baselineEyeOpennessRight?: number;
447
+ criteria: Partial<Record<IcaoGateCriterion, {
448
+ pass: boolean;
449
+ value: number | null;
450
+ waived?: boolean;
451
+ }>>;
452
+ /**
453
+ * The device verdict with the server's criterion names — the submission's
454
+ * `gate.criteria`: `framing` folds into `resolution`, unmeasured criteria are
455
+ * omitted (occlusion always; background when the profile does not require it).
456
+ */
457
+ verdict?: Partial<Record<IcaoCriterion, boolean>>;
458
+ /** The background-uniformity measurement behind the `background` criterion (numbers only). */
459
+ backgroundCheck?: Omit<BackgroundUniformity, "pixels">;
460
+ }
461
+ interface Measured {
462
+ pass: boolean;
463
+ value: number | null;
464
+ coach: IcaoCoachKey | null;
465
+ /** Not measured on this frame (left out of the verdict). */
466
+ none?: true;
467
+ }
468
+ /** The criteria a profile sets limits for (conformance.json `criteria`). */
469
+ type IcaoJudgedCriterion = "pose" | "eyes" | "mouth" | "lighting" | "background" | "resolution";
470
+ /**
471
+ * One frame's measures in the server's units (conformance.json `measures`);
472
+ * `null` = not measured on this frame.
473
+ */
474
+ interface IcaoMeasures {
475
+ /** Degrees; `pitch` is RAW (before `pitchOffsetDeg`). `null` = no transformation matrix. */
476
+ pose: HeadPose | null;
477
+ /** The value shown for a pose without matrix (roll from the eye line). */
478
+ eyeLineRoll?: number;
479
+ /** Openness of each eye (1 − the `eyeBlink*` blendshape). */
480
+ eyes: {
481
+ left: number;
482
+ right: number;
483
+ } | null;
484
+ /** The person's eye-openness baseline; `null` = the absolute floor only. */
485
+ baseline: number | null;
486
+ /** The baseline of each eye: when known, each eye is judged against its own (a stable asymmetry passes). */
487
+ baselines?: {
488
+ left: number;
489
+ right: number;
490
+ } | null;
491
+ /** Blendshapes: `jawOpen`, the larger `mouthSmile*`, `mouthPucker`. */
492
+ mouth: {
493
+ jawOpen: number;
494
+ smile: number;
495
+ pucker: number;
496
+ } | null;
497
+ lighting: {
498
+ faceLuma: number;
499
+ halfRatio: number;
500
+ clipped: number;
501
+ } | null;
502
+ background: {
503
+ luma: number;
504
+ sd: number;
505
+ } | null;
506
+ /** The web background-uniformity check; when present (and enabled) it decides the background. */
507
+ uniformity?: Pick<BackgroundUniformity, "uniform" | "colorStd"> | null;
508
+ iod: number;
509
+ frameWidth: number;
510
+ frameHeight: number;
511
+ }
512
+ /**
513
+ * The per-criterion decision on one frame's measures — pure, the same rule as
514
+ * kyc-portrait and the native gates (packages/sekyro-contract/icao/conformance.json;
515
+ * limits are inclusive).
516
+ */
517
+ declare function judgeIcao(m: IcaoMeasures, t: ResolvedIcaoTuning): Record<IcaoJudgedCriterion, Measured>;
518
+ /** Openness of one eye from the Landmarker's blink blendshape (1 − blink). */
519
+ declare function eyeOpenness(blendshapes: Readonly<Record<string, number>> | null | undefined): {
520
+ left: number;
521
+ right: number;
522
+ blinkLeft: number;
523
+ blinkRight: number;
524
+ } | null;
525
+ /** The `p`-quantile (0..1) of a sample, nearest-rank. */
526
+ declare function percentile(values: readonly number[], p: number): number | null;
527
+ /** Score one frame against the limits. Pure; `baseline` and `baselines` are the eye baselines so far. */
528
+ declare function scoreFrame(frame: IcaoFrameObservation, t: ResolvedIcaoTuning, baseline: number | null, baselines?: {
529
+ left: number;
530
+ right: number;
531
+ } | null): {
532
+ results: Record<IcaoGateCriterion, Measured>;
533
+ pose: HeadPose | null;
534
+ };
535
+ /** One frame's mouth blendshapes, rounded to 3 decimals (diagnostics: numbers only). */
536
+ interface IcaoMouthScores {
537
+ jawOpen: number;
538
+ smile: number;
539
+ pucker: number;
540
+ }
541
+ /** The mouth scores of this gate run, for the staff diagnostics (`portrait_gate` report, 2026-11-06). */
542
+ interface IcaoGateScores {
543
+ /** Since the first frame with scores of this run. */
544
+ elapsedMs: number;
545
+ latest: IcaoMouthScores;
546
+ /** The smallest value of each score over the run: how close the person got to each limit. */
547
+ lowest: IcaoMouthScores;
548
+ }
549
+ interface IcaoGate {
550
+ push(frame: IcaoFrameObservation, nowMs: number): IcaoGateUpdate;
551
+ /** The run's mouth scores (`null` before a frame had any). A retake starts a new run. */
552
+ scores(): IcaoGateScores | null;
553
+ /** The last update (`null` before the first frame). */
554
+ last(): IcaoGateUpdate | null;
555
+ /** The submission's `gate` block from the last update. */
556
+ summary(): IcaoGateSummary;
557
+ /** Start the holds over (a retake). The eye baseline is kept: it describes the person. */
558
+ reset(): void;
559
+ }
560
+ interface IcaoGateOptions {
561
+ /** `alert`: coaching only — ready `alertGraceMs` after the face was accepted at the latest. Default `reject`. */
562
+ policy?: "reject" | "alert";
563
+ }
564
+ declare function createIcaoGate(t: ResolvedIcaoTuning, options?: IcaoGateOptions): IcaoGate;
565
+
566
+ export { faceGeometry as A, type BackgroundStats as B, CLIPPED_LUMA as C, faceLighting as D, faceSharpness as E, type FaceGeometry as F, icaoPixelStats as G, HostedClient as H, type IcaoCoachKey as I, icaoWindow as J, judgeIcao as K, type LumaPlane as L, type MediaCheckType as M, lumaPlane as N, percentile as O, type Point as P, portraitCropRegion as Q, type RegionStats as R, SEKYRO_SDK_HEADER as S, poseFromMatrix as T, type UploadMedia as U, regionStats as V, scoreFrame as W, windowOverflow as X, type HostedClientOptions as a, type SubmitOptions as b, type HeadPose as c, type IcaoCriterionState as d, type IcaoGateCriterion as e, type IcaoGateSummary as f, type IcaoGateUpdate as g, type Box as h, type FaceLighting as i, ICAO_CANVAS as j, ICAO_GATE_CRITERIA as k, ICAO_SHARP_REF as l, type IcaoFrameObservation as m, type IcaoGate as n, type IcaoGateOptions as o, type IcaoGateScores as p, type IcaoJudgedCriterion as q, type IcaoMeasures as r, stripMimeParams as s, type IcaoMouthScores as t, type IcaoPixelStats as u, backgroundStats as v, createIcaoGate as w, eyeLineRoll as x, eyeOpenness as y, eyeSpecular as z };
@@ -0,0 +1 @@
1
+ import{h as a,i as b,j as c,k as d,l as e,m as f}from"./chunk-53POX7U4.js";export{a as ICAO_GATE_CRITERIA,f as createIcaoGate,c as eyeOpenness,b as judgeIcao,d as percentile,e as scoreFrame};
@@ -0,0 +1,71 @@
1
+ import { f as IcaoGateSummary } from './icao-gate-DI8VePWd.js';
2
+ import { R as HostedSessionView, I as HostedIcaoPolicy, ar as PortraitIcaoInput } from './types-C_XP92JQ.js';
3
+
4
+ /**
5
+ * Every error code the hosted page can receive from the session-token surface.
6
+ * A closed string-literal union — switch over {@link KnownCode} with a `never`
7
+ * default arm for compile-checked exhaustiveness.
8
+ */
9
+ declare const KNOWN_CODES: readonly ["session_token_invalid", "session_token_required", "session_token_session_mismatch", "session_not_found", "rate_limit_exceeded", "consent_required", "session_not_active", "check_not_found", "check_already_finalized", "check_out_of_order", "check_type_unsupported", "force_outcome_forbidden", "attestation_invalid", "platform_unregistered", "app_attest_invalid", "too_many_challenges", "inference_unavailable", "mobile_required", "nni_locked", "document_nni_mismatch", "media_content_type_not_allowed", "media_too_large", "media_key_invalid", "media_key_forbidden", "media_not_found", "media_unreadable", "media_session_invalid", "idempotency_key_collision", "idempotency_in_progress", "idempotency_key_required", "validation_error", "internal_error", "unknown_error", "upload_failed", "network_error", "timeout", "nfc_outcome_not_accepted", "identity_confirm_required", "identity_confirm_locked", "choice_not_found", "choice_locked", "choice_option_unavailable", "step_not_on_path", "check_not_active", "sekyro_app_not_allowed", "sekyro_app_unverified", "id_number_locked", "document_id_number_mismatch", "simulated_capture_forbidden"];
10
+ /** Closed union of {@link KNOWN_CODES} — exhaustively switchable. */
11
+ type KnownCode = (typeof KNOWN_CODES)[number];
12
+ /** Narrow an arbitrary wire code to the known union (unknown codes stay `string`). */
13
+ declare function isKnownCode(code: string): code is KnownCode;
14
+ /** One machine-readable problem of an error's `details` (Sekyro flows spec §9.4). */
15
+ interface HostedErrorIssue {
16
+ code: string;
17
+ message: string;
18
+ /** The request field (`option`, `nodeId`, …). */
19
+ path?: string;
20
+ /** A node of the flow. */
21
+ nodeId?: string;
22
+ service?: string;
23
+ field?: string;
24
+ }
25
+ /** `details` of a flow error envelope (`choice_*`, `step_not_on_path`, …): the issues, and more per code. */
26
+ interface HostedErrorDetails {
27
+ issues: HostedErrorIssue[];
28
+ /** `override_widens_flow`: the widened fields. */
29
+ fields?: string[];
30
+ [key: string]: unknown;
31
+ }
32
+ /**
33
+ * Typed transport error: EVERY failure surfaces as one of these — non-2xx
34
+ * responses, rejected fetches, timeouts, and unparseable bodies alike. The
35
+ * hosted page never sees a raw TypeError/DOMException from the client.
36
+ *
37
+ * - `code` — the public envelope's `code`, or a client-synthesized fallback
38
+ * ('unknown_error' / 'upload_failed' / 'network_error' / 'timeout'). Typed
39
+ * `string` because the wire may grow codes; narrow with {@link isKnownCode}
40
+ * before an exhaustive switch.
41
+ * - `status` — the HTTP status, or 0 when no response arrived at all
42
+ * ('network_error' / 'timeout').
43
+ * - `retryAfterSeconds` — parsed from the `Retry-After` header when present
44
+ * (rate-limit 429s always set it).
45
+ * - `details` — the envelope's machine-readable `details` when present (flow
46
+ * errors: `issues[]`).
47
+ */
48
+ declare class HostedApiError extends Error {
49
+ readonly status: number;
50
+ readonly code: string;
51
+ readonly retryAfterSeconds?: number;
52
+ readonly details?: HostedErrorDetails;
53
+ constructor(args: {
54
+ status: number;
55
+ code: string;
56
+ message: string;
57
+ retryAfterSeconds?: number;
58
+ details?: HostedErrorDetails | undefined;
59
+ });
60
+ }
61
+
62
+ /** The session's ICAO policy and profile, or `null` when the selfie is not ICAO-checked. */
63
+ declare function icaoPolicyOf(view: Pick<HostedSessionView, "portrait"> | null | undefined): HostedIcaoPolicy | null;
64
+ /**
65
+ * The `gate` block of a `portrait_icao` body from the gate's summary: the eye
66
+ * baseline, the device verdict under the server's criterion names, and the
67
+ * background-uniformity numbers (telemetry).
68
+ */
69
+ declare function portraitIcaoGate(summary: IcaoGateSummary): NonNullable<PortraitIcaoInput["gate"]>;
70
+
71
+ export { HostedApiError as H, KNOWN_CODES as K, type HostedErrorDetails as a, type HostedErrorIssue as b, type KnownCode as c, isKnownCode as d, icaoPolicyOf as i, portraitIcaoGate as p };