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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/LICENSE +25 -16
  3. package/README.md +6 -8
  4. package/THIRD-PARTY-NOTICES.txt +154 -0
  5. package/dist/background-monitor-A7FKJOAG.js +1 -0
  6. package/dist/capture-session-doc-YBE3UMJJ.js +1 -0
  7. package/dist/{capture-session-v3-Okq0EQHG.d.ts → capture-session-v3-CQK-G-qX.d.ts} +72 -3
  8. package/dist/{capture-session-v3-UQU_WjO2.d.cts → capture-session-v3-Dvob-uH2.d.cts} +72 -3
  9. package/dist/chunk-4RS2YIL4.js +1 -0
  10. package/dist/chunk-7V2M6Y2W.js +1 -0
  11. package/dist/chunk-7ZCZY3ZP.js +1 -0
  12. package/dist/chunk-A3FUGHAH.js +2 -0
  13. package/dist/chunk-BPE5NSQ2.js +1 -0
  14. package/dist/chunk-CJHMFPL6.js +1 -0
  15. package/dist/chunk-DFTCAWMP.js +1 -0
  16. package/dist/chunk-DK5YPBDQ.js +1 -0
  17. package/dist/chunk-DQWW4OCK.js +1 -0
  18. package/dist/chunk-FHJ7HO3M.js +1 -0
  19. package/dist/chunk-FPXL63KZ.js +1 -0
  20. package/dist/chunk-G6LKLN4U.js +1 -0
  21. package/dist/chunk-GI3UFGRQ.js +1 -0
  22. package/dist/chunk-LQ7C44JG.js +1 -0
  23. package/dist/chunk-M43ET4NJ.js +1 -0
  24. package/dist/chunk-MXWLCDFX.js +1 -0
  25. package/dist/chunk-MY6EXEL2.js +1 -0
  26. package/dist/chunk-O5WKNZ2C.js +1 -0
  27. package/dist/chunk-OKWG3PVH.js +1 -0
  28. package/dist/chunk-POIQGEZM.js +1 -0
  29. package/dist/chunk-RI3E7GBN.js +1 -0
  30. package/dist/chunk-RNRFHUJA.js +1 -0
  31. package/dist/chunk-RVHAKRAI.js +1 -0
  32. package/dist/chunk-SMKCBUJL.js +1 -0
  33. package/dist/chunk-SXZCL5NO.js +1 -0
  34. package/dist/chunk-TDLIXFDT.js +1 -0
  35. package/dist/chunk-XLN5OT25.js +1 -0
  36. package/dist/chunk-YDQBVWXG.js +1 -0
  37. package/dist/chunk-YPG7CB4O.js +1 -0
  38. package/dist/client/index.cjs +1 -357
  39. package/dist/client/index.d.cts +13 -3
  40. package/dist/client/index.d.ts +13 -3
  41. package/dist/client/index.js +1 -15
  42. package/dist/core/index.cjs +1 -1639
  43. package/dist/core/index.d.cts +3 -3
  44. package/dist/core/index.d.ts +3 -3
  45. package/dist/core/index.js +1 -139
  46. package/dist/core/ocr/worker.bundle.js +42 -0
  47. package/dist/core/ocr/worker.cjs +42 -0
  48. package/dist/core/ocr/worker.d.cts +84 -0
  49. package/dist/core/ocr/worker.d.ts +84 -0
  50. package/dist/core/ocr/worker.js +41 -0
  51. package/dist/core/v3/detect-worker.cjs +1 -392
  52. package/dist/core/v3/detect-worker.d.cts +1 -1
  53. package/dist/core/v3/detect-worker.d.ts +1 -1
  54. package/dist/core/v3/detect-worker.js +1 -13
  55. package/dist/create-document-capture-T4APHJMY.js +1 -0
  56. package/dist/create-portrait-capture-B57GE5FU.js +1 -0
  57. package/dist/create-verification-C0AVIcVW.d.ts +2787 -0
  58. package/dist/create-verification-DoFpgzok.d.cts +2787 -0
  59. package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
  60. package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
  61. package/dist/detector-scanic-YCDNLCGV.js +1 -0
  62. package/dist/icao-gate-D8qm1O2t.d.cts +1655 -0
  63. package/dist/icao-gate-D8qm1O2t.d.ts +1655 -0
  64. package/dist/icao-gate-PWBMKRGC.js +1 -0
  65. package/dist/icao-tuning-4GGVX6B4.js +1 -0
  66. package/dist/index.cjs +1 -3030
  67. package/dist/index.d.cts +52 -6
  68. package/dist/index.d.ts +52 -6
  69. package/dist/index.js +1 -85
  70. package/dist/internal/index.cjs +1 -4439
  71. package/dist/internal/index.d.cts +352 -312
  72. package/dist/internal/index.d.ts +352 -312
  73. package/dist/internal/index.js +1 -657
  74. package/dist/keyframe-rank-YAJLYJYF.js +1 -0
  75. package/dist/landmarker-KB7LVXAU.js +1 -0
  76. package/dist/mrz-band-VYHOTDHY.js +1 -0
  77. package/dist/plan-runner-UBK4B4CG.js +1 -0
  78. package/dist/popup/index.cjs +1 -76
  79. package/dist/popup/index.js +1 -11
  80. package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
  81. package/dist/segmenter-USLNBX65.js +1 -0
  82. package/dist/turnstile-FATNZ4AG.js +1 -0
  83. package/package.json +25 -10
  84. package/sbom.cdx.json +195 -0
  85. package/dist/chunk-MWNFSNMP.js +0 -52
  86. package/dist/chunk-MWNFSNMP.js.map +0 -1
  87. package/dist/chunk-NILNKLK6.js +0 -50
  88. package/dist/chunk-NILNKLK6.js.map +0 -1
  89. package/dist/chunk-NWF46H7K.js +0 -359
  90. package/dist/chunk-NWF46H7K.js.map +0 -1
  91. package/dist/chunk-R3SJQHYU.js +0 -1173
  92. package/dist/chunk-R3SJQHYU.js.map +0 -1
  93. package/dist/chunk-TG5IE552.js +0 -1128
  94. package/dist/chunk-TG5IE552.js.map +0 -1
  95. package/dist/chunk-WY6U7AIK.js +0 -193
  96. package/dist/chunk-WY6U7AIK.js.map +0 -1
  97. package/dist/chunk-YVFF4Q4G.js +0 -327
  98. package/dist/chunk-YVFF4Q4G.js.map +0 -1
  99. package/dist/client/index.cjs.map +0 -1
  100. package/dist/client/index.js.map +0 -1
  101. package/dist/core/index.cjs.map +0 -1
  102. package/dist/core/index.js.map +0 -1
  103. package/dist/core/v3/detect-worker.cjs.map +0 -1
  104. package/dist/core/v3/detect-worker.js.map +0 -1
  105. package/dist/create-verification-BKc9NFQj.d.cts +0 -455
  106. package/dist/create-verification-DjcMZHAQ.d.ts +0 -455
  107. package/dist/detector-scanic-4C6IEW2K.js +0 -787
  108. package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
  109. package/dist/hosted-client-DJXq_CB9.d.cts +0 -449
  110. package/dist/hosted-client-DJXq_CB9.d.ts +0 -449
  111. package/dist/index.cjs.map +0 -1
  112. package/dist/index.js.map +0 -1
  113. package/dist/internal/index.cjs.map +0 -1
  114. package/dist/internal/index.js.map +0 -1
  115. package/dist/popup/index.cjs.map +0 -1
  116. package/dist/popup/index.js.map +0 -1
  117. package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
  118. package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
