@sekyro/node 0.1.0-rc.8 → 1.0.0-rc.15

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,2460 @@
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
+ * A session that waited for a review and was taken over by a newer attempt of
15
+ * the same person (`session.superseded`) has `outcome: null` and names that
16
+ * attempt in {@link Session.supersededBy}: read the newer session for the
17
+ * verdict. `superseded` is no longer sent on the session view, its webhooks or
18
+ * the result token; it stays in this union for one release and may still
19
+ * appear on {@link PersonSession.outcome}.
20
+ * @public
21
+ */
22
+ type SessionOutcome = "approved" | "review" | "rejected" | "superseded";
23
+ /**
24
+ * What a finished session proved: `1` a live, real person (human), `2` that
25
+ * person's identity (document, chip, registry or supplied data bound to the
26
+ * face), `3` an identity corroborated by an independent source. `0` on a
27
+ * rejected session.
28
+ * @public
29
+ */
30
+ type VerificationLevel = 0 | 1 | 2 | 3;
31
+ /**
32
+ * How a session's {@link VerificationLevel} was proved: `live_only` (liveness
33
+ * only), `live_unique` (liveness plus a duplicate search), and the
34
+ * `*_biometric` values, where a face match bound the person to a document,
35
+ * its chip, the registry record or partner-supplied identity data, and
36
+ * `eid_authenticated`, where the person signed in with a national digital
37
+ * identity (level 3 without a Sekyro selfie).
38
+ * @public
39
+ */
40
+ type VerificationAssurance = "live_only" | "live_unique" | "document_biometric" | "chip_biometric" | "registry_biometric" | "supplied_biometric" | "eid_authenticated";
41
+ /** The one billing unit a finished session consumed. @public */
42
+ type VerificationUnit = "human_verification" | "identity_verification";
43
+ /** The lowest and highest {@link VerificationLevel} the session's flow can reach. @public */
44
+ interface LevelTarget {
45
+ min: VerificationLevel;
46
+ max: VerificationLevel;
47
+ }
48
+ /**
49
+ * Device and network risk facts of a finished session (booleans and a level
50
+ * word, never scores).
51
+ * @public
52
+ */
53
+ interface ResultRisk {
54
+ level: "low" | "medium" | "high";
55
+ vpn: boolean;
56
+ ipDocumentMismatch: boolean;
57
+ deviceTampered: boolean;
58
+ }
59
+ /**
60
+ * What the liveness step verified about the capture itself: the device
61
+ * attestation, the capture proof and the injection signals.
62
+ * @public
63
+ */
64
+ interface ResultCheckProofs {
65
+ attestation: "verified" | "missing" | "failed";
66
+ captureProof: "verified" | "missing";
67
+ injectionSignals: "clear" | "flagged";
68
+ }
69
+ /**
70
+ * How a session proved the person's minimum age: `estimated` (the age check
71
+ * (selfie) step estimated the face over the threshold by a safety margin), or
72
+ * from identity data: `document`, `chip`, `registry` or `eid`.
73
+ * @public
74
+ */
75
+ type AgeMethod = "estimated" | "document" | "chip" | "registry" | "eid";
76
+ /**
77
+ * The age answer of a session whose flow sets a minimum age. `over` is the
78
+ * flow's minimum age (the threshold), never the person's age. `estimate`
79
+ * (years, one decimal) and `sigma` (its spread in years) are present only on
80
+ * the API session and webhooks, and only when the age check (selfie) step's
81
+ * "Keep and show the estimated age" setting is on; the result token never
82
+ * carries them.
83
+ * @public
84
+ */
85
+ interface AgeResult {
86
+ over: number;
87
+ method: AgeMethod;
88
+ estimate?: number;
89
+ sigma?: number;
90
+ }
91
+ /** Another person the face already matched (duplicate search). @public */
92
+ interface ResultDuplicate {
93
+ /** That person's id, `per_` prefixed, as on `GET /people` and `Session.personId`. */
94
+ personId: string;
95
+ /**
96
+ * The same person, bare (24 hexadecimal characters).
97
+ * @deprecated Read {@link ResultDuplicate.personId}.
98
+ */
99
+ subjectId: string;
100
+ externalRef?: string;
101
+ }
102
+ /**
103
+ * How a `person.reuse` session runs: `recheck` verifies the same person
104
+ * again (liveness and face match against the stored photo), `step_up` raises
105
+ * the subject to identity level with a flow that proves level 2 on every path.
106
+ * @public
107
+ */
108
+ type SubjectReuseMode = "recheck" | "step_up";
109
+ /**
110
+ * Where the hosted flow sends the person when the session ends: an `https`
111
+ * URL on one of the app's web origins, or the app's `sekyro-<slug>://` scheme.
112
+ * `state` (up to 256 characters) is echoed back on the redirect.
113
+ * @public
114
+ */
115
+ interface SessionLinkInput {
116
+ returnUrl?: string;
117
+ state?: string;
118
+ }
119
+ /**
120
+ * How the person proves their identity on an optional-document app: type the
121
+ * national number, or photograph the document (`document_chip`: native NFC clients only).
122
+ * `national_eid`: the country's national eID (e.g. Houwiyeti for Mauritania),
123
+ * offered when the app's profile turns the national eID on.
124
+ * @public
125
+ */
126
+ type IdentityMethod = "national_number" | "document_photo" | "document_chip" | "national_eid";
127
+ /** The verification checks a flow may contain. @public */
128
+ type CheckType = "liveness" | "face_match" | "doc_ocr" | "population_registry" | "phone_otp" | "nfc_chip" | "email_otp" | "portrait_icao" | "eid_auth" | "aml_screening";
129
+ /** Per-check execution state within a session. @public */
130
+ type CheckState = "pending" | "input_required" | "processing" | "passed" | "failed" | "review" | "skipped";
131
+ /**
132
+ * Why a session was stopped by a profile-v2 policy gate rather than by a
133
+ * failed check:
134
+ * - `location_not_allowed` — the end user's IP location is not allowed for the app;
135
+ * - `anonymizer_blocked` — an anonymizer (VPN / proxy / Tor) was detected while the app blocks them;
136
+ * - `capture_tampered` — the device reported a tampered capture (virtual
137
+ * camera, hooking, emulator…) while the app's `device.tamper` is `block`;
138
+ * - `device_velocity_exceeded` — the device already verified more different
139
+ * people than `device.velocity` allows, with `action: 'block'`;
140
+ * - `device_cooldown` — the device had too many rejected sessions
141
+ * (`cooldown` tiers); {@link Session.retryAfter} says when it may try again.
142
+ * Not billed;
143
+ * - `platform_unsupported` — the flow requires a chip read and the person
144
+ * opened the link on the web (the link stays usable in a native app);
145
+ * - `cancelled_by_organization` — you cancelled the session
146
+ * ({@link SessionsApi.cancel});
147
+ * - `blocked_by_org`: one of your blocks (a device, a person, an account or a
148
+ * contact) stopped the session. Not retryable, not billed.
149
+ * @public
150
+ */
151
+ type SessionFailureReason = "location_not_allowed" | "anonymizer_blocked" | "capture_tampered" | "device_velocity_exceeded" | "device_cooldown" | "platform_unsupported" | "cancelled_by_organization" | "blocked_by_org";
152
+ /**
153
+ * Profile-v2 decision-mode reasons a check's {@link SessionStep.reason} may
154
+ * carry when the app decides automatically (`decisions.mode: 'automatic'`)
155
+ * instead of routing to human review. All are retryable within the step's
156
+ * attempts: `liveness_inconclusive` (liveness middle band),
157
+ * `match_inconclusive` (face match middle band on every reference),
158
+ * `document_authenticity` (doc_ocr authenticity warning — retake the original)
159
+ * and `mobile_required` (liveness captured on a desktop — continue on a phone;
160
+ * not billed). Every inconclusive attempt is billed.
161
+ * @public
162
+ */
163
+ type DecisionReason = "liveness_inconclusive" | "match_inconclusive" | "document_authenticity" | "mobile_required";
164
+ /**
165
+ * Profile-v2 eligibility reasons a check's {@link SessionStep.reason} may carry:
166
+ * `document_type_not_accepted` (doc_ocr; the person may pick another
167
+ * document), `nationality_not_allowed` and `underage` (doc_ocr or
168
+ * population_registry; terminal), and `age_unverifiable` (the app sets a
169
+ * minimum age but the birth date could not be read — doc_ocr: retryable with
170
+ * a clearer photo; population_registry: terminal).
171
+ * @public
172
+ */
173
+ type EligibilityReason = "document_type_not_accepted" | "nationality_not_allowed" | "underage" | "age_unverifiable" | "underage_estimated";
174
+ /**
175
+ * Why a profile-v2 policy ended a session: a session-level
176
+ * {@link SessionFailureReason} (location / anonymizer gate), or the failed
177
+ * check's policy reason — an {@link EligibilityReason} or
178
+ * `document_id_number_mismatch` (the document belongs to someone other than the
179
+ * ID number the session was created for; `document_nni_mismatch` is its former
180
+ * 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,
181
+ * so the live step ended without a capture; the session is rejected at level 0 unless your flow has a fallback),
182
+ * `subject_face_mismatch` (a step-up whose face did not match the person it was created for), or a review that
183
+ * ended at its deadline: `review_timeout` (nobody decided it) or `review_split` (two reviewers disagreed and
184
+ * nobody settled it); those two carry `decidedBy: "automatic"`.
185
+ * @public
186
+ */
187
+ type PolicyFailureReason = SessionFailureReason | EligibilityReason | "document_id_number_mismatch" | "document_nni_mismatch" | "camera_unavailable" | "subject_face_mismatch" | "review_timeout" | "review_split" | "aml_hit";
188
+ /**
189
+ * The ID-number reasons a check's {@link SessionStep.reason} may carry (person data
190
+ * spec Appendix A.2), each under its generic name and its former Mauritanian name:
191
+ * `id_number_invalid` (`nni_invalid`: the number fails its country's rule),
192
+ * `registry_record_not_found` (`nni_not_found`: no registry record for the number),
193
+ * `id_number_recheck` (`nni_recheck`: the number must be checked again) and
194
+ * `document_id_number_mismatch` (`document_nni_mismatch`). The API sends the former
195
+ * names until it switches to the generic ones; handle both.
196
+ * @public
197
+ */
198
+ 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";
199
+ /**
200
+ * Why the person had no camera (spec 2026-10-29 §3.4, 2026-10-30), when the SDK said: `denied` (the
201
+ * person refused camera access) or `no_camera` (no usable camera: none found, an insecure page or a
202
+ * browser that cannot capture). A detail under `failureReason: "camera_unavailable"`, never a reason of its own.
203
+ * @public
204
+ */
205
+ type CameraUnavailableCause = "denied" | "no_camera";
206
+ /**
207
+ * Profile-v2 matching reasons a check's {@link SessionStep.reason} may carry
208
+ * when the data you sent in {@link CreateSessionInput.person} differs from the
209
+ * reference identity: `name_mismatch`, `birth_date_mismatch`,
210
+ * `nationality_mismatch` (doc_ocr or population_registry) and
211
+ * `document_number_mismatch` (doc_ocr). All are final.
212
+ * @public
213
+ */
214
+ type MatchReason = "name_mismatch" | "birth_date_mismatch" | "nationality_mismatch" | "document_number_mismatch";
215
+ /**
216
+ * Reasons a `face_match` {@link SessionStep.reason} carries when an earlier
217
+ * human review of the same person, reference photo and face settled the match
218
+ * score instead of a new review: `prior_review_approved` (the step passed;
219
+ * final) and `prior_review_rejected` (the step failed; retryable, a better
220
+ * capture sends the session to a reviewer again). Both are billed like
221
+ * `review_band`. The step's {@link SessionStep.decision} has
222
+ * `source: "prior_review"` and names your earlier session.
223
+ * @public
224
+ */
225
+ type PriorReviewReason = "prior_review_approved" | "prior_review_rejected";
226
+ /**
227
+ * Review outcome reasons any reviewable step may carry: `superseded_by_retry`
228
+ * (a newer attempt of the same person took the review over; the session ends
229
+ * with `outcome: null` and {@link Session.supersededBy}) and `review_split` (two reviewers disagreed and
230
+ * nobody settled it before the review deadline; the session is rejected).
231
+ * Both are billed and retryable: the person may verify again. Neither counts
232
+ * toward the device cooldown.
233
+ * @public
234
+ */
235
+ type ReviewOutcomeReason = "superseded_by_retry" | "review_split";
236
+ /**
237
+ * What a review decision is about, on {@link SessionStepDecision.reasons}: the
238
+ * part that failed on a rejection (several may apply), or the check the
239
+ * reviewer overrode on an approval.
240
+ * @public
241
+ */
242
+ type ReviewReason = "document_authenticity" | "liveness" | "face_match" | "data_mismatch" | "screening" | "org_rule" | "other";
243
+ /**
244
+ * How a person decided a step: a reviewer (`source: "review"`), or an earlier
245
+ * review of the same person, reference photo and face that was reused
246
+ * (`source: "prior_review"`). Counts and enums only: never a reviewer's
247
+ * identity and never an individual vote.
248
+ * @public
249
+ */
250
+ interface SessionStepDecision {
251
+ source: "review" | "prior_review";
252
+ /** One reviewer (`single`) or two independent reviewers (`dual`). */
253
+ mode: "single" | "dual";
254
+ /** How many reviewer votes formed the decision (a third vote settles a dual split). */
255
+ votes: 1 | 2 | 3;
256
+ /** Dual review only: whether the first two reviewers agreed. */
257
+ agreement?: boolean;
258
+ /** What the decision was about ({@link ReviewReason}). */
259
+ reasons: ReviewReason[];
260
+ /** ISO 8601: when the decision was made. */
261
+ decidedAt: string;
262
+ /** `prior_review` only: your earlier session whose review decided this one. */
263
+ sessionId?: string;
264
+ }
265
+ /**
266
+ * A failure identification match (terminal sessions, when the flow's
267
+ * identify-failures setting is on and the search found one): who the face
268
+ * matches when the face match did not prove the claimed identity against a
269
+ * registry portrait. A signal, never a decision: the session state is
270
+ * unchanged. Ids, enums and numbers only, never a name or an ID number.
271
+ *
272
+ * `kind`: `presenter` (the live person is most likely the matched record),
273
+ * `shown_face` (the photo or screen shown carries the matched record, a
274
+ * possible victim) or `other_identity`. `other_identity` is informational
275
+ * only: the registry also knows this face under another record. The person may
276
+ * legitimately hold more than one identity document, for example a foreign
277
+ * passport, an older document, a second nationality or a residence permit. Do
278
+ * not treat this signal alone as fraud: use it as a lead for your own process.
279
+ * @public
280
+ */
281
+ interface FailureIdentification {
282
+ kind: "presenter" | "shown_face" | "other_identity";
283
+ /** The search scope: your verified persons (`org`) or the whole registry index (`registry`). */
284
+ scope: "org" | "registry";
285
+ match: {
286
+ /** Your verified person for the match, when you hold one, `per_` prefixed. */
287
+ personId?: string;
288
+ /**
289
+ * The same person, bare.
290
+ * @deprecated Read `personId`.
291
+ */
292
+ subjectId?: string;
293
+ /** An opaque reference of the matched person when you hold no verified subject for it, scoped to your organisation. */
294
+ reference?: string;
295
+ /** The registry photo that matched (an opaque id, scoped to your organisation). */
296
+ photoId?: string;
297
+ /** The grade of that photo: `1` or `2` registry, `3` an older bulk import photo. */
298
+ tier: 1 | 2 | 3;
299
+ /** Calibrated similarity on the face match scale, in [0, 1]. */
300
+ score: number;
301
+ band: "strong" | "moderate";
302
+ };
303
+ /** With `other_identity`: the reference the session passed against. */
304
+ referenceSource?: "registry" | "chip" | "document" | "subject" | "org_supplied";
305
+ }
306
+ /**
307
+ * Face-match probe-binding reason a `face_match` {@link SessionStep.reason} may
308
+ * carry (SDK spec §4.10): `probe_not_from_liveness` — the face image isn't the
309
+ * person in the liveness clip. Retryable within the step's attempts (the
310
+ * person re-takes the liveness capture); billed.
311
+ * @public
312
+ */
313
+ type ProbeBindingReason = "probe_not_from_liveness";
314
+ /**
315
+ * The languages the person being verified sees (hosted flow and SDK screens; spec 2026-10-29 §9), every screen in
316
+ * each. SMS and email messages stay in `ar`, `fr` or `en` (English for the three others).
317
+ * @public
318
+ */
319
+ type Locale = "ar" | "fr" | "en" | "es" | "pt" | "de";
320
+ /** The environment a webhook was emitted from. @public */
321
+ type SekyroEnvironment = "sandbox" | "live";
322
+ /**
323
+ * One check of a session, as the partner API projects it: enum/id fields only,
324
+ * never civil data.
325
+ * @public
326
+ */
327
+ interface SessionStep {
328
+ /** The node of your flow this step belongs to (e.g. `n_live`): the name of the step. Absent on sessions created before flows. */
329
+ id?: string;
330
+ /** What the step runs: the service of its node. Absent on sessions created before flows. */
331
+ service?: ServiceId;
332
+ state: CheckState;
333
+ /** Sekyro flows: the check failed and the flow's fallback took over. */
334
+ handled?: true;
335
+ /** Machine-readable failure/review reason, when the check has one. */
336
+ reason?: string;
337
+ /** With reason `camera_unavailable`: why, when the SDK said (`denied` or `no_camera`). */
338
+ reasonDetail?: CameraUnavailableCause;
339
+ /** Calibrated model score in [0, 1] for scored checks (liveness, face match). */
340
+ calibratedScore?: number;
341
+ /** The check failed after using all of its attempts. */
342
+ attemptsExhausted?: boolean;
343
+ /**
344
+ * `portrait_icao` only (ID mode): the per-criterion ICAO report of the last
345
+ * attempt — numbers and enums only, never the image.
346
+ */
347
+ report?: PortraitReportEntry[];
348
+ /**
349
+ * `face_match` only: the probe-quality measurement of the selfie that was
350
+ * matched (occlusion, head pose, eye openness, sharpness). Recorded for
351
+ * information only: it never changes the step's state or reason.
352
+ */
353
+ probeQuality?: ProbeQuality;
354
+ /**
355
+ * How a person decided this step ({@link SessionStepDecision}); absent when
356
+ * no person decided it.
357
+ */
358
+ decision?: SessionStepDecision;
359
+ /** The step last ran simulated in the Sandbox (no paid or external service). */
360
+ simulated?: true;
361
+ }
362
+ /**
363
+ * The probe-quality measurement on a `face_match` step. Numbers only; `null`
364
+ * means the value could not be measured. Informational: no threshold applies.
365
+ * @public
366
+ */
367
+ interface ProbeQuality {
368
+ /** Share of the inner face that is covered (a hand, a mask, a phone), in [0, 1]. */
369
+ occlusion: number | null;
370
+ /** Head pose in degrees. */
371
+ pose: {
372
+ yaw: number | null;
373
+ pitch: number | null;
374
+ roll: number | null;
375
+ };
376
+ /** Openness of the less-open eye, in [0, 1]. */
377
+ eyesOpen: number | null;
378
+ /** Sharpness of the face region (higher is sharper; no fixed scale). */
379
+ sharpness: number | null;
380
+ }
381
+ /**
382
+ * One row of the `portrait_icao` report (ID mode): the server's measurement of
383
+ * one ICAO criterion and the threshold that applied.
384
+ * @public
385
+ */
386
+ interface PortraitReportEntry {
387
+ criterion: "pose" | "eyes" | "mouth" | "occlusion" | "glare" | "lighting" | "background" | "resolution";
388
+ value: number | null;
389
+ threshold: number | string | null;
390
+ pass: boolean;
391
+ }
392
+ /**
393
+ * Out-of-band delivery of the session's hosted link, sent by Sekyro AI after the
394
+ * session is created. Best effort: a failed send never fails the create.
395
+ * @public
396
+ */
397
+ interface DeliverOptions {
398
+ /** Delivery channel. */
399
+ channel: "sms" | "whatsapp";
400
+ /** E.164 phone number of the recipient (`+` and the country code). */
401
+ to: string;
402
+ }
403
+ /**
404
+ * An ID number of the person (person data spec §4.1): the document type, the
405
+ * issuing country (ISO 3166-1 alpha-2; alpha-3 is accepted and normalized) and
406
+ * the number (1 to 40 characters, then the issuing country's rule, e.g. the
407
+ * check digit of a Mauritanian national ID number).
408
+ * @public
409
+ */
410
+ interface SubjectIdNumber {
411
+ type: "national_id" | "passport" | "residence_permit";
412
+ issuingCountry: string;
413
+ number: string;
414
+ }
415
+ /**
416
+ * The person's name in one script (ISO 15924 code, e.g. `Latn` or `Arab`).
417
+ * @public
418
+ */
419
+ interface SubjectName {
420
+ script: string;
421
+ /** 1 to 100 characters. */
422
+ given: string;
423
+ /** 1 to 100 characters. */
424
+ family: string;
425
+ /** Optional, 1 to 100 characters. */
426
+ patronymic?: string;
427
+ }
428
+ /**
429
+ * One birth place entry of {@link SessionPersonInput.birthPlace}: the place in
430
+ * one script (ISO 15924 code, e.g. `Latn` or `Arab`), 1 to 120 characters.
431
+ * @public
432
+ */
433
+ interface PersonBirthPlaceInput {
434
+ script: string;
435
+ value: string;
436
+ }
437
+ /**
438
+ * The person's identity document ({@link SessionPersonInput.document}): its
439
+ * type, issuing country (ISO 3166-1 alpha-2 or alpha-3) and the number it
440
+ * prints (1 to 40 letters, digits, spaces or hyphens). Compared with what the
441
+ * capture reads; it does not bind the session (`idNumber` does).
442
+ * @public
443
+ */
444
+ interface PersonDocumentInput {
445
+ type: "national_id" | "passport" | "residence_permit";
446
+ issuingCountry: string;
447
+ number: string;
448
+ }
449
+ /**
450
+ * What you already know about the person (`person` at session create). A
451
+ * closed object: unknown keys are refused (`400`). Every field is optional;
452
+ * `null` or blank counts as absent.
453
+ *
454
+ * The flow decides whether these are checked or believed: in a flow that checks
455
+ * identity from a document or a registry, they are a prefill compared with what
456
+ * the person shows; in a flow that verifies identity from your data (the
457
+ * response's `subjectUse: "reference"`), `idNumber`, `birthDate`, `photo` and
458
+ * `fetchedAt` are required and the record is the reference. `idNumber` binds the
459
+ * session to that identity in both cases: the hosted flow may omit it but cannot
460
+ * substitute another number.
461
+ * @public
462
+ */
463
+ interface SessionPersonInput {
464
+ /** The person's ID number. Binds the session. */
465
+ idNumber?: SubjectIdNumber;
466
+ /** E.164 phone number (`+` and the country code). */
467
+ phone?: string;
468
+ /** Email address, for the email OTP step. */
469
+ email?: string;
470
+ /** Full name, 1 to 200 characters, any script. */
471
+ fullName?: string;
472
+ /** The name per script, at most 4 entries, one per script. */
473
+ names?: SubjectName[];
474
+ /** ISO 8601 date (`YYYY-MM-DD`). */
475
+ birthDate?: string;
476
+ /**
477
+ * Place of birth (kept only with a reference record): a string of 1 to 120
478
+ * characters in any script, or one entry per script (at most 4).
479
+ */
480
+ birthPlace?: string | PersonBirthPlaceInput[];
481
+ /** `M`, `F` or `X` (ICAO 9303 values; kept only with a reference record). */
482
+ sex?: "M" | "F" | "X";
483
+ /** ISO 3166-1 alpha-2 codes, 1 to 4. */
484
+ nationalities?: string[];
485
+ /** The person's identity document ({@link PersonDocumentInput}). */
486
+ document?: PersonDocumentInput;
487
+ /**
488
+ * Base64 JPEG or PNG (optional data-URL prefix, at most 1 MB decoded): the
489
+ * face-match reference of a reference record. Refused in a flow that uses the
490
+ * data as a prefill (`422 subject_photo_not_used`).
491
+ */
492
+ photo?: string;
493
+ /** ISO 8601 date (`YYYY-MM-DD`) of the photo. */
494
+ photoDate?: string;
495
+ /**
496
+ * ISO 8601 date-time: when YOUR system obtained this data. Required with a
497
+ * reference record; at most 24 h old (`422 subject_record_stale`).
498
+ */
499
+ fetchedAt?: string;
500
+ /**
501
+ * Your own id for this person (1–128 characters). Echoed on the session and
502
+ * its webhooks, and searchable on the people API ({@link PeopleApi.list}).
503
+ */
504
+ externalRef?: string;
505
+ /**
506
+ * Returning user (profile v2 step 5): verify this already-verified subject
507
+ * again with liveness + face match only, against the reference photo stored
508
+ * on the subject. Name exactly one target. Errors at create:
509
+ * `404 subject_not_found`, `409 subject_revoked`, `409 subject_no_reference`,
510
+ * `409 subject_stale` (older than the flow's `returning.maxAgeMonths`),
511
+ * `409 reuse_disabled` (the flow turns returning-user sessions off) and
512
+ * `400` / `409 reuse_target_ambiguous`.
513
+ */
514
+ reuse?: SubjectReuseTarget;
515
+ }
516
+ /**
517
+ * Which person a returning-user session re-verifies: exactly ONE of the
518
+ * person id (`personId`, `per_...` or bare), your own `externalRef` (must match a
519
+ * single person) or the `idNumber` the person verified with.
520
+ * @public
521
+ */
522
+ type SubjectReuseTarget = ({
523
+ /** @deprecated Send `personId`. */
524
+ subjectId: string;
525
+ externalRef?: never;
526
+ idNumber?: never;
527
+ } | {
528
+ externalRef: string;
529
+ subjectId?: never;
530
+ idNumber?: never;
531
+ } | {
532
+ idNumber: SubjectIdNumber;
533
+ subjectId?: never;
534
+ externalRef?: never;
535
+ } | {
536
+ personId: string;
537
+ subjectId?: never;
538
+ externalRef?: never;
539
+ idNumber?: never;
540
+ }) & {
541
+ /**
542
+ * `recheck` (default) or `step_up` ({@link SubjectReuseMode}). `step_up` on
543
+ * a flow that does not prove level 2 on every path answers
544
+ * `400 step_up_flow_too_weak`.
545
+ */
546
+ mode?: SubjectReuseMode;
547
+ };
548
+ /** A document type the backend reads (kyc-docs-v2 vocabulary; `carte_identite` = identity card of any issuer). @public */
549
+ type ProfileDocumentType = "carte_identite" | "passport" | "residence_permit";
550
+ /**
551
+ * The services a Sekyro flow is built from. A session's steps
552
+ * ({@link SessionStep.service}) and {@link FlowOverrides.services} use these
553
+ * ids; one service may run several checks (e.g. `liveness` with an ICAO
554
+ * portrait).
555
+ * @public
556
+ */
557
+ type ServiceId = "device_network" | "phone_otp" | "email_otp" | "national_eid" | "document" | "nfc" | "population_registry" | "supplied_identity" | "summary_confirm" | "liveness" | "portrait" | "face_match" | "aml_screening" | "face_dedup" | "age_estimation";
558
+ /**
559
+ * The general settings of a flow that a session may override (the flow's
560
+ * `link`, `language` and override policy are not overridable). Country codes
561
+ * are ISO 3166-1 alpha-2 (`MR`). Used through {@link FlowOverrides.settings}.
562
+ * @public
563
+ */
564
+ interface FlowOverridableSettings {
565
+ /** Who may be verified. */
566
+ eligibility: {
567
+ /** Accepted nationalities: `'*'` or a list, optionally per IP location. */
568
+ nationalities: {
569
+ default: "*" | string[];
570
+ byLocation?: Record<string, "*" | string[]>;
571
+ };
572
+ /** Minimum age in years (1–120), or `null` for none. */
573
+ minAge: number | null;
574
+ };
575
+ /** Automatic decisions instead of human review (`retryConfidentRejects` lets confident rejects retry). */
576
+ decisions?: {
577
+ mode: "automatic" | "review";
578
+ retryConfidentRejects: boolean;
579
+ };
580
+ /** Data consistency across sources. */
581
+ fraud: {
582
+ /** Comparison of your `subject` data with the reference identity. */
583
+ nameMatch?: {
584
+ level: "strict" | "standard" | "lenient";
585
+ onMismatch: "fail" | "signal";
586
+ };
587
+ };
588
+ /** Returning-user sessions (`person.reuse`). */
589
+ returning: {
590
+ /** `false`: returning-user sessions are refused (`409 reuse_disabled`). */
591
+ enabled: boolean;
592
+ /** Maximum age in months (1–120) of the subject's last verification; `null` = no limit. */
593
+ maxAgeMonths: number | null;
594
+ };
595
+ /** Identity-document rules. */
596
+ documents: {
597
+ /** Accepted document types: `'*'` (all) or a list, optionally per issuing country. */
598
+ accepted: {
599
+ default: "*" | ProfileDocumentType[];
600
+ byIssuer?: Record<string, ProfileDocumentType[]>;
601
+ };
602
+ /** Expired documents: refused, allowed, or allowed for `graceDays` (1–365) after expiry. */
603
+ expired: "reject" | "allow" | {
604
+ graceDays: number;
605
+ };
606
+ authenticity: "standard" | "off";
607
+ };
608
+ }
609
+ /**
610
+ * Document substitution: the portrait a `document` or `nfc` step produces is
611
+ * compared with the registry portrait (or the chip with the printed photo).
612
+ * `signal` records a risk signal on a clear mismatch, `review` also sends the
613
+ * session to review, `off` compares nothing. `failBelow` is the mismatch bound
614
+ * in (0, 1), absent = the platform bound.
615
+ * @public
616
+ */
617
+ interface DocumentSubstitutionSettings {
618
+ mode: "off" | "signal" | "review";
619
+ failBelow?: number;
620
+ }
621
+ /**
622
+ * The per-service settings a session may override, by {@link ServiceId}.
623
+ * `attempts` limits are per step (absent = the platform default).
624
+ * @public
625
+ */
626
+ interface FlowServiceSettings {
627
+ /** Device & Network Intelligence: IP location, anonymizers, cooldown, device and capture postures. */
628
+ device_network: {
629
+ /** Where the end user may be (IP location). */
630
+ locations: {
631
+ mode: "all";
632
+ } | {
633
+ mode: "only" | "all_except";
634
+ countries: string[];
635
+ };
636
+ /** VPN / proxy / Tor. */
637
+ anonymizers: "allow" | "block";
638
+ /** Device cooldown after repeated rejections (at most 5 tiers; `[]` = off). */
639
+ cooldown?: {
640
+ tiers: Array<{
641
+ rejectedSessions: number;
642
+ windowHours: number;
643
+ waitMinutes: number;
644
+ }>;
645
+ };
646
+ /** Device tamper and velocity actions. */
647
+ device?: {
648
+ tamper: "block" | "signal";
649
+ velocity: {
650
+ maxIdentitiesPerDevice: number;
651
+ windowDays: number;
652
+ action: "signal" | "block";
653
+ };
654
+ };
655
+ attestation?: "off" | "signal" | "enforce";
656
+ captureIntegrity?: "off" | "signal" | "enforce";
657
+ };
658
+ phone_otp: {
659
+ /** Where the number comes from: your `person.phone`, the person, or either. */
660
+ numberSource: "prefilled" | "user_entered" | "prefilled_or_entered";
661
+ /** Narrow the channels the person may choose from (absent = every channel the org has on). */
662
+ channels?: Array<"whatsapp" | "sms">;
663
+ /** Which countries codes may be sent to (absent = the flow's allowed `locations`). */
664
+ destinations?: "locations" | "any" | {
665
+ countries: string[];
666
+ };
667
+ attempts?: number;
668
+ };
669
+ email_otp: {
670
+ /** Where the address comes from: your `input.email`, the person, or either. */
671
+ emailSource: "prefilled" | "user_entered" | "prefilled_or_entered";
672
+ /** Disposable (temporary) addresses: allowed, flagged as a risk signal (default), or refused. */
673
+ disposable?: "allow" | "signal" | "block";
674
+ attempts?: number;
675
+ };
676
+ national_eid: {
677
+ /**
678
+ * `'org'` (every national eID the org can use, resolved at session create)
679
+ * or provider ids (`{country}.{provider}`, e.g. `MR.houwiyeti`).
680
+ */
681
+ providers: "org" | string[];
682
+ /** The eID portrait is the face-match reference. */
683
+ portraitReference: boolean;
684
+ };
685
+ document: {
686
+ attempts?: number;
687
+ /** Compare the document photo with the registry photo (absent = the platform default). */
688
+ documentSubstitution?: DocumentSubstitutionSettings;
689
+ };
690
+ /** The chip read (its MRZ source is derived from the flow and is not overridable). */
691
+ nfc: {
692
+ maxAttempts?: number;
693
+ /** Compare the chip photo with the registry photo (absent = the platform default). */
694
+ documentSubstitution?: DocumentSubstitutionSettings;
695
+ };
696
+ population_registry: {
697
+ /** `'org'` (every registry the org can use, resolved at session create) or registry ids. */
698
+ sources: "org" | Array<"MR.anrpts">;
699
+ /**
700
+ * @deprecated Use `idNumberSource` (same values). Both with different values is
701
+ * `400 override_invalid`.
702
+ */
703
+ nniSource: "auto" | "typed" | "bound_only";
704
+ /** Where the ID number comes from: `auto`, `typed` (the person types it) or `bound_only` (your `person.idNumber`). */
705
+ idNumberSource: "auto" | "typed" | "bound_only";
706
+ onUncovered: "skip";
707
+ attempts?: number;
708
+ };
709
+ supplied_identity: Record<string, never>;
710
+ summary_confirm: {
711
+ /** Offer « Reprendre » (re-open the identity source). */
712
+ retake: boolean;
713
+ };
714
+ liveness: {
715
+ /** `off`, selfie ICAO `alert` / `reject`, or `id_document` (ID-photo portrait, always rejects). */
716
+ icao: "off" | "alert" | "reject" | "id_document";
717
+ attempts?: number;
718
+ };
719
+ /** The ICAO photo step. */
720
+ portrait: {
721
+ /** Where the photo comes from (absent = `camera`). */
722
+ source?: "camera" | "upload" | "choice";
723
+ /** Who holds the camera (absent = `self`). */
724
+ capture?: "self" | "assisted" | "choice";
725
+ /** An upload on a path with no liveness: `refuse`, or `mark` with the signal `portrait_unbound` (absent = `refuse`). */
726
+ unbound?: "refuse" | "mark";
727
+ /** `reject`: a failing photo asks for another; `alert`: it passes with the signal `icao_non_compliant`. */
728
+ policy: "reject" | "alert";
729
+ /** Crop, scale and straighten (absent = `on`). */
730
+ fixes?: "off" | "on";
731
+ /** Ask the person to confirm a fixed photo (absent = `confirm`). */
732
+ fixReview?: "confirm" | "silent";
733
+ /** The delivered format (absent = `icao_9303`). */
734
+ output?: "icao_9303" | "photo_35x45_300dpi" | "square_600";
735
+ attempts?: number;
736
+ };
737
+ face_match: {
738
+ reference: "auto" | "document" | "registry";
739
+ attempts?: number;
740
+ };
741
+ /**
742
+ * Sanctions and PEP screening of the person the flow verified. `onHit`: `signal`
743
+ * (the session goes on and the match is reported), `review` (a reviewer
744
+ * decides) or `fail` (the session is rejected with `aml_hit`).
745
+ */
746
+ aml_screening: {
747
+ lists: ScreeningList[];
748
+ onHit: "signal" | "review" | "fail";
749
+ };
750
+ face_dedup: {
751
+ scope: "app" | "org";
752
+ onDuplicate: "review" | "fail";
753
+ };
754
+ /** The age check (selfie); the threshold is the flow's `eligibility.minAge`. */
755
+ age_estimation: {
756
+ /** Keep and show the estimated age ({@link AgeResult.estimate}) on the API session and webhooks. Default `false`. */
757
+ showEstimatedAge?: boolean;
758
+ };
759
+ }
760
+ /**
761
+ * `T` with every property optional, recursively. Arrays are replaced as a
762
+ * whole, never merged element by element.
763
+ * @public
764
+ */
765
+ type DeepPartial<T> = T extends readonly unknown[] ? T : T extends object ? {
766
+ [K in keyof T]?: DeepPartial<T[K]>;
767
+ } : T;
768
+ /**
769
+ * A per-session override of the flow ({@link CreateSessionInput.overrides}).
770
+ *
771
+ * - `settings`: any subset of {@link FlowOverridableSettings}, at any depth.
772
+ * - `services`: keyed by service (applied to every node of that service): any
773
+ * subset of its {@link FlowServiceSettings}, or `'off'` to remove it from
774
+ * the flow. A service the flow does not use is ignored.
775
+ *
776
+ * Objects merge into the flow; arrays and scalar values replace. Unknown keys
777
+ * and invalid results answer `400 override_invalid`. An override may only
778
+ * make the flow stricter unless the flow allows widening; turning a service
779
+ * `'off'` always widens. A widening change answers `403 override_widens_flow`.
780
+ * The changed paths are reported on {@link Session.overriddenFields}.
781
+ *
782
+ * @example
783
+ * ```ts
784
+ * await sekyro.sessions.create({
785
+ * flow: "foreigners",
786
+ * overrides: {
787
+ * settings: { eligibility: { minAge: 21 } },
788
+ * services: { liveness: { attempts: 2 } },
789
+ * },
790
+ * });
791
+ * ```
792
+ * @public
793
+ */
794
+ interface FlowOverrides {
795
+ settings?: DeepPartial<FlowOverridableSettings>;
796
+ services?: {
797
+ [S in ServiceId]?: DeepPartial<FlowServiceSettings[S]> | "off";
798
+ };
799
+ }
800
+ /**
801
+ * The flow version a session runs: its `flw_` id, its slug and the published
802
+ * version pinned at create.
803
+ * @public
804
+ */
805
+ interface SessionFlowRef {
806
+ id: string;
807
+ slug: string;
808
+ version: number;
809
+ }
810
+ /**
811
+ * Input of {@link SessionsApi.simulate}.
812
+ * @public
813
+ */
814
+ interface SimulateSessionInput {
815
+ /** How the session ends. The flow must be able to reach it, else `422 simulate_outcome_unreachable`. */
816
+ outcome: "approved" | "rejected" | "review";
817
+ /**
818
+ * Only with `rejected`: the reason the failing step reports, e.g.
819
+ * `spoof_detected`. No step on the path can fail with it: `422 simulate_reason_invalid`.
820
+ */
821
+ reason?: string;
822
+ }
823
+ /**
824
+ * The API key in use, from {@link Sekyro.me}. Never carries the secret.
825
+ * @public
826
+ */
827
+ interface ApiKeyIdentity {
828
+ /** The environment the key belongs to. */
829
+ env: SekyroEnvironment;
830
+ /** The public start of the key, e.g. `sk_test_ab12`. */
831
+ keyPrefix: string;
832
+ scopes: string[];
833
+ app: {
834
+ id: string;
835
+ slug: string;
836
+ name: string;
837
+ };
838
+ org: {
839
+ name: string;
840
+ };
841
+ }
842
+ /**
843
+ * One flow of your app, from {@link FlowsApi.list}. Published flows only;
844
+ * pass `slug` or `id` as {@link CreateSessionInput.flow}.
845
+ * @public
846
+ */
847
+ interface FlowSummary {
848
+ /** `flw_` id. */
849
+ id: string;
850
+ slug: string;
851
+ name: string;
852
+ /** The published version a new session runs. */
853
+ version: number;
854
+ /** The flow a session runs when you send no `flow`. */
855
+ isDefault: boolean;
856
+ }
857
+ /**
858
+ * Input of {@link SessionsApi.create}. The API key belongs to an app; the
859
+ * app's flow (its default flow, or the one named in `flow`) decides the steps.
860
+ * @public
861
+ */
862
+ interface CreateSessionInput {
863
+ /**
864
+ * The app's flow to run: its slug (e.g. `foreigners`) or `flw_` id, as
865
+ * {@link FlowsApi.list} lists them. Absent = the app's default flow.
866
+ * Errors: `404 flow_not_found` (no such flow in the key's app),
867
+ * `409 flow_not_published`, `409 flow_archived`.
868
+ */
869
+ flow?: string;
870
+ /** Pins the hosted-flow language. Omit to let the person's device decide. */
871
+ locale?: Locale;
872
+ /**
873
+ * Pre-choose the identity method when the flow offers a choice of identity
874
+ * method (the hosted choice screen is then skipped). Ignored otherwise.
875
+ */
876
+ identityMethod?: IdentityMethod;
877
+ /**
878
+ * Session lifetime in minutes. Must fall within the flow's link range,
879
+ * otherwise the API answers `400 ttl_out_of_policy`. Omit to use the
880
+ * flow's default.
881
+ */
882
+ ttlMinutes?: number;
883
+ /** Also send the hosted link to the person by SMS or WhatsApp. */
884
+ deliver?: DeliverOptions;
885
+ /**
886
+ * Where the hosted flow returns the person when the session ends
887
+ * ({@link SessionLinkInput}). A URL outside the app's web origins and app
888
+ * scheme answers `400 return_url_not_allowed`.
889
+ */
890
+ link?: SessionLinkInput;
891
+ /**
892
+ * What you already know about the person (preferred over `input` for
893
+ * identity data).
894
+ */
895
+ person?: SessionPersonInput;
896
+ /**
897
+ * Your own id for the agent filming the person, for flows whose liveness
898
+ * capture is `assisted` (1 to 128 characters). Stored as is and echoed on
899
+ * the session and in webhooks.
900
+ */
901
+ assistedBy?: {
902
+ externalRef: string;
903
+ };
904
+ /**
905
+ * Override the flow for this session only ({@link FlowOverrides}): its
906
+ * general settings and per-service settings, or turn a service `'off'`.
907
+ * `400 override_invalid` for an unknown key or an invalid result;
908
+ * `403 override_widens_flow` for a change that makes the flow less strict
909
+ * when the flow does not allow widening.
910
+ */
911
+ overrides?: FlowOverrides;
912
+ /**
913
+ * An open record of branch facts your flow's `input.<key>` conditions read.
914
+ * Person data goes in {@link CreateSessionInput.person}: `nni`, `phone`,
915
+ * `email`, `fullName`, `birthDate` or `suppliedIdentity` here answers
916
+ * `400 input_field_misplaced`.
917
+ */
918
+ input?: Record<string, unknown>;
919
+ }
920
+ /** Per-request options. @public */
921
+ interface RequestOptions {
922
+ /**
923
+ * Sent as `X-Idempotency-Key`. Replaying the same key within 24 h returns the
924
+ * original response instead of creating a second session.
925
+ */
926
+ idempotencyKey?: string;
927
+ }
928
+ /**
929
+ * Result of {@link SessionsApi.create}. `clientToken` is returned ONCE and never
930
+ * again — hand it to the browser (`@sekyro/web`) and do not persist it.
931
+ * @public
932
+ */
933
+ interface CreatedSession {
934
+ id: string;
935
+ status: SessionStatus;
936
+ /** One-time credential for the client SDK / hosted flow. */
937
+ clientToken: string;
938
+ /** Hosted verification link for this session. */
939
+ hostedUrl: string;
940
+ /** The flow version the session runs (the default flow when you sent no `flow`). */
941
+ flow?: SessionFlowRef;
942
+ /** The checks on the session's path (checks of a lane not taken are omitted). */
943
+ steps: SessionStep[];
944
+ /** ISO 8601 — when the session (and its link) stop accepting input. */
945
+ expiresAt: string;
946
+ /** The levels the flow can reach on its paths; absent from older API versions. */
947
+ levelTarget?: LevelTarget;
948
+ /**
949
+ * How the flow uses the person data you sent: `reference` (believed, your
950
+ * record is the identity reference) or `prefill` (checked against the
951
+ * person's document or registry record). Absent from older API versions.
952
+ */
953
+ subjectUse?: "reference" | "prefill";
954
+ /**
955
+ * With {@link CreateSessionInput.deliver} only: the send of the hosted link.
956
+ * `failed` never fails the create; `simulated` on a simulated Sandbox session.
957
+ */
958
+ delivery?: {
959
+ status: "queued" | "failed" | "simulated";
960
+ };
961
+ }
962
+ /**
963
+ * Input of {@link PeopleApi.createSession}: a re-check or step-up session
964
+ * for an existing person in one call.
965
+ * @public
966
+ */
967
+ interface PersonSessionInput {
968
+ mode: SubjectReuseMode;
969
+ /** The app's flow to run (slug or `flw_` id); absent = the app's default flow. */
970
+ flow?: string;
971
+ link?: SessionLinkInput;
972
+ /** Session lifetime in minutes, within the flow's link range. */
973
+ ttlMinutes?: number;
974
+ locale?: Locale;
975
+ }
976
+ /**
977
+ * Which person {@link PeopleApi.createSession} targets: the person id
978
+ * (`per_...` or the bare 24 hexadecimal characters) or your own external
979
+ * reference.
980
+ * @public
981
+ */
982
+ type PersonSessionTarget = {
983
+ personId: string;
984
+ } | {
985
+ externalRef: string;
986
+ };
987
+ /** Result of {@link SessionsApi.resultToken}: a freshly signed result token. @public */
988
+ interface ResultTokenResponse {
989
+ /** ES256 JWT; check it with {@link verifyResultToken}. */
990
+ token: string;
991
+ /** ISO 8601: when the token expires (10 minutes after signing). */
992
+ expiresAt: string;
993
+ }
994
+ /**
995
+ * The end user's network at the start of the session (IP-derived, approximate).
996
+ * @public
997
+ */
998
+ interface SessionNetworkEvent {
999
+ /** ISO 8601. */
1000
+ at: string;
1001
+ /** ISO 3166-1 alpha-2. */
1002
+ country?: string;
1003
+ region?: string;
1004
+ city?: string;
1005
+ asn?: number;
1006
+ operator?: string;
1007
+ connectionType: "mobile" | "hosting" | "unknown";
1008
+ anonymizer: {
1009
+ /** A known commercial VPN service exit. */
1010
+ vpn: boolean;
1011
+ /** A Tor exit. */
1012
+ tor: boolean;
1013
+ /** A cloud, hosting or data center network. */
1014
+ hosting: boolean;
1015
+ /** A public open proxy. Present only when true. */
1016
+ proxy?: boolean;
1017
+ /**
1018
+ * Apple iCloud Private Relay. A privacy relay for Apple accounts, not counted
1019
+ * as an anonymizer. Present only when true.
1020
+ */
1021
+ relay?: boolean;
1022
+ };
1023
+ /** IANA time zone reported by the end user's device. */
1024
+ browserTimezone?: string;
1025
+ /** True when the device time zone does not belong to the IP country. */
1026
+ timezoneMismatch?: boolean;
1027
+ }
1028
+ /**
1029
+ * End-user network context; absent when not recorded.
1030
+ * @public
1031
+ */
1032
+ interface SessionNetwork {
1033
+ /** The start event's IP address. Never sent in webhooks. */
1034
+ ip?: string;
1035
+ /** True when a later call came from a different country than the start. */
1036
+ countryChanged: boolean;
1037
+ start: SessionNetworkEvent;
1038
+ }
1039
+ /**
1040
+ * Device signals detected on the end user's device.
1041
+ * @public
1042
+ */
1043
+ type SessionDeviceSignal = "webdriver" | "headless" | "emulator" | "rooted" | "jailbroken" | "debugger" | "hooking" | "virtual_camera";
1044
+ /**
1045
+ * End-user device summary; absent when not recorded.
1046
+ * @public
1047
+ */
1048
+ interface SessionDevice {
1049
+ platform: "web" | "android" | "ios";
1050
+ sdk?: string;
1051
+ os?: string;
1052
+ osVersion?: string;
1053
+ browser?: string;
1054
+ browserVersion?: string;
1055
+ deviceClass: "mobile" | "tablet" | "desktop" | "unknown";
1056
+ model?: string;
1057
+ /**
1058
+ * Opaque device identity inside your organization and environment, stable across sessions
1059
+ * while the device keeps its install id. May be absent (for example without a device
1060
+ * header).
1061
+ */
1062
+ deviceId?: string;
1063
+ /** Hashed device keys of this session, per organization. */
1064
+ deviceKeys: string[];
1065
+ signals: SessionDeviceSignal[];
1066
+ }
1067
+ /**
1068
+ * The national eID that verified the session's identity (the `eid_auth` check
1069
+ * passed): the provider id (`{country}.{provider}`, e.g. `MR.houwiyeti`), its
1070
+ * ISO 3166-1 alpha-2 country and when. A passed eID ends the session.
1071
+ * @public
1072
+ */
1073
+ interface EidResult {
1074
+ provider: string;
1075
+ country: string;
1076
+ verifiedAt: string;
1077
+ }
1078
+ /**
1079
+ * The full phone number and email address the person verified in a session
1080
+ * (an OTP check that passed) — sent ONLY to you (the session view and your
1081
+ * webhooks), never to the person's browser, and removed when the session's
1082
+ * personal data is purged. You are the controller of these values. A
1083
+ * prefilled value that was not verified is never listed.
1084
+ * @public
1085
+ */
1086
+ interface VerifiedContacts {
1087
+ /** From a passed `phone_otp` check. */
1088
+ phone?: {
1089
+ /** E.164 (`+` and the country code). */
1090
+ number: string;
1091
+ /** The channel the code was delivered on. */
1092
+ channel: "whatsapp" | "sms";
1093
+ /** ISO 8601. */
1094
+ verifiedAt: string;
1095
+ };
1096
+ /** From a passed `email_otp` check. */
1097
+ email?: {
1098
+ /** The verified address (domain lowercased). */
1099
+ address: string;
1100
+ /** ISO 8601. */
1101
+ verifiedAt: string;
1102
+ };
1103
+ }
1104
+ /**
1105
+ * Where a value of {@link Identity} comes from: the `document` (its machine
1106
+ * readable zone or printed text), the passport `chip`, the population
1107
+ * `registry`, a national `eid`, or the record you `supplied` at create.
1108
+ * @public
1109
+ */
1110
+ type IdentitySource = "document" | "chip" | "registry" | "eid" | "supplied";
1111
+ /**
1112
+ * How a name of {@link Identity.names} was obtained: `mrz` (the ICAO
1113
+ * transliteration of the machine readable zone: upper case, truncated, no
1114
+ * diacritics), `printed` (the visual zone, as written), `chip` (the chip's
1115
+ * data groups), `registry`, `eid` or `supplied`.
1116
+ * @public
1117
+ */
1118
+ type NameForm = "mrz" | "printed" | "chip" | "registry" | "eid" | "supplied";
1119
+ /**
1120
+ * One name as one source gives it. Names from different sources are never
1121
+ * merged. For an `mrz` entry `family` holds the ICAO primary identifier and
1122
+ * `given` the secondary one, as the document arranges them. To show a name,
1123
+ * pick the first entry whose `form` is not `mrz`.
1124
+ * @public
1125
+ */
1126
+ interface IdentityName {
1127
+ /** ISO 15924 script, e.g. `Latn` or `Arab`. */
1128
+ script: string;
1129
+ form: NameForm;
1130
+ /** Given names (the secondary identifier). */
1131
+ given?: string;
1132
+ /** Family name (the primary identifier). */
1133
+ family?: string;
1134
+ /** The father's given name, when the source distinguishes it. */
1135
+ patronymic?: string;
1136
+ /** The name as one string, when the source gives one (never built from the parts). */
1137
+ fullName?: string;
1138
+ source: IdentitySource;
1139
+ }
1140
+ /** One birth place as one source wrote it ({@link Identity.birthPlace}). @public */
1141
+ interface IdentityBirthPlace {
1142
+ /** ISO 15924 script. */
1143
+ script: string;
1144
+ value: string;
1145
+ source: IdentitySource;
1146
+ }
1147
+ /** The holder's national number, when a per-country rule recognises it ({@link Identity.idNumber}). @public */
1148
+ interface IdentityIdNumber {
1149
+ type: "national_id" | "passport" | "residence_permit";
1150
+ /** ISO 3166-1 alpha-2. */
1151
+ issuingCountry: string;
1152
+ /** The number, normalised. */
1153
+ number: string;
1154
+ }
1155
+ /** The document or chip that was read ({@link Identity.document}). @public */
1156
+ interface IdentityDocument {
1157
+ type: "national_id" | "passport" | "residence_permit";
1158
+ /** ISO 3166-1 alpha-2, or the ICAO code as read when it has no ISO equivalent. */
1159
+ issuingCountry?: string;
1160
+ /** The document number as read: upper case, no spaces. */
1161
+ number?: string;
1162
+ /** `YYYY-MM-DD`. */
1163
+ expiryDate?: string;
1164
+ /** `YYYY-MM-DD`, from the chip. */
1165
+ issueDate?: string;
1166
+ /** The issuing authority as written, from the chip. */
1167
+ issuingAuthority?: string;
1168
+ /** The keys whose value a check digit protects. Never the names. */
1169
+ mrzVerified?: Array<"number" | "birthDate" | "expiryDate" | "idNumber">;
1170
+ }
1171
+ /**
1172
+ * The scalar keys of {@link Identity} that {@link Identity.sources} reports on.
1173
+ * @public
1174
+ */
1175
+ type IdentityScalarKey = "idNumber" | "birthDate" | "sex" | "nationalities" | "document.number" | "document.expiryDate";
1176
+ /**
1177
+ * For each scalar key, the sources whose value equals the returned one. A
1178
+ * source that read another value is not listed (its step carries the mismatch
1179
+ * reason).
1180
+ * @public
1181
+ */
1182
+ type IdentitySources = Partial<Record<IdentityScalarKey, IdentitySource[]>>;
1183
+ /**
1184
+ * The identity data a session read (its document, chip, registry, eID or your
1185
+ * supplied record), present once one identity step settled, whatever the
1186
+ * outcome. On a person ({@link Person.identity}), the identity of the latest
1187
+ * approved session that read one. Every key is optional. Sent to you only (the
1188
+ * session view, the person view and the terminal webhooks).
1189
+ * @public
1190
+ */
1191
+ interface Identity {
1192
+ idNumber?: IdentityIdNumber;
1193
+ /** One entry per source and script, registry forms first. */
1194
+ names?: IdentityName[];
1195
+ /** ISO 8601 with the precision the source has: `YYYY-MM-DD`, `YYYY-MM` or `YYYY`. */
1196
+ birthDate?: string;
1197
+ birthPlace?: IdentityBirthPlace[];
1198
+ /** `null` when the source read an unspecified value; absent when no source read it. */
1199
+ sex?: "M" | "F" | "X" | null;
1200
+ /** ISO 3166-1 alpha-2 codes, or the ICAO code when it has no ISO equivalent. */
1201
+ nationalities?: string[];
1202
+ /** Set when the nationality code is not a country (e.g. `stateless`). */
1203
+ nationalityKind?: string;
1204
+ document?: IdentityDocument;
1205
+ sources?: IdentitySources;
1206
+ /** The registry a registry step passed against. */
1207
+ registry?: {
1208
+ id: string;
1209
+ fetchedAt?: string;
1210
+ };
1211
+ /** The national eID that verified the identity. */
1212
+ eid?: {
1213
+ provider: string;
1214
+ country: string;
1215
+ verifiedAt?: string;
1216
+ };
1217
+ /** ISO 8601: when the last identity step settled. */
1218
+ verifiedAt?: string;
1219
+ /** @deprecated Read {@link Identity.names}. The first Latin name as one string. */
1220
+ name?: string;
1221
+ }
1222
+ /**
1223
+ * The media kinds of a session, in the order the API lists them.
1224
+ * `reference_portrait` is the photo the face match compared against.
1225
+ * @public
1226
+ */
1227
+ type MediaKind = "icao_portrait" | "document_front" | "document_back" | "document_portrait" | "chip_portrait" | "reference_portrait" | "supplied_photo" | "selfie" | "liveness_clip";
1228
+ /**
1229
+ * One media object of a session ({@link SessionsApi.media}). `url` is a
1230
+ * download link valid 15 minutes, or the bytes route on this API
1231
+ * (`/api/v2/sessions/{id}/media/{kind}`), which needs your key: read it with
1232
+ * {@link SessionsApi.mediaBytes}. Never store the URL.
1233
+ * @public
1234
+ */
1235
+ interface MediaItem {
1236
+ kind: MediaKind;
1237
+ /** The check that produced or used it. */
1238
+ check: string;
1239
+ /** The attempt it came from (1, 2, ...); absent when it is not per attempt. */
1240
+ attempt?: number;
1241
+ /** It belongs to the attempt that settled the check. */
1242
+ decisive: boolean;
1243
+ /** The state of that attempt, else of the check. */
1244
+ state?: string;
1245
+ /** The reason of that attempt, when it did not pass. */
1246
+ reason?: string;
1247
+ /** The attempt was set aside (for example a retake) and not counted. */
1248
+ voided?: string;
1249
+ contentType: "image/jpeg" | "image/png" | "video/mp4" | "video/webm";
1250
+ /** `reference_portrait` and `supplied_photo`: where the photo came from (`stored`: kept from an earlier verification). */
1251
+ source?: "registry" | "eid" | "chip" | "document" | "supplied" | "stored";
1252
+ /** `reference_portrait`: the registry photo was fetched again for this match. */
1253
+ refreshed?: true;
1254
+ url: string;
1255
+ /** ISO 8601: when `url` expires. List the media again for fresh links. */
1256
+ expiresAt: string;
1257
+ }
1258
+ /** Result of {@link SessionsApi.media}. @public */
1259
+ interface MediaList {
1260
+ items: MediaItem[];
1261
+ }
1262
+ /** Options of {@link SessionsApi.mediaBytes}. @public */
1263
+ interface MediaBytesOptions {
1264
+ /** The attempt (1, 2, ...) to read; default: the decisive item, else the latest attempt. */
1265
+ attempt?: number;
1266
+ /** `reference_portrait` only: the first reference, when a second one decided the step. */
1267
+ reference?: "first";
1268
+ }
1269
+ /** Result of {@link SessionsApi.mediaBytes}: the bytes and their media type. @public */
1270
+ interface MediaBytes {
1271
+ contentType: string;
1272
+ bytes: Uint8Array;
1273
+ }
1274
+ /**
1275
+ * Who closed a completed or failed session: `review` when a person decided
1276
+ * the verdict (the deciding step carries its {@link SessionStepDecision}),
1277
+ * `automatic` otherwise (a review deadline included).
1278
+ * @public
1279
+ */
1280
+ type DecidedBy = "automatic" | "review";
1281
+ /**
1282
+ * The whitelisted session view returned by {@link SessionsApi.get}. Never
1283
+ * contains the client token.
1284
+ * @public
1285
+ */
1286
+ interface Session {
1287
+ id: string;
1288
+ /** Sekyro flows: the flow version the session runs (absent on sessions created before flows). */
1289
+ flow?: SessionFlowRef;
1290
+ status: SessionStatus;
1291
+ outcome: SessionOutcome | null;
1292
+ /** Completed and failed sessions: who decided the verdict ({@link DecidedBy}). */
1293
+ decidedBy?: DecidedBy;
1294
+ /**
1295
+ * A session closed because a newer attempt of the same person took over its
1296
+ * review: that session's id (`outcome` is `null`). Watch it instead.
1297
+ */
1298
+ supersededBy?: string;
1299
+ /**
1300
+ * What the session proved ({@link VerificationLevel}), on a completed or
1301
+ * failed session: `0` when it was rejected. Absent while the session is
1302
+ * active, and from older API versions.
1303
+ */
1304
+ level?: VerificationLevel | null;
1305
+ /** How the level was proved; `null` while the session is active. */
1306
+ assurance?: VerificationAssurance | null;
1307
+ /** The billing unit the session consumed; `null` while the session is active. */
1308
+ unit?: VerificationUnit | null;
1309
+ /** The levels the session's flow can reach. */
1310
+ levelTarget?: LevelTarget;
1311
+ /** The checks on the session's path (checks of a lane the person did not take are omitted). */
1312
+ steps: SessionStep[];
1313
+ /** ISO 8601. */
1314
+ expiresAt: string;
1315
+ /** ISO 8601. Absent on a session view that does not carry it. */
1316
+ createdAt?: string;
1317
+ /** ISO 8601: when the session reached a terminal state; `null` while it is active. */
1318
+ completedAt?: string | null;
1319
+ /** End-user network context; absent when not recorded. */
1320
+ network?: SessionNetwork;
1321
+ /** End-user device; absent when not recorded. */
1322
+ device?: SessionDevice;
1323
+ /**
1324
+ * Set when a profile-v2 policy ended the session: a session-level gate
1325
+ * (location, anonymizer) or a failed check's policy reason (eligibility,
1326
+ * `document_nni_mismatch`). Absent otherwise.
1327
+ */
1328
+ failureReason?: PolicyFailureReason;
1329
+ /** With failureReason `camera_unavailable`: why (`denied` or `no_camera`), when the SDK said. Absent otherwise. */
1330
+ failureDetail?: CameraUnavailableCause;
1331
+ /** The person (`per_...`) this session is linked to, once that person has passed a verification (absent before that). */
1332
+ personId?: string;
1333
+ /** Your own id for the person, from `person.externalRef` at create. */
1334
+ externalRef?: string;
1335
+ /** The agent reference sent as `assistedBy` at create, for assisted capture. */
1336
+ assistedBy?: {
1337
+ externalRef: string;
1338
+ };
1339
+ /**
1340
+ * `true` when an identifier this session read already belongs to a
1341
+ * different person than `personId`: the people are never merged.
1342
+ */
1343
+ personConflict?: boolean;
1344
+ /**
1345
+ * ISO 8601 — when the end user's device may verify again; set with
1346
+ * `failureReason: 'device_cooldown'`.
1347
+ */
1348
+ retryAfter?: string;
1349
+ /**
1350
+ * Dotted paths this session's {@link CreateSessionInput.overrides} changed
1351
+ * (e.g. `settings.decisions.mode`, `services.liveness`).
1352
+ */
1353
+ overriddenFields?: string[];
1354
+ /**
1355
+ * Risk signals recorded on the session (e.g. `device_velocity`,
1356
+ * `timezone_mismatch`, `icao_non_compliant` when an `alert` ICAO policy flagged
1357
+ * the selfie, `document_uploaded` and the `document_upload_*` signals when the
1358
+ * person uploaded a photo of the document) — signals only, never a verdict by themselves.
1359
+ */
1360
+ riskSignals?: string[];
1361
+ /**
1362
+ * `true` for a returning-user session (created with
1363
+ * {@link SessionPersonInput.reuse}): liveness + face match against the
1364
+ * subject's stored reference photo only.
1365
+ */
1366
+ returning?: true;
1367
+ /** On a returning-user session: the subject (person) it re-verifies. */
1368
+ reuseOf?: string;
1369
+ /**
1370
+ * On a session created for an existing subject: `recheck` (the same person
1371
+ * again) or `step_up` (raised to identity level). Absent otherwise.
1372
+ */
1373
+ reuseMode?: SubjectReuseMode;
1374
+ /** The contacts verified in this session (passed OTP checks only); absent when none. */
1375
+ verifiedContacts?: VerifiedContacts;
1376
+ /**
1377
+ * When the flow sets a minimum age and the session proved it: the threshold
1378
+ * and how it was proved ({@link AgeResult}). Absent otherwise.
1379
+ */
1380
+ age?: AgeResult;
1381
+ /**
1382
+ * The identity data the session read ({@link Identity}), once one identity
1383
+ * step settled. On an approved returning-user session, with a key that also
1384
+ * holds `people:read`, the identity stored on the person.
1385
+ */
1386
+ identity?: Identity;
1387
+ /** The media kinds this session has, in kind order: fetch them with {@link SessionsApi.media}. */
1388
+ media?: MediaKind[];
1389
+ /**
1390
+ * Terminal sessions, when result tokens are on: a signed result token
1391
+ * (ES256 JWT, valid 10 minutes). Check it with {@link verifyResultToken}.
1392
+ */
1393
+ resultToken?: string;
1394
+ /** Terminal sessions: other people the face matched in the duplicate search (non-empty only). */
1395
+ duplicates?: ResultDuplicate[];
1396
+ /** Terminal sessions: the duplicate search could not run. */
1397
+ dedupUnavailable?: true;
1398
+ /**
1399
+ * Terminal sessions: a failure identification match
1400
+ * ({@link FailureIdentification}), present only for a match and only when the
1401
+ * setting is on. A signal, never a decision.
1402
+ */
1403
+ failureIdentification?: FailureIdentification;
1404
+ /**
1405
+ * Terminal sessions whose flow screens the person against sanctions and PEP
1406
+ * lists: the result ({@link SessionScreening}), or why it could not run.
1407
+ */
1408
+ screening?: SessionScreening;
1409
+ }
1410
+ /**
1411
+ * `data` of the session lifecycle events (`session.started` |
1412
+ * `session.review_pending` | `session.completed` | `session.failed` |
1413
+ * `session.expired`). `outcome`, `decidedBy` and `steps` travel on
1414
+ * `completed` / `failed`, which are the one terminal event of a session: a
1415
+ * reviewer's decision arrives as one of them with `decidedBy: "review"` and
1416
+ * the `decision`. `review_pending` carries `steps` without an outcome;
1417
+ * `expired` carries the status and the session's refs (`flow`, person ids,
1418
+ * `overriddenFields`). `identity` and `media` (kinds only, never links) ride on
1419
+ * `completed` / `failed` when the platform sends them.
1420
+ * @public
1421
+ */
1422
+ interface SessionLifecycleEventData {
1423
+ /** The session id (`ses_...`). */
1424
+ sessionId: string;
1425
+ status: SessionStatus;
1426
+ outcome?: SessionOutcome | null;
1427
+ /** On `completed` / `failed`: who decided the verdict ({@link DecidedBy}). */
1428
+ decidedBy?: DecidedBy;
1429
+ /** On `completed` / `failed` with `decidedBy: "review"`: how the deciding step was decided. */
1430
+ decision?: SessionStepDecision;
1431
+ /** On `completed` / `failed`: the app the session belongs to. */
1432
+ appId?: string;
1433
+ /** On `completed` / `failed`: what the session proved ({@link VerificationLevel}). */
1434
+ level?: VerificationLevel | null;
1435
+ /** On `completed` / `failed`: how the level was proved. */
1436
+ assurance?: VerificationAssurance | null;
1437
+ /** On `completed` / `failed`: the billing unit the session consumed. */
1438
+ unit?: VerificationUnit | null;
1439
+ /** On `completed` / `failed`: ISO 8601 terminal time. */
1440
+ verifiedAt?: string;
1441
+ /** On `completed` / `failed`: device and network risk facts, when recorded. */
1442
+ risk?: ResultRisk;
1443
+ /** On `completed` / `failed`: other subjects the face matched, when a duplicate search ran. */
1444
+ duplicates?: ResultDuplicate[];
1445
+ /**
1446
+ * On `completed` / `failed`: the signed result token (ES256 JWT, valid
1447
+ * 10 minutes). Check it with {@link verifyResultToken}; absent when
1448
+ * result tokens are not enabled.
1449
+ */
1450
+ resultToken?: string;
1451
+ /** On `completed` / `failed`: the duplicate search could not run. */
1452
+ dedupUnavailable?: true;
1453
+ /**
1454
+ * The checks on the session's path (checks of a lane the person did not take
1455
+ * are omitted), each with its {@link SessionStepDecision} when a person decided it.
1456
+ */
1457
+ steps?: Array<Pick<SessionStep, "id" | "service" | "state" | "simulated" | "decision">>;
1458
+ /** Sekyro flows: the flow version the session runs (absent on sessions created before flows). */
1459
+ flow?: SessionFlowRef;
1460
+ /** Machine-readable reason, when the transition has one. */
1461
+ reason?: string;
1462
+ /** End-user network context (no IP); on `completed` / `failed` when recorded. */
1463
+ network?: Omit<SessionNetwork, "ip">;
1464
+ /** End-user device; on `completed` / `failed` when recorded. */
1465
+ device?: SessionDevice;
1466
+ /**
1467
+ * On `session.failed`: set when a profile-v2 policy ended the session — a
1468
+ * session-level gate (location, anonymizer) or a failed check's policy
1469
+ * reason (eligibility, `document_nni_mismatch`).
1470
+ */
1471
+ failureReason?: PolicyFailureReason;
1472
+ /** On `session.failed` with failureReason `camera_unavailable`: why (`denied` or `no_camera`), when the SDK said. Absent otherwise. */
1473
+ failureDetail?: CameraUnavailableCause;
1474
+ /** The person (`per_...`) the session is linked to, once that person has passed a verification (absent before that). */
1475
+ personId?: string;
1476
+ /** Your own id for the person, from `person.externalRef` at create. */
1477
+ externalRef?: string;
1478
+ /** The agent reference sent as `assistedBy` at create, for assisted capture. */
1479
+ assistedBy?: {
1480
+ externalRef: string;
1481
+ };
1482
+ /**
1483
+ * `true` when an identifier this session read already belongs to a
1484
+ * different person than `personId`: the people are never merged.
1485
+ */
1486
+ personConflict?: boolean;
1487
+ /** `true` on a returning-user session (liveness + face match against the stored photo). */
1488
+ returning?: true;
1489
+ /** On a returning-user session: the person (`per_...`) it re-verifies. */
1490
+ reuseOf?: string;
1491
+ /**
1492
+ * On a session created for an existing person: `recheck` (the same person
1493
+ * again) or `step_up` (raised to identity level). Absent otherwise.
1494
+ */
1495
+ reuseMode?: SubjectReuseMode;
1496
+ /**
1497
+ * On `completed` / `failed`: the `link.state` the session was created
1498
+ * with, echoed back; absent when the session had none.
1499
+ */
1500
+ link?: {
1501
+ state: string;
1502
+ };
1503
+ /**
1504
+ * On `session.failed` with `failureReason: 'device_cooldown'`: ISO time
1505
+ * from which the device may start a new verification.
1506
+ */
1507
+ retryAfter?: string;
1508
+ /** Dotted paths the session's create-time {@link CreateSessionInput.overrides} changed. */
1509
+ overriddenFields?: string[];
1510
+ /** On `completed` / `failed`: the contacts verified in this session (passed OTP checks only). */
1511
+ verifiedContacts?: VerifiedContacts;
1512
+ /** On `completed` / `failed`: the minimum age the session proved and how ({@link AgeResult}), when the flow sets one. */
1513
+ age?: AgeResult;
1514
+ /** On `completed` / `failed`: the identity data the session read ({@link Identity}), when the platform sends it. */
1515
+ identity?: Identity;
1516
+ /** On `completed` / `failed`: the media kinds of the session (never links), when the platform sends them. */
1517
+ media?: MediaKind[];
1518
+ /**
1519
+ * On `completed` / `failed`: a failure identification match
1520
+ * ({@link FailureIdentification}), when the setting is on and the search
1521
+ * found one before the event was sent. A signal, never a decision.
1522
+ */
1523
+ failureIdentification?: FailureIdentification;
1524
+ /** On `completed` / `failed`: the AML screening result ({@link SessionScreening}), when the flow screens the person. */
1525
+ screening?: SessionScreening;
1526
+ }
1527
+ /**
1528
+ * `data` of `person.updated`: either a session linked to the person reached
1529
+ * a terminal state (`sessionId`, session `status`, `outcome`), or the person
1530
+ * was revoked (`status: 'revoked'`, no session). Ids and enums only.
1531
+ * @public
1532
+ */
1533
+ interface PersonUpdatedEventData {
1534
+ /** The person (`per_...`). */
1535
+ personId: string;
1536
+ /** The session that reached a terminal state; absent on a revocation. */
1537
+ sessionId?: string;
1538
+ status: SessionStatus | "revoked";
1539
+ /** The session outcome; absent on a revocation. */
1540
+ outcome?: SessionOutcome | null;
1541
+ /** The session's level; absent on a revocation. */
1542
+ level?: VerificationLevel | null;
1543
+ /** The session's assurance; absent on a revocation. */
1544
+ assurance?: VerificationAssurance | null;
1545
+ /**
1546
+ * Your own ids for the person (`person.externalRef` values), so a
1547
+ * revocation can find your user without a lookup.
1548
+ */
1549
+ externalRefs?: string[];
1550
+ }
1551
+ /**
1552
+ * `data` of `person.enrolled`: the person's first reference photo was
1553
+ * stored (it can now be used for returning-user sessions). Ids and enums only.
1554
+ * @public
1555
+ */
1556
+ interface PersonEnrolledEventData {
1557
+ /** The person (`per_...`). */
1558
+ personId: string;
1559
+ /** The approved session the reference photo came from. */
1560
+ sessionId: string;
1561
+ assurance: SubjectAssurance;
1562
+ }
1563
+ /**
1564
+ * `data` of `person.deleted`. A delete through the people API carries
1565
+ * `personId`; a right-to-erasure request carries the tokenized `subjectRef`
1566
+ * (with `orgId` / `env`), and `personId` when it named exactly one person, never
1567
+ * the national number.
1568
+ * @public
1569
+ */
1570
+ interface PersonDeletedEventData {
1571
+ personId?: string;
1572
+ subjectRef?: string;
1573
+ orgId?: string;
1574
+ env?: SekyroEnvironment;
1575
+ /**
1576
+ * On a delete through the people API: your own ids for the person, so you
1577
+ * can find your user. Never on the erasure variant.
1578
+ */
1579
+ externalRefs?: string[];
1580
+ }
1581
+ /** Subject lifecycle: a revoked subject cannot be reused. @public */
1582
+ type SubjectStatus = "active" | "revoked";
1583
+ /**
1584
+ * How strongly a subject's identity was established: the reference photo
1585
+ * came from the national registry, the document's chip (`chip_biometric`, a
1586
+ * passed chip read plus a face match) or the document, and a face match passed
1587
+ * (`*_biometric`) or the session had no face match (`*_only`). `supplied_*`:
1588
+ * partner-supplied identity data (`input.suppliedIdentity`), with
1589
+ * (`supplied_biometric`) or without (`supplied_only`) a face match against its photo.
1590
+ * @public
1591
+ */
1592
+ type SubjectAssurance = "registry_biometric" | "chip_biometric" | "document_biometric" | "registry_only" | "document_only" | "supplied_biometric" | "supplied_only";
1593
+ /**
1594
+ * Origin of a subject's stored reference photo, best first (`chip`: the document chip's portrait;
1595
+ * `org_supplied`: the photo of your partner-supplied identity data).
1596
+ * @public
1597
+ */
1598
+ type SubjectReferenceSource = "registry" | "doc_registry" | "chip" | "org_supplied" | "document";
1599
+ /** One session linked to a person. @public */
1600
+ interface PersonSession {
1601
+ /** The session id (`ses_...`). */
1602
+ sessionId: string;
1603
+ appId: string | null;
1604
+ /** ISO 8601 — when the session was linked. */
1605
+ at: string;
1606
+ status: SessionStatus;
1607
+ outcome: SessionOutcome | null;
1608
+ /** What the session proved; present only when stored (sessions linked before the field existed have none). */
1609
+ level?: VerificationLevel;
1610
+ /** How the session's level was proved; present only when stored. */
1611
+ assurance?: VerificationAssurance;
1612
+ }
1613
+ /**
1614
+ * A person (the same person across your apps), as `GET /people/:id`
1615
+ * returns it. Never contains photo keys or URLs.
1616
+ * @public
1617
+ */
1618
+ interface Person {
1619
+ /** The person id (`per_...`). */
1620
+ id: string;
1621
+ /** The same value as `id`. Absent from older API versions. */
1622
+ personId?: string;
1623
+ status: SubjectStatus;
1624
+ /** ISO 8601 — present only when revoked. */
1625
+ revokedAt?: string;
1626
+ sessions: PersonSession[];
1627
+ externalRefs: string[];
1628
+ /** ISO 8601. */
1629
+ firstSeenAt: string;
1630
+ /** ISO 8601. */
1631
+ lastSeenAt: string;
1632
+ /** ISO 8601, or `null` before the first approved session. */
1633
+ lastPassedAt: string | null;
1634
+ /** ISO 8601 of the last approved full or returning session, or `null`. */
1635
+ lastVerifiedAt: string | null;
1636
+ /** The stored reference photo's origin and date — `null` until one is stored. */
1637
+ reference: {
1638
+ source: SubjectReferenceSource;
1639
+ capturedAt: string;
1640
+ } | null;
1641
+ assurance: SubjectAssurance | null;
1642
+ /**
1643
+ * The highest {@link VerificationLevel} an approved linked session proved;
1644
+ * `0` once the subject is revoked; `null` when no terminal session was
1645
+ * recorded since the field exists. Absent from API versions before the field.
1646
+ */
1647
+ level?: VerificationLevel | null | undefined;
1648
+ /** ISO 8601: when {@link Person.level} was last proved (the latest approved session at that level or higher); `null` with it. Absent with it. */
1649
+ levelAt?: string | null | undefined;
1650
+ /** The assurance of the session that proved {@link Person.level}; `null` with it. Absent with it. */
1651
+ levelAssurance?: VerificationAssurance | null | undefined;
1652
+ /**
1653
+ * A returning-user session can be created now: active, a reference photo is
1654
+ * stored, and the last FULL verification (returning-user sessions do not
1655
+ * reset it) is within the returning-user limit of your app's default flow
1656
+ * (`settings.returning`: turned on, and `maxAgeMonths` when set).
1657
+ */
1658
+ returningReady: boolean;
1659
+ /** The verified name / birth date of the latest approved session. */
1660
+ display?: {
1661
+ name?: string;
1662
+ birthDate?: string;
1663
+ };
1664
+ /** The identity of the latest approved session that read one ({@link Identity}). */
1665
+ identity?: Identity;
1666
+ }
1667
+ /**
1668
+ * Filters of {@link SessionsApi.list}, {@link SessionsApi.listPage} and
1669
+ * {@link SessionsApi.iterate}, combined with AND. Newest first.
1670
+ * @public
1671
+ */
1672
+ interface ListSessionsQuery {
1673
+ /** Your own id for the person (1 to 128 characters), exact match. */
1674
+ externalRef?: string;
1675
+ status?: SessionStatus;
1676
+ /** A flow id (`flw_...`) or slug. */
1677
+ flow?: string;
1678
+ /** Sessions created at or after this time (ISO 8601 or a `Date`). */
1679
+ createdAfter?: string | Date;
1680
+ /** Sessions created before this time (ISO 8601 or a `Date`). */
1681
+ createdBefore?: string | Date;
1682
+ /** Only the sessions of this device (`device.deviceId` of a session). */
1683
+ deviceId?: string;
1684
+ /** Page size, 1 to 100 (the API's default is 50). */
1685
+ limit?: number;
1686
+ /** The {@link Page.nextCursor} of the previous page. */
1687
+ cursor?: string;
1688
+ }
1689
+ /**
1690
+ * What a block holds, as {@link BlocksApi.list} shows it. `face` blocks are made in the dashboard.
1691
+ * @public
1692
+ */
1693
+ type BlockKind = "id_number" | "external_ref" | "phone" | "email" | "device" | "face";
1694
+ /** Why a block exists. `rule`: an automatic rule made it. @public */
1695
+ type BlockReason = "fraud_confirmed" | "chargeback" | "abuse" | "test" | "rule" | "other";
1696
+ /** How long a block lasts; `null` has no end. @public */
1697
+ type BlockDuration = "P1D" | "P7D" | "P30D" | null;
1698
+ /**
1699
+ * A block on one key of this environment. Never a value or a hash.
1700
+ * @public
1701
+ */
1702
+ interface Block {
1703
+ /** `blk_...` */
1704
+ id: string;
1705
+ kind: BlockKind;
1706
+ /** Four characters derived from the key, to tell blocks apart. */
1707
+ label: string;
1708
+ /** The device, on a device block. */
1709
+ deviceId?: string;
1710
+ effect: "block" | "flag" | "review";
1711
+ reason: BlockReason;
1712
+ /** When it ends; `null` has no end. */
1713
+ expiresAt: string | null;
1714
+ createdAt: string;
1715
+ status: "active" | "lifted" | "expired";
1716
+ /** `rul_...`: the rule that made it, on a block made by a rule. Such a block has no end date. */
1717
+ ruleId?: string;
1718
+ /** The version of that rule when it made the block. */
1719
+ ruleVersion?: number;
1720
+ liftedAt?: string;
1721
+ }
1722
+ /** An ID number as a document shows it. Hashed by the API, never stored. @public */
1723
+ interface BlockIdNumber {
1724
+ number: string;
1725
+ /** ISO 3166-1 alpha-2 or alpha-3 code of the issuer. */
1726
+ issuingCountry: string;
1727
+ type: "national_id" | "passport" | "residence_permit";
1728
+ }
1729
+ /**
1730
+ * What to block, with `sekyro.blocks.create`. `value` carries `external_ref`, `phone` and
1731
+ * `email`; `person` blocks each ID number of the person and answers a list.
1732
+ * @public
1733
+ */
1734
+ type CreateBlockInput = {
1735
+ expiresIn: BlockDuration;
1736
+ reason?: Exclude<BlockReason, "rule">;
1737
+ /** Your note. It stays on your dashboard. */
1738
+ note?: string;
1739
+ } & ({
1740
+ kind: "external_ref" | "phone" | "email";
1741
+ value: string;
1742
+ } | {
1743
+ kind: "id_number";
1744
+ idNumber: BlockIdNumber;
1745
+ } | {
1746
+ kind: "person";
1747
+ personId: string;
1748
+ } | ({
1749
+ kind: "device";
1750
+ force?: boolean;
1751
+ } & ({
1752
+ deviceId: string;
1753
+ } | {
1754
+ sessionId: string;
1755
+ })));
1756
+ /** What to look up, with {@link BlocksApi.check}. @public */
1757
+ type BlockCheckInput = {
1758
+ kind: "external_ref" | "phone" | "email";
1759
+ value: string;
1760
+ } | {
1761
+ kind: "id_number";
1762
+ idNumber: BlockIdNumber;
1763
+ } | {
1764
+ kind: "person";
1765
+ personId: string;
1766
+ } | {
1767
+ kind: "device";
1768
+ deviceId: string;
1769
+ };
1770
+ /** The answer of {@link BlocksApi.check}. @public */
1771
+ interface BlockCheck {
1772
+ blocked: boolean;
1773
+ /** When the block ends; `null` has no end. Only when blocked. */
1774
+ expiresAt?: string | null;
1775
+ }
1776
+ /** Why a block is lifted, with {@link BlocksApi.lift}. @public */
1777
+ interface LiftBlockInput {
1778
+ /**
1779
+ * `false_positive` also marks the signal behind the block, so no rule fires on it again. On a
1780
+ * block made by a rule it counts against the rule, which pauses after too many reports.
1781
+ */
1782
+ reason?: "false_positive" | "other";
1783
+ note?: string;
1784
+ }
1785
+ /**
1786
+ * Filters of {@link BlocksApi.list}, {@link BlocksApi.listPage} and {@link BlocksApi.iterate}.
1787
+ * Newest first.
1788
+ * @public
1789
+ */
1790
+ interface ListBlocksQuery {
1791
+ kind?: BlockKind;
1792
+ status?: Block["status"];
1793
+ /** Page size, 1 to 100 (the API's default is 50). */
1794
+ limit?: number;
1795
+ /** The {@link Page.nextCursor} of the previous page. */
1796
+ cursor?: string;
1797
+ }
1798
+ /**
1799
+ * A device of this environment, counted inside it.
1800
+ * @public
1801
+ */
1802
+ interface Device {
1803
+ /** `dev_...`, as a session's `device.deviceId`. */
1804
+ deviceId: string;
1805
+ platform: "web" | "android" | "ios";
1806
+ model?: string;
1807
+ firstSeenAt: string;
1808
+ lastSeenAt: string;
1809
+ /** Your sessions on this device. */
1810
+ sessions: number;
1811
+ /** Distinct verified people among them over 90 days. */
1812
+ people: number;
1813
+ /** An agent filmed on it, many verified people passed on it, or you marked it. */
1814
+ shared: boolean;
1815
+ /** Its active block. */
1816
+ block: {
1817
+ id: string;
1818
+ expiresAt: string | null;
1819
+ } | null;
1820
+ }
1821
+ /**
1822
+ * Filters of {@link PeopleApi.list}, {@link PeopleApi.listPage} and
1823
+ * {@link PeopleApi.iterate}. Newest first; only people who passed a verification.
1824
+ * @public
1825
+ */
1826
+ interface ListPeopleQuery {
1827
+ /** Your own id for the person, exact match. */
1828
+ externalRef?: string;
1829
+ /** Page size, 1 to 100 (the API's default is 50). */
1830
+ limit?: number;
1831
+ /** The {@link Page.nextCursor} of the previous page. */
1832
+ cursor?: string;
1833
+ }
1834
+ /**
1835
+ * One page of a list: the items and, when more exist, the cursor of the next
1836
+ * page (pass it as `cursor`). Opaque; absent on the last page.
1837
+ * @public
1838
+ */
1839
+ interface Page<T> {
1840
+ data: T[];
1841
+ nextCursor?: string;
1842
+ }
1843
+ /** Result of {@link PeopleApi.delete}. @public */
1844
+ interface DeletedPerson {
1845
+ /** The person id (`per_...`). */
1846
+ id: string;
1847
+ deleted: true;
1848
+ }
1849
+ /** The lists an AML screening can search. @public */
1850
+ type ScreeningList = "sanctions" | "pep" | "adverse_media";
1851
+ /**
1852
+ * Where a screening stands: `clear` (nothing scored above the possible
1853
+ * threshold), `possible` (a possible match), `hit` (a match), `confirmed` or
1854
+ * `dismissed` (a person of your organization decided the hits), `unavailable`
1855
+ * (the lists could not be searched; never billed).
1856
+ * @public
1857
+ */
1858
+ type ScreeningStatus = "clear" | "possible" | "hit" | "confirmed" | "dismissed" | "unavailable";
1859
+ /** Why the lists could not be searched. @public */
1860
+ type ScreeningUnavailableReason = "screening_unavailable" | "no_identity_data" | "no_list_covered";
1861
+ /** What ran a screening: a session step, a screening run again, or ongoing screening. @public */
1862
+ type ScreeningTrigger = "session" | "rescreen" | "monitor";
1863
+ /** A list entry that matched the person, best first. Public list data. @public */
1864
+ interface ScreeningHitSummary {
1865
+ /** The stable id of the list entry. */
1866
+ entityId: string;
1867
+ /** The name of the entry as the list publishes it. */
1868
+ caption: string;
1869
+ /** How closely the entry matches the person, 0 to 1. */
1870
+ score: number;
1871
+ /** The searched lists the entry is on. */
1872
+ lists: ScreeningList[];
1873
+ }
1874
+ /** A list entry that matched, with its public attributes and sources. @public */
1875
+ interface ScreeningHit extends ScreeningHitSummary {
1876
+ /** The tags of the entry on its lists (`sanction`, `role.pep`, ...). */
1877
+ topics: string[];
1878
+ /** The source datasets of the entry. */
1879
+ datasets: string[];
1880
+ /** Public attributes of the entry, when the list publishes them. */
1881
+ attributes: {
1882
+ birthDates?: string[];
1883
+ nationalities?: string[];
1884
+ positions?: string[];
1885
+ aliases?: string[];
1886
+ gender?: string;
1887
+ };
1888
+ /** Where the list publishes the entry. */
1889
+ sourceUrls: string[];
1890
+ firstSeen?: string;
1891
+ lastSeen?: string;
1892
+ }
1893
+ /**
1894
+ * {@link Session.screening}: the search a session's AML screening step ran, or
1895
+ * `{ unavailable }` alone when it could not run.
1896
+ * @public
1897
+ */
1898
+ type SessionScreening = {
1899
+ /** The screening id (`scr_...`); see {@link PeopleApi.screenings}. */
1900
+ id: string;
1901
+ status: Exclude<ScreeningStatus, "unavailable">;
1902
+ /** The lists the flow asked for. */
1903
+ lists: ScreeningList[];
1904
+ /** The lists actually searched. */
1905
+ listsCovered: ScreeningList[];
1906
+ /** The list data release the search ran on. */
1907
+ datasetVersion: string;
1908
+ /** The best score, 0 when nothing matched. */
1909
+ topScore: number;
1910
+ hits: ScreeningHitSummary[];
1911
+ } | {
1912
+ unavailable: ScreeningUnavailableReason;
1913
+ };
1914
+ /** One screening of a person ({@link PeopleApi.screen}, {@link PeopleApi.screenings}). @public */
1915
+ interface Screening {
1916
+ /** The screening id (`scr_...`). */
1917
+ id: string;
1918
+ trigger: ScreeningTrigger;
1919
+ status: ScreeningStatus;
1920
+ /** With `status: "unavailable"`: why the lists could not be searched. */
1921
+ unavailable?: ScreeningUnavailableReason;
1922
+ /** The lists asked for. */
1923
+ lists: ScreeningList[];
1924
+ /** The lists actually searched. */
1925
+ listsCovered: ScreeningList[];
1926
+ /** The list data release the search ran on. */
1927
+ datasetVersion: string;
1928
+ /** The best score, 0 when nothing matched. */
1929
+ topScore: number;
1930
+ /** The matching entries, best first. */
1931
+ hits: ScreeningHit[];
1932
+ /** The decision of a person of your organization on the hits, once made. */
1933
+ decision?: {
1934
+ outcome: "confirmed" | "dismissed";
1935
+ at: string;
1936
+ note?: string;
1937
+ };
1938
+ /** ISO 8601. */
1939
+ createdAt: string;
1940
+ }
1941
+ /** Input of {@link PeopleApi.screen}. @public */
1942
+ interface ScreenPersonInput {
1943
+ /** The lists to search, each once. Default `["sanctions", "pep"]`. */
1944
+ lists?: ScreeningList[];
1945
+ }
1946
+ /** Query of {@link PeopleApi.screenings}. @public */
1947
+ interface ListScreeningsQuery {
1948
+ /** Page size, 1 to 50 (the API's default is 25). */
1949
+ limit?: number;
1950
+ /** The {@link Page.nextCursor} of the previous page. */
1951
+ cursor?: string;
1952
+ }
1953
+ /**
1954
+ * `data` of `aml.match_flagged`: a screening settled `hit` or `possible`, from
1955
+ * a session step, a screening run again or ongoing screening. Sent once per
1956
+ * screening (de-duplicate on `screeningId`); a decision sends no event.
1957
+ * @public
1958
+ */
1959
+ interface AmlMatchFlaggedEventData {
1960
+ screeningId: string;
1961
+ trigger: ScreeningTrigger;
1962
+ /** The session the screening ran in, or the person's latest approved session. */
1963
+ sessionId?: string;
1964
+ /** The person (`per_...`), once known. */
1965
+ personId?: string;
1966
+ status: "hit" | "possible";
1967
+ lists: ScreeningList[];
1968
+ listsCovered: ScreeningList[];
1969
+ datasetVersion: string;
1970
+ topScore: number;
1971
+ hits: ScreeningHitSummary[];
1972
+ }
1973
+ /** Options of {@link PeopleApi.revoke}. @public */
1974
+ interface RevokePersonInput {
1975
+ /** Kept on the audit trail only (≤ 500 characters). Do not put personal data here. */
1976
+ reason?: string;
1977
+ }
1978
+ /**
1979
+ * Input of {@link SessionsApi.extendLink}: the new link lifetime in minutes,
1980
+ * counted from the session creation, or the new expiry. It must be later than
1981
+ * the current expiry and within the flow's maximum link lifetime.
1982
+ * @public
1983
+ */
1984
+ type ExtendLinkInput = {
1985
+ ttlMinutes: number;
1986
+ } | {
1987
+ expiresAt: string | Date;
1988
+ };
1989
+ /** Result of {@link SessionsApi.resendLink}: the new delivery attempt. @public */
1990
+ interface SessionLinkDelivery {
1991
+ delivery: {
1992
+ channel: "sms" | "whatsapp" | "email";
1993
+ /** `simulated` in the Sandbox: nothing is sent. */
1994
+ status: "queued" | "sent" | "failed" | "simulated";
1995
+ };
1996
+ }
1997
+ /** Result of {@link SessionsApi.extendLink}. @public */
1998
+ interface SessionLinkExpiry {
1999
+ /** ISO 8601: the new expiry of the link and its session. */
2000
+ expiresAt: string;
2001
+ }
2002
+ /**
2003
+ * `data` of `person.suspicious_activity`: a device already linked to ANOTHER
2004
+ * person was used for a session of this person. `count` is the person's running
2005
+ * total of such events. Ids only.
2006
+ * @public
2007
+ */
2008
+ interface PersonSuspiciousActivityEventData {
2009
+ /** The person (`per_...`). */
2010
+ personId: string;
2011
+ sessionId: string;
2012
+ count: number;
2013
+ }
2014
+ /**
2015
+ * `data` of `session.superseded`: a session that waited for a review closed
2016
+ * because a newer attempt of the same person took that review over. The
2017
+ * session ends with status `completed`, `outcome: null` and `supersededBy`;
2018
+ * its review step failed with `superseded_by_retry`; nothing of it is deleted.
2019
+ * Read the newer session (`supersededBy`) for the verdict. This is the one
2020
+ * terminal event of the superseded session.
2021
+ * @public
2022
+ */
2023
+ interface SessionSupersededEventData {
2024
+ /** The superseded session (`ses_...`). */
2025
+ sessionId: string;
2026
+ /** The newer session of the same person that took the review over (`ses_...`). */
2027
+ supersededBy: string;
2028
+ reason: "superseded_by_retry";
2029
+ /** Your own id for the person, from `person.externalRef` at create. */
2030
+ externalRef?: string;
2031
+ }
2032
+ /**
2033
+ * `usage.threshold_reached`: a usage, credit or spend threshold of the organization's
2034
+ * plan was reached (sent once per threshold and period). `kind` is `tier` for a monthly
2035
+ * tier, or the alert, e.g. `credit_80`, `usage_100_paid`, `spend_cap_reached`.
2036
+ * @public
2037
+ */
2038
+ interface UsageThresholdReachedEventData {
2039
+ kind: string;
2040
+ /** The verification unit, on per-unit alerts. */
2041
+ unit?: "human_verification" | "identity_verification";
2042
+ /** Percent of the limit (80, 100), or `overage` for the first verification beyond a tier. */
2043
+ threshold?: number | "overage";
2044
+ used?: number;
2045
+ limit?: number;
2046
+ /** UTC month, `YYYY-MM`. */
2047
+ period?: string;
2048
+ /** Tier alerts: verifications that reached a result this month. */
2049
+ confirmed?: number;
2050
+ /** Tier alerts: verifications beyond the tier this month. */
2051
+ overage?: number;
2052
+ }
2053
+ /**
2054
+ * Event type → the shape of its `data`. Session events are typed; the
2055
+ * remaining events carry an open record until their payloads are frozen.
2056
+ * @public
2057
+ */
2058
+ interface WebhookEventDataMap {
2059
+ "session.started": Record<string, unknown>;
2060
+ "session.review_pending": SessionLifecycleEventData;
2061
+ "session.completed": SessionLifecycleEventData;
2062
+ "session.expired": SessionLifecycleEventData;
2063
+ "session.failed": SessionLifecycleEventData;
2064
+ "session.superseded": SessionSupersededEventData;
2065
+ "person.enrolled": PersonEnrolledEventData;
2066
+ "person.updated": PersonUpdatedEventData;
2067
+ "person.suspicious_activity": PersonSuspiciousActivityEventData;
2068
+ "person.deleted": PersonDeletedEventData;
2069
+ "aml.match_flagged": AmlMatchFlaggedEventData;
2070
+ "payment.received": Record<string, unknown>;
2071
+ "invoice.generated": Record<string, unknown>;
2072
+ "invoice.paid": Record<string, unknown>;
2073
+ "invoice.overdue": Record<string, unknown>;
2074
+ "usage.threshold_reached": UsageThresholdReachedEventData;
2075
+ "webhook.test": Record<string, unknown>;
2076
+ }
2077
+ /** Every event a partner endpoint may receive. @public */
2078
+ type WebhookEventType = keyof WebhookEventDataMap;
2079
+ /**
2080
+ * The signed webhook payload for ONE event type. There is no global API
2081
+ * version; each event carries its own per-event `version`. Retried deliveries
2082
+ * keep the same `id` — de-duplicate on it.
2083
+ * @public
2084
+ */
2085
+ interface WebhookEnvelopeOf<E extends WebhookEventType> {
2086
+ /** UUIDv7, stable across delivery retries. */
2087
+ id: string;
2088
+ event: E;
2089
+ /** Per-event payload version. */
2090
+ version: number;
2091
+ /** ISO 8601. */
2092
+ createdAt: string;
2093
+ orgId: string;
2094
+ env: SekyroEnvironment;
2095
+ data: WebhookEventDataMap[E];
2096
+ }
2097
+ /**
2098
+ * The signed webhook payload, discriminated on `event`: narrowing on
2099
+ * `envelope.event` narrows `envelope.data` to that event's shape.
2100
+ *
2101
+ * @example
2102
+ * ```ts
2103
+ * const envelope = verifyWebhook(rawBody, header, secret);
2104
+ * switch (envelope.event) {
2105
+ * case "session.completed":
2106
+ * envelope.data.outcome; // SessionOutcome | null | undefined
2107
+ * break;
2108
+ * case "person.updated":
2109
+ * envelope.data.personId; // "per_..."
2110
+ * break;
2111
+ * }
2112
+ * ```
2113
+ * @public
2114
+ */
2115
+ type WebhookEnvelope<E extends WebhookEventType = WebhookEventType> = E extends WebhookEventType ? WebhookEnvelopeOf<E> : never;
2116
+
2117
+ /** Default partner API origin + version prefix. @public */
2118
+ declare const DEFAULT_BASE_URL = "https://api.sekyro.ai/api/v2";
2119
+ /** Default per-request timeout. @public */
2120
+ declare const DEFAULT_TIMEOUT_MS = 30000;
2121
+ /** `fetch`-compatible function; the global `fetch` by default. @public */
2122
+ type FetchLike = typeof globalThis.fetch;
2123
+ /** Constructor options of {@link Sekyro}. @public */
2124
+ interface SekyroOptions {
2125
+ /** Partner API key (server-side only). Sent as `Authorization: Bearer`. */
2126
+ apiKey: string;
2127
+ /** API base URL incl. the `/api/v2` prefix. Default {@link DEFAULT_BASE_URL}. */
2128
+ baseUrl?: string;
2129
+ /** Per-request timeout in ms. Default {@link DEFAULT_TIMEOUT_MS}. */
2130
+ timeoutMs?: number;
2131
+ /** Custom `fetch` (tests, proxies, custom agents). Default `globalThis.fetch`. */
2132
+ fetch?: FetchLike;
2133
+ /**
2134
+ * The auth-provider connector this client runs in, sent as the
2135
+ * `x-sekyro-connector: <provider>/<version>` header on every call so the
2136
+ * dashboard can show the connector as connected. Ids only. A connector
2137
+ * created with `createConnector` from `@sekyro/node/connect` sets it for you
2138
+ * (unless its `telemetry` option is `false`).
2139
+ */
2140
+ connector?: ConnectorIdentity;
2141
+ }
2142
+ /** A connector's provider id and package version, for {@link SekyroOptions.connector}. @public */
2143
+ interface ConnectorIdentity {
2144
+ /** The provider id, for example `supabase`: lowercase letters, digits and `-`, at most 32 characters. */
2145
+ provider: string;
2146
+ /** The connector package version, for example `0.1.0`: at most 64 characters. */
2147
+ version: string;
2148
+ }
2149
+ type HttpMethod = "GET" | "POST" | "PATCH" | "DELETE";
2150
+ /**
2151
+ * `sekyro.sessions` — create and read verification sessions.
2152
+ *
2153
+ * Exported as a TYPE only (`import type { SessionsApi }`): the class value is
2154
+ * not part of the package surface, so it can only be obtained through
2155
+ * {@link Sekyro.sessions} — never constructed by hand with an unchecked
2156
+ * transport.
2157
+ * @public
2158
+ */
2159
+ declare class SessionsApi {
2160
+ private readonly t;
2161
+ /**
2162
+ * Constructed by {@link Sekyro}; the transport is kept out of the public
2163
+ * surface on purpose (only its bound calls cross this boundary).
2164
+ * @internal
2165
+ */
2166
+ constructor(t: {
2167
+ call<T>(method: "GET" | "POST" | "DELETE", path: string, body?: unknown, idempotencyKey?: string): Promise<T>;
2168
+ page<T>(path: string): Promise<Page<T>>;
2169
+ bytes(path: string): Promise<MediaBytes>;
2170
+ });
2171
+ /**
2172
+ * `POST /sessions`. Returns the one-time `clientToken` — hand it to the
2173
+ * browser, never persist it. Pass an `idempotencyKey` so a retried call
2174
+ * cannot create a second session.
2175
+ */
2176
+ create(input?: CreateSessionInput, opts?: RequestOptions): Promise<CreatedSession>;
2177
+ /**
2178
+ * `POST /sessions/:id/method` — choose the identity method of an
2179
+ * optional-document session on the person's behalf (the hosted method
2180
+ * screen is then skipped). `409 method_locked` once the choice can no
2181
+ * longer change; `409 session_not_active` on a finished or expired session.
2182
+ * On a flow session: `409 choice_not_found` (the flow has no identity-method
2183
+ * choice), `409 choice_locked`, `409 choice_option_unavailable` (see
2184
+ * {@link isFlowError}).
2185
+ */
2186
+ selectMethod(id: string, method: IdentityMethod): Promise<Session>;
2187
+ /** `GET /sessions/:id` — the whitelisted view (no client token). Either id form (`ses_...` or bare) works. */
2188
+ get(id: string): Promise<Session>;
2189
+ /**
2190
+ * `POST /sessions/:id/cancel` — stop a session that has not ended. The
2191
+ * hosted link stops working, and one `session.failed` with
2192
+ * `failureReason: "cancelled_by_organization"` is sent. Returns the
2193
+ * cancelled session. `409 session_not_cancellable` once the session has
2194
+ * ended (a repeated cancel included). Needs the `sessions:create` scope.
2195
+ */
2196
+ cancel(id: string, opts?: RequestOptions): Promise<Session>;
2197
+ /**
2198
+ * `POST /sessions/:id/link/resend` — send the hosted link again through the
2199
+ * session's own `deliver` channel, to the same destination (neither can be
2200
+ * changed). Only for sessions created with `deliver`:
2201
+ * `409 link_not_deliverable` otherwise, `409 link_not_usable` once the
2202
+ * session ended, `429 resend_rate_limited` past the send limits. Needs the
2203
+ * `sessions:create` scope.
2204
+ */
2205
+ resendLink(id: string, opts?: RequestOptions): Promise<SessionLinkDelivery>;
2206
+ /**
2207
+ * `POST /sessions/:id/link/extend` — a later expiry for the hosted link
2208
+ * and its session: `{ ttlMinutes }` counted from the session creation, or
2209
+ * `{ expiresAt }`. `400 ttl_out_of_policy` when it is not later than the
2210
+ * current expiry or past the flow's maximum. Only for sessions created with
2211
+ * `deliver`. Needs the `sessions:create` scope.
2212
+ */
2213
+ extendLink(id: string, input: ExtendLinkInput, opts?: RequestOptions): Promise<SessionLinkExpiry>;
2214
+ /**
2215
+ * The first page of your sessions, newest first (`GET /sessions`; the API
2216
+ * returns 50 by default, at most 100 with `limit`). Read every page with
2217
+ * {@link SessionsApi.iterate}, or one page and its cursor with
2218
+ * {@link SessionsApi.listPage}. The `externalRef` and `status` filters are
2219
+ * applied again to the answer, so an API that ignores them never returns
2220
+ * another user's sessions.
2221
+ */
2222
+ list(query?: ListSessionsQuery): Promise<Session[]>;
2223
+ /** One page of {@link SessionsApi.list} with its `nextCursor` (absent on the last page). */
2224
+ listPage(query?: ListSessionsQuery): Promise<Page<Session>>;
2225
+ /**
2226
+ * Every session matching `query`, newest first, following `nextCursor` page
2227
+ * after page (`limit` sets the page size).
2228
+ *
2229
+ * @example
2230
+ * ```ts
2231
+ * for await (const s of sekyro.sessions.iterate({ status: "completed" })) {
2232
+ * console.log(s.id);
2233
+ * }
2234
+ * ```
2235
+ */
2236
+ iterate(query?: ListSessionsQuery): AsyncGenerator<Session, void, undefined>;
2237
+ /**
2238
+ * `GET /sessions/:id/media` — the session's media (documents, portraits,
2239
+ * the selfie, the clips), each with its check, attempt tags and a URL valid
2240
+ * 15 minutes ({@link MediaItem}). Needs the `sessions:read` scope.
2241
+ */
2242
+ media(id: string): Promise<MediaList>;
2243
+ /**
2244
+ * `GET /sessions/:id/media/:kind` — the bytes of one media item: the
2245
+ * decisive attempt of that kind by default, `attempt` for another one,
2246
+ * `reference: "first"` for the first reference of a `reference_portrait`
2247
+ * a second reference decided. `404 media_not_available` when the kind, the
2248
+ * attempt or the object is not there. Needs the `sessions:read` scope.
2249
+ */
2250
+ mediaBytes(id: string, kind: MediaKind, opts?: MediaBytesOptions): Promise<MediaBytes>;
2251
+ /**
2252
+ * `GET /sessions/:id/result-token`: a freshly signed result token for a
2253
+ * finished session (valid 10 minutes; check it with
2254
+ * {@link verifyResultToken}). `409 session_not_terminal` while the session
2255
+ * is still active. Needs the `sessions:read` scope.
2256
+ */
2257
+ resultToken(id: string): Promise<ResultTokenResponse>;
2258
+ /**
2259
+ * `POST /sessions/:id/simulate`: finishes a simulated Sandbox session in one
2260
+ * call, for tests and CI. It runs every step of the flow through the real
2261
+ * engine, so the status, the webhooks, the result token and the dashboard
2262
+ * behave as for a session driven by a person. Never billed. Returns the
2263
+ * finished session; pass an `idempotencyKey` to make a retry safe. Errors:
2264
+ * `400 sandbox_only` (Live key), `409 session_not_simulated` (bound to a
2265
+ * tester), `409 session_already_final`, `422 simulate_outcome_unreachable`
2266
+ * (`details.issues` says why), `422 simulate_reason_invalid`. Needs the
2267
+ * `sessions:create` scope.
2268
+ */
2269
+ simulate(id: string, input: SimulateSessionInput, opts?: RequestOptions): Promise<Session>;
2270
+ }
2271
+ /**
2272
+ * `sekyro.flows`: the flows of the API key's app.
2273
+ *
2274
+ * Exported as a TYPE only, like {@link SessionsApi}: obtained through
2275
+ * {@link Sekyro.flows}.
2276
+ * @public
2277
+ */
2278
+ declare class FlowsApi {
2279
+ private readonly t;
2280
+ /** @internal */
2281
+ constructor(t: {
2282
+ call<T>(method: HttpMethod, path: string, body?: unknown, idempotencyKey?: string): Promise<T>;
2283
+ });
2284
+ /**
2285
+ * `GET /flows`: the published flows of the API key's app (default flow
2286
+ * first, then by name). Pass a flow's `slug` or `id` as
2287
+ * {@link CreateSessionInput.flow}. Needs the `sessions:create` scope; an
2288
+ * invalid key answers `401 unauthorized`.
2289
+ */
2290
+ list(): Promise<FlowSummary[]>;
2291
+ }
2292
+ /**
2293
+ * `sekyro.people` — read and manage people (the same person across your
2294
+ * apps). Reads need the `people:read` scope, `revoke` / `delete` the
2295
+ * `people:write` scope. A person is
2296
+ * visible once they have passed a verification: a person who never passed,
2297
+ * an unknown id and a person of another organization or environment all
2298
+ * answer the same `404 subject_not_found` on `get`, `revoke` and `delete`,
2299
+ * and `list` leaves them out. Ids are `per_...`; the bare 24 hexadecimal
2300
+ * characters name the same person.
2301
+ *
2302
+ * Type-only export, like {@link SessionsApi}: obtained through
2303
+ * {@link Sekyro.people}.
2304
+ * @public
2305
+ */
2306
+ declare class PeopleApi {
2307
+ private readonly t;
2308
+ /** @internal */
2309
+ constructor(t: {
2310
+ call<T>(method: "GET" | "POST" | "DELETE", path: string, body?: unknown, idempotencyKey?: string): Promise<T>;
2311
+ page<T>(path: string): Promise<Page<T>>;
2312
+ });
2313
+ /** `GET /people/:id` — the person, their sessions and their returning-user readiness. */
2314
+ get(id: string): Promise<Person>;
2315
+ /**
2316
+ * The first page of the people who have passed a verification, newest
2317
+ * first (`GET /people`; 50 by default, at most 100 with `limit`),
2318
+ * optionally only those carrying your own id (`externalRef`). The list can
2319
+ * be empty while sessions with this `externalRef` exist. Every page:
2320
+ * {@link PeopleApi.iterate}.
2321
+ */
2322
+ list(query?: ListPeopleQuery): Promise<Person[]>;
2323
+ /** One page of {@link PeopleApi.list} with its `nextCursor` (absent on the last page). */
2324
+ listPage(query?: ListPeopleQuery): Promise<Page<Person>>;
2325
+ /** Every person matching `query`, newest first, following `nextCursor` page after page. */
2326
+ iterate(query?: ListPeopleQuery): AsyncGenerator<Person, void, undefined>;
2327
+ /**
2328
+ * `POST /people/:id/revoke` — the person can no longer be used for
2329
+ * returning-user sessions. Idempotent: revoking again returns the same view.
2330
+ * Emits `person.updated` with `status: 'revoked'`.
2331
+ */
2332
+ revoke(id: string, input?: RevokePersonInput, opts?: RequestOptions): Promise<Person>;
2333
+ /**
2334
+ * `POST /people/:id/screen` — screens a verified person again against
2335
+ * sanctions and PEP lists (`lists`, default sanctions and PEP), from the
2336
+ * person's stored name, birth date and the issuing countries of their identity
2337
+ * numbers. Billed as one AML screening; a refusal is not billed
2338
+ * (`400 screening_list_not_covered`, `403 service_not_in_plan`,
2339
+ * `503 screening_unavailable`). A hit or a possible match also sends
2340
+ * `aml.match_flagged`. Pass an `idempotencyKey` so a retried call is not
2341
+ * billed twice.
2342
+ */
2343
+ screen(id: string, input?: ScreenPersonInput, opts?: RequestOptions): Promise<Screening>;
2344
+ /**
2345
+ * The first page of a person's screenings, newest first
2346
+ * (`GET /people/:id/screenings`; 25 by default, at most 50 with `limit`).
2347
+ * Every page: {@link PeopleApi.iterateScreenings}.
2348
+ */
2349
+ screenings(id: string, query?: ListScreeningsQuery): Promise<Screening[]>;
2350
+ /** One page of {@link PeopleApi.screenings} with its `nextCursor` (absent on the last page). */
2351
+ screeningsPage(id: string, query?: ListScreeningsQuery): Promise<Page<Screening>>;
2352
+ /** Every screening of a person, newest first, following `nextCursor` page after page. */
2353
+ iterateScreenings(id: string, query?: ListScreeningsQuery): AsyncGenerator<Screening, void, undefined>;
2354
+ /**
2355
+ * `DELETE /people/:id` — deletes the person's stored photos, face
2356
+ * templates and identifiers, and the personal data and media of their
2357
+ * sessions, which it unlinks (they keep their outcome and steps). Emits
2358
+ * `person.deleted`. Cannot be undone; a second call answers `404`.
2359
+ */
2360
+ delete(id: string): Promise<DeletedPerson>;
2361
+ /**
2362
+ * A re-check or step-up session for an existing person in one call:
2363
+ * `POST /people/:id/sessions` when `target` is a person id (`per_...` or 24
2364
+ * hexadecimal characters) or `{ personId }`, otherwise
2365
+ * `POST /people/by-external-ref/:externalRef/sessions` (pass
2366
+ * `{ externalRef }` to force it). Same result and errors as
2367
+ * {@link SessionsApi.create}; needs the `sessions:create` and
2368
+ * `people:read` scopes.
2369
+ */
2370
+ createSession(target: string | PersonSessionTarget, input: PersonSessionInput, opts?: RequestOptions): Promise<CreatedSession>;
2371
+ }
2372
+ /**
2373
+ * Stops the next sessions of a device, a person, an account or a contact. Exposed as
2374
+ * {@link Sekyro.blocks}. Needs the `blocks:read` or `blocks:write` scope.
2375
+ * Exported as a TYPE only.
2376
+ * @public
2377
+ */
2378
+ declare class BlocksApi {
2379
+ private readonly t;
2380
+ /** @internal */
2381
+ constructor(t: {
2382
+ call<T>(method: HttpMethod, path: string, body?: unknown, idempotencyKey?: string): Promise<T>;
2383
+ page<T>(path: string): Promise<Page<T>>;
2384
+ });
2385
+ /**
2386
+ * `POST /blocks`: blocks the key, or answers the active block already on it. `kind: "person"`
2387
+ * blocks each ID number of the person and answers a list. A shared device answers
2388
+ * `409 device_shared` with `details.people` unless `force: true`. `403 blocks_disabled` while blocks
2389
+ * are turned off. The API requires an idempotency key: one is generated when you pass none, so
2390
+ * pass your own to make a retry of the same call safe.
2391
+ */
2392
+ create(input: CreateBlockInput & {
2393
+ kind: "person";
2394
+ }, opts?: RequestOptions): Promise<Block[]>;
2395
+ create(input: CreateBlockInput, opts?: RequestOptions): Promise<Block>;
2396
+ /** The first page of the blocks of this environment, newest first. Every page: {@link BlocksApi.iterate}. */
2397
+ list(query?: ListBlocksQuery): Promise<Block[]>;
2398
+ /** One page of {@link BlocksApi.list} with its `nextCursor` (absent on the last page). */
2399
+ listPage(query?: ListBlocksQuery): Promise<Page<Block>>;
2400
+ /** Every block matching `query`, newest first, following `nextCursor` page after page. */
2401
+ iterate(query?: ListBlocksQuery): AsyncGenerator<Block, void, undefined>;
2402
+ /** `GET /blocks/:id`. */
2403
+ get(id: string): Promise<Block>;
2404
+ /** `DELETE /blocks/:id`: the next sessions on its key go through. Lifting again is a no-op. */
2405
+ lift(id: string, input?: LiftBlockInput, opts?: RequestOptions): Promise<Block>;
2406
+ /** `POST /blocks/check`: whether a value is blocked. A POST, so it never sits in a URL or a log. */
2407
+ check(input: BlockCheckInput): Promise<BlockCheck>;
2408
+ }
2409
+ /**
2410
+ * What you know about a device before you block it. Exposed as {@link Sekyro.devices}. Needs the
2411
+ * `blocks:read` or `blocks:write` scope. Exported as a TYPE only.
2412
+ * @public
2413
+ */
2414
+ declare class DevicesApi {
2415
+ private readonly t;
2416
+ /** @internal */
2417
+ constructor(t: {
2418
+ call<T>(method: HttpMethod, path: string, body?: unknown, idempotencyKey?: string): Promise<T>;
2419
+ });
2420
+ /** `GET /devices/:deviceId`: `404 device_not_found` for a device of another environment. */
2421
+ get(deviceId: string): Promise<Device>;
2422
+ /**
2423
+ * `PATCH /devices/:deviceId`: marks or unmarks the device as shared. Unmarking only clears your
2424
+ * own mark: a device recognised as shared from its sessions stays shared.
2425
+ */
2426
+ update(deviceId: string, input: {
2427
+ shared: boolean;
2428
+ }, opts?: RequestOptions): Promise<Device>;
2429
+ }
2430
+ /**
2431
+ * Sekyro AI partner API client. Server-side only: it carries your API key.
2432
+ *
2433
+ * Throws {@link SekyroConfigError} synchronously when `apiKey` is missing or
2434
+ * `baseUrl` is not `https:` (plain `http:` is accepted for `localhost`,
2435
+ * `127.0.0.1` and `[::1]` only).
2436
+ *
2437
+ * @example
2438
+ * ```ts
2439
+ * const sekyro = new Sekyro({ apiKey: process.env.SEKYRO_API_KEY! });
2440
+ * const { id, hostedUrl } = await sekyro.sessions.create({ person: { externalRef: "<your user id>" } });
2441
+ * ```
2442
+ * @public
2443
+ */
2444
+ declare class Sekyro {
2445
+ #private;
2446
+ readonly sessions: SessionsApi;
2447
+ readonly people: PeopleApi;
2448
+ readonly blocks: BlocksApi;
2449
+ readonly devices: DevicesApi;
2450
+ readonly flows: FlowsApi;
2451
+ constructor(opts: SekyroOptions);
2452
+ /**
2453
+ * `GET /me`: which key this is. Tells a Sandbox key from a Live one, and
2454
+ * names its app, organization and scopes. Works with any valid secret key;
2455
+ * never returns the secret. An invalid key answers `401 unauthorized`.
2456
+ */
2457
+ me(): Promise<ApiKeyIdentity>;
2458
+ }
2459
+
2460
+ export { type FlowSummary as $, type AgeMethod as A, type Block as B, type CreatedSession as C, type CreateBlockInput as D, type CreateSessionInput as E, type FetchLike as F, DEFAULT_BASE_URL as G, DEFAULT_TIMEOUT_MS as H, type DecidedBy as I, type DecisionReason as J, type DeepPartial as K, type Locale as L, type DeletedPerson as M, type DeliverOptions as N, type Device as O, DevicesApi as P, type DocumentSubstitutionSettings as Q, type ReviewReason as R, Sekyro as S, type EidResult as T, type EligibilityReason as U, type VerificationLevel as V, type WebhookEventType as W, type ExtendLinkInput as X, type FlowOverridableSettings as Y, type FlowOverrides as Z, type FlowServiceSettings as _, type ServiceId as a, type SessionLinkInput as a$, FlowsApi as a0, type IdNumberReason as a1, type Identity as a2, type IdentityBirthPlace as a3, type IdentityDocument as a4, type IdentityIdNumber as a5, type IdentityMethod as a6, type IdentityName as a7, type IdentityScalarKey as a8, type IdentitySource as a9, type PolicyFailureReason as aA, type PortraitReportEntry as aB, type PriorReviewReason as aC, type ProbeBindingReason as aD, type ProbeQuality as aE, type ProfileDocumentType as aF, type RequestOptions as aG, type ResultTokenResponse as aH, type ReviewOutcomeReason as aI, type RevokePersonInput as aJ, type ScreenPersonInput as aK, type Screening as aL, type ScreeningHit as aM, type ScreeningHitSummary as aN, type ScreeningList as aO, type ScreeningStatus as aP, type ScreeningTrigger as aQ, type ScreeningUnavailableReason as aR, type SekyroOptions as aS, type Session as aT, type SessionDevice as aU, type SessionDeviceSignal as aV, type SessionFailureReason as aW, type SessionFlowRef as aX, type SessionLifecycleEventData as aY, type SessionLinkDelivery as aZ, type SessionLinkExpiry as a_, type IdentitySources as aa, type LevelTarget as ab, type LiftBlockInput as ac, type ListBlocksQuery as ad, type ListPeopleQuery as ae, type ListScreeningsQuery as af, type ListSessionsQuery as ag, type MatchReason as ah, type MediaBytes as ai, type MediaBytesOptions as aj, type MediaItem as ak, type MediaKind as al, type MediaList as am, type NameForm as an, type Page as ao, PeopleApi as ap, type Person as aq, type PersonBirthPlaceInput as ar, type PersonDeletedEventData as as, type PersonDocumentInput as at, type PersonEnrolledEventData as au, type PersonSession as av, type PersonSessionInput as aw, type PersonSessionTarget as ax, type PersonSuspiciousActivityEventData as ay, type PersonUpdatedEventData as az, type SessionPersonInput as b, type SessionNetwork as b0, type SessionNetworkEvent as b1, type SessionScreening as b2, type SessionStatus as b3, type SessionStep as b4, type SessionStepDecision as b5, type SessionSupersededEventData as b6, SessionsApi as b7, type SimulateSessionInput as b8, type SubjectAssurance as b9, type SubjectIdNumber as ba, type SubjectName as bb, type SubjectReferenceSource as bc, type SubjectReuseTarget as bd, type SubjectStatus as be, type UsageThresholdReachedEventData as bf, type VerifiedContacts as bg, type WebhookEnvelopeOf as bh, type WebhookEventDataMap as bi, 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 ResultRisk as i, type ResultCheckProofs as j, type ResultDuplicate as k, type FailureIdentification as l, type AgeResult as m, type AmlMatchFlaggedEventData as n, type ApiKeyIdentity as o, type BlockCheck as p, type BlockCheckInput as q, type BlockDuration as r, type BlockIdNumber as s, type BlockKind as t, type BlockReason as u, BlocksApi as v, type CameraUnavailableCause as w, type CheckState as x, type CheckType as y, type ConnectorIdentity as z };