@sekyro/web 0.1.0-rc.24 → 0.1.0-rc.26
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.
- package/CHANGELOG.md +22 -0
- package/README.md +32 -2
- package/dist/{capture-session-doc-RIBBH3M4.js → capture-session-doc-WZMI5XPE.js} +1 -1
- package/dist/{capture-session-v3-CPHzDT7E.d.cts → capture-session-v3-BKSjJ6L0.d.cts} +1 -1
- package/dist/{capture-session-v3-TUPtnvmu.d.ts → capture-session-v3-C1I_GLC9.d.ts} +1 -1
- package/dist/challenge-frame-NUGPTWFP.js +1 -0
- package/dist/{chunk-MXWLCDFX.js → chunk-4DEPREJ3.js} +1 -1
- package/dist/{chunk-LBH6KGTV.js → chunk-65JZHKVG.js} +1 -1
- package/dist/{chunk-FLA42JCK.js → chunk-7MZW3FFH.js} +1 -1
- package/dist/chunk-DVTK2DGX.js +1 -0
- package/dist/chunk-GPFAPAS6.js +3 -0
- package/dist/chunk-HVW2AB35.js +1 -0
- package/dist/{chunk-IFLOS5OT.js → chunk-LLX2CKZ3.js} +1 -1
- package/dist/chunk-LV23FCYP.js +1 -0
- package/dist/{chunk-TDLIXFDT.js → chunk-NFHLJOHW.js} +1 -1
- package/dist/{chunk-5YVQIHQA.js → chunk-OVP7FAMJ.js} +1 -1
- package/dist/{chunk-XI5FXEKC.js → chunk-XOTKATN6.js} +1 -1
- package/dist/chunk-ZCW6PNUX.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +1 -1
- package/dist/create-document-capture-OXPLKHOF.js +1 -0
- package/dist/{create-verification-acQzNRiB.d.ts → create-verification-7wPXJN_P.d.ts} +287 -120
- package/dist/{create-verification-DF60lg8Y.d.cts → create-verification-YeuI7_B0.d.cts} +287 -120
- package/dist/{detector-scanic-YCDNLCGV.js → detector-scanic-23DAYT3H.js} +1 -1
- package/dist/{icao-gate-CX0chQMM.d.cts → icao-gate-BK8TGaCk.d.ts} +1 -1
- package/dist/{icao-gate-VwsQo8Bq.d.ts → icao-gate-pD2dUV3P.d.cts} +1 -1
- package/dist/{icao-policy-WnG2OSyp.d.cts → icao-policy-CdR6PFHS.d.cts} +2 -2
- package/dist/{icao-policy-B02jDiox.d.ts → icao-policy-qJpZOOOu.d.ts} +2 -2
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +3 -1
- package/dist/internal/index.d.cts +69 -114
- package/dist/internal/index.d.ts +69 -114
- package/dist/internal/index.js +1 -1
- package/dist/plan-runner-EP26JU6A.js +1 -0
- package/dist/{types-1s8CQrEN.d.ts → types-DB-cZTSn.d.cts} +156 -29
- package/dist/{types-1s8CQrEN.d.cts → types-DB-cZTSn.d.ts} +156 -29
- package/dist/upload-file-EGXXM6TQ.js +1 -0
- package/package.json +1 -1
- package/sbom.cdx.json +10 -10
- package/dist/chunk-DMOGKGDS.js +0 -1
- package/dist/chunk-IC6TI6GV.js +0 -1
- package/dist/chunk-MQBX4DQQ.js +0 -1
- package/dist/chunk-QY6TJCOJ.js +0 -1
- package/dist/chunk-TDCLQRT4.js +0 -1
- package/dist/create-document-capture-XQURFZZK.js +0 -1
- package/dist/plan-runner-LDV4PYN7.js +0 -1
- package/dist/turnstile-52B3RFXD.js +0 -1
- package/dist/upload-file-UYXOHCRG.js +0 -1
|
@@ -286,7 +286,9 @@ type CheckState = "pending" | "input_required" | "processing" | "passed" | "fail
|
|
|
286
286
|
* profile v2 §4.6.5) confirms an email address with a one-time code;
|
|
287
287
|
* `eid_auth` (SDK spec §3.2) is the national eID sign-in (Houwiyeti in MR).
|
|
288
288
|
*/
|
|
289
|
-
type CheckType = "liveness" | "face_match" | "doc_ocr" | "population_registry" | "phone_otp" | "nfc_chip" | "email_otp" | "portrait_icao" | "eid_auth"
|
|
289
|
+
type CheckType = "liveness" | "face_match" | "doc_ocr" | "population_registry" | "phone_otp" | "nfc_chip" | "email_otp" | "portrait_icao" | "eid_auth"
|
|
290
|
+
/** Spec 2026-11-10 §5: the proof of address step (a bill or statement, images or one PDF). */
|
|
291
|
+
| "poa";
|
|
290
292
|
type LivenessReason = "no_face" | "media_unreadable" | "clip_too_short" | "spoof_detected" | "review_band" | "liveness_inconclusive" | "device_integrity_failed" | "mobile_required" | "capture_back_camera" | "capture_not_upright" | "capture_front_camera" | "multiple_faces" | "camera_unavailable";
|
|
291
293
|
type PopulationReason = "registry_record_not_found" | "nni_not_found" | "id_number_invalid" | "nni_invalid" | "registry_unavailable" | "nationality_not_allowed" | "underage" | "age_unverifiable" | "name_mismatch" | "birth_date_mismatch" | "nationality_mismatch" | "id_number_recheck" | "nni_recheck";
|
|
292
294
|
type FaceMatchReason = "no_face_source" | "no_face_reference" | "low_quality_reference" | "below_threshold" | "review_band" | "match_inconclusive" | "subject_revoked" | "probe_not_from_liveness" | "prior_review_approved";
|
|
@@ -320,7 +322,7 @@ type PhoneOtpReason = "otp_mismatch" | "otp_expired" | "otp_send_failed" | "otp_
|
|
|
320
322
|
* mail (`email_invalid`), or a disposable address the app blocks
|
|
321
323
|
* (`email_disposable`) — the person enters another address or resends.
|
|
322
324
|
*/
|
|
323
|
-
type EmailOtpReason = "otp_mismatch" | "otp_expired" | "otp_send_failed" | "otp_rate_limited" | "otp_resend_limit" | "email_invalid" | "email_disposable" | "otp_daily_cap_reached";
|
|
325
|
+
type EmailOtpReason = "otp_mismatch" | "otp_expired" | "otp_send_failed" | "otp_rate_limited" | "otp_resend_limit" | "email_invalid" | "email_disposable" | "otp_daily_cap_reached" | "payment_method_required" | "spend_cap_reached" | "insufficient_balance" | "account_verification_required";
|
|
324
326
|
/**
|
|
325
327
|
* nfc_chip reasons (M-nfc, SDK spec §4.3). Native SDKs read the chip; the web
|
|
326
328
|
* never does — on web the step arrives `skipped` (`platform_unsupported`) or
|
|
@@ -347,12 +349,23 @@ type EidReason = "eid_identifier_invalid" | "eid_code_invalid" | "eid_code_expir
|
|
|
347
349
|
* is final and ends the session.
|
|
348
350
|
*/
|
|
349
351
|
type AgeEstimationReason = "age_uncertain" | "age_unavailable" | "underage_estimated";
|
|
352
|
+
/**
|
|
353
|
+
* Reasons of the proof of address step (`poa`, spec 2026-11-10 §5.3), in the server's decision order:
|
|
354
|
+
* `provider_unavailable` (the document could not be checked now; retry), `unreadable` (a sharper, complete copy),
|
|
355
|
+
* `pdf_protected` (the PDF has a password, scripts, attachments or forms), `document_kind_not_accepted` and
|
|
356
|
+
* `document_too_old` (the step's rule for the document's country says what is accepted: `proofOfAddress.rule`),
|
|
357
|
+
* `document_date_invalid` (a date in the future), `document_tampered` (final), `name_mismatch`,
|
|
358
|
+
* `holder_letter_required` (the bill is in another person's name: the step asks for the holder's letter,
|
|
359
|
+
* `proofOfAddress.phase: "holder_letter"`), `holder_letter_missing` (the letter is incomplete) and `address_mismatch`
|
|
360
|
+
* (the address differs from the one the partner supplied).
|
|
361
|
+
*/
|
|
362
|
+
type PoaReason = "provider_unavailable" | "unreadable" | "pdf_protected" | "document_kind_not_accepted" | "document_date_invalid" | "document_too_old" | "document_tampered" | "name_mismatch" | "holder_letter_required" | "holder_letter_missing" | "address_mismatch";
|
|
350
363
|
/**
|
|
351
364
|
* Any frozen reason code. The backend declares the field `string`, but the
|
|
352
365
|
* taxonomy is frozen (do-not-drift) — the union IS the contract. NB: liveness
|
|
353
366
|
* and face_match both carry `review_band`.
|
|
354
367
|
*/
|
|
355
|
-
type CheckReason = LivenessReason | PopulationReason | FaceMatchReason | DocReason | PhoneOtpReason | EmailOtpReason | NfcChipReason | PortraitIcaoReason | EidReason
|
|
368
|
+
type CheckReason = LivenessReason | PopulationReason | FaceMatchReason | DocReason | PhoneOtpReason | EmailOtpReason | NfcChipReason | PortraitIcaoReason | EidReason | PoaReason
|
|
356
369
|
/**
|
|
357
370
|
* Spec 2026-10-27 (Sandbox testers), tester-bound sessions only:
|
|
358
371
|
* `tester_document_mismatch` (doc_ocr, nfc_chip) when the document read is
|
|
@@ -402,8 +415,11 @@ type CameraUnavailableCause = "denied" | "no_camera";
|
|
|
402
415
|
* error's `name` (letters only, at most 40 characters).
|
|
403
416
|
*/
|
|
404
417
|
interface CaptureIssueReport {
|
|
405
|
-
/**
|
|
406
|
-
|
|
418
|
+
/**
|
|
419
|
+
* The step whose camera failed (`portrait`: the portrait step's own camera, 2026-11-05), or `attestation`: the
|
|
420
|
+
* challenge frame produced no token (`kind: 'unavailable'`, the `ChallengeErrorCode` in `engineKind`).
|
|
421
|
+
*/
|
|
422
|
+
check: "liveness" | "document" | "portrait" | "attestation";
|
|
407
423
|
/** The public capture error kind shown, or `unavailable` (the SDK reason then rides in `engineKind`). */
|
|
408
424
|
kind: "permission" | "notfound" | "inuse" | "insecure" | "unsupported" | "generic" | "unavailable";
|
|
409
425
|
name?: string;
|
|
@@ -444,10 +460,11 @@ interface NationalEidOption {
|
|
|
444
460
|
type EidAfterPass = "end" | "continue";
|
|
445
461
|
/**
|
|
446
462
|
* The section a step belongs to (flow model 2026-10-23, SDK spec §3.7): Step 1
|
|
447
|
-
* `contact`, Step 2 `identity`, Step 3 `live_photo
|
|
448
|
-
*
|
|
463
|
+
* `contact`, Step 2 `identity`, Step 3 `live_photo`; `documents` holds the proof
|
|
464
|
+
* of address (spec 2026-11-10). Open: a value this SDK does not know is kept as
|
|
465
|
+
* is, so a client still places the step.
|
|
449
466
|
*/
|
|
450
|
-
type StepSection = "contact" | "identity" | "live_photo" | "screening" | (string & {});
|
|
467
|
+
type StepSection = "contact" | "identity" | "live_photo" | "screening" | "documents" | (string & {});
|
|
451
468
|
/** A contact channel of a contact choice (`phone_otp` → `phone`, `email_otp` → `email`). */
|
|
452
469
|
type ContactChannel = "phone" | "email";
|
|
453
470
|
/**
|
|
@@ -595,8 +612,12 @@ interface MethodChoiceView {
|
|
|
595
612
|
*/
|
|
596
613
|
nationalEid?: NationalEidOption;
|
|
597
614
|
}
|
|
598
|
-
/**
|
|
599
|
-
type
|
|
615
|
+
/**
|
|
616
|
+
* A document type the backend reads (kyc-docs-v2 vocabulary; `carte_identite` = identity card of any issuer).
|
|
617
|
+
* `drivers_license` (spec 2026-11-10 §6): a driving licence, two faces, no MRZ, offered only when the flow lists it
|
|
618
|
+
* (`"*"` never includes it).
|
|
619
|
+
*/
|
|
620
|
+
type AcceptedDocumentType = "carte_identite" | "passport" | "residence_permit" | "drivers_license";
|
|
600
621
|
/**
|
|
601
622
|
* Accepted document types per issuing country (profile v2 §5.3a): an issuer
|
|
602
623
|
* uses `byIssuer[iso2] ?? default`; `"*"` = every type.
|
|
@@ -1131,6 +1152,13 @@ interface HostedIntegrity {
|
|
|
1131
1152
|
appAttest: true;
|
|
1132
1153
|
};
|
|
1133
1154
|
}
|
|
1155
|
+
/** `HostedSessionView.challenge`: where the browser obtains its attestation token (spec 2026-11-10 §4.3). */
|
|
1156
|
+
interface HostedChallengeView {
|
|
1157
|
+
/** The challenge frame (`<hosted origin>/challenge`, always the platform host, never a custom domain). */
|
|
1158
|
+
url: string;
|
|
1159
|
+
/** The Turnstile site key the frame renders. */
|
|
1160
|
+
siteKey: string;
|
|
1161
|
+
}
|
|
1134
1162
|
interface HostedSessionView {
|
|
1135
1163
|
sessionId: string;
|
|
1136
1164
|
status: SessionStatus;
|
|
@@ -1161,15 +1189,13 @@ interface HostedSessionView {
|
|
|
1161
1189
|
*/
|
|
1162
1190
|
sdkOrigin?: string | null;
|
|
1163
1191
|
/**
|
|
1164
|
-
*
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1169
|
-
* environments. `null` only on a Live deployment without Turnstile: the SDK
|
|
1170
|
-
* sends no token and the server decides.
|
|
1192
|
+
* The Sekyro challenge frame the browser asks for an attestation token before it submits `liveness` (spec
|
|
1193
|
+
* 2026-11-10 §4.3): the platform's Turnstile widget runs inside a hidden frame at `url`, so the host page needs
|
|
1194
|
+
* only `frame-src <origin of url>`. On a Sandbox session `siteKey` is Cloudflare's always-passing test key, so the
|
|
1195
|
+
* same code runs in both environments. `null` only on a Live deployment without Turnstile: the SDK sends no token
|
|
1196
|
+
* and the server decides.
|
|
1171
1197
|
*/
|
|
1172
|
-
|
|
1198
|
+
challenge: HostedChallengeView | null;
|
|
1173
1199
|
/**
|
|
1174
1200
|
* A Sandbox (test) session: the hosted page marks it as a test session.
|
|
1175
1201
|
* Optional: absent on an older backend.
|
|
@@ -1343,6 +1369,12 @@ interface HostedSessionView {
|
|
|
1343
1369
|
* with no upload offered (and on older APIs): `{ source: "camera", uploadOffered: false }`.
|
|
1344
1370
|
*/
|
|
1345
1371
|
documents?: HostedDocumentsView;
|
|
1372
|
+
/**
|
|
1373
|
+
* Spec 2026-11-10 §5.4, §7.4: the open proof of address step's settings (the accepted kinds for the best known
|
|
1374
|
+
* country, the name rule, the phase, the photo source, the upload limits). Present only while a `poa` step is open;
|
|
1375
|
+
* absent on older APIs.
|
|
1376
|
+
*/
|
|
1377
|
+
proofOfAddress?: HostedProofOfAddressView;
|
|
1346
1378
|
/**
|
|
1347
1379
|
* Spec 2026-10-29 D12: where the hosted completion screen sends the person (`returnUrl`, checked at session
|
|
1348
1380
|
* create against the app's web origins or native scheme) and the partner's opaque `state`. Never the result.
|
|
@@ -1416,12 +1448,13 @@ interface SessionView {
|
|
|
1416
1448
|
createdAt?: string;
|
|
1417
1449
|
}
|
|
1418
1450
|
/** Media class — selects size cap, MIME allowlist and promoted prefix (media.policy.ts). */
|
|
1419
|
-
type MediaKind = "image" | "clip";
|
|
1451
|
+
type MediaKind = "image" | "clip" | "document_file";
|
|
1420
1452
|
/**
|
|
1421
1453
|
* Body of `POST /sessions/:id/media`. `contentType`/`contentLength` are the
|
|
1422
1454
|
* exact values SIGNED into the presigned PUT — the PUT must send them verbatim.
|
|
1423
1455
|
* Allowlists (media.policy.ts): image → image/jpeg | image/png (5 MB cap);
|
|
1424
|
-
* clip → video/webm | video/mp4 (15 MB cap)
|
|
1456
|
+
* clip → video/webm | video/mp4 (15 MB cap); document_file → application/pdf (10 MB cap, the proof of address
|
|
1457
|
+
* step's upload only, spec 2026-11-10 §7.1). BARE types only — no `;codecs=` params.
|
|
1425
1458
|
*/
|
|
1426
1459
|
interface PresignRequest {
|
|
1427
1460
|
kind: MediaKind;
|
|
@@ -1476,18 +1509,16 @@ interface CompleteMediaResult {
|
|
|
1476
1509
|
}
|
|
1477
1510
|
/**
|
|
1478
1511
|
* Liveness attestation bag (attestation-verifier.service.ts). The web SDK sends
|
|
1479
|
-
* `{channel: 'hosted_web',
|
|
1480
|
-
* `
|
|
1481
|
-
*
|
|
1482
|
-
*
|
|
1483
|
-
*
|
|
1512
|
+
* `{channel: 'hosted_web', turnstileToken}` in both environments, or
|
|
1513
|
+
* `{channel: 'hosted_web'}` when the challenge produced no token (the server's
|
|
1514
|
+
* attestation rules decide). The token comes from the Sekyro challenge frame
|
|
1515
|
+
* ({@link HostedChallengeView}) and is bound to the session and the page's
|
|
1516
|
+
* origin. Native SDKs use platform attestation.
|
|
1484
1517
|
*/
|
|
1485
1518
|
interface AttestationInput {
|
|
1486
1519
|
signature?: string;
|
|
1487
1520
|
channel?: "hosted_web";
|
|
1488
1521
|
turnstileToken?: string;
|
|
1489
|
-
/** The Turnstile site key the token was minted with (selects the verifying secret). */
|
|
1490
|
-
siteKey?: string;
|
|
1491
1522
|
}
|
|
1492
1523
|
/**
|
|
1493
1524
|
* liveness executor input: a promoted `clips/…` key + optional attestation.
|
|
@@ -1535,8 +1566,13 @@ interface LivenessCaptureInput {
|
|
|
1535
1566
|
cameraReadyMs?: number;
|
|
1536
1567
|
faceAcquireMs?: number;
|
|
1537
1568
|
captureMs?: number;
|
|
1538
|
-
/** Uploads settled → attestation token in hand (the
|
|
1569
|
+
/** Uploads settled → attestation token in hand (the challenge frame on the web), ms. */
|
|
1539
1570
|
attestationMs?: number;
|
|
1571
|
+
/**
|
|
1572
|
+
* Why the web challenge produced no token (a `ChallengeErrorCode`: `challenge_frame_blocked`, `timeout`, ...),
|
|
1573
|
+
* lower case, at most 32 characters. Absent when the token was obtained.
|
|
1574
|
+
*/
|
|
1575
|
+
attestationError?: string;
|
|
1540
1576
|
/** The camera the clip was filmed with (`environment` = back). */
|
|
1541
1577
|
facingMode?: 'user' | 'environment';
|
|
1542
1578
|
/**
|
|
@@ -1620,6 +1656,90 @@ interface HostedDocumentsView {
|
|
|
1620
1656
|
*/
|
|
1621
1657
|
uploadOffered: boolean;
|
|
1622
1658
|
}
|
|
1659
|
+
/** The document kinds a proof of address may be (spec §5.2). */
|
|
1660
|
+
type PoaKind = "utility_bill" | "telecom_bill" | "bank_statement" | "tax_notice" | "rental_agreement" | "government_certificate" | "insurance_statement";
|
|
1661
|
+
/**
|
|
1662
|
+
* How the name on the document is matched: `exact_person` (the person's own name), `family_name` (the same family
|
|
1663
|
+
* name), `third_party_letter` (another holder, with a signed letter from that holder).
|
|
1664
|
+
*/
|
|
1665
|
+
type PoaNameMatchMode = "exact_person" | "family_name" | "third_party_letter";
|
|
1666
|
+
/**
|
|
1667
|
+
* Where the step's rule came from: the flow's rule for the country (`flow_country`), the flow's default rule
|
|
1668
|
+
* (`flow_default`), Sekyro's preset for the country (`preset_country`) or the global preset (`preset_global`).
|
|
1669
|
+
*/
|
|
1670
|
+
type PoaRuleSource = "flow_country" | "flow_default" | "preset_country" | "preset_global";
|
|
1671
|
+
/** One accepted kind of the step's rule. */
|
|
1672
|
+
interface HostedPoaRuleKindView {
|
|
1673
|
+
kind: PoaKind;
|
|
1674
|
+
/** How old the document of this kind may be, in days. */
|
|
1675
|
+
maxAgeDays: number;
|
|
1676
|
+
/** ISO day: today minus `maxAgeDays`, computed by the server so every client says the same date. */
|
|
1677
|
+
earliestIssueDate: string;
|
|
1678
|
+
}
|
|
1679
|
+
/** The accepted documents the step shows (spec §5.4 "person-facing list"), resolved by the server. */
|
|
1680
|
+
interface HostedPoaRuleView {
|
|
1681
|
+
/** The country the rule was resolved for (ISO 3166-1 alpha-2); `null` = the global entry. */
|
|
1682
|
+
country: string | null;
|
|
1683
|
+
/**
|
|
1684
|
+
* How that country was chosen: the identity document's issuer, else the IP country, else global; after a
|
|
1685
|
+
* `document_kind_not_accepted` or `document_too_old` failure, the failed document's own country (`document`).
|
|
1686
|
+
*/
|
|
1687
|
+
countryFrom: "identity_document" | "ip" | "document" | "global";
|
|
1688
|
+
source: PoaRuleSource;
|
|
1689
|
+
kinds: HostedPoaRuleKindView[];
|
|
1690
|
+
}
|
|
1691
|
+
/** The open proof of address step (`HostedSessionView.proofOfAddress`). */
|
|
1692
|
+
interface HostedProofOfAddressView {
|
|
1693
|
+
rule: HostedPoaRuleView;
|
|
1694
|
+
nameMatch: PoaNameMatchMode;
|
|
1695
|
+
/** `holder_letter` once the bill was read under `third_party_letter` and the step waits for the holder's letter. */
|
|
1696
|
+
phase: "document" | "holder_letter";
|
|
1697
|
+
/** Where the pages come from ({@link PhotoSource}). */
|
|
1698
|
+
source: PhotoSource;
|
|
1699
|
+
/** The person's pick under `choice`, once made for this step. */
|
|
1700
|
+
sourcePick?: PhotoSourcePick;
|
|
1701
|
+
/** An upload would be accepted now. */
|
|
1702
|
+
uploadOffered: boolean;
|
|
1703
|
+
/** Pages per document, at most. */
|
|
1704
|
+
maxPages: 3;
|
|
1705
|
+
/** A PDF upload's limits. */
|
|
1706
|
+
pdf: {
|
|
1707
|
+
maxBytes: number;
|
|
1708
|
+
maxPages: 3;
|
|
1709
|
+
};
|
|
1710
|
+
/**
|
|
1711
|
+
* Spec 2026-11-10 §5.3 licence shortcut: the step accepts the address of the driving licence read earlier in the
|
|
1712
|
+
* session, so the person may continue without a document ({@link PoaLicenceInput}). Present only in the `document`
|
|
1713
|
+
* phase.
|
|
1714
|
+
*/
|
|
1715
|
+
licenceAddressAccepted?: true;
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* `poa` executor input (spec 2026-11-10 §7): the document (or, in the `holder_letter` phase, the holder's letter) as
|
|
1719
|
+
* 1 to 3 promoted page images, or as one promoted PDF (`document_file` media kind).
|
|
1720
|
+
*/
|
|
1721
|
+
type PoaInput = PoaImagesInput | PoaPdfInput | PoaLicenceInput;
|
|
1722
|
+
/**
|
|
1723
|
+
* The licence shortcut (spec 2026-11-10 §5.3): no media; the server decides from the driving licence read earlier in
|
|
1724
|
+
* the session. Only while the view's `proofOfAddress.licenceAddressAccepted` is set.
|
|
1725
|
+
*/
|
|
1726
|
+
interface PoaLicenceInput {
|
|
1727
|
+
part: "document";
|
|
1728
|
+
}
|
|
1729
|
+
/** The pages as images, in order. */
|
|
1730
|
+
interface PoaImagesInput {
|
|
1731
|
+
part: "document" | "holder_letter";
|
|
1732
|
+
source: PhotoSourcePick;
|
|
1733
|
+
/** 1 to 3 promoted `image` keys. */
|
|
1734
|
+
imageKeys: string[];
|
|
1735
|
+
}
|
|
1736
|
+
/** The document as one PDF (always picked from the device). */
|
|
1737
|
+
interface PoaPdfInput {
|
|
1738
|
+
part: "document" | "holder_letter";
|
|
1739
|
+
source: "upload";
|
|
1740
|
+
/** The promoted `document_file` key. */
|
|
1741
|
+
pdfKey: string;
|
|
1742
|
+
}
|
|
1623
1743
|
/** doc_ocr executor input: a promoted `doc-images/…` key + which side it shows. */
|
|
1624
1744
|
interface DocOcrInput {
|
|
1625
1745
|
imageKey: string;
|
|
@@ -1635,6 +1755,11 @@ interface DocOcrInput {
|
|
|
1635
1755
|
* view's `documents.uploadOffered`; else 400 `document_upload_not_allowed`). Absent = `camera`.
|
|
1636
1756
|
*/
|
|
1637
1757
|
source?: PhotoSourcePick;
|
|
1758
|
+
/**
|
|
1759
|
+
* Spec 2026-11-10 §6.2: `drivers_license` when the person picked the driving licence, so the server reads both faces
|
|
1760
|
+
* with its document reader instead of the MRZ pipeline. Absent for every other type (the server keeps its path).
|
|
1761
|
+
*/
|
|
1762
|
+
documentType?: "drivers_license";
|
|
1638
1763
|
}
|
|
1639
1764
|
/** The `doc_ocr` device-read hint (identity-backend DeviceReadSchema; strict, text-free). */
|
|
1640
1765
|
interface DocDeviceRead {
|
|
@@ -1791,6 +1916,8 @@ interface CheckInputByType {
|
|
|
1791
1916
|
portrait_icao: PortraitIcaoInput;
|
|
1792
1917
|
/** SDK spec §3.2: the national eID sign-in. */
|
|
1793
1918
|
eid_auth: EidAuthInput;
|
|
1919
|
+
/** Spec 2026-11-10 §5: the proof of address pages or PDF. */
|
|
1920
|
+
poa: PoaInput;
|
|
1794
1921
|
}
|
|
1795
1922
|
/**
|
|
1796
1923
|
* Body of `POST /sessions/:id/checks/:checkType` (SubmitCheckSchema).
|
|
@@ -1806,4 +1933,4 @@ interface SubmitCheckBody {
|
|
|
1806
1933
|
forceOutcome?: "pass" | "fail" | "age_over" | "age_uncertain" | "age_under" | "age_unavailable";
|
|
1807
1934
|
}
|
|
1808
1935
|
|
|
1809
|
-
export { type
|
|
1936
|
+
export { type HostedVoiceView as $, type AcceptedDocumentType as A, type HostedDocumentsView as B, type CaptureContext as C, type DecisionReason as D, type EidAfterPass as E, type FaceMatchInput as F, type HostedEidView as G, type HostedAcceptedDocuments as H, type HostedEmailOtpView as I, type HostedFlowRef as J, type HostedIcaoPolicy as K, type HostedIntegrity as L, type HostedLivePhotoTuning as M, type HostedNativeCaptureTuning as N, type HostedOcrTuning as O, type HostedOtpView as P, type HostedPlanView as Q, type HostedPoaRuleKindView as R, type HostedPoaRuleView as S, type HostedPortraitPendingFix as T, type HostedPortraitView as U, type HostedProofOfAddressView as V, type HostedSessionView as W, type HostedSimulationView as X, type HostedStepView as Y, type HostedTesterGateView as Z, type HostedVoiceLocale as _, type AttestationInput as a, type CameraUnavailableCause as a$, type IcaoCriterion as a0, type IcaoReportEntry as a1, type IdentityConfirmDecision as a2, type IdentityMethod as a3, type IdentitySummarySource as a4, type IdentitySummaryView as a5, type LivenessCaptureInput as a6, type LivenessInput as a7, type LivenessReason as a8, type MatchReason as a9, type PopulationInput as aA, type PopulationReason as aB, type PortraitFix as aC, type PortraitFixReviewInput as aD, type PortraitIcaoInput as aE, type PortraitIcaoReason as aF, type PortraitOutputFormat as aG, type PresignRequest as aH, type PresignUploadResult as aI, type RecordConsentResult as aJ, type ResolvedCaptureMode as aK, type SessionDecidingStep as aL, type SessionFailureReason as aM, type SessionReason as aN, type SessionStatus as aO, type SessionStepView as aP, type SessionView as aQ, type SimulatedCaptureInput as aR, type StepResult as aS, type StepSection as aT, type SubmitCheckBody as aU, type TesterGateInput as aV, type TesterGateResponse as aW, type VerificationAssurance as aX, type VerificationLevel as aY, type ScreenRampColour as aZ, type AgeEstimationReason as a_, type MediaKind as aa, type MethodChoiceView as ab, type NationalEidOption as ac, type NfcChipReason as ad, type NfcStepView as ae, type OtpChoiceView as af, type PhoneCountryRule as ag, type PhoneFormat as ah, type PhoneOtpInput as ai, type PhoneOtpReason as aj, type PhotoSource as ak, type PhotoSourcePick as al, type PlanAttempts as am, type PlanChoiceKind as an, type PlanChoiceOption as ao, type PlanChoiceView as ap, type PlanSectionView as aq, type PlanStepView as ar, type PoaImagesInput as as, type PoaInput as at, type PoaKind as au, type PoaLicenceInput as av, type PoaNameMatchMode as aw, type PoaPdfInput as ax, type PoaReason as ay, type PoaRuleSource as az, type CaptureMode as b, type CaptureIssueReport as b0, type CaptureProvenance as b1, type HostedBranding as b2, type HostedBrandingColorKey as b3, type HostedLivenessCaptureTuning as b4, type IcaoCaptureTuning as b5, type RetakeHint as b6, type ScreenRampChallenge as b7, type ScreenRampPaint as b8, type ScreenRampRendered as b9, type ScreenRampReport as ba, ICAO_FALLBACK as bb, type IcaoProfile as bc, type ResolvedIcaoTuning as bd, resolveIcaoTuning as be, type PersonMask as bf, type BackgroundUniformity as bg, type CaptureNoncesResult as c, type CaptureProof as d, type CheckInputByType as e, type CheckReason as f, type CheckState as g, type CheckType as h, type ClosedBy as i, type CompleteMediaResult as j, type ConsentLocale as k, type ContactChannel as l, type DocDeviceRead as m, type DocOcrInput as n, type DocReason as o, type DocSide as p, type EidAuthInput as q, type EidReason as r, type EmailOtpInput as s, type EmailOtpReason as t, type FaceMatchReason as u, type HostedCaptureTuning as v, type HostedChallengeView as w, type HostedConsentView as x, type HostedDocumentCaptureTuning as y, type HostedDocumentScanTuning as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var U=5242880,_=2560,g=[.92,.85,.75],m=new Set(["","image/jpeg","image/jpg","image/pjpeg","image/png","image/heic","image/heif","image/heic-sequence","image/heif-sequence"]),h=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]);function w(e){if(e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255)return"jpeg";if(e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10)return"png";if(e.length>=12&&e[4]===102&&e[5]===116&&e[6]===121&&e[7]===112){let t=String.fromCharCode(e[8],e[9],e[10],e[11]);return h.has(t)?"heif":null}return null}function x(e){return e.length>=5&&e[0]===37&&e[1]===80&&e[2]===68&&e[3]===70&&e[4]===45}var b=new Set(["application/pdf","application/x-pdf"]);async function E(e){let t=(e.type??"").toLowerCase();if(t!==""&&!b.has(t))return"other";let n;try{n=x(await p(e))}catch{n=!1}return n?"pdf":t===""?"other":"bad"}async function p(e){let t=e.slice(0,16);return typeof t.arrayBuffer=="function"?new Uint8Array(await t.arrayBuffer()):new Promise((n,r)=>{let o=new FileReader;o.onload=()=>n(new Uint8Array(o.result)),o.onerror=()=>r(o.error),o.readAsArrayBuffer(t)})}var y=async e=>{let t=await createImageBitmap(e,{imageOrientation:"from-image"});return{width:t.width,height:t.height,draw:(n,r,o)=>n.drawImage(t,0,0,r,o),close:()=>t.close()}},A=(e,t)=>{let n=document.createElement("canvas");n.width=e.width,n.height=e.height;let r=n.getContext("2d");return r===null?Promise.resolve(null):(e.draw(r,e.width,e.height),new Promise(o=>n.toBlob(o,"image/jpeg",t)))};async function P(e,t={}){let n=(e.type??"").toLowerCase();if(!m.has(n)||e.size===0)throw new TypeError("unsupported_file");let r;try{r=w(await p(e))}catch{r=null}if(r===null)throw new TypeError("unsupported_file");if(r!=="heif"&&e.size<=5242880)return{blob:e,contentType:r==="png"?"image/png":"image/jpeg",converted:!1};let o=t.decode??y,d=t.encode??A,i;try{i=await o(e)}catch{throw new TypeError("unsupported_file")}try{if(!(i.width>0&&i.height>0))throw new TypeError("unsupported_file");let l=Math.min(2560,Math.max(i.width,i.height));for(let c=0;c<2;c+=1){let s=l/Math.max(i.width,i.height),u={width:Math.max(1,Math.round(i.width*s)),height:Math.max(1,Math.round(i.height*s)),draw:i.draw};for(let f of g){let a=await d(u,f).catch(()=>null);if(a!==null&&a.size>0&&a.size<=5242880)return{blob:a,contentType:"image/jpeg",converted:!0}}l=Math.round(l*.75)}throw new TypeError("unsupported_file")}finally{i.close()}}export{U as UPLOAD_MAX_BYTES,_ as UPLOAD_MAX_LONG_SIDE,E as pdfFileKind,P as prepareUploadFile,x as sniffPdf,w as sniffUploadFormat};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sekyro/web",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.26",
|
|
4
4
|
"description": "Sekyro AI web SDK \u2014 browser liveness capture, hosted-verification client and popup embed for Sekyro AI identity verification",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
package/sbom.cdx.json
CHANGED
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"type": "application",
|
|
98
98
|
"name": "web",
|
|
99
99
|
"group": "@sekyro",
|
|
100
|
-
"version": "0.1.0-rc.
|
|
101
|
-
"bom-ref": "@sekyro/web@0.1.0-rc.
|
|
100
|
+
"version": "0.1.0-rc.26",
|
|
101
|
+
"bom-ref": "@sekyro/web@0.1.0-rc.26",
|
|
102
102
|
"description": "Sekyro AI web SDK — browser liveness capture, hosted-verification client and popup embed for Sekyro AI identity verification",
|
|
103
103
|
"licenses": [
|
|
104
104
|
{
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
],
|
|
111
|
-
"purl": "pkg:npm/%40sekyro/web@0.1.0-rc.
|
|
111
|
+
"purl": "pkg:npm/%40sekyro/web@0.1.0-rc.26?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23packages%2Fsekyro-web",
|
|
112
112
|
"externalReferences": [
|
|
113
113
|
{
|
|
114
114
|
"url": "https://github.com/IBTIKAR-Technologies/ibtikar-identity/issues",
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"name": "tasks-vision",
|
|
151
151
|
"group": "@mediapipe",
|
|
152
152
|
"version": "0.10.35",
|
|
153
|
-
"bom-ref": "@sekyro/web@0.1.0-rc.
|
|
153
|
+
"bom-ref": "@sekyro/web@0.1.0-rc.26|@mediapipe/tasks-vision@0.10.35",
|
|
154
154
|
"licenses": [
|
|
155
155
|
{
|
|
156
156
|
"license": {
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
"name": "thumbmarkjs",
|
|
186
186
|
"group": "@thumbmarkjs",
|
|
187
187
|
"version": "1.12.0",
|
|
188
|
-
"bom-ref": "@sekyro/web@0.1.0-rc.
|
|
188
|
+
"bom-ref": "@sekyro/web@0.1.0-rc.26|@thumbmarkjs/thumbmarkjs@1.12.0",
|
|
189
189
|
"licenses": [
|
|
190
190
|
{
|
|
191
191
|
"license": {
|
|
@@ -218,17 +218,17 @@
|
|
|
218
218
|
],
|
|
219
219
|
"dependencies": [
|
|
220
220
|
{
|
|
221
|
-
"ref": "@sekyro/web@0.1.0-rc.
|
|
221
|
+
"ref": "@sekyro/web@0.1.0-rc.26",
|
|
222
222
|
"dependsOn": [
|
|
223
|
-
"@sekyro/web@0.1.0-rc.
|
|
224
|
-
"@sekyro/web@0.1.0-rc.
|
|
223
|
+
"@sekyro/web@0.1.0-rc.26|@mediapipe/tasks-vision@0.10.35",
|
|
224
|
+
"@sekyro/web@0.1.0-rc.26|@thumbmarkjs/thumbmarkjs@1.12.0"
|
|
225
225
|
]
|
|
226
226
|
},
|
|
227
227
|
{
|
|
228
|
-
"ref": "@sekyro/web@0.1.0-rc.
|
|
228
|
+
"ref": "@sekyro/web@0.1.0-rc.26|@mediapipe/tasks-vision@0.10.35"
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
|
-
"ref": "@sekyro/web@0.1.0-rc.
|
|
231
|
+
"ref": "@sekyro/web@0.1.0-rc.26|@thumbmarkjs/thumbmarkjs@1.12.0"
|
|
232
232
|
}
|
|
233
233
|
]
|
|
234
234
|
}
|
package/dist/chunk-DMOGKGDS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as qe,B as Ye,C as We,a as De,b as Le,c as Ne,d as U,e as W,f as j,g as He,h as D,i as Ue,j as R,k as L,l as I,m as se,n as E,o as F,p as B,q as Z,r as Fe,s as Be,t as Ge,u as Ke}from"./chunk-QY6TJCOJ.js";import{n as Ee}from"./chunk-LBH6KGTV.js";import{a as we}from"./chunk-7QZWBDI5.js";import{c as re,e as Te,g as Ve,h as $}from"./chunk-XI5FXEKC.js";import{c as Me,d as ie}from"./chunk-TSA6GHUG.js";function J(e){return e.idNumberBound??e.nniBound}function G(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function je(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Ct="https://api.sekyro.ai",_t=5e3,kt=24e4,Pt=3e4,bt=1500,Rt=10;function xt(e){return new Promise(t=>setTimeout(t,e))}function Ot(){let e=globalThis.crypto;if(e!==void 0&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e!==void 0&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<16;r+=1)t[r]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let o=[...t].map(r=>r.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}function Cn(e){return vt(e,{})}function vt(e,t){let o=e.apiOrigin??Ct,r=e.autoRetry??!0,i=e.rearm??"auto",s=t.client??new Ve({apiOrigin:o,sessionToken:e.clientToken,fetch:e.fetch}),u=t.sleep??xt,c=t.uuid??Ot,p=t.getTurnstileToken??((n,a)=>import("./turnstile-52B3RFXD.js").then(l=>l.executeTurnstile(n,a))),m=we(),g=null,x=null,d=!1,C=new AbortController,f=null,w=null,K=null,q=()=>K??Fe(f),pe=()=>Be(Z(f),q()),O=n=>{f=n,m.emit("view",n),g?.onView(n)},k=()=>f!==null?Promise.resolve(f):(w??(w=s.getSession().then(n=>(O(n),n)).finally(()=>{w=null})),w),v=async()=>{let n=await s.getSession();return O(n),n},Q=async(n,a)=>{n.plan!==void 0?O(n):await v()},X=null,fe=async n=>{let a=await k();if(n||!a.consentRecorded){let l=await s.recordConsent(e.locale);l.plan!==void 0?O(l):f!==null&&O({...f,consentRecorded:!0})}Re(a.turnstileSiteKey)},A=n=>n?.force===!0?fe(!0):(X??(X=fe(!1).finally(()=>{X=null})),X),z={client:s,ensureConsent:n=>A(n),sleep:u,uuid:c,...t.random!==void 0?{random:t.random}:{},onBusy:n=>{d||m.emit("busy",n)}},me=!1,he=null,ee=n=>{if(n.status==="verified"||n.status==="not_verified"||n.status==="review"){if(me)return;me=!0}he=JSON.stringify(n),m.emit("result",n)},st=n=>{he!==JSON.stringify(n)&&ee(n)},Se=async n=>{let a=f;n&&(a=await v().catch(()=>f));let l=a===null?null:D(a);return l!==null&&!d&&m.emit("method",l),l!==null},ye=null,ge=!1,Ce=!1,_e=()=>qe(z,(n,a)=>n.submitCheck("population_registry",{},{idempotencyKey:a})),ke=n=>J(n)===!0||G(I(n,"population_registry"))===!0,at=async()=>{try{let n=await k();if(R(n)||D(n)!==null||L(n)?.checkType!=="population_registry")return;if(!ke(n)&&G(I(n,"population_registry"))===void 0&&(n=await v()),!ke(n)){Ce=!0;return}await A(),await Q(await _e(),"population_registry");let a=f===null?void 0:I(f,"population_registry");if(a?.state==="input_required"&&a.reason==="registry_unavailable"&&j(a)>0){if(await u(_t),d)return;await Q(await _e(),"population_registry")}}catch(n){if(n instanceof re&&(n.code==="check_not_active"||n.code==="step_not_on_path")){await v().catch(()=>{});return}ge=!0;return}f!==null&&R(f)&&ee(F(f,{autoRetry:r}))},Pe=()=>(ye??(ye=at()),ye),te=t.now??Date.now,T=null,ne=n=>p(n,{signal:C.signal}),be=(n,a)=>n!==null&&n.siteKey===a&&te()-n.at<kt,Re=n=>{if(n===null||d||be(T,n))return;let a=ne(n);a.catch(()=>{}),T={siteKey:n,at:te(),token:a}},ct=async n=>{let a=T;T=null;let l=be(a,n),y=l?a.at:te(),h=l?a.token.catch(()=>ne(n)):ne(n);h.catch(()=>{});let b,V=new Promise(_=>{b=setTimeout(()=>_("late"),Pt)});try{let _=await Promise.race([h.then(S=>({value:S}),()=>null),V]);return _==="late"?(!d&&T===null&&(T={siteKey:n,at:y,token:h}),null):_===null?null:_.value}finally{clearTimeout(b)}},xe=async()=>{let a=(await k()).turnstileSiteKey;if(a===null)return{};let l=await ct(a);return l===null?{channel:"hosted_web",siteKey:a}:{channel:"hosted_web",siteKey:a,turnstileToken:l}},Y=n=>{if(d)return;let a=s.reportCaptureIssue;if(a===void 0)return;let l=n.formFactor;try{l??(l=Me())}catch{}try{Promise.resolve(a.call(s,{...n,...l!==void 0?{formFactor:l}:{}})).catch(()=>{})}catch{}},P=null,Oe=Promise.resolve(),H=0,ut=async()=>{let n=await k();for(let a=0;a<Rt&&!d&&!R(n)&&L(n)===void 0&&W(n).some(l=>l.state==="processing")&&(await u(bt),!d);a+=1)n=await v();return n},dt=async(n,a,l)=>{let{capture:y}=n,h=()=>d,b=()=>n.alive&&n.attempt===l,V=S=>{b()&&y.setFlowState(S)},_=S=>{if(!h()&&(S.status==="unavailable"&&S.reasonCode!==void 0&&!De(S.reasonCode)&&Y({check:"liveness",kind:"unavailable",phase:"upload",engineKind:S.reasonCode,attempt:Math.max(0,n.issues.value)}),ee(S),!!b())){if(S.status==="retry"&&i==="auto"){y.handle.retry();return}y.setFlowState("done")}};if(a.degraded==="NO_RECORDER"){let S=f?.sessionId??(await k().catch(()=>null))?.sessionId??"";_(E(S,"no_recorder"));return}V("uploading");try{if(await Pe(),h())return;let S=await k(),Ae;if(!R(S)&&D(S)!==null){await Se(!1),_(E(S.sessionId,"method_required"));return}if(!R(S)){if(L(S)?.checkType==="population_registry"){_(E(S.sessionId,Ce?"nni_unbound":ge?"network":"registry_unavailable"));return}if(await A(),h())return;Ae=f??S;let oe=await Ye({...z,artifacts:a,getAttestation:xe,getView:()=>f??S,refreshView:v,applySubmit:Q,onPhase:V,isCancelled:h,onKeyframePromoted:gt=>{x=gt}});if(h())return;if(oe.kind==="unavailable"){_(E(S.sessionId,oe.reason));return}if(oe.kind==="resync"&&await v(),f!==null&&D(f)!==null){await Se(!1),_(E(S.sessionId,"method_required"));return}S=await ut()}_(F(S,{autoRetry:r,previous:Ae}))}catch{if(h())return;_(E(f?.sessionId??"","network"))}},lt=(n,a)=>{let l=n.attempt;H>0&&n.alive&&n.capture.setFlowState("uploading"),H+=1,Oe=Oe.then(()=>dt(n,a,l)).finally(()=>{H-=1,H===0&&g?.onChainIdle()}).catch(()=>{})},ve=n=>{P?.capture.handle.destroy(),P!==null&&(P.alive=!1);let a=Ee(n,g?.captureInternals?.(n)??t.capture,()=>f?.capture?.liveness?.keyframe?.rank===!0,pe,()=>f?.capture?.liveness?.screenRamp,{session:()=>Z(f),onModeChange:h=>{K=h}}),l={capture:a,alive:!0,attempt:0,issues:Ne()};P=l,a.handle.on("error",h=>{Y(Le("liveness",h,l.issues.value))}),a.handle.on("state",h=>{if(l.issues.note(h),h==="starting"){l.attempt+=1,Re(f?.turnstileSiteKey??null);let b=f===null?void 0:L(f)?.checkType;(b==="liveness"||b==="face_match")&&A().catch(()=>{})}}),a.handle.on("captured",h=>{Promise.resolve().then(()=>lt(l,h))});let y=a.handle;return{get state(){return y.state},get captureMode(){return y.captureMode},get facingMode(){return y.facingMode},on:(h,b)=>y.on(h,b),start:async h=>{if(f===null&&await k().catch(()=>{}),!!l.alive)return y.start(h)},retry:()=>y.retry(),switchCamera:()=>y.switchCamera(),canSwitchCaptureMode:()=>y.canSwitchCaptureMode(),setCaptureMode:h=>y.setCaptureMode(h),destroy:()=>{l.alive=!1,P===l&&(P=null),y.destroy()}}},pt=async()=>{if(d)return null;try{let n=await k();return d?null:D(n)}catch{return null}},ft=async()=>{if(d)return"self";try{let n=await k();if(d)return"self";let a=Z(n);return a==="choice"?q()??a:a}catch{return"self"}},mt=async()=>{if(d)return!1;try{let n=await k();return d||R(n)||ie()?!1:B(n,L(n))==="phone"||B(n,I(n,"liveness"))==="phone"}catch{return!1}},ht=async()=>{if(d)return!1;try{let n=await k();return!d&&n.returning===!0}catch{return!1}},St=async n=>{let a=(await k()).plan?.choice,l=a?.options.find(h=>U[h.service]===n);if(!l)throw new RangeError(`method ${String(n)} is not offered`);let y=await s.choose(a.nodeId,l.id);d||O(y)},Ie=null,yt=()=>(Ie??(Ie=import("./plan-runner-LDV4PYN7.js").then(n=>{let a=n.createPlanRunner({runtime:z,currentView:()=>f,cameraMode:pe,captureModeSwitch:{pick:q,choose:l=>{K=l}},ensureView:k,refreshView:v,ensureConsent:()=>A(),liveness:ve,stopLiveness:()=>{P!==null&&(P.alive=!1,P.capture.handle.destroy(),P=null)},chainBusy:()=>H>0,destroyed:()=>d,sleep:u,isMobile:ie,now:t.now??Date.now,keptFaceKey:()=>x,setView:O,baseCapture:t.capture,emitStep:l=>{d||m.emit("step",l)},emitResult:st,reportCaptureIssue:Y,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto,uploadInternals:t.upload});return g=a,a})),Ie);return{consent:()=>A(),startRegistry:Pe,methodChoice:pt,selectMethod:St,reportCameraUnavailable:async n=>{await A();let a=s.reportCameraUnavailable;if(a===void 0)throw new TypeError("this client cannot report a missing camera");let l=await a.call(s,n).catch(y=>{if(y instanceof re&&y.code==="check_out_of_order")return s.getSession();throw y});d||O(l)},reportCaptureIssue:Y,testerGate:async n=>{let a=s.testerGate;if(a===void 0)throw new TypeError("this client cannot run the tester gate");let l=n.clip,y=Te(n.clipMime??"");if(l===void 0||!Ke.includes(y))throw new TypeError("the capture has no clip");await A();let h=await Ge(s,"clip",y,l.size,{engine:n.engine,durationMs:n.clipMs});await s.uploadToSpaces(h.uploadUrl,l,y);let{key:b}=await s.completeMedia(h.key),V=await a.call(s,{clipKey:b,attestation:await xe(),captureChannel:n.captureChannel,capture:We(n)}),{bound:_,...S}=V;return d||(S.plan!==void 0?O(S):await v()),{bound:_===!0}},mobileRequired:mt,captureMode:ft,chooseCaptureMode:n=>{K=n},get captureChoice(){return q()},returning:ht,liveness:ve,run:async()=>{if(d)throw new Error("verification destroyed");return(await yt()).run()},currentStep:()=>g?.current()??null,voiceClips:async()=>{if(d)return null;try{let n=await k();return d?null:n.voice??null}catch{return null}},on:(n,a)=>m.on(n,a),destroy:()=>{d=!0,C.abort(),g?.destroy(),P!==null&&(P.alive=!1,P.capture.handle.destroy(),P=null),m.clear()}}}var Ze=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var It=["carte_identite","passport","residence_permit"];function At(e,t){let o=e.byIssuer?.[t]??e.default;return It.filter(r=>o==="*"||o.includes(r))}function bn(e,t=Ze){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(r=>At(e,r).length>0).sort()}function $e(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function Rn(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var Je=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),Mt=new Map(Object.entries(Je)),On=new Map(Object.entries(Je).map(([e,t])=>[t,e]));function Qe(e){return Mt.get(e)??e}var Vn=["national_number","document_photo","national_eid"],wt=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation"]),Et=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),ce=["document","population_registry","national_eid"],ue=["phone_otp","email_otp"],et={identity_method:ce,contact:ue},Tt=["population_registry","document"],de="platform_unsupported",Vt=new Set(["prefilled","user_entered","prefilled_or_entered"]),Dt={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function M(e){return e.section??Dt[e.checkType]??null}function Lt(e,t){let o=e.plan?.choice;if(o===void 0||o.locked)return;let r=o.options.find(i=>i.id!==o.selected&&i.available!==!1&&t.includes(i.service));return r===void 0?void 0:{nodeId:o.nodeId,option:r}}function le(e){let t=e.plan,o=t?.choice;if(t===void 0||o===void 0||o.locked||t.current===null||t.current===o.nodeId||R(e))return null;let r=et[o.kind]??[...ce,...ue],i=o.options.flatMap(c=>c.available===!1||!r.includes(c.service)?[]:[c.nationalEid!=null?{id:c.id,service:c.service,nationalEid:c.nationalEid}:{id:c.id,service:c.service}]),s=t.steps.find(c=>c.id===t.current)?.service,u=o.selected??i.find(c=>c.service===s)?.id??null;return i.some(c=>c.id!==u)?{nodeId:o.nodeId,kind:o.kind,current:u,options:i}:null}function tt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Nt(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:o,skipCapture:r}=t;return typeof o=="string"&&o!==""&&typeof r=="boolean"?{otpCode:o,skipCapture:r}:void 0}function Ht(e){let t=(e.plan?.sections??[]).map(u=>({id:u.id,state:u.state})),o={sessionId:se(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(u=>u.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(o.branding=e.branding),e.cameraUnavailableHandled===!0&&(o.cameraUnavailableHandled=!0);let r=Nt(e);r!==void 0&&(o.simulation=r);let i=e.testerGate;i?.offered===!0&&typeof i.attemptsLeft=="number"&&i.attemptsLeft>0&&(o.testerGate={attemptsLeft:i.attemptsLeft});let s=le(e);return s!==null&&(o.switchable=s),o}function Ut(e){let t={attemptsRemaining:j(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var nt={phone_otp:"phone",email_otp:"email"};function Ft(e,t){let o=Lt(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return o===void 0?void 0:nt[o.option.service]}function Bt(e,t,o,r){let i=t.checkType==="email_otp",s=(i?t.emailOtp:t.otp)??{},u=i?t.emailOtp?.emailSource:t.otp?.numberSource,c=u!==void 0&&Vt.has(u)?u:i?"prefilled_or_entered":"user_entered",p=typeof s.sentToMasked=="string"&&s.sentToMasked.length>0,m=s.prefilled===!0,g=Ft(e,i?"email_otp":"phone_otp"),x={key:t.checkType,context:o,section:M(t),phase:p?"verify":"send",canSwitch:g!==void 0,...r},d=i?{kind:"email_otp",...x,emailSource:c,needsEmail:c!=="prefilled"&&!m}:{kind:"phone_otp",...x,numberSource:c,needsPhone:c!=="prefilled"&&!m,channels:(t.otp?.channels??[]).filter(C=>C==="whatsapp"||C==="sms")};if(g!==void 0&&(d.switchChannel=g),m&&(d.prefilled=!0),p&&(d.sentToMasked=s.sentToMasked),!i&&t.otp?.channel!==void 0&&(d.channel=t.otp.channel),!i&&Array.isArray(t.phoneCountries)&&(d.phoneCountries=t.phoneCountries.filter(C=>typeof C=="string"&&/^[A-Z]{2}$/.test(C))),!i&&Array.isArray(t.phoneRules)){let C=d.phoneCountries??[];d.phoneRules=t.phoneRules.flatMap(f=>{let w=qt(f);return w!==void 0&&C.includes(w.code)?[w]:[]})}return!i&&t.phoneInternational===!0&&(d.phoneInternational=!0),s.expiresAt!==void 0&&(d.codeExpiresAt=s.expiresAt),s.resendAvailableAt!==void 0&&(d.resendAvailableAt=s.resendAvailableAt),d}var Gt=/^[\d[\]\-|()?:^]{1,64}$/;function Kt(e){try{return typeof e=="string"&&Gt.test(e)&&new RegExp(e)!==null}catch{return!1}}var Xe=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function qt(e){let{code:t,dial:o,trunk:r,lengths:i,formats:s}=e??{};if(typeof t!="string"||typeof o!="string"||!/^\d{1,3}$/.test(o)||r!==void 0&&(typeof r!="string"||!/^\d{1,3}$/.test(r))||!Array.isArray(i)||i.length===0||!i.every(Xe))return;let u={code:t,dial:o,lengths:[...i].sort((c,p)=>c-p)};if(r!==void 0&&(u.trunk=r),s!==void 0){if(!(Array.isArray(s)&&s.length<=8&&s.every(p=>Kt(p?.leading)&&Array.isArray(p.groups)&&p.groups.every(Xe)&&i.includes(p.groups.reduce((m,g)=>m+g,0)))))return;u.formats=s.map(p=>({leading:p.leading,groups:[...p.groups]}))}return u}function Yt(e,t,o,r){let i=J(e)===!0?"bound":G(t)===!0?"document":"typed",s=i==="typed"&&t.state==="input_required"&&t.reason!==void 0&&Qe(t.reason)==="id_number_recheck",u=tt(le(e)),c=!r.attemptsExhausted&&u.length===1&&u[0]?.service==="document";return{kind:"registry",key:"registry",context:o,section:M(t),state:t.state==="input_required"?"input_required":"pending",source:i,recheck:s,canUseDocument:c,...r}}function Wt(e,t,o,r,i){let s=[...t.acceptedSides??[]],u={kind:"document",key:"document",context:o,section:M(t),side:s.includes("recto")?"verso":"recto",acceptedSides:s,documents:$e(e),photo:it(ot(e.documents),i),...r};return e.detectedCountry!==void 0&&(u.detectedCountry=e.detectedCountry),jt(e)&&(u.ageStepUp=!0),u}function ot(e,t=!0){let o=e?.source==="upload"||e?.source==="choice"?e.source:"camera",r=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:o,pick:r,uploadOffered:t&&e?.uploadOffered===!0}}function it(e,t){return t?{...e,cameraOnPhone:!0}:e}function jt(e){let t=W(e).find(r=>r.checkType==="age_estimation"),o=t?.reason;return t?.state==="failed"&&(o==="age_uncertain"||o==="age_unavailable")}function Zt(e){let t=I(e,"liveness");return t?.state==="passed"||t?.state==="review"}function ze(e,t,o,r,i,s=!1){let u=t.icao?.report,c=e.portrait,p=i==="capture"?c?.pendingFix??null:null;p!==null&&(i="review");let m=rt(e);return{kind:"portrait",key:`portrait:${i}`,context:o,section:M(t),phase:i,report:Array.isArray(u)?u:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:$(e),retakeOnly:i==="capture"&&t.state==="input_required"&&m===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Zt(e),photo:it(ot(c,i==="capture"),s&&i==="capture"),pendingFix:p,...m!==void 0?{captureMode:m}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...r}}function rt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ae={minLongSidePx:1280,jpegQuality:.95};function $t(e,t){let o=e.capture?.livePhoto;if(o?.oneCapture!==!0)return null;let r=I(e,"portrait_icao"),i=o.still??ae;return{icao:t==="liveness"&&$(e)!==null&&rt(e)===void 0&&r!==void 0&&r.state==="pending"&&r.reason===void 0,still:{minLongSidePx:i.minLongSidePx??ae.minLongSidePx,jpegQuality:i.jpegQuality??ae.jpegQuality}}}function Jt(e,t,o,r){let i=t.eid,s=M(t);if(i===void 0||i.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:o,section:s,checkType:"eid_auth",reason:"update_required"};let u=tt(le(e)),c=u.length===1&&Tt.includes(u[0]?.service??"")?u[0]:void 0,p=c===void 0?void 0:U[c.service],m=p!==void 0,g={kind:"eid",key:"eid",context:o,section:s,provider:i.provider,providerName:i.providerName,country:i.country,challenge:"app_code",phase:i.awaiting==="code"?"code":"identifier",identifierBound:i.identifierBound===!0,canUseCamera:m,afterPass:i.afterPass==="continue"?"continue":"end",...r};return m&&(g.cameraMethod=p),i.expiresAt!==void 0&&(g.codeExpiresAt=i.expiresAt),i.resendAvailableAt!==void 0&&(g.resendAvailableAt=i.resendAvailableAt),i.resendsRemaining!==void 0&&(g.resendsRemaining=i.resendsRemaining),i.codeAttemptsRemaining!==void 0&&(g.codeAttemptsRemaining=i.codeAttemptsRemaining),g}function Qt(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let o=I(e,"portrait_icao");return o!==void 0&&(o.state==="passed"||o.state==="review")?o:null}var Xt={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function zt(e){return e.reasonCode===de?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?Xt[e.reason]:void 0)??"rejected"}function en(e,t){let o=zt(e),r=o==="platform_unsupported"?{sessionId:se(e.sessionId),status:"unavailable",reasonCode:de}:F(e,{autoRetry:!1}),i={kind:"result",key:"result",context:t,section:null,display:o,result:r};return e.status==="not_verified"&&e.reason!==void 0&&(i.reason=e.reason),e.reasonCode!==void 0&&(i.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(i.step=e.step),e.retryAfter!==void 0&&(i.retryAfter=e.retryAfter),i}function tn(e,t,o){let r=e.identitySummary;if(r==null)return null;let i={kind:"identity_summary",key:"identity_summary",context:t,section:o??"identity",summaryKind:r.kind==="partial"?"partial":r.kind??"full",source:r.source,portraitAvailable:r.portrait?.available===!0,retakeAvailable:r.retakeAvailable===!0};for(let u of nn){let c=r[u];typeof c=="string"&&c!==""&&(i[u]=c)}let s=je(r);return s!==void 0&&(i.idNumberMasked=s,i.nniMasked=s),i}var nn=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function N(e,t,o,r){return{kind:"unsupported",key:`unsupported:${o}`,context:e,section:t,checkType:o,reason:r}}function on(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function rn(e,t){let o=et[e.kind]??[...ce,...ue],r=on(e),i=e.options.flatMap(u=>{if(u.available===!1||!o.includes(u.service))return[];let c={id:u.id,service:u.service};u.nationalEid!=null&&(c.nationalEid=u.nationalEid);let p=(u.channels??[]).filter(m=>m==="whatsapp"||m==="sms");return u.service==="phone_otp"&&p.length>0&&(c.channels=p),[c]});if(i.length===0){let u=e.options.length>0&&e.options.every(c=>c.service==="nfc");return N(t,r,"choice",u?"platform_unsupported":"update_required")}let s={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:i};if(e.kind==="identity_method"){let u={kind:"method",key:"method",context:t,section:r,options:i.map(p=>U[p.service]),choice:s},c=i.find(p=>p.nationalEid!==void 0)?.nationalEid;return c!==void 0&&(u.nationalEid=c),u}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:r,options:i.map(u=>nt[u.service]),selected:null,locked:!1,choice:s}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:r,choice:s}}function Dn(e,t={}){let o=Ht(e);if(R(e)||e.reasonCode===de)return en(e,o);let r=e.plan;if(r===void 0||!Array.isArray(r.sections))return N(o,null,"plan","update_required");let i=He(e);if(i!==null)return rn(i,o);let s=r.current===null?void 0:r.steps.find(d=>d.id===r.current),u=d=>{let C={kind:"processing",key:"processing",context:o,section:d!==void 0?M(d):r.sections.find(f=>f.state==="current")?.id??null,stalled:!1};return typeof d?.service=="string"&&d.service!==""&&(C.service=d.service),C};if(r.current===null)return u(r.steps.find(d=>d.state==="processing"));if(s===void 0)return N(o,null,"step","update_required");if(!wt.has(s.service))return s.interaction==="server"?u(s):N(o,M(s),s.service,"update_required");if(Et.has(s.service)||!Ue(s))return u(s);let c=s,p=Ut(c),m=c.checkType,g=M(c),x=t.isMobile===!1?B(e,c):null;if(x==="phone")return{kind:"mobile_required",key:"mobile_required",context:o,section:g,checkType:m};switch(m){case"phone_otp":case"email_otp":return Bt(e,c,o,p);case"population_registry":return Yt(e,c,o,p);case"eid_auth":return Jt(e,c,o,p);case"doc_ocr":return Wt(e,c,o,p,x==="upload_or_phone");case"identity_confirm":return tn(e,o,g)??u(c);case"portrait_icao":return ze(e,c,o,p,"capture",x==="upload_or_phone");case"liveness":case"face_match":{let d=Qt(e,c);if(d!==null)return ze(e,d,o,p,"match");let C=c.requiresMobile===!0,f=$(e);return{kind:"liveness",key:"biometric",context:o,section:g,mode:m==="face_match"?"selfie":"liveness",requiresMobile:C,instructions:f===null?"standard":"icao",icao:f,livePhoto:$t(e,m),...p}}case"nfc_chip":return N(o,g,m,"platform_unsupported");default:return N(o,g,m,"update_required")}}export{Ct as a,_t as b,bt as c,Rt as d,Ot as e,Cn as f,vt as g,Ze as h,It as i,At as j,bn as k,$e as l,Rn as m,Vn as n,de as o,M as p,le as q,tt as r,Qt as s,Dn as t};
|
package/dist/chunk-IC6TI6GV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as ke,D as x,E as j,d as K,e as he,f as Se,g as ge,i as ye,j as ee,l as q,m as te,o as be,p as Ce,t as Pe}from"./chunk-QY6TJCOJ.js";import{c as pe,d as me,e as fe}from"./chunk-FPXL63KZ.js";import{c as F,h as Q,i as _e}from"./chunk-XI5FXEKC.js";var Re=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var We=["carte_identite","passport","residence_permit"];function qe(e,t){let i=e.byIssuer?.[t]??e.default;return We.filter(a=>i==="*"||i.includes(a))}function Yt(e,t=Re){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(a=>qe(e,a).length>0).sort()}function Me(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}var Qe=640,$e=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),Ee=6,Ae=1500,Ie={sharpness:1,exposure:1,meanLuma:128},ve=null;function Je(e,t){try{ve??(ve=document.createElement("canvas"));let i=ve,a=96/Math.max(1,t.width);i.width=Math.max(1,Math.round(t.width*a)),i.height=Math.max(1,Math.round(t.height*a));let r=i.getContext("2d");if(r===null)return Ie;r.drawImage(e,t.x,t.y,t.width,t.height,0,0,i.width,i.height);let u=r.getImageData(0,0,i.width,i.height);return{sharpness:me(u),exposure:fe(u),meanLuma:pe(u)}}catch{return Ie}}async function ze(e,t){let i=e.source;return"convertToBlob"in i?i.convertToBlob({type:"image/jpeg",quality:t}):new Promise((a,r)=>{i.toBlob(u=>u===null?r(new Error("encode failed")):a(u),"image/jpeg",t)})}function $t(e,t={}){let i=t.now??(()=>performance.now()),a=t.setTimer??((m,C)=>setTimeout(m,C)),r=t.clearTimer??(m=>clearTimeout(m)),u=t.encode??ze,l=t.quality??Je,c=e.tuningVersion??null,p=new Set,S=!1,y=e.video??null,E=null,f=t.grabFrame??null,b=null,v=1e3/Ee,A=null,I=null,T=!1,N=!1,D=Number.NEGATIVE_INFINITY,M=null,G=0,L=null,B=null,J=Promise.all([import("./icao-gate-T3BTOKFJ.js"),import("./icao-tuning-4ETMF53W.js"),import("./create-portrait-capture-5VGYZUOK.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([m,C,R,w,O])=>{let _=C.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);_.background.required&&(I=O.createBackgroundMonitor({tuning:_.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:i})),E=m.createIcaoGate(_,{policy:e.policy??"reject"}),f??(f=R.defaultGrabber()),b=R.observe,v=1e3/Math.min(Ee,_.cadenceHz);let n=(t.createLandmarker??w.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),o=await new Promise((s,d)=>{let h=setTimeout(()=>{d(new Error("landmarker init timeout")),n.then(g=>g.close(),()=>{})},w.LANDMARKER_INIT_TIMEOUT_MS);n.then(g=>{clearTimeout(h),s(g)},g=>{clearTimeout(h),d(g)})});S?o.close():A=o}).catch(()=>{T=!0}),H=m=>{for(let C of p)C({holding:N||T,update:m})},Y=()=>{if(M=null,!(S||A===null||E===null||f===null||b===null||y===null)){if(i()-D>Ae){H(null);return}try{let m=f(y,Qe);if(m!==null){let C=Math.max(i(),G+1);G=C;let R=A.detect(m.source,C),w=y.videoWidth||m.width,O=y.videoHeight||m.height,_=b(R,m,w,O);_.geometry!==null&&I!==null&&(_.backgroundCheck=I.measure(m,_.geometry.box,w,O));let n=E.push(_,i());N=n.ready,H(n)}}catch{}M=a(Y,v)}},Z=()=>{let m=i()-D>Ae;D=i(),m&&(E?.reset(),N=!1,L=null,B=null),M===null&&A!==null&&!S&&(M=a(Y,0))},z=()=>{let m=f===null||y===null?null:f(y,null);if(m===null||E===null||Math.max(m.width,m.height)<e.still.minLongSidePx)return Promise.resolve(null);let C=E.summary();return u(m,e.still.jpegQuality).then(R=>({image:R,width:m.width,height:m.height,gate:C}),()=>null)},W=null;return{engineOptions:{measureQuality:(m,C)=>{y=m,Z();let R=l(m,C);return N||T?R:{...R,sharpness:0}},telemetry:m=>{if(m.type!=="fired"||S)return;L=z();let C=W;C!==null&&L.then(R=>R===null?void 0:C(R).catch(()=>{})),N=!1,M!==null&&r(M),M=null,D=Number.NEGATIVE_INFINITY}},decorate:m=>{let C=new WeakMap,R=new Map,w=o=>{let s=C.get(o);return s===void 0&&(s=(async()=>{let d=await Pe(m,"image","image/jpeg",o.image.size,{engine:"portrait"});return await m.uploadToSpaces(d.uploadUrl,o.image,"image/jpeg"),(await m.completeMedia(d.key)).key})(),s.catch(()=>C.delete(o)),C.set(o,s)),s};W=w;let O=async o=>{let s;try{s=await w(o)}catch(d){let h=d?.code;if(typeof h=="string"&&$e.has(h))throw d;return null}return{media:{portrait:s},gate:_e(o.gate),...c!==null?{tuningVersion:c}:{}}},_=m.submitCheck.bind(m),n=(async(o,s,d)=>{if(o!=="liveness")return _(o,s,d);let h=d?.idempotencyKey,g=h===void 0?void 0:R.get(h);if(g===void 0){let de=L;g=de===null?Promise.resolve(null):de.then(le=>le===null?null:O(le)),h!==void 0&&(R.set(h,g),g.catch(()=>R.delete(h)))}let P=await g;if(P===null)return _("liveness",s,d);let k=await _("liveness",{...s,portraitIcao:P},d);return B=P,k});return new Proxy(m,{get(o,s){if(s==="submitCheck")return n;let d=Reflect.get(o,s);return typeof d=="function"?d.bind(o):d}})},onGate:m=>(p.add(m),()=>p.delete(m)),lastPortraitInput:()=>B,destroy:()=>{S=!0,L=null,B=null,M!==null&&r(M),M=null,p.clear(),J.then(()=>{A?.close(),A=null,I?.close(),I=null})}}}function Te(e){return e.idNumberBound??e.nniBound}function Oe(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function we(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var xe=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),Xe=new Map(Object.entries(xe)),Xt=new Map(Object.entries(xe).map(([e,t])=>[t,e]));function Ne(e){return Xe.get(e)??e}var et=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation"]),tt=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),ie=["document","population_registry","national_eid"],oe=["phone_otp","email_otp"],De={identity_method:ie,contact:oe},nt=["population_registry","document"],re="platform_unsupported",it=new Set(["prefilled","user_entered","prefilled_or_entered"]),ot={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function V(e){return e.section??ot[e.checkType]??null}function se(e,t){let i=e.plan?.choice;if(i===void 0||i.locked)return;let a=i.options.find(r=>r.id!==i.selected&&r.available!==!1&&t.includes(r.service));return a===void 0?void 0:{nodeId:i.nodeId,option:a}}function ae(e){let t=e.plan,i=t?.choice;if(t===void 0||i===void 0||i.locked||t.current===null||t.current===i.nodeId||ee(e))return null;let a=De[i.kind]??[...ie,...oe],r=i.options.flatMap(c=>c.available===!1||!a.includes(c.service)?[]:[c.nationalEid!=null?{id:c.id,service:c.service,nationalEid:c.nationalEid}:{id:c.id,service:c.service}]),u=t.steps.find(c=>c.id===t.current)?.service,l=i.selected??r.find(c=>c.service===u)?.id??null;return r.some(c=>c.id!==l)?{nodeId:i.nodeId,kind:i.kind,current:l,options:r}:null}function He(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function rt(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:i,skipCapture:a}=t;return typeof i=="string"&&i!==""&&typeof a=="boolean"?{otpCode:i,skipCapture:a}:void 0}function st(e){let t=(e.plan?.sections??[]).map(l=>({id:l.id,state:l.state})),i={sessionId:te(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(l=>l.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(i.branding=e.branding),e.cameraUnavailableHandled===!0&&(i.cameraUnavailableHandled=!0);let a=rt(e);a!==void 0&&(i.simulation=a);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(i.testerGate={attemptsLeft:r.attemptsLeft});let u=ae(e);return u!==null&&(i.switchable=u),i}function at(e){let t={attemptsRemaining:Se(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Ge={phone_otp:"phone",email_otp:"email"};function ct(e,t){let i=se(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return i===void 0?void 0:Ge[i.option.service]}function ut(e,t,i,a){let r=t.checkType==="email_otp",u=(r?t.emailOtp:t.otp)??{},l=r?t.emailOtp?.emailSource:t.otp?.numberSource,c=l!==void 0&&it.has(l)?l:r?"prefilled_or_entered":"user_entered",p=typeof u.sentToMasked=="string"&&u.sentToMasked.length>0,S=u.prefilled===!0,y=ct(e,r?"email_otp":"phone_otp"),E={key:t.checkType,context:i,section:V(t),phase:p?"verify":"send",canSwitch:y!==void 0,...a},f=r?{kind:"email_otp",...E,emailSource:c,needsEmail:c!=="prefilled"&&!S}:{kind:"phone_otp",...E,numberSource:c,needsPhone:c!=="prefilled"&&!S,channels:(t.otp?.channels??[]).filter(b=>b==="whatsapp"||b==="sms")};if(y!==void 0&&(f.switchChannel=y),S&&(f.prefilled=!0),p&&(f.sentToMasked=u.sentToMasked),!r&&t.otp?.channel!==void 0&&(f.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(f.phoneCountries=t.phoneCountries.filter(b=>typeof b=="string"&&/^[A-Z]{2}$/.test(b))),!r&&Array.isArray(t.phoneRules)){let b=f.phoneCountries??[];f.phoneRules=t.phoneRules.flatMap(v=>{let A=pt(v);return A!==void 0&&b.includes(A.code)?[A]:[]})}return!r&&t.phoneInternational===!0&&(f.phoneInternational=!0),u.expiresAt!==void 0&&(f.codeExpiresAt=u.expiresAt),u.resendAvailableAt!==void 0&&(f.resendAvailableAt=u.resendAvailableAt),f}var dt=/^[\d[\]\-|()?:^]{1,64}$/;function lt(e){try{return typeof e=="string"&&dt.test(e)&&new RegExp(e)!==null}catch{return!1}}var Le=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function pt(e){let{code:t,dial:i,trunk:a,lengths:r,formats:u}=e??{};if(typeof t!="string"||typeof i!="string"||!/^\d{1,3}$/.test(i)||a!==void 0&&(typeof a!="string"||!/^\d{1,3}$/.test(a))||!Array.isArray(r)||r.length===0||!r.every(Le))return;let l={code:t,dial:i,lengths:[...r].sort((c,p)=>c-p)};if(a!==void 0&&(l.trunk=a),u!==void 0){if(!(Array.isArray(u)&&u.length<=8&&u.every(p=>lt(p?.leading)&&Array.isArray(p.groups)&&p.groups.every(Le)&&r.includes(p.groups.reduce((S,y)=>S+y,0)))))return;l.formats=u.map(p=>({leading:p.leading,groups:[...p.groups]}))}return l}function mt(e,t,i,a){let r=Te(e)===!0?"bound":Oe(t)===!0?"document":"typed",u=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&Ne(t.reason)==="id_number_recheck",l=He(ae(e)),c=!a.attemptsExhausted&&l.length===1&&l[0]?.service==="document";return{kind:"registry",key:"registry",context:i,section:V(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:u,canUseDocument:c,...a}}function ft(e,t,i,a,r){let u=[...t.acceptedSides??[]],l={kind:"document",key:"document",context:i,section:V(t),side:u.includes("recto")?"verso":"recto",acceptedSides:u,documents:Me(e),photo:Ue(Be(e.documents),r),...a};return e.detectedCountry!==void 0&&(l.detectedCountry=e.detectedCountry),ht(e)&&(l.ageStepUp=!0),l}function Be(e,t=!0){let i=e?.source==="upload"||e?.source==="choice"?e.source:"camera",a=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:i,pick:a,uploadOffered:t&&e?.uploadOffered===!0}}function Ue(e,t){return t?{...e,cameraOnPhone:!0}:e}function ht(e){let t=he(e).find(a=>a.checkType==="age_estimation"),i=t?.reason;return t?.state==="failed"&&(i==="age_uncertain"||i==="age_unavailable")}function St(e){let t=q(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Ve(e,t,i,a,r,u=!1){let l=t.icao?.report,c=e.portrait,p=r==="capture"?c?.pendingFix??null:null;p!==null&&(r="review");let S=Fe(e);return{kind:"portrait",key:`portrait:${r}`,context:i,section:V(t),phase:r,report:Array.isArray(l)?l:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:Q(e),retakeOnly:r==="capture"&&t.state==="input_required"&&S===void 0&&e.capture?.livePhoto?.oneCapture===!0&&St(e),photo:Ue(Be(c,r==="capture"),u&&r==="capture"),pendingFix:p,...S!==void 0?{captureMode:S}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...a}}function Fe(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ne={minLongSidePx:1280,jpegQuality:.95};function gt(e,t){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let a=q(e,"portrait_icao"),r=i.still??ne;return{icao:t==="liveness"&&Q(e)!==null&&Fe(e)===void 0&&a!==void 0&&a.state==="pending"&&a.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ne.minLongSidePx,jpegQuality:r.jpegQuality??ne.jpegQuality}}}function yt(e,t,i,a){let r=t.eid,u=V(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:i,section:u,checkType:"eid_auth",reason:"update_required"};let l=He(ae(e)),c=l.length===1&&nt.includes(l[0]?.service??"")?l[0]:void 0,p=c===void 0?void 0:K[c.service],S=p!==void 0,y={kind:"eid",key:"eid",context:i,section:u,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:S,afterPass:r.afterPass==="continue"?"continue":"end",...a};return S&&(y.cameraMethod=p),r.expiresAt!==void 0&&(y.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(y.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(y.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(y.codeAttemptsRemaining=r.codeAttemptsRemaining),y}function bt(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let i=q(e,"portrait_icao");return i!==void 0&&(i.state==="passed"||i.state==="review")?i:null}var Ct={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function Pt(e){return e.reasonCode===re?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?Ct[e.reason]:void 0)??"rejected"}function kt(e,t){let i=Pt(e),a=i==="platform_unsupported"?{sessionId:te(e.sessionId),status:"unavailable",reasonCode:re}:be(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:i,result:a};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function _t(e,t,i){let a=e.identitySummary;if(a==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:i??"identity",summaryKind:a.kind==="partial"?"partial":a.kind??"full",source:a.source,portraitAvailable:a.portrait?.available===!0,retakeAvailable:a.retakeAvailable===!0};for(let l of Rt){let c=a[l];typeof c=="string"&&c!==""&&(r[l]=c)}let u=we(a);return u!==void 0&&(r.idNumberMasked=u,r.nniMasked=u),r}var Rt=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function U(e,t,i,a){return{kind:"unsupported",key:`unsupported:${i}`,context:e,section:t,checkType:i,reason:a}}function Mt(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function Et(e,t){let i=De[e.kind]??[...ie,...oe],a=Mt(e),r=e.options.flatMap(l=>{if(l.available===!1||!i.includes(l.service))return[];let c={id:l.id,service:l.service};l.nationalEid!=null&&(c.nationalEid=l.nationalEid);let p=(l.channels??[]).filter(S=>S==="whatsapp"||S==="sms");return l.service==="phone_otp"&&p.length>0&&(c.channels=p),[c]});if(r.length===0){let l=e.options.length>0&&e.options.every(c=>c.service==="nfc");return U(t,a,"choice",l?"platform_unsupported":"update_required")}let u={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let l={kind:"method",key:"method",context:t,section:a,options:r.map(p=>K[p.service]),choice:u},c=r.find(p=>p.nationalEid!==void 0)?.nationalEid;return c!==void 0&&(l.nationalEid=c),l}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:a,options:r.map(l=>Ge[l.service]),selected:null,locked:!1,choice:u}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:a,choice:u}}function $(e,t={}){let i=st(e);if(ee(e)||e.reasonCode===re)return kt(e,i);let a=e.plan;if(a===void 0||!Array.isArray(a.sections))return U(i,null,"plan","update_required");let r=ge(e);if(r!==null)return Et(r,i);let u=a.current===null?void 0:a.steps.find(f=>f.id===a.current),l=f=>{let b={kind:"processing",key:"processing",context:i,section:f!==void 0?V(f):a.sections.find(v=>v.state==="current")?.id??null,stalled:!1};return typeof f?.service=="string"&&f.service!==""&&(b.service=f.service),b};if(a.current===null)return l(a.steps.find(f=>f.state==="processing"));if(u===void 0)return U(i,null,"step","update_required");if(!et.has(u.service))return u.interaction==="server"?l(u):U(i,V(u),u.service,"update_required");if(tt.has(u.service)||!ye(u))return l(u);let c=u,p=at(c),S=c.checkType,y=V(c),E=t.isMobile===!1?Ce(e,c):null;if(E==="phone")return{kind:"mobile_required",key:"mobile_required",context:i,section:y,checkType:S};switch(S){case"phone_otp":case"email_otp":return ut(e,c,i,p);case"population_registry":return mt(e,c,i,p);case"eid_auth":return yt(e,c,i,p);case"doc_ocr":return ft(e,c,i,p,E==="upload_or_phone");case"identity_confirm":return _t(e,i,y)??l(c);case"portrait_icao":return Ve(e,c,i,p,"capture",E==="upload_or_phone");case"liveness":case"face_match":{let f=bt(e,c);if(f!==null)return Ve(e,f,i,p,"match");let b=c.requiresMobile===!0,v=Q(e);return{kind:"liveness",key:"biometric",context:i,section:y,mode:S==="face_match"?"selfie":"liveness",requiresMobile:b,instructions:v===null?"standard":"icao",icao:v,livePhoto:gt(e,S),...p}}case"nfc_chip":return U(i,y,S,"platform_unsupported");default:return U(i,y,S,"update_required")}}var At=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,It=Object.freeze({normalize:e=>e.trim().toUpperCase().replace(/\s+/g," "),check:e=>At.test(e),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"});function vt(e){return typeof e=="string"&&/^\d{10}$/.test(e)&&Number(e)%97===1}var Tt=Object.freeze({normalize:e=>e.trim(),check:e=>vt(e),registrySources:Object.freeze(["MR.anrpts"]),describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}),Ot=Object.freeze({"MR:national_id":Tt});function ce(e,t){return Ot[`${e.toUpperCase()}:${t}`]??It}var wt=Object.freeze({MRT:"MR"});function Ke(e,t){let i=e.trim().toUpperCase();return ce(wt[i]??i,t)}function je(e){let t=Ke(e.issuingCountry,e.type);return t.check(t.normalize(e.number))}function Ye(e){return ce("MR","national_id").check(e)}function ue(e){let t="";for(let i of e){let a=i.codePointAt(0)??0;a>=1632&&a<=1641?t+=String(a-1632):a>=1776&&a<=1785?t+=String(a-1776):i!==" "&&i!=="-"&&i!==" "&&(t+=i)}return t}var xt=[1e3,2e3,4e3,8e3,15e3],Nt=3e4,Lt=/^\+[1-9]\d{6,14}$/,Vt=/^\d{6}$/,Dt=/^\d{6}$/,Ht=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ze=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","identity_confirm_locked","choice_locked","choice_option_unavailable","choice_not_found","step_not_on_path","check_not_active"]),Gt={simulatedCapture:!0},Bt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function yn(e){let t=!1,i=null,a="",r=!1,u=!1,l=!1,c={},p={},S=new Set,y=!1,E=!1,f=null,b="idle",v=new Map,A=new Map,I=(n,o,s)=>{let d=`${n}.${o}`,h=v.get(d);if(h!==void 0)return h;let g=A.get(n),P=(g===void 0?s():g.then(s)).finally(()=>{v.delete(d)});v.set(d,P);let k=P.then(()=>{},()=>{});return A.set(n,k),k.then(()=>{A.get(n)===k&&A.delete(n)}),P},T=async(n,o,s)=>{await e.ensureConsent();let d;try{d=await ke(e.runtime,o)}catch(g){if(g instanceof F&&Ze.has(g.code)){await e.refreshView();return}throw g}if(s?.(d),e.destroyed())return;let h=d;h.plan!==void 0&&e.setView!==void 0?e.setView(h):await e.refreshView()},N=async n=>{await e.ensureConsent();let o;try{try{o=await n(e.runtime.client)}catch(s){if(!(s instanceof F)||s.code!=="consent_required")throw s;await e.runtime.ensureConsent({force:!0}),o=await n(e.runtime.client)}}catch(s){if(s instanceof F&&Ze.has(s.code)){await e.refreshView();return}throw s}e.destroyed()||(o!==void 0&&e.setView!==void 0?e.setView(o):await e.refreshView())},D=(n,o)=>I("choice",`${n}:${o}`,()=>N(s=>s.choose(n,o))),M=(n,o)=>n.options.some(s=>s.id===o)?D(n.nodeId,o):Promise.reject(new RangeError(`option ${String(o)} is not offered`)),G=(n,o)=>{let s=e.currentView(),d=s===null?void 0:se(s,n);return d===void 0?Promise.reject(new RangeError(`the ${o} is not offered`)):D(d.nodeId,d.option.id)},L=n=>I("identity",n,()=>N(o=>o.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):o.confirmIdentity(n))),B=(n,o)=>{let s=n.kind,d=s==="phone_otp",h=d?"phone":"email",g={action:"send"};if(d?n.needsPhone:n.needsEmail){let P=o[h]??p[s],k=d?P?.replace(/[\s().-]/g,""):P?.trim();if(k!==void 0||n.phase!=="verify"){if(k===void 0||!(d?Lt:Ht).test(k))return Promise.reject(d?new x("phone","format"):new j("email","format"));g[h]=k}}if(d){let P=n.channels,k=o.channel??(P.length===1?P[0]:void 0);if(P.length>0){if(k===void 0)return Promise.reject(new j("channel","required"));if(!P.includes(k))return Promise.reject(new j("channel","unavailable"))}k!==void 0&&(g.channel=k),g.phoneRules=1}return I(s,"send",()=>T(s,(P,k)=>P.submitCheck(s,g,{idempotencyKey:k}),P=>{Ft(P,s)||(c[s]=e.now(),g[h]!==void 0&&(p[s]=g[h]))}))},J=(n,o)=>Vt.test(o)?I(n,"verify",()=>T(n,(s,d)=>s.submitCheck(n,{action:"verify",code:o},{idempotencyKey:d}))):Promise.reject(new x("code","format")),H=(n,o)=>I("eid_auth",n,()=>T("eid_auth",(s,d)=>s.submitCheck("eid_auth",o,{idempotencyKey:d}))),Y=(n,o)=>{if(n.identifierBound)return H("start",{action:"start"});let s=ue(o??"");if(n.country==="MR"){if(!/^\d{10}$/.test(s))return Promise.reject(new x("nni","format"));if(!Ye(s))return Promise.reject(new x("nni","check_digit"))}else if(s==="")return Promise.reject(new x("nni","format"));return H("start",{action:"start",identifier:s})},Z=(n,o,s)=>{if(n.source!=="typed")return Promise.reject(new RangeError("this session already holds the ID number"));let d=ue(o);return/^\d{10}$/.test(d)?je({type:"national_id",issuingCountry:"MR",number:d})?I("population_registry","submitIdNumber",()=>T("population_registry",(h,g)=>h.submitCheck("population_registry",{idNumber:d,nni:d},{idempotencyKey:g}),()=>{f=`\u2022\u2022\u2022\u2022\u2022\u2022${d.slice(-4)}`})):Promise.reject(new x(s,"check_digit")):Promise.reject(new x(s,"format"))},z=n=>(e.stopCameras?.(),I(n,"skipCapture",()=>T(n,(o,s)=>o.submitCheck(n,Gt,{idempotencyKey:s}),()=>{(n==="liveness"||n==="portrait_icao")&&(y=!0)}))),W=n=>{if(n.kind==="result"||n.context.simulation?.skipCapture!==!0)return n;let o=Ut(n);return o===null?n:{...n,skipCapture:()=>z(o)}},X=n=>((n.kind==="document"||n.kind==="portrait")&&n.photo?.cameraOnPhone===!0&&(n.refresh=async()=>{await e.refreshView()}),n),m=n=>{switch(n.kind){case"phone_otp":case"email_otp":{let o={...n,send:(d={})=>B(n,d),verify:d=>J(n.kind,d),switchTo:()=>n.canSwitch&&n.switchChannel!==void 0?G([n.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},s=c[n.kind];return o.resendAvailableAt===void 0&&s!==void 0&&(o.resendAvailableAt=new Date(s+Nt).toISOString()),o}case"eid":return{...n,start:o=>Y(n,o),verify:o=>Dt.test(o)?H("verify",{action:"verify",code:o}):Promise.reject(new x("code","format")),resend:()=>n.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):H("resend",{action:"resend"}),useCamera:()=>n.canUseCamera&&n.cameraMethod!==void 0?G(n.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...n,select:o=>{let s=n.choice.options.find(d=>K[d.service]===o);return s!==void 0?M(n.choice,s.id):Promise.reject(new RangeError(`method ${String(o)} is not offered`))},choose:o=>M(n.choice,o)};case"choice":return{...n,choose:o=>M(n.choice,o)};case"registry":return{...n,submitIdNumber:o=>Z(n,o,"idNumber"),submitNni:o=>Z(n,o,"nni"),confirm:()=>I("population_registry","confirm",()=>T("population_registry",(o,s)=>o.submitCheck("population_registry",{},{idempotencyKey:s}))),useDocument:()=>n.canUseDocument?G(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?X(e.bindDocument(n,_)):{...n,issuer:null,documentType:null,captureSide:null,selectDocument:()=>{throw new Error("document capture is not available in this build")},capture:()=>{throw new Error("document capture is not available in this build")},uploadDocument:()=>Promise.reject(new Error("document upload is not available in this build"))};case"portrait":return e.bindPortrait!==void 0?X(e.bindPortrait(n,_)):{...n,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")},uploadPortrait:()=>Promise.reject(new Error("portrait upload is not available in this build")),confirmFix:()=>Promise.reject(new Error("portrait review is not available in this build"))};case"contact_choice":return{...n,select:o=>{let s=o==="phone"?"phone_otp":o==="email"?"email_otp":void 0,d=n.choice.options.find(h=>h.service===s);return d!==void 0?M(n.choice,d.id):Promise.reject(new RangeError(`contact ${String(o)} is not offered`))},choose:o=>M(n.choice,o)};case"identity_summary":return{...n,...n.idNumberMasked===void 0&&n.summaryKind==="partial"&&f!==null?{idNumberMasked:f,nniMasked:f}:{},portrait:async()=>{let o=e.runtime.client;if(!n.portraitAvailable||o.identityPortrait===void 0)return null;try{return await o.identityPortrait()}catch{return null}},confirm:()=>L("confirm"),retake:()=>n.retakeAvailable?L("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...n,capture:o=>e.liveness(o),onLivePhoto:o=>n.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(o):()=>{}};case"mobile_required":case"processing":return{...n,refresh:async()=>{r=!1,await e.refreshView()}};case"unsupported":case"result":return{...n};default:{let o=n;throw new Error(`runner: unhandled step ${JSON.stringify(o)}`)}}},C=n=>W(m(n)),R=async()=>{if(!u){u=!0;try{for(let n of xt){if(await e.sleep(n),!t||e.destroyed())return;let o=await e.refreshView().catch(()=>null);if(o!==null&&$(o,{isMobile:e.isMobile()}).kind!=="processing")return}r=!0,_()}finally{u=!1}}},w=n=>{if(n.kind!=="liveness"||n.mode!=="selfie")return null;let o={kind:"processing",key:"processing",context:n.context,section:n.section,stalled:!1};if(b==="inflight")return o;if(!E||b==="done")return null;let s=e.keptFaceKey?.()??null;return s===null?null:(b="inflight",T("face_match",(d,h)=>d.submitCheck("face_match",{imageKey:s},{idempotencyKey:h}),()=>{b="done"}).then(()=>{b==="inflight"&&(b="done",_())},()=>{b="done",_()}),o)},O=(n,o=!1)=>{if(!t||e.destroyed()||e.chainBusy())return;let s=$(n,{isMobile:e.isMobile()});s.kind==="registry"&&s.recheck&&(E=!0,b="idle"),s=w(s)??s,s.kind==="processing"?s.stalled=r:r=!1;let d=C(s),h=s.kind==="result"?void 0:s.context.switchable,g=h===void 0?d:{...d,chooseOption:k=>M({nodeId:h.nodeId,kind:h.kind,selected:h.current,options:h.options},k)},P=JSON.stringify(g);s.kind==="registry"&&s.source==="document"&&s.state==="pending"&&!S.has("registry")&&(S.add("registry"),g.confirm().catch(k=>{(!(k instanceof F)||Bt.has(k.code))&&S.delete("registry")})),!(!o&&P===a)&&(a=P,i=g,e.emitStep(g),s.kind==="processing"&&!r&&b!=="inflight"&&R(),s.kind==="result"&&!l&&(l=!0,e.emitResult(s.result)))};function _(){let n=e.currentView();n!==null&&O(n,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");t=!0;let n=await e.ensureView();return i===null&&O(n),i??C($(n,{isMobile:e.isMobile()}))},current:()=>i,onView:n=>O(n),onChainIdle:()=>{let n=e.currentView();n!==null&&O(n)},republish:_,submit:T,faceProbeSkipped:()=>y}}function Ut(e){switch(e.kind){case"document":return"doc_ocr";case"liveness":return e.mode==="selfie"?"face_match":"liveness";case"portrait":return e.phase==="capture"?"portrait_icao":null;case"mobile_required":return e.checkType;case"unsupported":return e.checkType==="nfc_chip"?"nfc_chip":null;default:return null}}function Ft(e,t){let i=e,a=i?.plan?.steps??i?.steps;return Array.isArray(a)?a.some(r=>r.checkType===t&&typeof r.reason=="string"):!1}export{qe as a,Yt as b,Ee as c,Ae as d,$t as e,Fe as f,$ as g,xt as h,Nt as i,yn as j};
|