@@ -1,449 +0,0 @@
1
- /** Session lifecycle status (spec §4 two-field status/outcome model). */
2
- type SessionStatus = "created" | "in_progress" | "review_pending" | "completed" | "expired" | "failed";
3
- /** Terminal verdict, orthogonal to `status`; `null` until terminal/review. */
4
- type SessionOutcome = "approved" | "review" | "rejected";
5
- /** Per-check seven-state machine (spec §4.3). */
6
- type CheckState = "pending" | "input_required" | "processing" | "passed" | "failed" | "review" | "skipped";
7
- /** The frozen check-type vocabulary (CHECK_TYPES). `phone_otp` joined in Task 13. */
8
- type CheckType = "liveness" | "face_match" | "doc_ocr" | "population_registry" | "phone_otp";
9
- type LivenessReason = "no_face" | "media_unreadable" | "clip_too_short" | "spoof_detected" | "review_band";
10
- type PopulationReason = "nni_not_found" | "nni_invalid" | "registry_unavailable" | "result_from_cache";
11
- type FaceMatchReason = "no_face_source" | "no_face_reference" | "low_quality_reference" | "below_threshold" | "review_band";
12
- type DocReason = "side_missing" | "mrz_checksum_failed" | "unreadable" | "expired_document" | "authenticity_review" | "registry_mismatch";
13
- /**
14
- * phone_otp reasons (Task 13). All transient — the caller fixes them by
15
- * re-entering / resending: `otp_mismatch` (wrong or missing code),
16
- * `otp_expired` (code lapsed or no active send), `otp_send_failed` (the OTP
17
- * service was unreachable / a send returned no token).
18
- */
19
- type PhoneOtpReason = "otp_mismatch" | "otp_expired" | "otp_send_failed";
20
- /**
21
- * Any frozen reason code. The backend declares the field `string`, but the
22
- * taxonomy is frozen (do-not-drift) — the union IS the contract. NB: liveness
23
- * and face_match both carry `review_band`.
24
- */
25
- type CheckReason = LivenessReason | PopulationReason | FaceMatchReason | DocReason | PhoneOtpReason;
26
- /**
27
- * phone_otp DISPLAY-SAFE surface (Task 16). The backend stashes the OTP
28
- * service `verifToken` on the check's persisted outputs (the doc_ocr partial
29
- * mechanism), but that token is NEVER projected here — only the fields the
30
- * hosted OTP step renders. `numberSource` (org-authored config) drives the
31
- * send-phase UI (prefilled display vs entry); the rest appear ONLY once a send
32
- * has parked the check (`sentToMasked` present ⇒ verify phase).
33
- */
34
- interface HostedOtpView {
35
- /**
36
- * Per-step `config.numberSource` — drives the send-phase UI (prefilled
37
- * display vs entry). Narrowed to the frontend contract; the backend field is
38
- * `string` (dynamic config) but the projection only ever emits these three.
39
- */
40
- numberSource?: "prefilled" | "user_entered" | "prefilled_or_entered";
41
- /** Masked target the last send went to (e.g. `+222 ** ** 34 56`); absent pre-send. */
42
- sentToMasked?: string;
43
- /** Delivery channel of the last send. */
44
- channel?: "sms" | "whatsapp";
45
- /** ISO-8601 OTP expiry from the last send — drives the verify-phase countdown. */
46
- expiresAt?: string;
47
- }
48
- /**
49
- * Per-check projection in a {@link HostedSessionView} — the spec'd hosted step
50
- * shape. NEVER carries `calibratedScore` or the raw check `outputs`; the only
51
- * output-derived data is the phone_otp `HostedOtpView` display subset
52
- * (masked number/channel/expiry — never the verifToken).
53
- */
54
- interface HostedStepView {
55
- checkType: CheckType;
56
- state: CheckState;
57
- /** Frozen-taxonomy reason code explaining a `failed`/`review` state. */
58
- reason?: CheckReason;
59
- /**
60
- * Submissions the page may still make for this check (`max(0, cap - attempts)`).
61
- * Meaningful only while the check is executable — a finalized check may still
62
- * report more than 0, but re-submitting it 409s regardless.
63
- */
64
- attemptsRemaining: number;
65
- /** doc_ocr only: sides already accepted into the partial accumulator (['recto'] or ['verso']). */
66
- acceptedSides?: ("recto" | "verso")[];
67
- /** phone_otp only: the display-safe OTP send/config surface (never the verifToken). */
68
- otp?: HostedOtpView;
69
- }
70
- /** A locale the Sekyro-hosted voice clips are recorded in. */
71
- type HostedVoiceLocale = "ar" | "fr" | "en";
72
- /**
73
- * The session's Sekyro-hosted voice-guidance clips (the active clip set).
74
- *
75
- * `clips[locale]` maps a voice key (`fcv3.*`, the `@sekyro/react` voice-key
76
- * namespace) to an ABSOLUTE URL on the Sekyro assets host
77
- * (`https://assets.sekyro.ai/voice/<setId>/<locale>/<name>.mp3`; staging:
78
- * `assets-staging.sekyro.ai`). URLs are immutable per `setId`. A locale or key
79
- * may be missing — the player falls back to the device voice for it.
80
- *
81
- * A page with a Content-Security-Policy must allow the assets origin in
82
- * `media-src` for the clips to play (see the partner web-SDK guide, CSP note).
83
- */
84
- interface HostedVoiceView {
85
- /** Identifier of the active clip set (part of every clip URL). */
86
- setId: string;
87
- /** Per-locale map of voice key (`fcv3.*`) → absolute clip URL. */
88
- clips: {
89
- readonly [L in HostedVoiceLocale]?: Readonly<Record<string, string>>;
90
- };
91
- }
92
- /**
93
- * Token-addressed hosted-page bootstrap (`GET /hosted/session`). A separate
94
- * shape from the partner `SessionView`: `sessionId` instead of `id`,
95
- * hosted step hints, the consent flag, and the org display name (may be `''`
96
- * when the org lookup degrades).
97
- */
98
- interface HostedSessionView {
99
- sessionId: string;
100
- status: SessionStatus;
101
- outcome: SessionOutcome | null;
102
- steps: HostedStepView[];
103
- /** ISO-8601 timestamp (Date on the server, string on the wire). */
104
- expiresAt: string;
105
- consentRecorded: boolean;
106
- orgName: string;
107
- /**
108
- * The FIRST allowlisted web-SDK origin of the owning org (Task 12), or null
109
- * when none is registered. The hosted page posts the SDK popup postMessage
110
- * events (event name + sessionId ONLY) to exactly this origin — never `'*'`.
111
- * The backend declares it required (`string | null`); optional here so
112
- * pre-Task-12 consumers/fixtures stay valid (additive field, always on the
113
- * wire from Task 12 onward).
114
- */
115
- sdkOrigin?: string | null;
116
- /**
117
- * Cloudflare Turnstile site key the browser must solve an execute-mode
118
- * challenge against before submitting `liveness` (Plan A Task 5): the org's
119
- * own widget key when the request origin is one of the org's allowlisted SDK
120
- * origins, else the hosted widget key, else `null`. `null` means the session
121
- * cannot be attested from the browser — the SDK sends `{sandbox: true}`,
122
- * which the backend honours ONLY on sandbox sessions (fails closed on live).
123
- */
124
- turnstileSiteKey: string | null;
125
- /**
126
- * The session was minted with a server-bound NNI (`POST /sessions`
127
- * `input.nni`, Plan A Task 2): `population_registry` is submitted with an
128
- * EMPTY input and the backend reads the sealed value. `false` means the
129
- * person must supply the NNI (hosted population form); the SDK never submits
130
- * the registry check on an unbound session. The VALUE is never exposed. The
131
- * backend declares it required; optional here so pre-Task-8 fixtures stay
132
- * valid (additive field, always on the wire from Task 8 onward).
133
- */
134
- nniBound?: boolean;
135
- /**
136
- * The Sekyro-hosted voice-guidance clips of this session, or `null` when no
137
- * clip set is active (the device voice is used). Optional: older APIs omit
138
- * the field — treat absent like `null`.
139
- */
140
- voice?: HostedVoiceView | null;
141
- }
142
- /** `POST /hosted/consent` result — 201 on first record, 200 `{alreadyRecorded: true}` on replay. */
143
- interface RecordConsentResult {
144
- alreadyRecorded: boolean;
145
- }
146
- /** Consent locale — the page's `[locale]` URL segment echoed back (HostedConsentSchema picklist). */
147
- type ConsentLocale = "ar" | "fr" | "en";
148
- /** Per-check projection in a {@link SessionView} — enum/id only, never civil data. */
149
- interface SessionStepView {
150
- checkType: CheckType;
151
- state: CheckState;
152
- reason?: CheckReason;
153
- calibratedScore?: number;
154
- }
155
- /**
156
- * Client-facing session projection returned by
157
- * `POST /sessions/:id/checks/:checkType`. Whitelist-only — never the client token.
158
- */
159
- interface SessionView {
160
- id: string;
161
- status: SessionStatus;
162
- outcome: SessionOutcome | null;
163
- steps: SessionStepView[];
164
- /** ISO-8601 timestamp (Date on the server, string on the wire). */
165
- expiresAt: string;
166
- /** ISO-8601 timestamp (Date on the server, string on the wire). */
167
- createdAt?: string;
168
- }
169
- /** Media class — selects size cap, MIME allowlist and promoted prefix (media.policy.ts). */
170
- type MediaKind = "image" | "clip";
171
- /**
172
- * Body of `POST /sessions/:id/media`. `contentType`/`contentLength` are the
173
- * exact values SIGNED into the presigned PUT — the PUT must send them verbatim.
174
- * Allowlists (media.policy.ts): image → image/jpeg | image/png (5 MB cap);
175
- * clip → video/webm | video/mp4 (15 MB cap). BARE types only — no `;codecs=` params.
176
- */
177
- interface PresignRequest {
178
- kind: MediaKind;
179
- contentType: string;
180
- contentLength: number;
181
- }
182
- /** Result of a presign — the presigned PUT URL plus the pending object key. */
183
- interface PresignUploadResult {
184
- key: string;
185
- uploadUrl: string;
186
- /** Presign TTL in seconds (900 = 15 min). */
187
- expiresIn: number;
188
- }
189
- /** Result of `POST /sessions/:id/media/complete` — the PROMOTED (class-prefixed) key. */
190
- interface CompleteMediaResult {
191
- ready: true;
192
- /** e.g. `clips/{sessionId}/{uuid}` or `doc-images/{sessionId}/{uuid}` — submit THIS key, not the pending one. */
193
- key: string;
194
- }
195
- /**
196
- * Liveness attestation bag (attestation-verifier.service.ts). The web SDK sends
197
- * `{channel: 'hosted_web', siteKey, turnstileToken}` — `siteKey` echoes the
198
- * `HostedSessionView.turnstileSiteKey` the challenge was rendered with, so the
199
- * backend picks the matching widget secret deterministically (Turnstile tokens
200
- * are single-use: siteverify runs exactly once, never "org then global").
201
- * `sandbox: true` is honored only on sandbox sessions; `signature` is the
202
- * future native-SDK channel.
203
- */
204
- interface AttestationInput {
205
- sandbox?: boolean;
206
- signature?: string;
207
- channel?: "hosted_web";
208
- turnstileToken?: string;
209
- /** The Turnstile site key the token was minted with (selects the verifying secret). */
210
- siteKey?: string;
211
- }
212
- /** liveness executor input: a promoted `clips/…` key + optional attestation. */
213
- interface LivenessInput {
214
- clipKey: string;
215
- attestation?: AttestationInput;
216
- /** Declared capture channel — the liveness band is mobile-calibrated, so the
217
- * backend clamps non-mobile verdicts to review (uncalibrated_capture_channel).
218
- * Client-declared by design (not a security boundary); absent = legacy
219
- * clients, treated as mobile server-side during the rollout window. */
220
- captureChannel?: 'mobile' | 'desktop';
221
- /** Capture metadata (engine, dimensions, clip length, face-capture timing)
222
- * — the backend's allowlisted, non-PII `capture` block (session insights). */
223
- capture?: LivenessCaptureInput;
224
- }
225
- /** `LivenessInput.capture`: what the SDK's `captured` event measured. All ms are whole, ≥ 0. */
226
- interface LivenessCaptureInput {
227
- engine?: 'v1' | 'v3';
228
- width?: number;
229
- height?: number;
230
- clipMs?: number;
231
- cameraReadyMs?: number;
232
- faceAcquireMs?: number;
233
- captureMs?: number;
234
- }
235
- /**
236
- * population_registry adapter input. `nni` is the 10-digit NNI for an UNBOUND
237
- * session; a session minted with a server-side `input.nni` is BOUND to it
238
- * (Plan A Task 2) — the browser submits `{}` and the backend reads the sealed
239
- * value. Sending a DIFFERENT nni on a bound session answers 409 `nni_locked`.
240
- */
241
- interface PopulationInput {
242
- nni?: string;
243
- }
244
- /** face_match executor input: a promoted `doc-images/…` key (the source selfie frame). */
245
- interface FaceMatchInput {
246
- imageKey: string;
247
- }
248
- /** Document side (docs.types.ts DocSide). */
249
- type DocSide = "recto" | "verso" | "single";
250
- /** doc_ocr executor input: a promoted `doc-images/…` key + which side it shows. */
251
- interface DocOcrInput {
252
- imageKey: string;
253
- side: DocSide;
254
- }
255
- /**
256
- * phone_otp executor input (Task 13): a two-phase check. `send` dispatches (or
257
- * resends) an OTP — resolving the number from the trusted server-side prefill
258
- * or the user-entered `phone` per the step's `numberSource`; `verify` checks
259
- * the entered `code` against the parked token. `phone` is IGNORED for a
260
- * `prefilled` step (a client number is never trusted as "prefilled").
261
- */
262
- interface PhoneOtpInput {
263
- /** Phase selector: `send` dispatches/resends, `verify` checks the code. Defaults to `send`. */
264
- action: "send" | "verify";
265
- /** USER-entered E.164 number (`user_entered` / `prefilled_or_entered` sends only). */
266
- phone?: string;
267
- /** The code the user typed — `verify` only. */
268
- code?: string;
269
- /** Delivery channel override for `send` (default `sms`). */
270
- channel?: "sms" | "whatsapp";
271
- /** OTP message locale override for `send`. */
272
- locale?: "ar" | "fr" | "en";
273
- }
274
- /** Per-check-type submission input shapes, keyed by the frozen vocabulary. */
275
- interface CheckInputByType {
276
- liveness: LivenessInput;
277
- face_match: FaceMatchInput;
278
- doc_ocr: DocOcrInput;
279
- population_registry: PopulationInput;
280
- phone_otp: PhoneOtpInput;
281
- }
282
- /**
283
- * Body of `POST /sessions/:id/checks/:checkType` (SubmitCheckSchema).
284
- * `forceOutcome` is SANDBOX-ONLY (plan D-C) — a live session rejects it with
285
- * 403 `force_outcome_forbidden`.
286
- */
287
- interface SubmitCheckBody {
288
- input?: Record<string, unknown>;
289
- forceOutcome?: "pass" | "fail";
290
- }
291
-
292
- /**
293
- * Strip MIME parameters: `video/webm;codecs=vp8,opus` → `video/webm`.
294
- *
295
- * The capture engine (Task 4) emits `clipMimeType` WITH codec parameters, but
296
- * the presign allowlist holds BARE types only (['video/webm','video/mp4'] /
297
- * ['image/jpeg','image/png']) and the presigned PUT signs the exact declared
298
- * Content-Type. Exported so pages can normalize once and stay byte-consistent
299
- * between presign and PUT.
300
- */
301
- declare function stripMimeParams(contentType: string): string;
302
- /** Media-bearing check types → the input field the promoted key goes into. */
303
- declare const MEDIA_INPUT_FIELD: {
304
- readonly liveness: "clipKey";
305
- readonly face_match: "imageKey";
306
- readonly doc_ocr: "imageKey";
307
- };
308
- /** Check types that take an uploaded media key (population_registry does not). */
309
- type MediaCheckType = keyof typeof MEDIA_INPUT_FIELD;
310
- interface SubmitOptions {
311
- /**
312
- * Sent as `x-idempotency-key` (the header IdempotencyInterceptor reads).
313
- * One key per LOGICAL submit — a flaky-network retry with the same key
314
- * replays the first response without burning another attempt.
315
- */
316
- idempotencyKey?: string;
317
- /** SANDBOX-ONLY deterministic override (plan D-C); a live session 403s it. */
318
- forceOutcome?: "pass" | "fail";
319
- }
320
- interface UploadMedia {
321
- kind: MediaKind;
322
- blob: Blob;
323
- /** May carry codec params (engine `clipMimeType`) — stripped before presign AND PUT. */
324
- contentType: string;
325
- }
326
- interface HostedClientOptions {
327
- /** API origin, e.g. `https://api.sekyro.ai` — paths are `${apiOrigin}/api/v2/...`. */
328
- apiOrigin: string;
329
- /** The raw session token from the hosted URL (short code; legacy `cst_` during its TTL) — sent as `x-session-token` on every API call. */
330
- sessionToken: string;
331
- /** Injection seam (tests / non-window contexts). Defaults to `globalThis.fetch`. */
332
- fetch?: typeof globalThis.fetch;
333
- /** Per-request timeout for API calls (NOT the Spaces PUT). Default 30 000 ms. */
334
- requestTimeoutMs?: number;
335
- /**
336
- * Tuning for the ONLY automatic retry the client performs: 409
337
- * `idempotency_in_progress` (a concurrent identical request is mid-flight
338
- * server-side; the real response lands once it finishes). `attempts` counts
339
- * retries AFTER the first try. Defaults: 5 × 400 ms.
340
- */
341
- inProgressRetry?: {
342
- attempts?: number;
343
- delayMs?: number;
344
- };
345
- }
346
- /**
347
- * Hand-authored typed client for the five session-token endpoints:
348
- *
349
- * GET /api/v2/hosted/session → {@link getSession}
350
- * POST /api/v2/hosted/consent → {@link recordConsent}
351
- * POST /api/v2/sessions/:id/media → {@link presign}
352
- * POST /api/v2/sessions/:id/media/complete → {@link completeMedia}
353
- * POST /api/v2/sessions/:id/checks/:checkType → {@link submitCheck}
354
- *
355
- * plus the bare presigned Spaces PUT ({@link uploadToSpaces}) and the
356
- * presign→PUT→complete→submit composition ({@link uploadAndSubmit}).
357
- *
358
- * Envelopes (verified against sessions-docs.e2e-spec.ts):
359
- * - success: `{success: true, data}` — unwrapped here, methods return the payload;
360
- * - error: flat `{code, message}` → thrown as {@link HostedApiError}.
361
- *
362
- * The media/checks routes are `:id`-addressed while the token itself is the
363
- * only credential the page starts with — the client learns its sessionId from
364
- * `GET /hosted/session` (token-addressed) and lazily bootstraps it when a
365
- * `:id` route is called first.
366
- *
367
- * No automatic retry EXCEPT bounded short-delay retry on 409
368
- * `idempotency_in_progress`. Everything else — including 429 with its parsed
369
- * `retryAfterSeconds` — is surfaced to the page to handle.
370
- */
371
- declare class HostedClient {
372
- private readonly apiOrigin;
373
- private readonly sessionToken;
374
- private readonly fetchImpl;
375
- private readonly requestTimeoutMs;
376
- private readonly retryAttempts;
377
- private readonly retryDelayMs;
378
- private sessionId;
379
- private bootstrap;
380
- constructor(opts: HostedClientOptions);
381
- /** Token-addressed bootstrap — the hosted page's first call. Caches the sessionId. */
382
- getSession(): Promise<HostedSessionView>;
383
- /**
384
- * Record consent once (201; an idempotent replay answers 200 with
385
- * `alreadyRecorded: true`). Until recorded, media presign/complete AND check
386
- * submission answer 409 `consent_required`.
387
- */
388
- recordConsent(locale: ConsentLocale): Promise<RecordConsentResult>;
389
- /**
390
- * Presign a Spaces PUT for a new pending object. `contentType` is stripped of
391
- * MIME parameters defensively (the allowlist holds bare types; the engine's
392
- * `clipMimeType` carries codec params) — PUT with the SAME bare type, or the
393
- * signed-header check rejects the upload.
394
- */
395
- presign(kind: MediaKind, contentType: string, contentLength: number): Promise<PresignUploadResult>;
396
- /**
397
- * Bare PUT to the presigned Spaces URL: EXACTLY the signed headers — the
398
- * declared Content-Type and the blob body. NO `x-session-token` (the
399
- * signature IS the credential; an extra header breaks nothing but leaks the
400
- * token to a third-party host) and no JSON envelope.
401
- *
402
- * `contentType` is param-stripped here too (idempotent for bare types): the
403
- * presign strips internally, so a caller composing manually with the engine's
404
- * parameterful `clipMimeType` would otherwise sign `video/webm` but PUT
405
- * `video/webm;codecs=…` — a signed-header mismatch S3 rejects at runtime.
406
- *
407
- * Timeout: 15 min (`AbortSignal.timeout(900_000)`, matching the presign TTL)
408
- * rather than the API calls' 30 s — a 15 MB clip on a slow link legitimately
409
- * exceeds 30 s, but a stalled in-flight socket must still be bounded (the TTL
410
- * alone only bounds when a PUT can START).
411
- *
412
- * Failures are ALWAYS typed: non-2xx throws {@link HostedApiError} with the
413
- * client-synthesized `upload_failed` (message carries a truncated S3 body
414
- * snippet — e.g. SignatureDoesNotMatch); a mid-transfer drop → `network_error`;
415
- * the timeout → `timeout`.
416
- */
417
- uploadToSpaces(uploadUrl: string, blob: Blob, contentType: string): Promise<void>;
418
- /** Finalize an upload: the backend sniffs + promotes; returns the PROMOTED key to submit. */
419
- completeMedia(key: string): Promise<CompleteMediaResult>;
420
- /**
421
- * Submit one check. Sends `{input, forceOutcome?}` (SubmitCheckSchema) and the
422
- * optional `x-idempotency-key` header. Returns the whitelisted SessionView.
423
- */
424
- submitCheck<T extends CheckType>(checkType: T, input: CheckInputByType[T], opts?: SubmitOptions): Promise<SessionView>;
425
- /**
426
- * Convenience composition: presign → PUT → complete → submit, passing the
427
- * PROMOTED key (from complete's response — never the pending presign key)
428
- * into the check's media input field (`clipKey` for liveness, `imageKey` for
429
- * face_match/doc_ocr). `extraInput` carries the remaining input fields
430
- * (liveness `attestation`, doc_ocr `side`). The media content type is
431
- * param-stripped ONCE and used for both presign and PUT, so the signed
432
- * header always matches.
433
- */
434
- uploadAndSubmit<T extends MediaCheckType>(checkType: T, media: UploadMedia, extraInput: Omit<CheckInputByType[T], (typeof MEDIA_INPUT_FIELD)[T]>, opts?: SubmitOptions): Promise<SessionView>;
435
- /** The token's own sessionId — cached from getSession(), lazily bootstrapped. */
436
- private ensureSessionId;
437
- /**
438
- * One API request: `${apiOrigin}/api/v2${path}`, `x-session-token` always,
439
- * AbortSignal timeout (30 s default), `{success, data}` unwrap on 2xx, flat
440
- * `{code, message}` → {@link HostedApiError} on non-2xx. EVERY failure is
441
- * typed: a rejected fetch → `network_error`, the timeout → `timeout`, an
442
- * unparseable 2xx body → `unknown_error` — the page never sees a raw
443
- * TypeError/DOMException. The ONLY automatic retry is 409
444
- * `idempotency_in_progress` (bounded, short delay).
445
- */
446
- private api;
447
- }
448
-
449
- export { type AttestationInput as A, type SubmitOptions as B, type CheckReason as C, type DocReason as D, stripMimeParams as E, type FaceMatchReason as F, type HostedOtpView as H, type LivenessReason as L, type MediaCheckType as M, type PhoneOtpReason as P, type RecordConsentResult as R, type SessionOutcome as S, type UploadMedia as U, type CheckState as a, type CheckType as b, type HostedSessionView as c, type HostedStepView as d, type HostedVoiceLocale as e, type HostedVoiceView as f, type PopulationReason as g, type SessionStatus as h, HostedClient as i, type SessionView as j, type CheckInputByType as k, type CompleteMediaResult as l, type ConsentLocale as m, type DocOcrInput as n, type DocSide as o, type FaceMatchInput as p, type HostedClientOptions as q, type LivenessCaptureInput as r, type LivenessInput as s, type MediaKind as t, type PhoneOtpInput as u, type PopulationInput as v, type PresignRequest as w, type PresignUploadResult as x, type SessionStepView as y, type SubmitCheckBody as z };