@sekyro/node 0.1.0-rc.1 → 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.
@@ -0,0 +1,1669 @@
1
+ /**
2
+ * Wire-level enums and shapes of the Sekyro AI partner API (`/api/v2`). These
3
+ * mirror the backend's frozen partner contract; they are plain string unions so
4
+ * a newer API value never throws at runtime — it simply widens the type in the
5
+ * next SDK release.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /** Session lifecycle status. @public */
10
+ type SessionStatus = "created" | "in_progress" | "review_pending" | "completed" | "expired" | "failed";
11
+ /**
12
+ * Terminal verdict, orthogonal to {@link SessionStatus}. `null` until the session
13
+ * reaches a terminal status; `review` when a human reviewer must adjudicate.
14
+ * @public
15
+ */
16
+ type SessionOutcome = "approved" | "review" | "rejected";
17
+ /**
18
+ * What a finished session proved: `1` a live, real person (human), `2` that
19
+ * person's identity (document, chip, registry or supplied data bound to the
20
+ * face), `3` an identity corroborated by an independent source. `0` on a
21
+ * rejected session.
22
+ * @public
23
+ */
24
+ type VerificationLevel = 0 | 1 | 2 | 3;
25
+ /**
26
+ * How a session's {@link VerificationLevel} was proved: `live_only` (liveness
27
+ * only), `live_unique` (liveness plus a duplicate search), and the
28
+ * `*_biometric` values, where a face match bound the person to a document,
29
+ * its chip, the registry record or partner-supplied identity data, and
30
+ * `eid_authenticated`, where the person signed in with a national digital
31
+ * identity (level 3 without a Sekyro selfie).
32
+ * @public
33
+ */
34
+ type VerificationAssurance = "live_only" | "live_unique" | "document_biometric" | "chip_biometric" | "registry_biometric" | "supplied_biometric" | "eid_authenticated";
35
+ /** The one billing unit a finished session consumed. @public */
36
+ type VerificationUnit = "human_verification" | "identity_verification";
37
+ /** The lowest and highest {@link VerificationLevel} the session's flow can reach. @public */
38
+ interface LevelTarget {
39
+ min: VerificationLevel;
40
+ max: VerificationLevel;
41
+ }
42
+ /**
43
+ * Device and network risk facts of a finished session (booleans and a level
44
+ * word, never scores).
45
+ * @public
46
+ */
47
+ interface ResultRisk {
48
+ level: "low" | "medium" | "high";
49
+ vpn: boolean;
50
+ ipDocumentMismatch: boolean;
51
+ deviceTampered: boolean;
52
+ }
53
+ /**
54
+ * What the liveness step verified about the capture itself: the device
55
+ * attestation, the capture proof and the injection signals.
56
+ * @public
57
+ */
58
+ interface ResultCheckProofs {
59
+ attestation: "verified" | "missing" | "failed";
60
+ captureProof: "verified" | "missing";
61
+ injectionSignals: "clear" | "flagged";
62
+ }
63
+ /**
64
+ * How a session proved the person's minimum age: `estimated` (the age check
65
+ * (selfie) step estimated the face over the threshold by a safety margin), or
66
+ * from identity data: `document`, `chip`, `registry` or `eid`.
67
+ * @public
68
+ */
69
+ type AgeMethod = "estimated" | "document" | "chip" | "registry" | "eid";
70
+ /**
71
+ * The age answer of a session whose flow sets a minimum age. `over` is the
72
+ * flow's minimum age (the threshold), never the person's age. `estimate`
73
+ * (years, one decimal) and `sigma` (its spread in years) are present only on
74
+ * the API session and webhooks, and only when the age check (selfie) step's
75
+ * "Keep and show the estimated age" setting is on; the result token never
76
+ * carries them.
77
+ * @public
78
+ */
79
+ interface AgeResult {
80
+ over: number;
81
+ method: AgeMethod;
82
+ estimate?: number;
83
+ sigma?: number;
84
+ }
85
+ /** Another subject the person's face already matched (duplicate search). @public */
86
+ interface ResultDuplicate {
87
+ subjectId: string;
88
+ externalRef?: string;
89
+ }
90
+ /**
91
+ * How a `subject.reuse` session runs: `recheck` verifies the same person
92
+ * again (liveness and face match against the stored photo), `step_up` raises
93
+ * the subject to identity level with a flow that proves level 2 on every path.
94
+ * @public
95
+ */
96
+ type SubjectReuseMode = "recheck" | "step_up";
97
+ /**
98
+ * Where the hosted flow sends the person when the session ends: an `https`
99
+ * URL on one of the app's web origins, or the app's `sekyro-<slug>://` scheme.
100
+ * `state` (up to 256 characters) is echoed back on the redirect.
101
+ * @public
102
+ */
103
+ interface SessionLinkInput {
104
+ returnUrl?: string;
105
+ state?: string;
106
+ }
107
+ /**
108
+ * How the person proves their identity on an optional-document app: type the
109
+ * national number, or photograph the document (`document_chip`: native NFC clients only).
110
+ * `national_eid`: the country's national eID (e.g. Houwiyeti for Mauritania),
111
+ * offered when the app's profile turns the national eID on.
112
+ * @public
113
+ */
114
+ type IdentityMethod = "national_number" | "document_photo" | "document_chip" | "national_eid";
115
+ /** The verification checks a flow may contain. @public */
116
+ type CheckType = "liveness" | "face_match" | "doc_ocr" | "population_registry" | "phone_otp" | "nfc_chip" | "email_otp" | "portrait_icao" | "eid_auth";
117
+ /** Per-check execution state within a session. @public */
118
+ type CheckState = "pending" | "input_required" | "processing" | "passed" | "failed" | "review" | "skipped";
119
+ /**
120
+ * Why a session was stopped by a profile-v2 policy gate rather than by a
121
+ * failed check:
122
+ * - `location_not_allowed` — the end user's IP location is not allowed for the app;
123
+ * - `anonymizer_blocked` — an anonymizer (VPN / proxy / Tor) was detected while the app blocks them;
124
+ * - `capture_tampered` — the device reported a tampered capture (virtual
125
+ * camera, hooking, emulator…) while the app's `device.tamper` is `block`;
126
+ * - `device_velocity_exceeded` — the device already verified more different
127
+ * people than `device.velocity` allows, with `action: 'block'`;
128
+ * - `device_cooldown` — the device had too many rejected sessions
129
+ * (`cooldown` tiers); {@link Session.retryAfter} says when it may try again.
130
+ * Not billed.
131
+ * @public
132
+ */
133
+ type SessionFailureReason = "location_not_allowed" | "anonymizer_blocked" | "capture_tampered" | "device_velocity_exceeded" | "device_cooldown";
134
+ /**
135
+ * Profile-v2 decision-mode reasons a check's {@link SessionStep.reason} may
136
+ * carry when the app decides automatically (`decisions.mode: 'automatic'`)
137
+ * instead of routing to human review. All are retryable within the step's
138
+ * attempts: `liveness_inconclusive` (liveness middle band),
139
+ * `match_inconclusive` (face match middle band on every reference),
140
+ * `document_authenticity` (doc_ocr authenticity warning — retake the original)
141
+ * and `mobile_required` (liveness captured on a desktop — continue on a phone;
142
+ * not billed). Every inconclusive attempt is billed.
143
+ * @public
144
+ */
145
+ type DecisionReason = "liveness_inconclusive" | "match_inconclusive" | "document_authenticity" | "mobile_required";
146
+ /**
147
+ * Profile-v2 eligibility reasons a check's {@link SessionStep.reason} may carry:
148
+ * `document_type_not_accepted` (doc_ocr; the person may pick another
149
+ * document), `nationality_not_allowed` and `underage` (doc_ocr or
150
+ * population_registry; terminal), and `age_unverifiable` (the app sets a
151
+ * minimum age but the birth date could not be read — doc_ocr: retryable with
152
+ * a clearer photo; population_registry: terminal).
153
+ * @public
154
+ */
155
+ type EligibilityReason = "document_type_not_accepted" | "nationality_not_allowed" | "underage" | "age_unverifiable" | "underage_estimated";
156
+ /**
157
+ * Why a profile-v2 policy ended a session: a session-level
158
+ * {@link SessionFailureReason} (location / anonymizer gate), or the failed
159
+ * check's policy reason — an {@link EligibilityReason} or
160
+ * `document_id_number_mismatch` (the document belongs to someone other than the
161
+ * ID number the session was created for; `document_nni_mismatch` is its former
162
+ * name, still sent until the API switches to the new names), or `camera_unavailable` (spec 2026-10-29 §3.4: the person had no usable camera,
163
+ * so the live step ended without a capture; the session is rejected at level 0 unless your flow has a fallback).
164
+ * @public
165
+ */
166
+ type PolicyFailureReason = SessionFailureReason | EligibilityReason | "document_id_number_mismatch" | "document_nni_mismatch" | "camera_unavailable";
167
+ /**
168
+ * The ID-number reasons a check's {@link SessionStep.reason} may carry (person data
169
+ * spec Appendix A.2), each under its generic name and its former Mauritanian name:
170
+ * `id_number_invalid` (`nni_invalid`: the number fails its country's rule),
171
+ * `registry_record_not_found` (`nni_not_found`: no registry record for the number),
172
+ * `id_number_recheck` (`nni_recheck`: the number must be checked again) and
173
+ * `document_id_number_mismatch` (`document_nni_mismatch`). The API sends the former
174
+ * names until it switches to the generic ones; handle both.
175
+ * @public
176
+ */
177
+ type IdNumberReason = "id_number_invalid" | "nni_invalid" | "registry_record_not_found" | "nni_not_found" | "id_number_recheck" | "nni_recheck" | "document_id_number_mismatch" | "document_nni_mismatch";
178
+ /**
179
+ * Why the person had no camera (spec 2026-10-29 §3.4, 2026-10-30), when the SDK said: `denied` (the
180
+ * person refused camera access) or `no_camera` (no usable camera: none found, an insecure page or a
181
+ * browser that cannot capture). A detail under `failureReason: "camera_unavailable"`, never a reason of its own.
182
+ * @public
183
+ */
184
+ type CameraUnavailableCause = "denied" | "no_camera";
185
+ /**
186
+ * Profile-v2 matching reasons a check's {@link SessionStep.reason} may carry
187
+ * when the data you sent in {@link CreateSessionInput.subject} differs from the
188
+ * reference identity: `name_mismatch`, `birth_date_mismatch`,
189
+ * `nationality_mismatch` (doc_ocr or population_registry) and
190
+ * `document_number_mismatch` (doc_ocr). All are final.
191
+ * @public
192
+ */
193
+ type MatchReason = "name_mismatch" | "birth_date_mismatch" | "nationality_mismatch" | "document_number_mismatch";
194
+ /**
195
+ * Face-match probe-binding reason a `face_match` {@link SessionStep.reason} may
196
+ * carry (SDK spec §4.10): `probe_not_from_liveness` — the face image isn't the
197
+ * person in the liveness clip. Retryable within the step's attempts (the
198
+ * person re-takes the liveness capture); billed.
199
+ * @public
200
+ */
201
+ type ProbeBindingReason = "probe_not_from_liveness";
202
+ /**
203
+ * The languages the person being verified sees (hosted flow and SDK screens; spec 2026-10-29 §9). `ar`, `fr` and `en`
204
+ * carry every screen; `es`, `pt` and `de` carry the Human verification screens and show English elsewhere. SMS and
205
+ * email messages stay in `ar`, `fr` or `en` (English for the three others).
206
+ * @public
207
+ */
208
+ type Locale = "ar" | "fr" | "en" | "es" | "pt" | "de";
209
+ /** The environment a webhook was emitted from. @public */
210
+ type SekyroEnvironment = "sandbox" | "live";
211
+ /**
212
+ * One check of a session, as the partner API projects it: enum/id fields only,
213
+ * never civil data.
214
+ * @public
215
+ */
216
+ interface SessionStep {
217
+ checkType: CheckType;
218
+ state: CheckState;
219
+ /** Sekyro flows: the flow node this check belongs to (e.g. `n_live`). */
220
+ nodeId?: string;
221
+ /** Sekyro flows: the service of that node. */
222
+ service?: ServiceId;
223
+ /** Sekyro flows: the check failed and the flow's fallback took over. */
224
+ handled?: true;
225
+ /** Machine-readable failure/review reason, when the check has one. */
226
+ reason?: string;
227
+ /** With reason `camera_unavailable`: why, when the SDK said (`denied` or `no_camera`). */
228
+ reasonDetail?: CameraUnavailableCause;
229
+ /** Calibrated model score in [0, 1] for scored checks (liveness, face match). */
230
+ calibratedScore?: number;
231
+ /** The check failed after using all of its attempts. */
232
+ attemptsExhausted?: boolean;
233
+ /**
234
+ * `portrait_icao` only (ID mode): the per-criterion ICAO report of the last
235
+ * attempt — numbers and enums only, never the image.
236
+ */
237
+ report?: PortraitReportEntry[];
238
+ /**
239
+ * `face_match` only: the probe-quality measurement of the selfie that was
240
+ * matched (occlusion, head pose, eye openness, sharpness). Recorded for
241
+ * information only: it never changes the step's state or reason.
242
+ */
243
+ probeQuality?: ProbeQuality;
244
+ }
245
+ /**
246
+ * The probe-quality measurement on a `face_match` step. Numbers only; `null`
247
+ * means the value could not be measured. Informational: no threshold applies.
248
+ * @public
249
+ */
250
+ interface ProbeQuality {
251
+ /** Share of the inner face that is covered (a hand, a mask, a phone), in [0, 1]. */
252
+ occlusion: number | null;
253
+ /** Head pose in degrees. */
254
+ pose: {
255
+ yaw: number | null;
256
+ pitch: number | null;
257
+ roll: number | null;
258
+ };
259
+ /** Openness of the less-open eye, in [0, 1]. */
260
+ eyesOpen: number | null;
261
+ /** Sharpness of the face region (higher is sharper; no fixed scale). */
262
+ sharpness: number | null;
263
+ }
264
+ /**
265
+ * One row of the `portrait_icao` report (ID mode): the server's measurement of
266
+ * one ICAO criterion and the threshold that applied.
267
+ * @public
268
+ */
269
+ interface PortraitReportEntry {
270
+ criterion: "pose" | "eyes" | "mouth" | "occlusion" | "glare" | "lighting" | "background" | "resolution";
271
+ value: number | null;
272
+ threshold: number | string | null;
273
+ pass: boolean;
274
+ }
275
+ /**
276
+ * A short-lived link to a session's ICAO portrait (480×640 JPEG), from
277
+ * {@link SessionsApi.portrait}. Download it before `expiresAt`; never store the URL.
278
+ * @public
279
+ */
280
+ interface SessionPortraitLink {
281
+ url: string;
282
+ /** ISO 8601 (about 5 minutes after the call). */
283
+ expiresAt: string;
284
+ }
285
+ /**
286
+ * Out-of-band delivery of the session's hosted link, sent by Sekyro AI after the
287
+ * session is created. Best effort: a failed send never fails the create.
288
+ * @public
289
+ */
290
+ interface DeliverOptions {
291
+ /** Delivery channel. */
292
+ channel: "sms" | "whatsapp";
293
+ /** E.164 phone number of the recipient (`+` and the country code). */
294
+ to: string;
295
+ }
296
+ /**
297
+ * An ID number of the person (person data spec §4.1): the document type, the
298
+ * issuing country (ISO 3166-1 alpha-2; alpha-3 is accepted and normalized) and
299
+ * the number (1 to 40 characters, then the issuing country's rule, e.g. the
300
+ * check digit of a Mauritanian national ID number).
301
+ * @public
302
+ */
303
+ interface SubjectIdNumber {
304
+ type: "national_id" | "passport" | "residence_permit";
305
+ issuingCountry: string;
306
+ number: string;
307
+ }
308
+ /**
309
+ * The person's name in one script (ISO 15924 code, e.g. `Latn` or `Arab`).
310
+ * @public
311
+ */
312
+ interface SubjectName {
313
+ script: string;
314
+ /** 1 to 100 characters. */
315
+ given: string;
316
+ /** 1 to 100 characters. */
317
+ family: string;
318
+ /** Optional, 1 to 100 characters. */
319
+ patronymic?: string;
320
+ }
321
+ /**
322
+ * What you already know about the person (`subject` at session create). A
323
+ * closed object: unknown keys are refused (`400`). Every field is optional;
324
+ * `null` or blank counts as absent.
325
+ *
326
+ * The flow decides whether these are checked or believed: in a flow that checks
327
+ * identity from a document or a registry, they are a prefill compared with what
328
+ * the person shows; in a flow that verifies identity from your data (the
329
+ * response's `subjectUse: "reference"`), `idNumber`, `birthDate`, `photo` and
330
+ * `fetchedAt` are required and the record is the reference. `idNumber` binds the
331
+ * session to that identity in both cases: the hosted flow may omit it but cannot
332
+ * substitute another number.
333
+ * @public
334
+ */
335
+ interface SessionSubjectInput {
336
+ /** The person's ID number. Binds the session. */
337
+ idNumber?: SubjectIdNumber;
338
+ /**
339
+ * @deprecated Use `idNumber: { type: "national_id", issuingCountry: "MR", number }`.
340
+ * A Mauritanian national ID number (10 digits), as a string.
341
+ */
342
+ nni?: string;
343
+ /** E.164 phone number (`+` and the country code). */
344
+ phone?: string;
345
+ /** Email address, for the email OTP step. */
346
+ email?: string;
347
+ /** Full name, 1 to 200 characters, any script. */
348
+ fullName?: string;
349
+ /** The name per script, at most 4 entries, one per script. */
350
+ names?: SubjectName[];
351
+ /** ISO 8601 date (`YYYY-MM-DD`). */
352
+ birthDate?: string;
353
+ /** Place of birth, 1 to 120 characters, any script (kept only with a reference record). */
354
+ birthPlace?: string;
355
+ /** `M`, `F` or `X` (ICAO 9303 values; kept only with a reference record). */
356
+ sex?: "M" | "F" | "X";
357
+ /** ISO 3166-1 alpha-2. */
358
+ nationality?: string;
359
+ /**
360
+ * @deprecated Use `idNumber` with the document's `type` and `issuingCountry`.
361
+ * Identity-document number (1 to 40 characters).
362
+ */
363
+ documentNumber?: string;
364
+ /**
365
+ * Base64 JPEG or PNG (optional data-URL prefix, at most 1 MB decoded): the
366
+ * face-match reference of a reference record. Refused in a flow that uses the
367
+ * data as a prefill (`422 subject_photo_not_used`).
368
+ */
369
+ photo?: string;
370
+ /** ISO 8601 date (`YYYY-MM-DD`) of the photo. */
371
+ photoDate?: string;
372
+ /**
373
+ * ISO 8601 date-time: when YOUR system obtained this data. Required with a
374
+ * reference record; at most 24 h old (`422 subject_record_stale`).
375
+ */
376
+ fetchedAt?: string;
377
+ /**
378
+ * Your own id for this person (1–128 characters). Echoed on the session and
379
+ * its webhooks, and searchable on the subjects API.
380
+ */
381
+ externalRef?: string;
382
+ /**
383
+ * Returning user (profile v2 step 5): verify this already-verified subject
384
+ * again with liveness + face match only, against the reference photo stored
385
+ * on the subject. Name exactly one target. Errors at create:
386
+ * `404 subject_not_found`, `409 subject_revoked`, `409 subject_no_reference`,
387
+ * `409 subject_stale` (older than the flow's `returning.maxAgeMonths`),
388
+ * `409 reuse_disabled` (the flow turns returning-user sessions off) and
389
+ * `400` / `409 reuse_target_ambiguous`.
390
+ */
391
+ reuse?: SubjectReuseTarget;
392
+ }
393
+ /**
394
+ * An identity document for {@link SubjectReuseTarget}: the document type, the
395
+ * issuing country (ISO 3166-1 alpha-2 or alpha-3) and its number.
396
+ * @public
397
+ */
398
+ interface SubjectReuseDocument {
399
+ type: "national_id" | "passport" | "residence_permit";
400
+ issuingCountry: string;
401
+ number: string;
402
+ }
403
+ /**
404
+ * Which subject a returning-user session re-verifies: exactly ONE of the
405
+ * subject id, your own `externalRef` (must match a single subject) or the
406
+ * `idNumber` the person verified with. `nni` and `document` are the deprecated
407
+ * names of the `idNumber` target: an `nni` is an `idNumber` of type
408
+ * `national_id` issued by `MR`; a `document` has the same three parts.
409
+ * @public
410
+ */
411
+ type SubjectReuseTarget = ({
412
+ subjectId: string;
413
+ externalRef?: never;
414
+ nni?: never;
415
+ document?: never;
416
+ idNumber?: never;
417
+ } | {
418
+ externalRef: string;
419
+ subjectId?: never;
420
+ nni?: never;
421
+ document?: never;
422
+ idNumber?: never;
423
+ } | {
424
+ /** @deprecated Use `idNumber` with type `national_id` and issuing country `MR`. */
425
+ nni: string;
426
+ subjectId?: never;
427
+ externalRef?: never;
428
+ document?: never;
429
+ idNumber?: never;
430
+ } | {
431
+ /** @deprecated Use `idNumber` (the same three parts). */
432
+ document: SubjectReuseDocument;
433
+ subjectId?: never;
434
+ externalRef?: never;
435
+ nni?: never;
436
+ idNumber?: never;
437
+ } | {
438
+ idNumber: SubjectIdNumber;
439
+ subjectId?: never;
440
+ externalRef?: never;
441
+ nni?: never;
442
+ document?: never;
443
+ }) & {
444
+ /**
445
+ * `recheck` (default) or `step_up` ({@link SubjectReuseMode}). `step_up` on
446
+ * a flow that does not prove level 2 on every path answers
447
+ * `400 step_up_flow_too_weak`.
448
+ */
449
+ mode?: SubjectReuseMode;
450
+ };
451
+ /** A document type the backend reads (kyc-docs-v2 vocabulary; `carte_identite` = identity card of any issuer). @public */
452
+ type ProfileDocumentType = "carte_identite" | "passport" | "residence_permit";
453
+ /**
454
+ * The services a Sekyro flow is built from. A session's steps
455
+ * ({@link SessionStep.service}) and {@link FlowOverrides.services} use these
456
+ * ids; one service may run several checks (e.g. `liveness` with an ICAO
457
+ * portrait).
458
+ * @public
459
+ */
460
+ type ServiceId = "device_network" | "phone_otp" | "email_otp" | "national_eid" | "document" | "nfc" | "population_registry" | "supplied_identity" | "summary_confirm" | "liveness" | "face_match" | "aml_screening" | "face_dedup" | "age_estimation";
461
+ /**
462
+ * The general settings of a flow that a session may override (the flow's
463
+ * `link`, `language` and override policy are not overridable). Country codes
464
+ * are ISO 3166-1 alpha-2 (`MR`). Used through {@link FlowOverrides.settings}.
465
+ * @public
466
+ */
467
+ interface FlowOverridableSettings {
468
+ /** Who may be verified. */
469
+ eligibility: {
470
+ /** Accepted nationalities: `'*'` or a list, optionally per IP location. */
471
+ nationalities: {
472
+ default: "*" | string[];
473
+ byLocation?: Record<string, "*" | string[]>;
474
+ };
475
+ /** Minimum age in years (1–120), or `null` for none. */
476
+ minAge: number | null;
477
+ };
478
+ /** Automatic decisions instead of human review (`retryConfidentRejects` lets confident rejects retry). */
479
+ decisions?: {
480
+ mode: "automatic" | "review";
481
+ retryConfidentRejects: boolean;
482
+ };
483
+ /** Data consistency across sources. */
484
+ fraud: {
485
+ /** Comparison of your `subject` data with the reference identity. */
486
+ nameMatch?: {
487
+ level: "strict" | "standard" | "lenient";
488
+ onMismatch: "fail" | "signal";
489
+ };
490
+ };
491
+ /** Returning-user sessions (`subject.reuse`). */
492
+ returning: {
493
+ /** `false`: returning-user sessions are refused (`409 reuse_disabled`). */
494
+ enabled: boolean;
495
+ /** Maximum age in months (1–120) of the subject's last verification; `null` = no limit. */
496
+ maxAgeMonths: number | null;
497
+ };
498
+ /** Identity-document rules. */
499
+ documents: {
500
+ /** Accepted document types: `'*'` (all) or a list, optionally per issuing country. */
501
+ accepted: {
502
+ default: "*" | ProfileDocumentType[];
503
+ byIssuer?: Record<string, ProfileDocumentType[]>;
504
+ };
505
+ /** Expired documents: refused, allowed, or allowed for `graceDays` (1–365) after expiry. */
506
+ expired: "reject" | "allow" | {
507
+ graceDays: number;
508
+ };
509
+ authenticity: "standard" | "off";
510
+ };
511
+ }
512
+ /**
513
+ * Document substitution: the portrait a `document` or `nfc` step produces is
514
+ * compared with the registry portrait (or the chip with the printed photo).
515
+ * `signal` records a risk signal on a clear mismatch, `review` also sends the
516
+ * session to review, `off` compares nothing. `failBelow` is the mismatch bound
517
+ * in (0, 1), absent = the platform bound.
518
+ * @public
519
+ */
520
+ interface DocumentSubstitutionSettings {
521
+ mode: "off" | "signal" | "review";
522
+ failBelow?: number;
523
+ }
524
+ /**
525
+ * The per-service settings a session may override, by {@link ServiceId}.
526
+ * `attempts` limits are per step (absent = the platform default).
527
+ * @public
528
+ */
529
+ interface FlowServiceSettings {
530
+ /** Device & Network Intelligence: IP location, anonymizers, cooldown, device and capture postures. */
531
+ device_network: {
532
+ /** Where the end user may be (IP location). */
533
+ locations: {
534
+ mode: "all";
535
+ } | {
536
+ mode: "only" | "all_except";
537
+ countries: string[];
538
+ };
539
+ /** VPN / proxy / Tor. */
540
+ anonymizers: "allow" | "block";
541
+ /** Device cooldown after repeated rejections (at most 5 tiers; `[]` = off). */
542
+ cooldown?: {
543
+ tiers: Array<{
544
+ rejectedSessions: number;
545
+ windowHours: number;
546
+ waitMinutes: number;
547
+ }>;
548
+ };
549
+ /** Device tamper and velocity actions. */
550
+ device?: {
551
+ tamper: "block" | "signal";
552
+ velocity: {
553
+ maxIdentitiesPerDevice: number;
554
+ windowDays: number;
555
+ action: "signal" | "block";
556
+ };
557
+ };
558
+ attestation?: "off" | "signal" | "enforce";
559
+ captureIntegrity?: "off" | "signal" | "enforce";
560
+ };
561
+ phone_otp: {
562
+ /** Where the number comes from: your `subject.phone` / `input.phone`, the person, or either. */
563
+ numberSource: "prefilled" | "user_entered" | "prefilled_or_entered";
564
+ /** Narrow the channels the person may choose from (absent = every channel the org has on). */
565
+ channels?: Array<"whatsapp" | "sms">;
566
+ /** Which countries codes may be sent to (absent = the flow's allowed `locations`). */
567
+ destinations?: "locations" | "any" | {
568
+ countries: string[];
569
+ };
570
+ attempts?: number;
571
+ };
572
+ email_otp: {
573
+ /** Where the address comes from: your `input.email`, the person, or either. */
574
+ emailSource: "prefilled" | "user_entered" | "prefilled_or_entered";
575
+ /** Disposable (temporary) addresses: allowed, flagged as a risk signal (default), or refused. */
576
+ disposable?: "allow" | "signal" | "block";
577
+ attempts?: number;
578
+ };
579
+ national_eid: {
580
+ /**
581
+ * `'org'` (every national eID the org can use, resolved at session create)
582
+ * or provider ids (`{country}.{provider}`, e.g. `MR.houwiyeti`).
583
+ */
584
+ providers: "org" | string[];
585
+ /** The eID portrait is the face-match reference. */
586
+ portraitReference: boolean;
587
+ };
588
+ document: {
589
+ attempts?: number;
590
+ /** Compare the document photo with the registry photo (absent = the platform default). */
591
+ documentSubstitution?: DocumentSubstitutionSettings;
592
+ };
593
+ /** The chip read (its MRZ source is derived from the flow and is not overridable). */
594
+ nfc: {
595
+ maxAttempts?: number;
596
+ /** Compare the chip photo with the registry photo (absent = the platform default). */
597
+ documentSubstitution?: DocumentSubstitutionSettings;
598
+ };
599
+ population_registry: {
600
+ /** `'org'` (every registry the org can use, resolved at session create) or registry ids. */
601
+ sources: "org" | Array<"MR.anrpts">;
602
+ /**
603
+ * @deprecated Use `idNumberSource` (same values). Both with different values is
604
+ * `400 override_invalid`.
605
+ */
606
+ nniSource: "auto" | "typed" | "bound_only";
607
+ /** Where the ID number comes from: `auto`, `typed` (the person types it) or `bound_only` (your `subject.idNumber`). */
608
+ idNumberSource: "auto" | "typed" | "bound_only";
609
+ onUncovered: "skip";
610
+ attempts?: number;
611
+ };
612
+ supplied_identity: Record<string, never>;
613
+ summary_confirm: {
614
+ /** Offer « Reprendre » (re-open the identity source). */
615
+ retake: boolean;
616
+ };
617
+ liveness: {
618
+ /** `off`, selfie ICAO `alert` / `reject`, or `id_document` (ID-photo portrait, always rejects). */
619
+ icao: "off" | "alert" | "reject" | "id_document";
620
+ attempts?: number;
621
+ };
622
+ face_match: {
623
+ reference: "auto" | "document" | "registry";
624
+ attempts?: number;
625
+ };
626
+ aml_screening: {
627
+ lists: Array<"sanctions" | "pep" | "adverse_media">;
628
+ onHit: "review" | "fail";
629
+ };
630
+ face_dedup: {
631
+ scope: "app" | "org";
632
+ onDuplicate: "review" | "fail";
633
+ };
634
+ /** The age check (selfie); the threshold is the flow's `eligibility.minAge`. */
635
+ age_estimation: {
636
+ /** Keep and show the estimated age ({@link AgeResult.estimate}) on the API session and webhooks. Default `false`. */
637
+ showEstimatedAge?: boolean;
638
+ };
639
+ }
640
+ /**
641
+ * `T` with every property optional, recursively. Arrays are replaced as a
642
+ * whole, never merged element by element.
643
+ * @public
644
+ */
645
+ type DeepPartial<T> = T extends readonly unknown[] ? T : T extends object ? {
646
+ [K in keyof T]?: DeepPartial<T[K]>;
647
+ } : T;
648
+ /**
649
+ * A per-session override of the flow ({@link CreateSessionInput.overrides}).
650
+ *
651
+ * - `settings`: any subset of {@link FlowOverridableSettings}, at any depth.
652
+ * - `services`: keyed by service (applied to every node of that service): any
653
+ * subset of its {@link FlowServiceSettings}, or `'off'` to remove it from
654
+ * the flow. A service the flow does not use is ignored.
655
+ *
656
+ * Objects merge into the flow; arrays and scalar values replace. Unknown keys
657
+ * and invalid results answer `400 override_invalid`. An override may only
658
+ * make the flow stricter unless the flow allows widening; turning a service
659
+ * `'off'` always widens. A widening change answers `403 override_widens_flow`.
660
+ * The changed paths are reported on {@link Session.overriddenFields}.
661
+ *
662
+ * @example
663
+ * ```ts
664
+ * await sekyro.sessions.create({
665
+ * flow: "foreigners",
666
+ * overrides: {
667
+ * settings: { eligibility: { minAge: 21 } },
668
+ * services: { liveness: { attempts: 2 } },
669
+ * },
670
+ * });
671
+ * ```
672
+ * @public
673
+ */
674
+ interface FlowOverrides {
675
+ settings?: DeepPartial<FlowOverridableSettings>;
676
+ services?: {
677
+ [S in ServiceId]?: DeepPartial<FlowServiceSettings[S]> | "off";
678
+ };
679
+ }
680
+ /**
681
+ * The flow version a session runs: its `flw_` id, its slug and the published
682
+ * version pinned at create.
683
+ * @public
684
+ */
685
+ interface SessionFlowRef {
686
+ id: string;
687
+ slug: string;
688
+ version: number;
689
+ }
690
+ /**
691
+ * One flow of your app, from {@link Sekyro.listFlows}. Published flows only;
692
+ * pass `slug` or `id` as {@link CreateSessionInput.flow}.
693
+ * @public
694
+ */
695
+ interface FlowSummary {
696
+ /** `flw_` id. */
697
+ id: string;
698
+ slug: string;
699
+ name: string;
700
+ /** The published version a new session runs. */
701
+ version: number;
702
+ /** The flow a session runs when you send no `flow`. */
703
+ isDefault: boolean;
704
+ }
705
+ /**
706
+ * Input of {@link SessionsApi.create}. The API key belongs to an app; the
707
+ * app's flow (its default flow, or the one named in `flow`) decides the steps.
708
+ * @public
709
+ */
710
+ interface CreateSessionInput {
711
+ /**
712
+ * The app's flow to run: its slug (e.g. `foreigners`) or `flw_` id, as
713
+ * {@link Sekyro.listFlows} lists them. Absent = the app's default flow.
714
+ * Errors: `404 flow_not_found` (no such flow in the key's app),
715
+ * `409 flow_not_published`, `409 flow_archived`.
716
+ */
717
+ flow?: string;
718
+ /** Pins the hosted-flow language. Omit to let the person's device decide. */
719
+ locale?: Locale;
720
+ /**
721
+ * Pre-choose the identity method when the flow offers a choice of identity
722
+ * method (the hosted choice screen is then skipped). Ignored otherwise.
723
+ */
724
+ identityMethod?: IdentityMethod;
725
+ /**
726
+ * Session lifetime in minutes. Must fall within the flow's link range,
727
+ * otherwise the API answers `400 ttl_out_of_policy`. Omit to use the
728
+ * flow's default.
729
+ */
730
+ ttlMinutes?: number;
731
+ /** Also send the hosted link to the person by SMS or WhatsApp. */
732
+ deliver?: DeliverOptions;
733
+ /**
734
+ * Where the hosted flow returns the person when the session ends
735
+ * ({@link SessionLinkInput}). A URL outside the app's web origins and app
736
+ * scheme answers `400 return_url_not_allowed`.
737
+ */
738
+ link?: SessionLinkInput;
739
+ /**
740
+ * What you already know about the person (preferred over `input` for
741
+ * identity data). A key sent in both `subject` and `input` with different
742
+ * values answers `400 subject_input_conflict`.
743
+ */
744
+ subject?: SessionSubjectInput;
745
+ /**
746
+ * Your own id for the agent filming the person, for flows whose liveness
747
+ * capture is `assisted` (1 to 128 characters). Stored as is and echoed on
748
+ * the session and in webhooks.
749
+ */
750
+ assistedBy?: {
751
+ externalRef: string;
752
+ };
753
+ /**
754
+ * Override the flow for this session only ({@link FlowOverrides}): its
755
+ * general settings and per-service settings, or turn a service `'off'`.
756
+ * `400 override_invalid` for an unknown key or an invalid result;
757
+ * `403 override_widens_flow` for a change that makes the flow less strict
758
+ * when the flow does not allow widening.
759
+ */
760
+ overrides?: FlowOverrides;
761
+ /**
762
+ * Step inputs consumed server-side: an open record of branch facts your flow's
763
+ * conditions read. The person keys below are deprecated: send them in
764
+ * {@link CreateSessionInput.subject} (the response's `warnings` names each one
765
+ * you used). Values are strings (a number is a string, never a JSON number).
766
+ */
767
+ input?: {
768
+ /**
769
+ * @deprecated Use `subject.idNumber: { type: "national_id", issuingCountry: "MR", number }`.
770
+ * A Mauritanian national ID number (10 digits), as a string.
771
+ */
772
+ nni?: string;
773
+ /** @deprecated Use `subject.phone`. E.164 phone number. */
774
+ phone?: string;
775
+ /** @deprecated Use `subject.email`. Email address for the email OTP step. */
776
+ email?: string;
777
+ /** @deprecated Use `subject.fullName`. */
778
+ fullName?: string;
779
+ /** @deprecated Use `subject.birthDate`. ISO 8601 date (`YYYY-MM-DD`). */
780
+ birthDate?: string;
781
+ /**
782
+ * @deprecated Use the reference keys of `subject` (`idNumber`, `names`,
783
+ * `birthDate`, `photo`, `fetchedAt`, ...), for example from
784
+ * {@link subjectFromNationalRegistry}.
785
+ * Partner-supplied identity data (`supplied` mode only).
786
+ */
787
+ suppliedIdentity?: SuppliedIdentityRecord;
788
+ } & Record<string, unknown>;
789
+ }
790
+ /**
791
+ * @deprecated Send the record in `subject` instead (`idNumber`, `names`,
792
+ * `birthDate`, `birthPlace`, `sex`, `nationality`, `photo`, `photoDate`,
793
+ * `fetchedAt`), for example from {@link subjectFromNationalRegistry}.
794
+ *
795
+ * Partner-supplied identity data (`sessions.create` `input.suppliedIdentity`):
796
+ * the person's biographic record and photo, as your organization holds them.
797
+ * Refusals at create: `400 supplied_identity_nni_mismatch`,
798
+ * `422 supplied_identity_stale` (`fetchedAt` older than 24 h),
799
+ * `422 supplied_identity_photo_unusable` (not a JPEG/PNG of at most 1 MB within the
800
+ * size bounds).
801
+ * @public
802
+ */
803
+ interface SuppliedIdentityRecord {
804
+ /** 10-digit national ID number, as a string. */
805
+ nni: string;
806
+ firstNameFr: string;
807
+ lastNameFr: string;
808
+ fatherNameFr?: string;
809
+ firstNameAr: string;
810
+ lastNameAr: string;
811
+ fatherNameAr?: string;
812
+ /** ISO 8601 date (`YYYY-MM-DD`). */
813
+ birthDate: string;
814
+ birthPlaceFr?: string;
815
+ birthPlaceAr?: string;
816
+ sex?: "M" | "F";
817
+ /** Nationality text as your source holds it. */
818
+ nationalities?: string[];
819
+ /** Base64 JPEG or PNG (at most 1 MB decoded). */
820
+ photo: string;
821
+ /** ISO 8601 date (`YYYY-MM-DD`) of the registry photo. */
822
+ photoDate?: string;
823
+ /** ISO 8601 date-time at which your system obtained this record. */
824
+ fetchedAt: string;
825
+ }
826
+ /** Per-request options. @public */
827
+ interface RequestOptions {
828
+ /**
829
+ * Sent as `X-Idempotency-Key`. Replaying the same key within 24 h returns the
830
+ * original response instead of creating a second session.
831
+ */
832
+ idempotencyKey?: string;
833
+ }
834
+ /**
835
+ * Result of {@link SessionsApi.create}. `clientToken` is returned ONCE and never
836
+ * again — hand it to the browser (`@sekyro/web`) and do not persist it.
837
+ * @public
838
+ */
839
+ interface CreatedSession {
840
+ id: string;
841
+ status: SessionStatus;
842
+ /** One-time credential for the client SDK / hosted flow. */
843
+ clientToken: string;
844
+ /** Hosted verification link for this session. */
845
+ hostedUrl: string;
846
+ /** The flow version the session runs (the default flow when you sent no `flow`). */
847
+ flow?: SessionFlowRef;
848
+ /** The checks on the session's path (checks of a lane not taken are omitted). */
849
+ steps: SessionStep[];
850
+ /** ISO 8601 — when the session (and its link) stop accepting input. */
851
+ expiresAt: string;
852
+ /** The levels the flow can reach on its paths; absent from older API versions. */
853
+ levelTarget?: LevelTarget;
854
+ /**
855
+ * How the flow uses the person data you sent: `reference` (believed, your
856
+ * record is the identity reference) or `prefill` (checked against the
857
+ * person's document or registry record). Absent from older API versions.
858
+ */
859
+ subjectUse?: "reference" | "prefill";
860
+ /** One entry per deprecated request key you used, naming its replacement. Absent otherwise. */
861
+ warnings?: CreatedSessionWarning[];
862
+ }
863
+ /**
864
+ * A deprecation warning of {@link CreatedSession.warnings}: `field` is the
865
+ * deprecated key you sent (e.g. `input.nni`), `replacement` the key to send
866
+ * instead (e.g. `subject.idNumber`).
867
+ * @public
868
+ */
869
+ interface CreatedSessionWarning {
870
+ code: "deprecated_field";
871
+ field: string;
872
+ replacement: string;
873
+ }
874
+ /**
875
+ * Input of {@link SubjectsApi.createSession}: a re-check or step-up session
876
+ * for an existing subject in one call.
877
+ * @public
878
+ */
879
+ interface SubjectSessionInput {
880
+ mode: SubjectReuseMode;
881
+ /** The app's flow to run (slug or `flw_` id); absent = the app's default flow. */
882
+ flow?: string;
883
+ link?: SessionLinkInput;
884
+ /** Session lifetime in minutes, within the flow's link range. */
885
+ ttlMinutes?: number;
886
+ locale?: Locale;
887
+ }
888
+ /**
889
+ * Which subject {@link SubjectsApi.createSession} targets: the subject id or
890
+ * your own external reference.
891
+ * @public
892
+ */
893
+ type SubjectSessionTarget = {
894
+ subjectId: string;
895
+ } | {
896
+ externalRef: string;
897
+ };
898
+ /** Result of {@link SessionsApi.resultToken}: a freshly signed result token. @public */
899
+ interface ResultTokenResponse {
900
+ /** ES256 JWT; check it with {@link verifyResultToken}. */
901
+ token: string;
902
+ /** ISO 8601: when the token expires (10 minutes after signing). */
903
+ expiresAt: string;
904
+ }
905
+ /**
906
+ * The end user's network at the start of the session (IP-derived, approximate).
907
+ * @public
908
+ */
909
+ interface SessionNetworkEvent {
910
+ /** ISO 8601. */
911
+ at: string;
912
+ /** ISO 3166-1 alpha-2. */
913
+ country?: string;
914
+ region?: string;
915
+ city?: string;
916
+ asn?: number;
917
+ operator?: string;
918
+ connectionType: "mobile" | "hosting" | "unknown";
919
+ anonymizer: {
920
+ vpn: boolean;
921
+ tor: boolean;
922
+ hosting: boolean;
923
+ };
924
+ /** IANA time zone reported by the end user's device. */
925
+ browserTimezone?: string;
926
+ /** True when the device time zone does not belong to the IP country. */
927
+ timezoneMismatch?: boolean;
928
+ }
929
+ /**
930
+ * End-user network context; absent when not recorded.
931
+ * @public
932
+ */
933
+ interface SessionNetwork {
934
+ /** The start event's IP address. Never sent in webhooks. */
935
+ ip?: string;
936
+ /** True when a later call came from a different country than the start. */
937
+ countryChanged: boolean;
938
+ start: SessionNetworkEvent;
939
+ }
940
+ /**
941
+ * Device signals detected on the end user's device.
942
+ * @public
943
+ */
944
+ type SessionDeviceSignal = "webdriver" | "headless" | "emulator" | "rooted" | "jailbroken" | "debugger" | "hooking" | "virtual_camera";
945
+ /**
946
+ * End-user device summary; absent when not recorded.
947
+ * @public
948
+ */
949
+ interface SessionDevice {
950
+ platform: "web" | "android" | "ios";
951
+ sdk?: string;
952
+ os?: string;
953
+ osVersion?: string;
954
+ browser?: string;
955
+ browserVersion?: string;
956
+ deviceClass: "mobile" | "tablet" | "desktop" | "unknown";
957
+ model?: string;
958
+ /** Device ids hashed with a key unique to your organization. */
959
+ deviceKeys: string[];
960
+ signals: SessionDeviceSignal[];
961
+ }
962
+ /**
963
+ * The national eID that verified the session's identity (the `eid_auth` check
964
+ * passed): the provider id (`{country}.{provider}`, e.g. `MR.houwiyeti`), its
965
+ * ISO 3166-1 alpha-2 country and when. A passed eID ends the session.
966
+ * @public
967
+ */
968
+ interface EidResult {
969
+ provider: string;
970
+ country: string;
971
+ verifiedAt: string;
972
+ }
973
+ /**
974
+ * The full phone number and email address the person verified in a session
975
+ * (an OTP check that passed) — sent ONLY to you (the session view and your
976
+ * webhooks), never to the person's browser, and removed when the session's
977
+ * personal data is purged. You are the controller of these values. A
978
+ * prefilled value that was not verified is never listed.
979
+ * @public
980
+ */
981
+ interface VerifiedContacts {
982
+ /** From a passed `phone_otp` check. */
983
+ phone?: {
984
+ /** E.164 (`+` and the country code). */
985
+ number: string;
986
+ /** The channel the code was delivered on. */
987
+ channel: "whatsapp" | "sms";
988
+ /** ISO 8601. */
989
+ verifiedAt: string;
990
+ };
991
+ /** From a passed `email_otp` check. */
992
+ email?: {
993
+ /** The verified address (domain lowercased). */
994
+ address: string;
995
+ /** ISO 8601. */
996
+ verifiedAt: string;
997
+ };
998
+ }
999
+ /**
1000
+ * The whitelisted session view returned by {@link SessionsApi.get}. Never
1001
+ * contains the client token.
1002
+ * @public
1003
+ */
1004
+ interface Session {
1005
+ id: string;
1006
+ /** Sekyro flows: the flow version the session runs (absent on sessions created before flows). */
1007
+ flow?: SessionFlowRef;
1008
+ status: SessionStatus;
1009
+ outcome: SessionOutcome | null;
1010
+ /**
1011
+ * What the session proved ({@link VerificationLevel}); `null` while the
1012
+ * session is active, `0` when it was rejected. Absent from older API versions.
1013
+ */
1014
+ level?: VerificationLevel | null;
1015
+ /** How the level was proved; `null` while the session is active. */
1016
+ assurance?: VerificationAssurance | null;
1017
+ /** The billing unit the session consumed; `null` while the session is active. */
1018
+ unit?: VerificationUnit | null;
1019
+ /** The levels the session's flow can reach. */
1020
+ levelTarget?: LevelTarget;
1021
+ /** The checks on the session's path (checks of a lane the person did not take are omitted). */
1022
+ steps: SessionStep[];
1023
+ /** ISO 8601. */
1024
+ expiresAt: string;
1025
+ /** ISO 8601. */
1026
+ createdAt: string;
1027
+ /** ISO 8601: when the session reached a terminal state; `null` while it is active. */
1028
+ completedAt?: string | null;
1029
+ /** End-user network context; absent when not recorded. */
1030
+ network?: SessionNetwork;
1031
+ /** End-user device; absent when not recorded. */
1032
+ device?: SessionDevice;
1033
+ /**
1034
+ * Set when a profile-v2 policy ended the session: a session-level gate
1035
+ * (location, anonymizer) or a failed check's policy reason (eligibility,
1036
+ * `document_nni_mismatch`). Absent otherwise.
1037
+ */
1038
+ failureReason?: PolicyFailureReason;
1039
+ /** With failureReason `camera_unavailable`: why (`denied` or `no_camera`), when the SDK said. Absent otherwise. */
1040
+ failureDetail?: CameraUnavailableCause;
1041
+ /** The subject (person) this session is linked to, once that subject has passed a verification (absent before that). */
1042
+ subjectId?: string;
1043
+ /** Your own id for the person, from `subject.externalRef` at create. */
1044
+ externalRef?: string;
1045
+ /** The agent reference sent as `assistedBy` at create, for assisted capture. */
1046
+ assistedBy?: {
1047
+ externalRef: string;
1048
+ };
1049
+ /**
1050
+ * `true` when an identifier this session read already belongs to a
1051
+ * different subject than `subjectId` — the subjects are never merged.
1052
+ */
1053
+ subjectConflict?: boolean;
1054
+ /**
1055
+ * ISO 8601 — when the end user's device may verify again; set with
1056
+ * `failureReason: 'device_cooldown'`.
1057
+ */
1058
+ retryAfter?: string;
1059
+ /**
1060
+ * Dotted paths this session's {@link CreateSessionInput.overrides} changed
1061
+ * (e.g. `settings.decisions.mode`, `services.liveness`).
1062
+ */
1063
+ overriddenFields?: string[];
1064
+ /**
1065
+ * Risk signals recorded on the session (e.g. `device_velocity`,
1066
+ * `timezone_mismatch`, `icao_non_compliant` when an `alert` ICAO policy flagged
1067
+ * the selfie) — signals only, never a verdict by themselves.
1068
+ */
1069
+ riskSignals?: string[];
1070
+ /**
1071
+ * `true` for a returning-user session (created with
1072
+ * {@link SessionSubjectInput.reuse}): liveness + face match against the
1073
+ * subject's stored reference photo only.
1074
+ */
1075
+ returning?: true;
1076
+ /** On a returning-user session: the subject (person) it re-verifies. */
1077
+ reuseOf?: string;
1078
+ /**
1079
+ * On a session created for an existing subject: `recheck` (the same person
1080
+ * again) or `step_up` (raised to identity level). Absent otherwise.
1081
+ */
1082
+ reuseMode?: SubjectReuseMode;
1083
+ /** The contacts verified in this session (passed OTP checks only); absent when none. */
1084
+ verifiedContacts?: VerifiedContacts;
1085
+ /** The national eID that verified this session (the `eid_auth` check passed); absent otherwise. */
1086
+ eid?: EidResult;
1087
+ /**
1088
+ * When the flow sets a minimum age and the session proved it: the threshold
1089
+ * and how it was proved ({@link AgeResult}). Absent otherwise.
1090
+ */
1091
+ age?: AgeResult;
1092
+ /**
1093
+ * ID mode (`portrait.purpose = id_document`) only: the ICAO portrait can be
1094
+ * fetched with {@link SessionsApi.portrait}.
1095
+ */
1096
+ portraitAvailable?: boolean;
1097
+ }
1098
+ /**
1099
+ * `data` of the terminal / review-pending session lifecycle events
1100
+ * (`session.completed` | `session.failed` | `session.review_pending` |
1101
+ * `session.expired`): ids and enums only, no civil data,
1102
+ * scores or links. `outcome` and `steps` travel on `completed` / `failed`;
1103
+ * `review_pending` carries `steps` without an outcome; `expired` carries the
1104
+ * status and the session's refs (`flow`, subject ids, `overriddenFields`).
1105
+ * @public
1106
+ */
1107
+ interface SessionLifecycleEventData {
1108
+ sessionId: string;
1109
+ status: SessionStatus;
1110
+ outcome?: SessionOutcome | null;
1111
+ /** On `completed` / `failed`: the app the session belongs to. */
1112
+ appId?: string;
1113
+ /** On `completed` / `failed`: what the session proved ({@link VerificationLevel}). */
1114
+ level?: VerificationLevel | null;
1115
+ /** On `completed` / `failed`: how the level was proved. */
1116
+ assurance?: VerificationAssurance | null;
1117
+ /** On `completed` / `failed`: the billing unit the session consumed. */
1118
+ unit?: VerificationUnit | null;
1119
+ /** On `completed` / `failed`: ISO 8601 terminal time. */
1120
+ verifiedAt?: string;
1121
+ /** On `completed` / `failed`: device and network risk facts, when recorded. */
1122
+ risk?: ResultRisk;
1123
+ /** On `completed` / `failed`: other subjects the face matched, when a duplicate search ran. */
1124
+ duplicates?: ResultDuplicate[];
1125
+ /**
1126
+ * On `completed` / `failed`: the signed result token (ES256 JWT, valid
1127
+ * 10 minutes). Check it with {@link verifyResultToken}; absent when
1128
+ * result tokens are not enabled.
1129
+ */
1130
+ resultToken?: string;
1131
+ /** The checks on the session's path (checks of a lane the person did not take are omitted). */
1132
+ steps?: Array<Pick<SessionStep, "checkType" | "state" | "nodeId" | "service">>;
1133
+ /** Sekyro flows: the flow version the session runs (absent on sessions created before flows). */
1134
+ flow?: SessionFlowRef;
1135
+ /** Machine-readable reason, when the transition has one. */
1136
+ reason?: string;
1137
+ /** End-user network context (no IP); on `completed` / `failed` when recorded. */
1138
+ network?: Omit<SessionNetwork, "ip">;
1139
+ /** End-user device; on `completed` / `failed` when recorded. */
1140
+ device?: SessionDevice;
1141
+ /**
1142
+ * On `session.failed`: set when a profile-v2 policy ended the session — a
1143
+ * session-level gate (location, anonymizer) or a failed check's policy
1144
+ * reason (eligibility, `document_nni_mismatch`).
1145
+ */
1146
+ failureReason?: PolicyFailureReason;
1147
+ /** On `session.failed` with failureReason `camera_unavailable`: why (`denied` or `no_camera`), when the SDK said. Absent otherwise. */
1148
+ failureDetail?: CameraUnavailableCause;
1149
+ /** The subject (person) the session is linked to, once that subject has passed a verification (absent before that). */
1150
+ subjectId?: string;
1151
+ /** Your own id for the person, from `subject.externalRef` at create. */
1152
+ externalRef?: string;
1153
+ /**
1154
+ * `true` when an identifier this session read already belongs to a
1155
+ * different subject than `subjectId` — the subjects are never merged.
1156
+ */
1157
+ subjectConflict?: boolean;
1158
+ /** `true` on a returning-user session (liveness + face match against the stored photo). */
1159
+ returning?: true;
1160
+ /** On a returning-user session: the subject (person) it re-verifies. */
1161
+ reuseOf?: string;
1162
+ /**
1163
+ * On a session created for an existing subject: `recheck` (the same person
1164
+ * again) or `step_up` (raised to identity level). Absent otherwise.
1165
+ */
1166
+ reuseMode?: SubjectReuseMode;
1167
+ /**
1168
+ * On `completed` / `failed`: the `link.state` the session was created
1169
+ * with, echoed back; absent when the session had none.
1170
+ */
1171
+ link?: {
1172
+ state: string;
1173
+ };
1174
+ /**
1175
+ * On `session.failed` with `failureReason: 'device_cooldown'`: ISO time
1176
+ * from which the device may start a new verification.
1177
+ */
1178
+ retryAfter?: string;
1179
+ /** Dotted paths the session's create-time {@link CreateSessionInput.overrides} changed. */
1180
+ overriddenFields?: string[];
1181
+ /** On `completed` / `failed`: the contacts verified in this session (passed OTP checks only). */
1182
+ verifiedContacts?: VerifiedContacts;
1183
+ /** On `completed` / `failed`: the national eID that verified this session, when one did. */
1184
+ eid?: EidResult;
1185
+ /** On `completed` / `failed`: the minimum age the session proved and how ({@link AgeResult}), when the flow sets one. */
1186
+ age?: AgeResult;
1187
+ /**
1188
+ * ID mode only, on `completed` / `failed`: the ICAO portrait can be fetched
1189
+ * with {@link SessionsApi.portrait} (the event never carries the image).
1190
+ */
1191
+ portraitAvailable?: boolean;
1192
+ }
1193
+ /**
1194
+ * `data` of `subject.updated` — either a session linked to the subject reached
1195
+ * a terminal state (`sessionId`, session `status`, `outcome`), or the subject
1196
+ * was revoked (`status: 'revoked'`, no session). Ids and enums only.
1197
+ * @public
1198
+ */
1199
+ interface SubjectUpdatedEventData {
1200
+ subjectId: string;
1201
+ /** The session that reached a terminal state; absent on a revocation. */
1202
+ sessionId?: string;
1203
+ status: SessionStatus | "revoked";
1204
+ /** The session outcome; absent on a revocation. */
1205
+ outcome?: SessionOutcome | null;
1206
+ /** The session's level; absent on a revocation. */
1207
+ level?: VerificationLevel | null;
1208
+ /** The session's assurance; absent on a revocation. */
1209
+ assurance?: VerificationAssurance | null;
1210
+ /**
1211
+ * Your own ids for the person (`subject.externalRef` values), so a
1212
+ * revocation can find your user without a lookup. Absent from older API versions.
1213
+ */
1214
+ externalRefs?: string[];
1215
+ }
1216
+ /**
1217
+ * `data` of `subject.enrolled` — the subject's first reference photo was
1218
+ * stored (it can now be used for returning-user sessions). Ids and enums only.
1219
+ * @public
1220
+ */
1221
+ interface SubjectEnrolledEventData {
1222
+ subjectId: string;
1223
+ /** The approved session the reference photo came from. */
1224
+ sessionId: string;
1225
+ assurance: SubjectAssurance;
1226
+ }
1227
+ /**
1228
+ * `data` of `subject.deleted`. A delete through the subjects API carries
1229
+ * `subjectId`; a right-to-erasure request carries the tokenized `subjectRef`
1230
+ * (with `orgId` / `env`) instead — never the national number.
1231
+ * @public
1232
+ */
1233
+ interface SubjectDeletedEventData {
1234
+ subjectId?: string;
1235
+ subjectRef?: string;
1236
+ orgId?: string;
1237
+ env?: SekyroEnvironment;
1238
+ /**
1239
+ * With `subjectId` (a delete through the subjects API): your own ids for
1240
+ * the person, so you can find your user. Never on the erasure variant.
1241
+ */
1242
+ externalRefs?: string[];
1243
+ }
1244
+ /** Subject lifecycle: a revoked subject cannot be reused. @public */
1245
+ type SubjectStatus = "active" | "revoked";
1246
+ /**
1247
+ * How strongly a subject's identity was established: the reference photo
1248
+ * came from the national registry, the document's chip (`chip_biometric`, a
1249
+ * passed chip read plus a face match) or the document, and a face match passed
1250
+ * (`*_biometric`) or the session had no face match (`*_only`). `supplied_*`:
1251
+ * partner-supplied identity data (`input.suppliedIdentity`), with
1252
+ * (`supplied_biometric`) or without (`supplied_only`) a face match against its photo.
1253
+ * @public
1254
+ */
1255
+ type SubjectAssurance = "registry_biometric" | "chip_biometric" | "document_biometric" | "registry_only" | "document_only" | "supplied_biometric" | "supplied_only";
1256
+ /**
1257
+ * Origin of a subject's stored reference photo, best first (`chip`: the document chip's portrait;
1258
+ * `org_supplied`: the photo of your partner-supplied identity data).
1259
+ * @public
1260
+ */
1261
+ type SubjectReferenceSource = "registry" | "doc_registry" | "chip" | "org_supplied" | "document";
1262
+ /** One session linked to a subject. @public */
1263
+ interface SubjectSession {
1264
+ sessionId: string;
1265
+ appId: string | null;
1266
+ /** ISO 8601 — when the session was linked. */
1267
+ at: string;
1268
+ status: SessionStatus;
1269
+ outcome: SessionOutcome | null;
1270
+ /** What the session proved; present only when stored (sessions linked before the field existed have none). */
1271
+ level?: VerificationLevel;
1272
+ /** How the session's level was proved; present only when stored. */
1273
+ assurance?: VerificationAssurance;
1274
+ }
1275
+ /**
1276
+ * A subject (the same person across your apps), as `GET /subjects/:id`
1277
+ * returns it. Never contains photo keys or URLs.
1278
+ * @public
1279
+ */
1280
+ interface Subject {
1281
+ id: string;
1282
+ status: SubjectStatus;
1283
+ /** ISO 8601 — present only when revoked. */
1284
+ revokedAt?: string;
1285
+ sessions: SubjectSession[];
1286
+ externalRefs: string[];
1287
+ /** ISO 8601. */
1288
+ firstSeenAt: string;
1289
+ /** ISO 8601. */
1290
+ lastSeenAt: string;
1291
+ /** ISO 8601, or `null` before the first approved session. */
1292
+ lastPassedAt: string | null;
1293
+ /** ISO 8601 of the last approved full or returning session, or `null`. */
1294
+ lastVerifiedAt: string | null;
1295
+ /** The stored reference photo's origin and date — `null` until one is stored. */
1296
+ reference: {
1297
+ source: SubjectReferenceSource;
1298
+ capturedAt: string;
1299
+ } | null;
1300
+ assurance: SubjectAssurance | null;
1301
+ /**
1302
+ * The highest {@link VerificationLevel} an approved linked session proved;
1303
+ * `0` once the subject is revoked; `null` when no terminal session was
1304
+ * recorded since the field exists. Absent from API versions before the field.
1305
+ */
1306
+ level?: VerificationLevel | null | undefined;
1307
+ /** ISO 8601: when {@link Subject.level} was last proved (the latest approved session at that level or higher); `null` with it. Absent with it. */
1308
+ levelAt?: string | null | undefined;
1309
+ /** The assurance of the session that proved {@link Subject.level}; `null` with it. Absent with it. */
1310
+ levelAssurance?: VerificationAssurance | null | undefined;
1311
+ /**
1312
+ * A returning-user session can be created now: active, a reference photo is
1313
+ * stored, and the last FULL verification (returning-user sessions do not
1314
+ * reset it) is within the returning-user limit of your app's default flow
1315
+ * (`settings.returning`: turned on, and `maxAgeMonths` when set).
1316
+ */
1317
+ returningReady: boolean;
1318
+ /** The verified name / birth date of the latest approved session. */
1319
+ display?: {
1320
+ name?: string;
1321
+ birthDate?: string;
1322
+ };
1323
+ }
1324
+ /**
1325
+ * Filters of {@link SessionsApi.list}: your own user id
1326
+ * (`subject.externalRef` at create) and/or a status.
1327
+ * @public
1328
+ */
1329
+ interface ListSessionsQuery {
1330
+ /** Your own id for the person (1 to 128 characters). */
1331
+ externalRef?: string;
1332
+ status?: SessionStatus;
1333
+ }
1334
+ /** Result of {@link SubjectsApi.delete}. @public */
1335
+ interface DeletedSubject {
1336
+ id: string;
1337
+ deleted: true;
1338
+ }
1339
+ /** Options of {@link SubjectsApi.revoke}. @public */
1340
+ interface RevokeSubjectInput {
1341
+ /** Kept on the audit trail only (≤ 500 characters). Do not put personal data here. */
1342
+ reason?: string;
1343
+ }
1344
+ /**
1345
+ * `data` of `subject.suspicious_activity` — a device already linked to
1346
+ * ANOTHER subject was used for a session of this subject. `count` is the
1347
+ * subject's running total of such events. Ids only.
1348
+ * @public
1349
+ */
1350
+ interface SubjectSuspiciousActivityEventData {
1351
+ subjectId: string;
1352
+ sessionId: string;
1353
+ count: number;
1354
+ }
1355
+ /**
1356
+ * `data` of `session.step.completed` — the check that just passed.
1357
+ * @public
1358
+ */
1359
+ interface SessionStepCompletedEventData {
1360
+ sessionId: string;
1361
+ checkType: CheckType;
1362
+ state: CheckState;
1363
+ /** Sekyro flows: the flow node of the passed check. */
1364
+ nodeId?: string;
1365
+ /** Sekyro flows: the service of that node. */
1366
+ service?: ServiceId;
1367
+ /** Sekyro flows: the flow version the session runs (absent on sessions created before flows). */
1368
+ flow?: SessionFlowRef;
1369
+ /** The subject (person) the session is linked to, once that subject has passed a verification (absent before that). */
1370
+ subjectId?: string;
1371
+ /** Your own id for the person, from `subject.externalRef` at create. */
1372
+ externalRef?: string;
1373
+ /**
1374
+ * `true` when an identifier this session read already belongs to a
1375
+ * different subject than `subjectId` — the subjects are never merged.
1376
+ */
1377
+ subjectConflict?: boolean;
1378
+ /** `true` on a returning-user session (liveness + face match against the stored photo). */
1379
+ returning?: true;
1380
+ /** On a returning-user session: the subject (person) it re-verifies. */
1381
+ reuseOf?: string;
1382
+ /** When the passed check is `phone_otp` / `email_otp`: that one verified contact. */
1383
+ verifiedContacts?: VerifiedContacts;
1384
+ }
1385
+ /**
1386
+ * `data` of `session.review_decided` — a human (or the review-timeout sweep)
1387
+ * decided a pending review. `outcome` speaks the REVIEW vocabulary
1388
+ * (`pass` | `fail`), not the session outcome; `reason` is the reviewer's code
1389
+ * (e.g. `review_timeout` for an expired review).
1390
+ * @public
1391
+ */
1392
+ interface SessionReviewDecidedEventData {
1393
+ sessionId: string;
1394
+ outcome: "pass" | "fail";
1395
+ reason: string;
1396
+ /** Sekyro flows: the flow version the session runs (absent on sessions created before flows). */
1397
+ flow?: SessionFlowRef;
1398
+ /** The subject (person) the session is linked to, once that subject has passed a verification (absent before that). */
1399
+ subjectId?: string;
1400
+ /** Your own id for the person, from `subject.externalRef` at create. */
1401
+ externalRef?: string;
1402
+ /**
1403
+ * `true` when an identifier this session read already belongs to a
1404
+ * different subject than `subjectId` — the subjects are never merged.
1405
+ */
1406
+ subjectConflict?: boolean;
1407
+ /** `true` on a returning-user session (liveness + face match against the stored photo). */
1408
+ returning?: true;
1409
+ /** On a returning-user session: the subject (person) it re-verifies. */
1410
+ reuseOf?: string;
1411
+ /** ID mode only: the ICAO portrait can be fetched with {@link SessionsApi.portrait}. */
1412
+ portraitAvailable?: boolean;
1413
+ }
1414
+ /**
1415
+ * `usage.threshold_reached`: a usage, credit or spend threshold of the organization's
1416
+ * plan was reached (sent once per threshold and period). `kind` is `tier` for a monthly
1417
+ * tier, or the alert, e.g. `credit_80`, `usage_100_paid`, `spend_cap_reached`.
1418
+ * @public
1419
+ */
1420
+ interface UsageThresholdReachedEventData {
1421
+ kind: string;
1422
+ /** The verification unit, on per-unit alerts. */
1423
+ unit?: "human_verification" | "identity_verification";
1424
+ /** Percent of the limit (80, 100), or `overage` for the first verification beyond a tier. */
1425
+ threshold?: number | "overage";
1426
+ used?: number;
1427
+ limit?: number;
1428
+ /** UTC month, `YYYY-MM`. */
1429
+ period?: string;
1430
+ /** Tier alerts: verifications that reached a result this month. */
1431
+ confirmed?: number;
1432
+ /** Tier alerts: verifications beyond the tier this month. */
1433
+ overage?: number;
1434
+ }
1435
+ /**
1436
+ * Event type → the shape of its `data`. Session events are typed; the
1437
+ * remaining events carry an open record until their payloads are frozen.
1438
+ * @public
1439
+ */
1440
+ interface WebhookEventDataMap {
1441
+ "session.created": Record<string, unknown>;
1442
+ "session.started": Record<string, unknown>;
1443
+ "session.step.completed": SessionStepCompletedEventData;
1444
+ "session.review_pending": SessionLifecycleEventData;
1445
+ "session.review_decided": SessionReviewDecidedEventData;
1446
+ "session.completed": SessionLifecycleEventData;
1447
+ "session.expired": SessionLifecycleEventData;
1448
+ "session.failed": SessionLifecycleEventData;
1449
+ "subject.enrolled": SubjectEnrolledEventData;
1450
+ "subject.updated": SubjectUpdatedEventData;
1451
+ "subject.suspicious_activity": SubjectSuspiciousActivityEventData;
1452
+ "subject.deleted": SubjectDeletedEventData;
1453
+ "aml.match_flagged": Record<string, unknown>;
1454
+ "payment.received": Record<string, unknown>;
1455
+ "invoice.generated": Record<string, unknown>;
1456
+ "invoice.paid": Record<string, unknown>;
1457
+ "invoice.overdue": Record<string, unknown>;
1458
+ "usage.threshold_reached": UsageThresholdReachedEventData;
1459
+ "webhook.test": Record<string, unknown>;
1460
+ }
1461
+ /** Every event a partner endpoint may receive. @public */
1462
+ type WebhookEventType = keyof WebhookEventDataMap;
1463
+ /**
1464
+ * The signed webhook payload for ONE event type. There is no global API
1465
+ * version; each event carries its own per-event `version`. Retried deliveries
1466
+ * keep the same `id` — de-duplicate on it.
1467
+ * @public
1468
+ */
1469
+ interface WebhookEnvelopeOf<E extends WebhookEventType> {
1470
+ /** UUIDv7, stable across delivery retries. */
1471
+ id: string;
1472
+ event: E;
1473
+ /** Per-event payload version. */
1474
+ version: number;
1475
+ /** ISO 8601. */
1476
+ createdAt: string;
1477
+ orgId: string;
1478
+ env: SekyroEnvironment;
1479
+ data: WebhookEventDataMap[E];
1480
+ }
1481
+ /**
1482
+ * The signed webhook payload, discriminated on `event`: narrowing on
1483
+ * `envelope.event` narrows `envelope.data` to that event's shape.
1484
+ *
1485
+ * @example
1486
+ * ```ts
1487
+ * const envelope = verifyWebhook(rawBody, header, secret);
1488
+ * switch (envelope.event) {
1489
+ * case "session.completed":
1490
+ * envelope.data.outcome; // SessionOutcome | null | undefined
1491
+ * break;
1492
+ * case "session.review_decided":
1493
+ * envelope.data.outcome; // "pass" | "fail"
1494
+ * break;
1495
+ * }
1496
+ * ```
1497
+ * @public
1498
+ */
1499
+ type WebhookEnvelope<E extends WebhookEventType = WebhookEventType> = E extends WebhookEventType ? WebhookEnvelopeOf<E> : never;
1500
+ /**
1501
+ * `data` of any `session.*` event.
1502
+ * @deprecated Use {@link SessionLifecycleEventData}, {@link SessionStepCompletedEventData}
1503
+ * or {@link SessionReviewDecidedEventData}, or narrow a {@link WebhookEnvelope} on `event`.
1504
+ * @public
1505
+ */
1506
+ type SessionEventData = SessionLifecycleEventData | SessionStepCompletedEventData | SessionReviewDecidedEventData;
1507
+
1508
+ /** Default partner API origin + version prefix. @public */
1509
+ declare const DEFAULT_BASE_URL = "https://api.sekyro.ai/api/v2";
1510
+ /** Default per-request timeout. @public */
1511
+ declare const DEFAULT_TIMEOUT_MS = 30000;
1512
+ /** `fetch`-compatible function; the global `fetch` by default. @public */
1513
+ type FetchLike = typeof globalThis.fetch;
1514
+ /** Constructor options of {@link Sekyro}. @public */
1515
+ interface SekyroOptions {
1516
+ /** Partner API key (server-side only). Sent as `Authorization: Bearer`. */
1517
+ apiKey: string;
1518
+ /** API base URL incl. the `/api/v2` prefix. Default {@link DEFAULT_BASE_URL}. */
1519
+ baseUrl?: string;
1520
+ /** Per-request timeout in ms. Default {@link DEFAULT_TIMEOUT_MS}. */
1521
+ timeoutMs?: number;
1522
+ /** Custom `fetch` (tests, proxies, custom agents). Default `globalThis.fetch`. */
1523
+ fetch?: FetchLike;
1524
+ /**
1525
+ * The auth-provider connector this client runs in, sent as the
1526
+ * `x-sekyro-connector: <provider>/<version>` header on every call so the
1527
+ * dashboard can show the connector as connected. Ids only. A connector
1528
+ * created with `createConnector` from `@sekyro/node/connect` sets it for you
1529
+ * (unless its `telemetry` option is `false`).
1530
+ */
1531
+ connector?: ConnectorIdentity;
1532
+ }
1533
+ /** A connector's provider id and package version, for {@link SekyroOptions.connector}. @public */
1534
+ interface ConnectorIdentity {
1535
+ /** The provider id, for example `supabase`: lowercase letters, digits and `-`, at most 32 characters. */
1536
+ provider: string;
1537
+ /** The connector package version, for example `0.1.0`: at most 64 characters. */
1538
+ version: string;
1539
+ }
1540
+ /**
1541
+ * `sekyro.sessions` — create and read verification sessions.
1542
+ *
1543
+ * Exported as a TYPE only (`import type { SessionsApi }`): the class value is
1544
+ * not part of the package surface, so it can only be obtained through
1545
+ * {@link Sekyro.sessions} — never constructed by hand with an unchecked
1546
+ * transport.
1547
+ * @public
1548
+ */
1549
+ declare class SessionsApi {
1550
+ private readonly call;
1551
+ /**
1552
+ * Constructed by {@link Sekyro}; the transport is kept out of the public
1553
+ * surface on purpose (only its bound `call` crosses this boundary).
1554
+ * @internal
1555
+ */
1556
+ constructor(call: <T>(method: "GET" | "POST" | "DELETE", path: string, body?: unknown, idempotencyKey?: string) => Promise<T>);
1557
+ /**
1558
+ * `POST /sessions`. Returns the one-time `clientToken` — hand it to the
1559
+ * browser, never persist it. Pass an `idempotencyKey` so a retried call
1560
+ * cannot create a second session.
1561
+ */
1562
+ create(input?: CreateSessionInput, opts?: RequestOptions): Promise<CreatedSession>;
1563
+ /**
1564
+ * `POST /sessions/:id/method` — choose the identity method of an
1565
+ * optional-document session on the person's behalf (the hosted method
1566
+ * screen is then skipped). `409 method_locked` once the choice can no
1567
+ * longer change; `409 session_not_active` on a finished or expired session.
1568
+ * On a flow session: `409 choice_not_found` (the flow has no identity-method
1569
+ * choice), `409 choice_locked`, `409 choice_option_unavailable` (see
1570
+ * {@link isFlowError}).
1571
+ */
1572
+ selectMethod(id: string, method: IdentityMethod): Promise<Session>;
1573
+ /** `GET /sessions/:id` — the whitelisted view (no client token). */
1574
+ get(id: string): Promise<Session>;
1575
+ /**
1576
+ * `GET /sessions?externalRef=&status=`: your newest sessions (at most 100),
1577
+ * optionally filtered by your own user id and/or a status. The filters are
1578
+ * applied again to the answer, so an API that ignores them never returns
1579
+ * another user's sessions.
1580
+ */
1581
+ list(query?: ListSessionsQuery): Promise<Session[]>;
1582
+ /**
1583
+ * `GET /sessions/:id/portrait?format=url` — ID mode: a 5-minute presigned
1584
+ * link to the 480×640 ICAO portrait (JPEG). Needs the `portrait:read` scope
1585
+ * (keys minted from the dashboard carry it). `404 portrait_not_available`
1586
+ * until the session's `portrait_icao` check has passed (`portraitAvailable`).
1587
+ */
1588
+ portrait(id: string): Promise<SessionPortraitLink>;
1589
+ /**
1590
+ * `GET /sessions/:id/result-token`: a freshly signed result token for a
1591
+ * finished session (valid 10 minutes; check it with
1592
+ * {@link verifyResultToken}). `409 session_not_terminal` while the session
1593
+ * is still active. Needs the `sessions:read` scope.
1594
+ */
1595
+ resultToken(id: string): Promise<ResultTokenResponse>;
1596
+ }
1597
+ /**
1598
+ * `sekyro.subjects` — read and manage subjects (the same person across your
1599
+ * apps). Reads need the `subjects:read` scope, `revoke` / `delete` the
1600
+ * `subjects:write` scope (keys minted from the dashboard carry both; an older
1601
+ * key answers `403 insufficient_scope`). A foreign or unknown id answers
1602
+ * `404 subject_not_found`.
1603
+ *
1604
+ * Type-only export, like {@link SessionsApi}: obtained through
1605
+ * {@link Sekyro.subjects}.
1606
+ * @public
1607
+ */
1608
+ declare class SubjectsApi {
1609
+ private readonly call;
1610
+ /** @internal */
1611
+ constructor(call: <T>(method: "GET" | "POST" | "DELETE", path: string, body?: unknown, idempotencyKey?: string) => Promise<T>);
1612
+ /** `GET /subjects/:id` — the subject, its sessions and its returning-user readiness. */
1613
+ get(id: string): Promise<Subject>;
1614
+ /** `GET /subjects?externalRef=…` — the subjects carrying your own id (newest first, at most 50). */
1615
+ list(query: {
1616
+ externalRef: string;
1617
+ }): Promise<Subject[]>;
1618
+ /**
1619
+ * `POST /subjects/:id/revoke` — the subject can no longer be used for
1620
+ * returning-user sessions. Idempotent: revoking again returns the same view.
1621
+ * Emits `subject.updated` with `status: 'revoked'`.
1622
+ */
1623
+ revoke(id: string, input?: RevokeSubjectInput, opts?: RequestOptions): Promise<Subject>;
1624
+ /**
1625
+ * `DELETE /subjects/:id` — deletes the subject's stored photos, face
1626
+ * templates and identifiers, and unlinks its sessions. Emits
1627
+ * `subject.deleted`. Cannot be undone; a second call answers `404`.
1628
+ */
1629
+ delete(id: string): Promise<DeletedSubject>;
1630
+ /**
1631
+ * A re-check or step-up session for an existing subject in one call:
1632
+ * `POST /subjects/:id/sessions` when `target` is a subject id (24
1633
+ * hexadecimal characters) or `{ subjectId }`, otherwise
1634
+ * `POST /subjects/by-external-ref/:externalRef/sessions` (pass
1635
+ * `{ externalRef }` to force it). Same result and errors as
1636
+ * {@link SessionsApi.create}; needs the `sessions:create` and
1637
+ * `subjects:read` scopes.
1638
+ */
1639
+ createSession(target: string | SubjectSessionTarget, input: SubjectSessionInput, opts?: RequestOptions): Promise<CreatedSession>;
1640
+ }
1641
+ /**
1642
+ * Sekyro AI partner API client. Server-side only: it carries your API key.
1643
+ *
1644
+ * Throws {@link SekyroConfigError} synchronously when `apiKey` is missing or
1645
+ * `baseUrl` is not `https:` (plain `http:` is accepted for `localhost`,
1646
+ * `127.0.0.1` and `[::1]` only).
1647
+ *
1648
+ * @example
1649
+ * ```ts
1650
+ * const sekyro = new Sekyro({ apiKey: process.env.SEKYRO_API_KEY! });
1651
+ * const { id, clientToken } = await sekyro.sessions.create({ input: { nni: "1357924632" } });
1652
+ * ```
1653
+ * @public
1654
+ */
1655
+ declare class Sekyro {
1656
+ #private;
1657
+ readonly sessions: SessionsApi;
1658
+ readonly subjects: SubjectsApi;
1659
+ constructor(opts: SekyroOptions);
1660
+ /**
1661
+ * `GET /flows` — the published flows of the API key's app (default flow
1662
+ * first, then by name). Pass a flow's `slug` or `id` as
1663
+ * {@link CreateSessionInput.flow}. Needs the `sessions:create` scope; an
1664
+ * invalid key answers `401 unauthorized`.
1665
+ */
1666
+ listFlows(): Promise<FlowSummary[]>;
1667
+ }
1668
+
1669
+ export { type SessionDevice as $, type AgeMethod as A, type FlowServiceSettings as B, type CreatedSession as C, DEFAULT_BASE_URL as D, type EidResult as E, type FetchLike as F, type FlowSummary as G, type IdentityMethod as H, type IdNumberReason as I, type LevelTarget as J, type ListSessionsQuery as K, type Locale as L, type MatchReason as M, type PortraitReportEntry as N, type ProbeBindingReason as O, type PolicyFailureReason as P, type ProbeQuality as Q, type ResultRisk as R, Sekyro as S, type ProfileDocumentType as T, type RequestOptions as U, type VerificationLevel as V, type WebhookEventType as W, type ResultTokenResponse as X, type RevokeSubjectInput as Y, type SekyroOptions as Z, type Session as _, type ServiceId as a, type SessionDeviceSignal as a0, type SessionEventData as a1, type SessionFailureReason as a2, type SessionFlowRef as a3, type SessionLifecycleEventData as a4, type SessionLinkInput as a5, type SessionNetwork as a6, type SessionNetworkEvent as a7, type SessionPortraitLink as a8, type SessionReviewDecidedEventData as a9, type SessionStatus as aa, type SessionStep as ab, type SessionStepCompletedEventData as ac, SessionsApi as ad, type Subject as ae, type SubjectAssurance as af, type SubjectDeletedEventData as ag, type SubjectEnrolledEventData as ah, type SubjectIdNumber as ai, type SubjectName as aj, type SubjectReferenceSource as ak, type SubjectReuseDocument as al, type SubjectReuseTarget as am, type SubjectSession as an, type SubjectSessionInput as ao, type SubjectSessionTarget as ap, type SubjectStatus as aq, type SubjectSuspiciousActivityEventData as ar, type SubjectUpdatedEventData as as, SubjectsApi as at, type SuppliedIdentityRecord as au, type UsageThresholdReachedEventData as av, type VerifiedContacts as aw, type WebhookEnvelopeOf as ax, type WebhookEventDataMap as ay, type SessionSubjectInput as b, type WebhookEnvelope as c, type SekyroEnvironment as d, type VerificationAssurance as e, type SessionOutcome as f, type VerificationUnit as g, type SubjectReuseMode as h, type ResultCheckProofs as i, type ResultDuplicate as j, type AgeResult as k, type CameraUnavailableCause as l, type CheckState as m, type CheckType as n, type ConnectorIdentity as o, type CreateSessionInput as p, type CreatedSessionWarning as q, DEFAULT_TIMEOUT_MS as r, type DecisionReason as s, type DeepPartial as t, type DeletedSubject as u, type DeliverOptions as v, type DocumentSubstitutionSettings as w, type EligibilityReason as x, type FlowOverridableSettings as y, type FlowOverrides as z };