@sekyro/web 0.1.0-rc.10 → 0.1.0-rc.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{capture-session-doc-GK6G7JOI.js → capture-session-doc-KW5VR4IR.js} +1 -1
  3. package/dist/{capture-session-v3-DGG2stO6.d.ts → capture-session-v3-DqUUcIU-.d.ts} +34 -3
  4. package/dist/{capture-session-v3-CmJw_bK0.d.cts → capture-session-v3-xNtY5m-7.d.cts} +34 -3
  5. package/dist/{chunk-BAGSM67V.js → chunk-4IVRXJR2.js} +1 -1
  6. package/dist/chunk-6DPFJNGL.js +1 -0
  7. package/dist/{chunk-SEC64KZ3.js → chunk-73M7LS4H.js} +1 -1
  8. package/dist/chunk-EF52BRBD.js +1 -0
  9. package/dist/chunk-GT2ZLGF7.js +1 -0
  10. package/dist/chunk-IF6YOFFO.js +1 -0
  11. package/dist/chunk-MUVEJRGK.js +1 -0
  12. package/dist/{chunk-UGMHAFEY.js → chunk-OBLQOE66.js} +1 -1
  13. package/dist/chunk-U6TYL2IJ.js +1 -0
  14. package/dist/{chunk-FFDB6LQN.js → chunk-U6YQAQBD.js} +1 -1
  15. package/dist/chunk-Y7S7LYCL.js +1 -0
  16. package/dist/chunk-YZH5PR5R.js +1 -0
  17. package/dist/client/index.cjs +1 -1
  18. package/dist/client/index.d.cts +5 -3
  19. package/dist/client/index.d.ts +5 -3
  20. package/dist/client/index.js +1 -1
  21. package/dist/core/index.cjs +1 -1
  22. package/dist/core/index.d.cts +3 -2
  23. package/dist/core/index.d.ts +3 -2
  24. package/dist/core/index.js +1 -1
  25. package/dist/{create-document-capture-IGUQP2NS.js → create-document-capture-PXOJHLWV.js} +1 -1
  26. package/dist/{create-portrait-capture-RJSFY37D.js → create-portrait-capture-C462EIB6.js} +1 -1
  27. package/dist/{create-verification-Bb20j6zk.d.ts → create-verification-CDOTGHQj.d.ts} +87 -9
  28. package/dist/{create-verification-CtqF4A9W.d.cts → create-verification-D4749F6L.d.cts} +87 -9
  29. package/dist/icao-gate-BRuIgOE2.d.cts +503 -0
  30. package/dist/icao-gate-CphntEQ2.d.ts +503 -0
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.cts +16 -5
  33. package/dist/index.d.ts +16 -5
  34. package/dist/index.js +1 -1
  35. package/dist/internal/index.cjs +1 -1
  36. package/dist/internal/index.d.cts +17 -8
  37. package/dist/internal/index.d.ts +17 -8
  38. package/dist/internal/index.js +1 -1
  39. package/dist/{plan-runner-QCK2SOGS.js → plan-runner-2FJLUALJ.js} +1 -1
  40. package/dist/popup/index.cjs +1 -1
  41. package/dist/popup/index.d.cts +7 -1
  42. package/dist/popup/index.d.ts +7 -1
  43. package/dist/popup/index.js +1 -1
  44. package/dist/{icao-gate-terzKYD7.d.cts → types-4rgeNIlz.d.cts} +179 -498
  45. package/dist/{icao-gate-terzKYD7.d.ts → types-4rgeNIlz.d.ts} +179 -498
  46. package/package.json +1 -1
  47. package/sbom.cdx.json +7 -7
  48. package/dist/chunk-3MSUJYBO.js +0 -1
  49. package/dist/chunk-ETY6SAAZ.js +0 -1
  50. package/dist/chunk-HAO6EQTH.js +0 -1
  51. package/dist/chunk-HWAXEQD5.js +0 -1
  52. package/dist/chunk-SXZCL5NO.js +0 -1
  53. package/dist/chunk-SZ7YGNUZ.js +0 -1
  54. package/dist/chunk-WKJJEPWA.js +0 -1
  55. package/dist/chunk-XR64UFLK.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @sekyro/web
2
2
 
3
+ ## 0.1.0-rc.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 22acfcf: Adds the Age check (selfie) processing step and renders any future server step as processing. Deploy this version before turning on the age check for your organization. The processing snapshot names the running step (`service`), plan steps carry `interaction` (`person` or `server`) on newer servers, `AgeEstimationReason` lists the step's reasons (`age_uncertain`, `age_unavailable`, `underage_estimated`), `underage_estimated` joins the policy reasons, and a sandbox liveness submit accepts `forceOutcome` `age_over`, `age_uncertain`, `age_under` and `age_unavailable`.
8
+
9
+ ## 0.1.0-rc.11
10
+
11
+ ### Minor Changes
12
+
13
+ - a3247a3: Screen ramp and capture provenance (liveness v7). When the session's capture tuning carries `capture.liveness.screenRamp` (a server-issued challenge: three pastel colours and their onsets), `@sekyro/web` paints them through the new `ramp` event of the liveness capture handle while the clip records, stamps each change on the clip's own timeline (the recorder's start, corrected by the video element's frame clock when the browser reports one) and sends what it rendered as `input.capture.screenRamp: {nonce, rendered: [{tMs, colour}]}`. `@sekyro/react` paints the layer in both stages (the face camera of `SekyroVerification` and the 0.1 stage) and hands it to a custom stage renderer as `ramp` on the stage view; a host on `@sekyro/web` alone subscribes to `ramp` and paints a fixed full-viewport element with `screenRampColourValue(colour)`, or leaves the event unbound (then no ramp is reported). Hosts that want ramp verification bind the `ramp` event: `provenance.rampPainter` tells the backend whether a painter was bound, so an unbound host is a client without the ramp rather than one missing it. No ramp in an assisted capture or without a challenge. Every liveness submit now also carries `input.capture.provenance` (the video track's settings with the device id hashed, whether `getCapabilities` exists, the camera label's class against a small list of virtual-camera products, `requestVideoFrameCallback` statistics over the recording, and whether the capture prototypes are still native code): signals only, no media, no raw identifiers. New types: `ScreenRampChallenge`, `ScreenRampColour`, `ScreenRampReport`, `CaptureProvenance`, `HostedLivenessCaptureTuning`. The native SDKs decode the challenge in this release and render it in the following one.
14
+
15
+ ### Patch Changes
16
+
17
+ - 032585b: Liveness retakes: `VerificationResult.retakeHint` and `StepAttempts.retakeHint` (`appearance | motion | lighting | framing`) carry the backend's retake hint; `@sekyro/react` shows the matching `hints.*` copy in place of the reason's generic text. A parked step whose attempts did not grow (a voided capture) is always a `retry`, and `capture_back_camera` / `capture_not_upright` are retryable.
18
+ - f13b832: Adds the `sekyro_app_not_allowed` error code (400, not retryable): the native SDKs receive it when a verification runs in the Sekyro AI app on an application that does not allow it, with `details.continueUrl` to continue in the browser when the request carries a session token. The web SDK does not change its behaviour.
19
+ - 90dde69: Adds the `sekyro_app_unverified` error code (400, not retryable, `details.continueUrl`): the native SDKs receive it when the Sekyro AI app cannot prove itself on an application that has not registered that native platform, and offer to continue in the browser. The web SDK does not change its behaviour.
20
+
3
21
  ## 0.1.0-rc.10
4
22
 
5
23
  ### Minor Changes
@@ -1 +1 @@
1
- import{C as a,D as b,E as c,F as d,G as e,H as f,I as g,J as h}from"./chunk-UGMHAFEY.js";import"./chunk-SMKCBUJL.js";import"./chunk-MXWLCDFX.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-POIQGEZM.js";import"./chunk-FHJ7HO3M.js";import"./chunk-FPXL63KZ.js";import"./chunk-BAGSM67V.js";import"./chunk-DK5YPBDQ.js";export{h as CAPTURE_CANDIDATE_SPACING_MS,g as CAPTURE_EXTRA_CANDIDATES,e as CaptureSessionDoc,b as DOC_CADENCE_HZ,c as DOC_SHUTTER_DEFAULTS,f as passportBandOf,d as resolveDocShutterTuning,a as warmDocDetector};
1
+ import{C as a,D as b,E as c,F as d,G as e,H as f,I as g,J as h}from"./chunk-OBLQOE66.js";import"./chunk-SMKCBUJL.js";import"./chunk-MXWLCDFX.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-POIQGEZM.js";import"./chunk-FHJ7HO3M.js";import"./chunk-FPXL63KZ.js";import"./chunk-4IVRXJR2.js";import"./chunk-DK5YPBDQ.js";export{h as CAPTURE_CANDIDATE_SPACING_MS,g as CAPTURE_EXTRA_CANDIDATES,e as CaptureSessionDoc,b as DOC_CADENCE_HZ,c as DOC_SHUTTER_DEFAULTS,f as passportBandOf,d as resolveDocShutterTuning,a as warmDocDetector};
@@ -1,3 +1,4 @@
1
+ import { am as ScreenRampReport, j as CaptureProvenance, ak as ScreenRampChallenge, S as ScreenRampColour } from './types-4rgeNIlz.js';
1
2
  import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-DclNxkZT.js';
2
3
 
3
4
  /** MP4-first ladder: one container (H.264 MP4) covers iOS/macOS Safari + Chrome 130+.
@@ -67,8 +68,14 @@ declare class ClipRecorder {
67
68
  * instead of waiting for the blob. PURE NOTIFICATION — it does not touch
68
69
  * timers, chunks, or the finalize path, so it is calibration-neutral (no
69
70
  * effect on clip bytes). Never fires on a rejected capture (error /
70
- * cliptoolarge settle before the hard-stop and clear the timer). */
71
- record(stream: MediaStream, onStopped?: () => void): Promise<ClipResult>;
71
+ * cliptoolarge settle before the hard-stop and clear the timer).
72
+ *
73
+ * `onStarted` (optional, liveness v7 §4.4) fires ONCE on the recorder's
74
+ * `start` event: the zero of the clip's own timeline, which the screen ramp
75
+ * stamps its colour changes against. PURE NOTIFICATION as well (the
76
+ * `onstart` handler was unset before; nothing else changes), so it is
77
+ * calibration-neutral. Never fires when construction or `start()` failed. */
78
+ record(stream: MediaStream, onStopped?: () => void, onStarted?: () => void): Promise<ClipResult>;
72
79
  /** Idempotent teardown: stop recorder + ALL tracks (v1 `stopAndCleanup` + the unmount
73
80
  * effect). Optional `stream` override mirrors v1's `stopAndCleanup(stream?)`.
74
81
  *
@@ -134,6 +141,10 @@ interface CaptureArtifacts {
134
141
  previewDataUrl: string;
135
142
  /** Capture-phase timing of the attempt that produced these artifacts. */
136
143
  timing?: CaptureTiming;
144
+ /** Liveness v7 §4.4: the screen ramp rendered against the session's issued challenge (clip mode, a challenge issued, a host painting). */
145
+ screenRamp?: ScreenRampReport;
146
+ /** Liveness v7 §4.5 item 2: how the capture was made (whenever the engine had a camera track). */
147
+ provenance?: CaptureProvenance;
137
148
  }
138
149
  interface CaptureSessionEvents {
139
150
  statechange: {
@@ -350,6 +361,9 @@ declare const UPRIGHT_WATCH_MS = 200;
350
361
  /** Best-of-N keyframe window: up to 4 candidates over the first 600ms. */
351
362
  declare const KEYFRAME_CANDIDATES = 4;
352
363
  declare const KEYFRAME_WINDOW_MS = 600;
364
+ /** Liveness v7 §4.5 item 2: the longest the capture waits on the track description (its WebCrypto hash) once the
365
+ * clip is done; past it the artifacts ship without `provenance`. */
366
+ declare const PROVENANCE_WAIT_MS = 1000;
353
367
  interface V3ChecksPayload {
354
368
  engine: "v3";
355
369
  /** Gate integrator 0..1 — the ring drives off this directly. */
@@ -383,6 +397,12 @@ interface CaptureSessionV3Events {
383
397
  frozen: {
384
398
  previewDataUrl: string;
385
399
  };
400
+ /** Liveness v7 §4.4: paint the full-viewport screen-ramp layer this colour (`null` clears it). Clip mode, a
401
+ * challenge issued by `screenRamp()`; at most four events per recording. CHROME-only: the host paints, the
402
+ * engine stamps the clip timeline. */
403
+ ramp: {
404
+ colour: ScreenRampColour | null;
405
+ };
386
406
  }
387
407
  type V3TelemetryEvent = {
388
408
  type: "detector";
@@ -491,6 +511,11 @@ interface CaptureSessionV3Options {
491
511
  * starts (prefetches the lazy ranker) and again when the capture fires.
492
512
  * Off → today's sharpest-of-N, byte for byte. */
493
513
  rankKeyframes?: () => boolean;
514
+ /** Screen-ramp challenge (liveness v7 §4.4; server tuning `capture.liveness.screenRamp`): read once when the
515
+ * clip recording starts. A challenge → the engine emits `ramp` at each issued onset on the clip timeline and
516
+ * reports what it rendered in `artifacts.screenRamp`; `undefined` (older backends, assisted sessions, no host
517
+ * painting) → no ramp, no field. Photo mode never ramps. */
518
+ screenRamp?: () => ScreenRampChallenge | undefined;
494
519
  /** INERT (Phase 3 escalation seam — see EscalationHook). Accepted and
495
520
  * retained, never called in Phases 1–2. */
496
521
  escalation?: EscalationHook;
@@ -532,6 +557,10 @@ declare class CaptureSessionV3 {
532
557
  private lastGateSnapshotAt;
533
558
  /** The upright guard applies to this attempt (a phone). */
534
559
  private uprightGuard;
560
+ /** Liveness v7 §4.5 item 2: the attempt's video track described right after getUserMedia (null: no track). */
561
+ private trackProvenance;
562
+ /** The ramp of the clip being recorded (stopped with the recording, the attempt or the session). */
563
+ private ramp;
535
564
  constructor(options: CaptureSessionV3Options);
536
565
  get state(): CaptureState;
537
566
  on<K extends keyof CaptureSessionV3Events>(event: K, handler: Handler<K>): () => void;
@@ -550,6 +579,8 @@ declare class CaptureSessionV3 {
550
579
  private startScheduler;
551
580
  private detectTick;
552
581
  private fire;
582
+ /** `{ provenance }` from the live track's description, the recording's frame statistics and the painter flag; `{}` without a track. */
583
+ private provenance;
553
584
  /** A phone showing a landscape frame: the guard holds the gate. */
554
585
  private isLandscape;
555
586
  /** Positioning on a sideways phone: no detection, the gate restarts from zero and the coaching says why. */
@@ -582,4 +613,4 @@ declare class CaptureSessionV3 {
582
613
  private now;
583
614
  }
584
615
 
585
- export { isMediaRecorderSupported as $, MIME_CANDIDATES as A, type V3GateFactor as B, type CameraErrorKind as C, DEFAULT_CLIP_MIME as D, type EscalationClipArtifact as E, FaceGateV3 as F, GATE_SNAPSHOT_MS as G, HOLD_UPRIGHT_KEY as H, type V3GateQuality as I, type V3GateThresholds as J, KEYFRAME_CANDIDATES as K, type V3GateTick as L, MAX_CLIP_BYTES as M, type V3GateTickInput as N, type V3TelemetryEvent as O, V3_GATE_DEFAULTS as P, VIDEO_BPS as Q, blockReasonOf as R, STOP_GRACE_MS as S, TIMESLICE_MS as T, UPRIGHT_WATCH_MS as U, type V3ChecksPayload as V, buildLivenessV2FormData as W, cameraPreflight as X, classifyDevice as Y, extForMime as Z, isClipTooLarge as _, CLIP_MS as a, mapGetUserMediaError as a0, pickMimeType as a1, probeDevice as a2, type CaptureArtifacts as b, type CaptureErrorKind as c, type CaptureSessionEvents as d, CaptureSessionV3 as e, type CaptureSessionV3Events as f, type CaptureSessionV3Options as g, type CaptureSessionV3StartOptions as h, type CaptureState as i, type CaptureTiming as j, ClipError as k, type ClipErrorKind as l, ClipRecorder as m, type ClipResult as n, DEVICE_PROFILES as o, type DeviceClass as p, type DeviceProbe as q, type DeviceProfile as r, DeviceProfiler as s, type EscalationHook as t, type GateBlockEntry as u, type GateBlockReason as v, GateBlockStats as w, type GateBlockSummary as x, type GateChecks as y, KEYFRAME_WINDOW_MS as z };
616
+ export { isClipTooLarge as $, MIME_CANDIDATES as A, type V3GateFactor as B, type CameraErrorKind as C, DEFAULT_CLIP_MIME as D, type EscalationClipArtifact as E, FaceGateV3 as F, GATE_SNAPSHOT_MS as G, HOLD_UPRIGHT_KEY as H, type V3GateQuality as I, type V3GateThresholds as J, KEYFRAME_CANDIDATES as K, type V3GateTick as L, MAX_CLIP_BYTES as M, type V3GateTickInput as N, type V3TelemetryEvent as O, PROVENANCE_WAIT_MS as P, V3_GATE_DEFAULTS as Q, VIDEO_BPS as R, STOP_GRACE_MS as S, TIMESLICE_MS as T, UPRIGHT_WATCH_MS as U, type V3ChecksPayload as V, blockReasonOf as W, buildLivenessV2FormData as X, cameraPreflight as Y, classifyDevice as Z, extForMime as _, CLIP_MS as a, isMediaRecorderSupported as a0, mapGetUserMediaError as a1, pickMimeType as a2, probeDevice as a3, type CaptureArtifacts as b, type CaptureErrorKind as c, type CaptureSessionEvents as d, CaptureSessionV3 as e, type CaptureSessionV3Events as f, type CaptureSessionV3Options as g, type CaptureSessionV3StartOptions as h, type CaptureState as i, type CaptureTiming as j, ClipError as k, type ClipErrorKind as l, ClipRecorder as m, type ClipResult as n, DEVICE_PROFILES as o, type DeviceClass as p, type DeviceProbe as q, type DeviceProfile as r, DeviceProfiler as s, type EscalationHook as t, type GateBlockEntry as u, type GateBlockReason as v, GateBlockStats as w, type GateBlockSummary as x, type GateChecks as y, KEYFRAME_WINDOW_MS as z };
@@ -1,3 +1,4 @@
1
+ import { am as ScreenRampReport, j as CaptureProvenance, ak as ScreenRampChallenge, S as ScreenRampColour } from './types-4rgeNIlz.cjs';
1
2
  import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-DclNxkZT.cjs';
2
3
 
3
4
  /** MP4-first ladder: one container (H.264 MP4) covers iOS/macOS Safari + Chrome 130+.
@@ -67,8 +68,14 @@ declare class ClipRecorder {
67
68
  * instead of waiting for the blob. PURE NOTIFICATION — it does not touch
68
69
  * timers, chunks, or the finalize path, so it is calibration-neutral (no
69
70
  * effect on clip bytes). Never fires on a rejected capture (error /
70
- * cliptoolarge settle before the hard-stop and clear the timer). */
71
- record(stream: MediaStream, onStopped?: () => void): Promise<ClipResult>;
71
+ * cliptoolarge settle before the hard-stop and clear the timer).
72
+ *
73
+ * `onStarted` (optional, liveness v7 §4.4) fires ONCE on the recorder's
74
+ * `start` event: the zero of the clip's own timeline, which the screen ramp
75
+ * stamps its colour changes against. PURE NOTIFICATION as well (the
76
+ * `onstart` handler was unset before; nothing else changes), so it is
77
+ * calibration-neutral. Never fires when construction or `start()` failed. */
78
+ record(stream: MediaStream, onStopped?: () => void, onStarted?: () => void): Promise<ClipResult>;
72
79
  /** Idempotent teardown: stop recorder + ALL tracks (v1 `stopAndCleanup` + the unmount
73
80
  * effect). Optional `stream` override mirrors v1's `stopAndCleanup(stream?)`.
74
81
  *
@@ -134,6 +141,10 @@ interface CaptureArtifacts {
134
141
  previewDataUrl: string;
135
142
  /** Capture-phase timing of the attempt that produced these artifacts. */
136
143
  timing?: CaptureTiming;
144
+ /** Liveness v7 §4.4: the screen ramp rendered against the session's issued challenge (clip mode, a challenge issued, a host painting). */
145
+ screenRamp?: ScreenRampReport;
146
+ /** Liveness v7 §4.5 item 2: how the capture was made (whenever the engine had a camera track). */
147
+ provenance?: CaptureProvenance;
137
148
  }
138
149
  interface CaptureSessionEvents {
139
150
  statechange: {
@@ -350,6 +361,9 @@ declare const UPRIGHT_WATCH_MS = 200;
350
361
  /** Best-of-N keyframe window: up to 4 candidates over the first 600ms. */
351
362
  declare const KEYFRAME_CANDIDATES = 4;
352
363
  declare const KEYFRAME_WINDOW_MS = 600;
364
+ /** Liveness v7 §4.5 item 2: the longest the capture waits on the track description (its WebCrypto hash) once the
365
+ * clip is done; past it the artifacts ship without `provenance`. */
366
+ declare const PROVENANCE_WAIT_MS = 1000;
353
367
  interface V3ChecksPayload {
354
368
  engine: "v3";
355
369
  /** Gate integrator 0..1 — the ring drives off this directly. */
@@ -383,6 +397,12 @@ interface CaptureSessionV3Events {
383
397
  frozen: {
384
398
  previewDataUrl: string;
385
399
  };
400
+ /** Liveness v7 §4.4: paint the full-viewport screen-ramp layer this colour (`null` clears it). Clip mode, a
401
+ * challenge issued by `screenRamp()`; at most four events per recording. CHROME-only: the host paints, the
402
+ * engine stamps the clip timeline. */
403
+ ramp: {
404
+ colour: ScreenRampColour | null;
405
+ };
386
406
  }
387
407
  type V3TelemetryEvent = {
388
408
  type: "detector";
@@ -491,6 +511,11 @@ interface CaptureSessionV3Options {
491
511
  * starts (prefetches the lazy ranker) and again when the capture fires.
492
512
  * Off → today's sharpest-of-N, byte for byte. */
493
513
  rankKeyframes?: () => boolean;
514
+ /** Screen-ramp challenge (liveness v7 §4.4; server tuning `capture.liveness.screenRamp`): read once when the
515
+ * clip recording starts. A challenge → the engine emits `ramp` at each issued onset on the clip timeline and
516
+ * reports what it rendered in `artifacts.screenRamp`; `undefined` (older backends, assisted sessions, no host
517
+ * painting) → no ramp, no field. Photo mode never ramps. */
518
+ screenRamp?: () => ScreenRampChallenge | undefined;
494
519
  /** INERT (Phase 3 escalation seam — see EscalationHook). Accepted and
495
520
  * retained, never called in Phases 1–2. */
496
521
  escalation?: EscalationHook;
@@ -532,6 +557,10 @@ declare class CaptureSessionV3 {
532
557
  private lastGateSnapshotAt;
533
558
  /** The upright guard applies to this attempt (a phone). */
534
559
  private uprightGuard;
560
+ /** Liveness v7 §4.5 item 2: the attempt's video track described right after getUserMedia (null: no track). */
561
+ private trackProvenance;
562
+ /** The ramp of the clip being recorded (stopped with the recording, the attempt or the session). */
563
+ private ramp;
535
564
  constructor(options: CaptureSessionV3Options);
536
565
  get state(): CaptureState;
537
566
  on<K extends keyof CaptureSessionV3Events>(event: K, handler: Handler<K>): () => void;
@@ -550,6 +579,8 @@ declare class CaptureSessionV3 {
550
579
  private startScheduler;
551
580
  private detectTick;
552
581
  private fire;
582
+ /** `{ provenance }` from the live track's description, the recording's frame statistics and the painter flag; `{}` without a track. */
583
+ private provenance;
553
584
  /** A phone showing a landscape frame: the guard holds the gate. */
554
585
  private isLandscape;
555
586
  /** Positioning on a sideways phone: no detection, the gate restarts from zero and the coaching says why. */
@@ -582,4 +613,4 @@ declare class CaptureSessionV3 {
582
613
  private now;
583
614
  }
584
615
 
585
- export { isMediaRecorderSupported as $, MIME_CANDIDATES as A, type V3GateFactor as B, type CameraErrorKind as C, DEFAULT_CLIP_MIME as D, type EscalationClipArtifact as E, FaceGateV3 as F, GATE_SNAPSHOT_MS as G, HOLD_UPRIGHT_KEY as H, type V3GateQuality as I, type V3GateThresholds as J, KEYFRAME_CANDIDATES as K, type V3GateTick as L, MAX_CLIP_BYTES as M, type V3GateTickInput as N, type V3TelemetryEvent as O, V3_GATE_DEFAULTS as P, VIDEO_BPS as Q, blockReasonOf as R, STOP_GRACE_MS as S, TIMESLICE_MS as T, UPRIGHT_WATCH_MS as U, type V3ChecksPayload as V, buildLivenessV2FormData as W, cameraPreflight as X, classifyDevice as Y, extForMime as Z, isClipTooLarge as _, CLIP_MS as a, mapGetUserMediaError as a0, pickMimeType as a1, probeDevice as a2, type CaptureArtifacts as b, type CaptureErrorKind as c, type CaptureSessionEvents as d, CaptureSessionV3 as e, type CaptureSessionV3Events as f, type CaptureSessionV3Options as g, type CaptureSessionV3StartOptions as h, type CaptureState as i, type CaptureTiming as j, ClipError as k, type ClipErrorKind as l, ClipRecorder as m, type ClipResult as n, DEVICE_PROFILES as o, type DeviceClass as p, type DeviceProbe as q, type DeviceProfile as r, DeviceProfiler as s, type EscalationHook as t, type GateBlockEntry as u, type GateBlockReason as v, GateBlockStats as w, type GateBlockSummary as x, type GateChecks as y, KEYFRAME_WINDOW_MS as z };
616
+ export { isClipTooLarge as $, MIME_CANDIDATES as A, type V3GateFactor as B, type CameraErrorKind as C, DEFAULT_CLIP_MIME as D, type EscalationClipArtifact as E, FaceGateV3 as F, GATE_SNAPSHOT_MS as G, HOLD_UPRIGHT_KEY as H, type V3GateQuality as I, type V3GateThresholds as J, KEYFRAME_CANDIDATES as K, type V3GateTick as L, MAX_CLIP_BYTES as M, type V3GateTickInput as N, type V3TelemetryEvent as O, PROVENANCE_WAIT_MS as P, V3_GATE_DEFAULTS as Q, VIDEO_BPS as R, STOP_GRACE_MS as S, TIMESLICE_MS as T, UPRIGHT_WATCH_MS as U, type V3ChecksPayload as V, blockReasonOf as W, buildLivenessV2FormData as X, cameraPreflight as Y, classifyDevice as Z, extForMime as _, CLIP_MS as a, isMediaRecorderSupported as a0, mapGetUserMediaError as a1, pickMimeType as a2, probeDevice as a3, type CaptureArtifacts as b, type CaptureErrorKind as c, type CaptureSessionEvents as d, CaptureSessionV3 as e, type CaptureSessionV3Events as f, type CaptureSessionV3Options as g, type CaptureSessionV3StartOptions as h, type CaptureState as i, type CaptureTiming as j, ClipError as k, type ClipErrorKind as l, ClipRecorder as m, type ClipResult as n, DEVICE_PROFILES as o, type DeviceClass as p, type DeviceProbe as q, type DeviceProfile as r, DeviceProfiler as s, type EscalationHook as t, type GateBlockEntry as u, type GateBlockReason as v, GateBlockStats as w, type GateBlockSummary as x, type GateChecks as y, KEYFRAME_WINDOW_MS as z };
@@ -1 +1 @@
1
- var c="0.1.0-rc.10";var d="sekyro.did",l;function g(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}catch{}}function f(){try{let t=localStorage.getItem(d);if(t)return t;let e=g();return e!==void 0&&localStorage.setItem(d,e),e}catch{return l??(l=g()),l}}async function m(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),n=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function p(t){let e=new TextEncoder().encode(t),r="";for(let n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function y(t){let e,r;return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},async deviceHeader(){try{r??(r=m().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let i=await r,s=f(),u={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...s?[{kind:"web_local",value:s.slice(0,128)}]:[],...i?[{kind:"web_fp",value:i}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{}};return p(JSON.stringify(u))}catch{return}}}}var o=Symbol.for("sekyro.web.clientContext"),a=globalThis,b=a[o]??(a[o]=y({sdk:`@sekyro/web@${c}`}));function C(t){try{let e=t.getVideoTracks?.()[0];e&&b.noteCameraLabel(e.label)}catch{}}export{b as a,C as b};
1
+ var c="0.1.0-rc.12";var d="sekyro.did",l;function g(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}catch{}}function f(){try{let t=localStorage.getItem(d);if(t)return t;let e=g();return e!==void 0&&localStorage.setItem(d,e),e}catch{return l??(l=g()),l}}async function m(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),n=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function p(t){let e=new TextEncoder().encode(t),r="";for(let n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function y(t){let e,r;return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},async deviceHeader(){try{r??(r=m().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let i=await r,s=f(),u={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...s?[{kind:"web_local",value:s.slice(0,128)}]:[],...i?[{kind:"web_fp",value:i}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{}};return p(JSON.stringify(u))}catch{return}}}}var o=Symbol.for("sekyro.web.clientContext"),a=globalThis,b=a[o]??(a[o]=y({sdk:`@sekyro/web@${c}`}));function C(t){try{let e=t.getVideoTracks?.()[0];e&&b.noteCameraLabel(e.label)}catch{}}export{b as a,C as b};
@@ -0,0 +1 @@
1
+ import{c as j,d as pe,e as me,f as fe,h as he,i as z,k as Y,m as Se,n as ge,u as ye,w as O,x as q}from"./chunk-IF6YOFFO.js";import{c as le,d as de,e as ue}from"./chunk-FPXL63KZ.js";import{c as K,f as $,g as ke}from"./chunk-MUVEJRGK.js";var ve=["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 Me=["carte_identite","passport","residence_permit"];function Ve(e,n){let i=e.byIssuer?.[n]??e.default;return Me.filter(s=>i==="*"||i.includes(s))}function ht(e,n=ve){return[...new Set([...n,...Object.keys(e.byIssuer??{})])].filter(s=>Ve(e,s).length>0).sort()}function _e(e){if(e.acceptedDocuments)return e.acceptedDocuments;let n=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:n}}}var Le=640,He=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),be=6,Pe=1500,Ce={sharpness:1,exposure:1,meanLuma:128},we=null;function De(e,n){try{we??(we=document.createElement("canvas"));let i=we,s=96/Math.max(1,n.width);i.width=Math.max(1,Math.round(n.width*s)),i.height=Math.max(1,Math.round(n.height*s));let a=i.getContext("2d");if(a===null)return Ce;a.drawImage(e,n.x,n.y,n.width,n.height,0,0,i.width,i.height);let c=a.getImageData(0,0,i.width,i.height);return{sharpness:de(c),exposure:ue(c),meanLuma:le(c)}}catch{return Ce}}async function Ne(e,n){let i=e.source;return"convertToBlob"in i?i.convertToBlob({type:"image/jpeg",quality:n}):new Promise((s,a)=>{i.toBlob(c=>c===null?a(new Error("encode failed")):s(c),"image/jpeg",n)})}function vt(e,n={}){let i=n.now??(()=>performance.now()),s=n.setTimer??((t,o)=>setTimeout(t,o)),a=n.clearTimer??(t=>clearTimeout(t)),c=n.encode??Ne,u=n.quality??De,l=e.tuningVersion??null,g=new Set,v=!1,S=e.video??null,f=null,y=n.grabFrame??null,x=null,M=1e3/be,P=null,w=null,D=!1,A=!1,E=Number.NEGATIVE_INFINITY,C=null,B=0,V=null,N=null,G=Promise.all([import("./icao-gate-PWBMKRGC.js"),import("./icao-tuning-4GGVX6B4.js"),import("./create-portrait-capture-C462EIB6.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([t,o,r,d,h])=>{let m=o.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);m.background.required&&(w=h.createBackgroundMonitor({tuning:m.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...n.createSegmenter!==void 0?{createSegmenter:n.createSegmenter}:{},now:i})),f=t.createIcaoGate(m,{policy:e.policy??"reject"}),y??(y=r.defaultGrabber()),x=r.observe,M=1e3/Math.min(be,m.cadenceHz);let k=(n.createLandmarker??d.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),p=await new Promise((_,b)=>{let I=setTimeout(()=>{b(new Error("landmarker init timeout")),k.then(T=>T.close(),()=>{})},d.LANDMARKER_INIT_TIMEOUT_MS);k.then(T=>{clearTimeout(I),_(T)},T=>{clearTimeout(I),b(T)})});v?p.close():P=p}).catch(()=>{D=!0}),Q=t=>{for(let o of g)o({holding:A||D,update:t})},F=()=>{if(C=null,!(v||P===null||f===null||y===null||x===null||S===null)){if(i()-E>Pe){Q(null);return}try{let t=y(S,Le);if(t!==null){let o=Math.max(i(),B+1);B=o;let r=P.detect(t.source,o),d=S.videoWidth||t.width,h=S.videoHeight||t.height,m=x(r,t,d,h);m.geometry!==null&&w!==null&&(m.backgroundCheck=w.measure(t,m.geometry.box,d,h));let k=f.push(m,i());A=k.ready,Q(k)}}catch{}C=s(F,M)}},Z=()=>{let t=i()-E>Pe;E=i(),t&&(f?.reset(),A=!1,V=null,N=null),C===null&&P!==null&&!v&&(C=s(F,0))},J=()=>{let t=y===null||S===null?null:y(S,null);if(t===null||f===null||Math.max(t.width,t.height)<e.still.minLongSidePx)return Promise.resolve(null);let o=f.summary();return c(t,e.still.jpegQuality).then(r=>({image:r,width:t.width,height:t.height,gate:o}),()=>null)},L=null;return{engineOptions:{measureQuality:(t,o)=>{S=t,Z();let r=u(t,o);return A||D?r:{...r,sharpness:0}},telemetry:t=>{if(t.type!=="fired"||v)return;V=J();let o=L;o!==null&&V.then(r=>r===null?void 0:o(r).catch(()=>{})),A=!1,C!==null&&a(C),C=null,E=Number.NEGATIVE_INFINITY}},decorate:t=>{let o=new WeakMap,r=new Map,d=p=>{let _=o.get(p);return _===void 0&&(_=(async()=>{let b=await ge(t,"image","image/jpeg",p.image.size,{engine:"portrait"});return await t.uploadToSpaces(b.uploadUrl,p.image,"image/jpeg"),(await t.completeMedia(b.key)).key})(),_.catch(()=>o.delete(p)),o.set(p,_)),_};L=d;let h=async p=>{let _;try{_=await d(p)}catch(b){let I=b?.code;if(typeof I=="string"&&He.has(I))throw b;return null}return{media:{portrait:_},gate:ke(p.gate),...l!==null?{tuningVersion:l}:{}}},m=t.submitCheck.bind(t),k=(async(p,_,b)=>{if(p!=="liveness")return m(p,_,b);let I=b?.idempotencyKey,T=I===void 0?void 0:r.get(I);if(T===void 0){let ae=V;T=ae===null?Promise.resolve(null):ae.then(ce=>ce===null?null:h(ce)),I!==void 0&&(r.set(I,T),T.catch(()=>r.delete(I)))}let X=await T;if(X===null)return m("liveness",_,b);let Re=await m("liveness",{..._,portraitIcao:X},b);return N=X,Re});return new Proxy(t,{get(p,_){if(_==="submitCheck")return k;let b=Reflect.get(p,_);return typeof b=="function"?b.bind(p):b}})},onGate:t=>(g.add(t),()=>g.delete(t)),lastPortraitInput:()=>N,destroy:()=>{v=!0,V=null,N=null,C!==null&&a(C),C=null,g.clear(),G.then(()=>{P?.close(),P=null,w?.close(),w=null})}}}var Ge=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","face_match","aml_screening","face_dedup","age_estimation"]),Ue=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),te=["document","population_registry","national_eid"],ne=["phone_otp","email_otp"],Ee={identity_method:te,contact:ne},Be=["population_registry","document"],Ie="platform_unsupported",Fe=new Set(["prefilled","user_entered","prefilled_or_entered"]),Ke={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 R(e){return e.section??Ke[e.checkType]??null}function ie(e,n){let i=e.plan?.choice;if(i===void 0||i.locked)return;let s=i.options.find(a=>a.id!==i.selected&&a.available!==!1&&n.includes(a.service));return s===void 0?void 0:{nodeId:i.nodeId,option:s}}function oe(e){let n=e.plan,i=n?.choice;if(n===void 0||i===void 0||i.locked||n.current===null||n.current===i.nodeId||z(e))return null;let s=Ee[i.kind]??[...te,...ne],a=i.options.flatMap(l=>l.available===!1||!s.includes(l.service)?[]:[l.nationalEid!=null?{id:l.id,service:l.service,nationalEid:l.nationalEid}:{id:l.id,service:l.service}]),c=n.steps.find(l=>l.id===n.current)?.service,u=i.selected??a.find(l=>l.service===c)?.id??null;return a.some(l=>l.id!==u)?{nodeId:i.nodeId,kind:i.kind,current:u,options:a}:null}function Te(e){return e==null?[]:e.options.filter(n=>n.id!==e.current)}function je(e){let n=(e.plan?.sections??[]).map(a=>({id:a.id,state:a.state})),i={sessionId:e.sessionId,orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:n.map(a=>a.id),progress:n,purpose:e.purpose??"identity"};e.branding!==void 0&&(i.branding=e.branding),e.cameraUnavailableHandled===!0&&(i.cameraUnavailableHandled=!0);let s=oe(e);return s!==null&&(i.switchable=s),i}function qe(e){let n={attemptsRemaining:me(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(n.reason=e.reason),e.retakeHint!==void 0&&(n.retakeHint=e.retakeHint),n}var Oe={phone_otp:"phone",email_otp:"email"};function Qe(e,n){let i=ie(e,[n==="phone_otp"?"email_otp":"phone_otp"]);return i===void 0?void 0:Oe[i.option.service]}function Ye(e,n,i,s){let a=n.checkType==="email_otp",c=(a?n.emailOtp:n.otp)??{},u=a?n.emailOtp?.emailSource:n.otp?.numberSource,l=u!==void 0&&Fe.has(u)?u:a?"prefilled_or_entered":"user_entered",g=typeof c.sentToMasked=="string"&&c.sentToMasked.length>0,v=Qe(e,a?"email_otp":"phone_otp"),S={key:n.checkType,context:i,section:R(n),phase:g?"verify":"send",canSwitch:v!==void 0,...s},f=a?{kind:"email_otp",...S,emailSource:l,needsEmail:l!=="prefilled"}:{kind:"phone_otp",...S,numberSource:l,needsPhone:l!=="prefilled",channels:(n.otp?.channels??[]).filter(y=>y==="whatsapp"||y==="sms")};return v!==void 0&&(f.switchChannel=v),g&&(f.sentToMasked=c.sentToMasked),!a&&n.otp?.channel!==void 0&&(f.channel=n.otp.channel),c.expiresAt!==void 0&&(f.codeExpiresAt=c.expiresAt),c.resendAvailableAt!==void 0&&(f.resendAvailableAt=c.resendAvailableAt),f}function $e(e,n,i,s){let a=e.nniBound===!0?"bound":n.nniFromDocument===!0?"document":"typed",c=a==="typed"&&n.state==="input_required"&&n.reason==="nni_recheck",u=Te(oe(e)),l=!s.attemptsExhausted&&u.length===1&&u[0]?.service==="document";return{kind:"registry",key:"registry",context:i,section:R(n),state:n.state==="input_required"?"input_required":"pending",source:a,recheck:c,canUseDocument:l,...s}}function We(e,n,i,s){let a=[...n.acceptedSides??[]];return{kind:"document",key:"document",context:i,section:R(n),side:a.includes("recto")?"verso":"recto",acceptedSides:a,documents:_e(e),...s}}function Ze(e){let n=Y(e,"liveness");return n?.state==="passed"||n?.state==="review"}function xe(e,n,i,s,a){let c=n.icao?.report;return{kind:"portrait",key:`portrait:${a}`,context:i,section:R(n),phase:a,report:Array.isArray(c)?c:null,review:n.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:$(e),retakeOnly:a==="capture"&&n.state==="input_required"&&e.capture?.livePhoto?.oneCapture===!0&&Ze(e),...s}}var ee={minLongSidePx:1280,jpegQuality:.95};function Je(e,n){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let s=Y(e,"portrait_icao"),a=i.still??ee;return{icao:n==="liveness"&&$(e)!==null&&s!==void 0&&s.state==="pending"&&s.reason===void 0,still:{minLongSidePx:a.minLongSidePx??ee.minLongSidePx,jpegQuality:a.jpegQuality??ee.jpegQuality}}}function Xe(e,n,i,s){let a=n.eid,c=R(n);if(a===void 0||a.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:i,section:c,checkType:"eid_auth",reason:"update_required"};let u=Te(oe(e)),l=u.length===1&&Be.includes(u[0]?.service??"")?u[0]:void 0,g=l===void 0?void 0:j[l.service],v=g!==void 0,S={kind:"eid",key:"eid",context:i,section:c,provider:a.provider,providerName:a.providerName,country:a.country,challenge:"app_code",phase:a.awaiting==="code"?"code":"identifier",identifierBound:a.identifierBound===!0,canUseCamera:v,afterPass:a.afterPass==="continue"?"continue":"end",...s};return v&&(S.cameraMethod=g),a.expiresAt!==void 0&&(S.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(S.resendAvailableAt=a.resendAvailableAt),a.resendsRemaining!==void 0&&(S.resendsRemaining=a.resendsRemaining),a.codeAttemptsRemaining!==void 0&&(S.codeAttemptsRemaining=a.codeAttemptsRemaining),S}function ze(e,n){if(n.checkType!=="face_match"||n.reason!==void 0)return null;let i=Y(e,"portrait_icao");return i!==void 0&&(i.state==="passed"||i.state==="review")?i:null}function et(e){return pe(e).filter(n=>n.state==="failed").pop()?.attemptsExhausted===!0}function tt(e,n){let i=e.failureReason,s;i===Ie?s="platform_unsupported":e.status==="expired"?s="expired":e.status==="review_pending"?s="review":e.status==="completed"&&e.outcome==="approved"?s="approved":e.status==="completed"&&e.outcome==="review"?s="review":i==="device_cooldown"?s="cooldown":i!==void 0?s="policy_stop":et(e)?s="attempts_exhausted":s="rejected";let a=s==="platform_unsupported"?{sessionId:e.sessionId,status:"unavailable"}:Se(e,{autoRetry:!1}),c={kind:"result",key:"result",context:n,section:null,display:s,result:a};return i!==void 0&&(c.failureReason=i),e.retryAfter!==void 0&&(c.retryAfter=e.retryAfter),c}function nt(e,n,i){let s=e.identitySummary;if(s==null)return null;let a={kind:"identity_summary",key:"identity_summary",context:n,section:i??"identity",summaryKind:s.kind==="partial"?"partial":s.kind??"full",source:s.source,portraitAvailable:s.portrait?.available===!0,retakeAvailable:s.retakeAvailable===!0};for(let c of it){let u=s[c];typeof u=="string"&&u!==""&&(a[c]=u)}return a}var it=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","nniMasked","expiryDate","retakeTarget"];function U(e,n,i,s){return{kind:"unsupported",key:`unsupported:${i}`,context:e,section:n,checkType:i,reason:s}}function ot(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function rt(e,n){let i=Ee[e.kind]??[...te,...ne],s=ot(e),a=e.options.flatMap(u=>{if(u.available===!1||!i.includes(u.service))return[];let l={id:u.id,service:u.service};return u.nationalEid!=null&&(l.nationalEid=u.nationalEid),[l]});if(a.length===0){let u=e.options.length>0&&e.options.every(l=>l.service==="nfc");return U(n,s,"choice",u?"platform_unsupported":"update_required")}let c={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:a};if(e.kind==="identity_method"){let u={kind:"method",key:"method",context:n,section:s,options:a.map(g=>j[g.service]),choice:c},l=a.find(g=>g.nationalEid!==void 0)?.nationalEid;return l!==void 0&&(u.nationalEid=l),u}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:n,section:s,options:a.map(u=>Oe[u.service]),selected:null,locked:!1,choice:c}:{kind:"choice",key:`choice:${e.nodeId}`,context:n,section:s,choice:c}}function W(e,n={}){let i=je(e);if(z(e)||e.failureReason===Ie)return tt(e,i);let s=e.plan;if(s===void 0||!Array.isArray(s.sections))return U(i,null,"plan","update_required");let a=fe(e);if(a!==null)return rt(a,i);let c=s.current===null?void 0:s.steps.find(f=>f.id===s.current),u=f=>{let y={kind:"processing",key:"processing",context:i,section:f!==void 0?R(f):s.sections.find(x=>x.state==="current")?.id??null,stalled:!1};return typeof f?.service=="string"&&f.service!==""&&(y.service=f.service),y};if(s.current===null)return u(s.steps.find(f=>f.state==="processing"));if(c===void 0)return U(i,null,"step","update_required");if(!Ge.has(c.service))return c.interaction==="server"?u(c):U(i,R(c),c.service,"update_required");if(Ue.has(c.service)||!he(c))return u(c);let l=c,g=qe(l),v=l.checkType,S=R(l);switch(v){case"phone_otp":case"email_otp":return Ye(e,l,i,g);case"population_registry":return $e(e,l,i,g);case"eid_auth":return Xe(e,l,i,g);case"doc_ocr":return We(e,l,i,g);case"identity_confirm":return nt(e,i,S)??u(l);case"portrait_icao":return xe(e,l,i,g,"capture");case"liveness":case"face_match":{let f=ze(e,l);if(f!==null)return xe(e,f,i,g,"match");let y=l.requiresMobile===!0,x=$(e);return y&&n.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:i,section:S,checkType:v}:{kind:"liveness",key:"biometric",context:i,section:S,mode:v==="face_match"?"selfie":"liveness",requiresMobile:y,instructions:x===null?"standard":"icao",icao:x,livePhoto:Je(e,v),...g}}case"nfc_chip":return U(i,S,v,"platform_unsupported");default:return U(i,S,v,"update_required")}}function re(e){return/^\d{10}$/.test(e)&&Number(e)%97===1}function se(e){let n="";for(let i of e){let s=i.codePointAt(0)??0;s>=1632&&s<=1641?n+=String(s-1632):s>=1776&&s<=1785?n+=String(s-1776):i!==" "&&i!=="-"&&i!=="\xA0"&&(n+=i)}return n}var st=[1e3,2e3,4e3,8e3,15e3],at=3e4,ct=/^\+[1-9]\d{7,14}$/,lt=/^\d{6}$/,dt=/^\d{6}$/,ut=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ae=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"]),pt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function Mt(e){let n=!1,i=null,s="",a=!1,c=!1,u=!1,l={},g={},v=new Set,S=!1,f=null,y="idle",x=new Map,M=new Map,P=(t,o,r)=>{let d=`${t}.${o}`,h=x.get(d);if(h!==void 0)return h;let m=M.get(t),k=(m===void 0?r():m.then(r)).finally(()=>{x.delete(d)});x.set(d,k);let p=k.then(()=>{},()=>{});return M.set(t,p),p.then(()=>{M.get(t)===p&&M.delete(t)}),k},w=async(t,o,r)=>{await e.ensureConsent();let d;try{d=await ye(e.runtime,o)}catch(m){if(m instanceof K&&Ae.has(m.code)){await e.refreshView();return}throw m}if(r?.(),e.destroyed())return;let h=d;h.plan!==void 0&&e.setView!==void 0?e.setView(h):await e.refreshView()},D=async t=>{await e.ensureConsent();let o;try{try{o=await t(e.runtime.client)}catch(r){if(!(r instanceof K)||r.code!=="consent_required")throw r;await e.runtime.ensureConsent({force:!0}),o=await t(e.runtime.client)}}catch(r){if(r instanceof K&&Ae.has(r.code)){await e.refreshView();return}throw r}e.destroyed()||(o!==void 0&&e.setView!==void 0?e.setView(o):await e.refreshView())},A=(t,o)=>P("choice",`${t}:${o}`,()=>D(r=>r.choose(t,o))),E=(t,o)=>t.options.some(r=>r.id===o)?A(t.nodeId,o):Promise.reject(new RangeError(`option ${String(o)} is not offered`)),C=(t,o)=>{let r=e.currentView(),d=r===null?void 0:ie(r,t);return d===void 0?Promise.reject(new RangeError(`the ${o} is not offered`)):A(d.nodeId,d.option.id)},B=t=>P("identity",t,()=>D(o=>o.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):o.confirmIdentity(t))),V=(t,o)=>{let r=t.kind,d=r==="phone_otp",h=d?"phone":"email",m={action:"send"};if(d?t.needsPhone:t.needsEmail){let k=o[h]??g[r],p=d?k?.replace(/[\s().-]/g,""):k?.trim();if(p===void 0||!(d?ct:ut).test(p))return Promise.reject(d?new O("phone","format"):new q("email","format"));m[h]=p}if(d){let k=t.channels,p=o.channel??(k.length===1?k[0]:void 0);if(k.length>0){if(p===void 0)return Promise.reject(new q("channel","required"));if(!k.includes(p))return Promise.reject(new q("channel","unavailable"))}p!==void 0&&(m.channel=p)}return P(r,"send",()=>w(r,(k,p)=>k.submitCheck(r,m,{idempotencyKey:p}),()=>{l[r]=e.now(),m[h]!==void 0&&(g[r]=m[h])}))},N=(t,o)=>lt.test(o)?P(t,"verify",()=>w(t,(r,d)=>r.submitCheck(t,{action:"verify",code:o},{idempotencyKey:d}))):Promise.reject(new O("code","format")),G=(t,o)=>P("eid_auth",t,()=>w("eid_auth",(r,d)=>r.submitCheck("eid_auth",o,{idempotencyKey:d}))),Q=(t,o)=>{if(t.identifierBound)return G("start",{action:"start"});let r=se(o??"");if(t.country==="MR"){if(!/^\d{10}$/.test(r))return Promise.reject(new O("nni","format"));if(!re(r))return Promise.reject(new O("nni","check_digit"))}else if(r==="")return Promise.reject(new O("nni","format"));return G("start",{action:"start",identifier:r})},F=t=>{switch(t.kind){case"phone_otp":case"email_otp":{let o={...t,send:(d={})=>V(t,d),verify:d=>N(t.kind,d),switchTo:()=>t.canSwitch&&t.switchChannel!==void 0?C([t.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},r=l[t.kind];return o.resendAvailableAt===void 0&&r!==void 0&&(o.resendAvailableAt=new Date(r+at).toISOString()),o}case"eid":return{...t,start:o=>Q(t,o),verify:o=>dt.test(o)?G("verify",{action:"verify",code:o}):Promise.reject(new O("code","format")),resend:()=>t.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):G("resend",{action:"resend"}),useCamera:()=>t.canUseCamera&&t.cameraMethod!==void 0?C(t.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...t,select:o=>{let r=t.choice.options.find(d=>j[d.service]===o);return r!==void 0?E(t.choice,r.id):Promise.reject(new RangeError(`method ${String(o)} is not offered`))},choose:o=>E(t.choice,o)};case"choice":return{...t,choose:o=>E(t.choice,o)};case"registry":return{...t,submitNni:o=>{if(t.source!=="typed")return Promise.reject(new RangeError("this session already holds the NNI"));let r=se(o);return/^\d{10}$/.test(r)?re(r)?P("population_registry","submitNni",()=>w("population_registry",(d,h)=>d.submitCheck("population_registry",{nni:r},{idempotencyKey:h}),()=>{f=`\u2022\u2022\u2022\u2022\u2022\u2022${r.slice(-4)}`})):Promise.reject(new O("nni","check_digit")):Promise.reject(new O("nni","format"))},confirm:()=>P("population_registry","confirm",()=>w("population_registry",(o,r)=>o.submitCheck("population_registry",{},{idempotencyKey:r}))),useDocument:()=>t.canUseDocument?C(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?e.bindDocument(t,H):{...t,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")}};case"portrait":return e.bindPortrait!==void 0?e.bindPortrait(t,H):{...t,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")}};case"contact_choice":return{...t,select:o=>{let r=o==="phone"?"phone_otp":o==="email"?"email_otp":void 0,d=t.choice.options.find(h=>h.service===r);return d!==void 0?E(t.choice,d.id):Promise.reject(new RangeError(`contact ${String(o)} is not offered`))},choose:o=>E(t.choice,o)};case"identity_summary":return{...t,...t.nniMasked===void 0&&t.summaryKind==="partial"&&f!==null?{nniMasked:f}:{},portrait:async()=>{let o=e.runtime.client;if(!t.portraitAvailable||o.identityPortrait===void 0)return null;try{return await o.identityPortrait()}catch{return null}},confirm:()=>B("confirm"),retake:()=>t.retakeAvailable?B("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...t,capture:o=>e.liveness(o),onLivePhoto:o=>t.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(o):()=>{}};case"mobile_required":case"processing":return{...t,refresh:async()=>{a=!1,await e.refreshView()}};case"unsupported":case"result":return{...t};default:{let o=t;throw new Error(`runner: unhandled step ${JSON.stringify(o)}`)}}},Z=async()=>{if(!c){c=!0;try{for(let t of st){if(await e.sleep(t),!n||e.destroyed())return;let o=await e.refreshView().catch(()=>null);if(o!==null&&W(o,{isMobile:e.isMobile()}).kind!=="processing")return}a=!0,H()}finally{c=!1}}},J=t=>{if(t.kind!=="liveness"||t.mode!=="selfie")return null;let o={kind:"processing",key:"processing",context:t.context,section:t.section,stalled:!1};if(y==="inflight")return o;if(!S||y==="done")return null;let r=e.keptFaceKey?.()??null;return r===null?null:(y="inflight",w("face_match",(d,h)=>d.submitCheck("face_match",{imageKey:r},{idempotencyKey:h}),()=>{y="done"}).then(()=>{y==="inflight"&&(y="done",H())},()=>{y="done",H()}),o)},L=(t,o=!1)=>{if(!n||e.destroyed()||e.chainBusy())return;let r=W(t,{isMobile:e.isMobile()});r.kind==="registry"&&r.recheck&&(S=!0,y="idle"),r=J(r)??r,r.kind==="processing"?r.stalled=a:a=!1;let d=F(r),h=r.kind==="result"?void 0:r.context.switchable,m=h===void 0?d:{...d,chooseOption:p=>E({nodeId:h.nodeId,kind:h.kind,selected:h.current,options:h.options},p)},k=JSON.stringify(m);r.kind==="registry"&&r.source==="document"&&r.state==="pending"&&!v.has("registry")&&(v.add("registry"),m.confirm().catch(p=>{(!(p instanceof K)||pt.has(p.code))&&v.delete("registry")})),!(!o&&k===s)&&(s=k,i=m,e.emitStep(m),r.kind==="processing"&&!a&&y!=="inflight"&&Z(),r.kind==="result"&&!u&&(u=!0,e.emitResult(r.result)))};function H(){let t=e.currentView();t!==null&&L(t,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");n=!0;let t=await e.ensureView();return i===null&&L(t),i??F(W(t,{isMobile:e.isMobile()}))},current:()=>i,onView:t=>L(t),onChainIdle:()=>{let t=e.currentView();t!==null&&L(t)},republish:H,submit:w}}export{Ve as a,ht as b,be as c,Pe as d,vt as e,W as f,st as g,at as h,Mt as i};
@@ -1 +1 @@
1
- import{a as ie,d as ue}from"./chunk-CJHMFPL6.js";import{a as ce}from"./chunk-RI3E7GBN.js";import{a as G,e as ne,g as re,m as ae}from"./chunk-7ZCZY3ZP.js";import{b as oe}from"./chunk-BPE5NSQ2.js";import{a as Z,d as ee,e as te}from"./chunk-HAO6EQTH.js";import{e as Q}from"./chunk-FUHDOEBP.js";import{d as $}from"./chunk-FHJ7HO3M.js";var ye=250,xe=180,be=96;function se(n){let{data:t,width:e,height:r}=n,a=new Uint8Array(e*r);for(let o=0,u=0;o<a.length;o+=1,u+=4)a[o]=Math.round(.299*(t[u]??0)+.587*(t[u+1]??0)+.114*(t[u+2]??0));return{data:a,width:e,height:r}}function q(n,t){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(t.width,Math.ceil(n.x+n.width)),y1:Math.min(t.height,Math.ceil(n.y+n.height))}}function T(n,t,e){let r=q(t,n),a=e===void 0?null:q(e,n),o=0,u=0,s=0,d=0;for(let c=r.y0;c<r.y1;c+=1)for(let p=r.x0;p<r.x1;p+=1){if(a!==null&&p>=a.x0&&p<a.x1&&c>=a.y0&&c<a.y1)continue;let M=n.data[c*n.width+p];o+=1,u+=M,s+=M*M,M>=ye&&(d+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let m=u/o;return{mean:m,sd:Math.sqrt(Math.max(0,s/o-m*m)),clipped:d/o,count:o}}function le(n){let{box:t}=n,r=(n.leftEye.y+n.rightEye.y)/2-.1*t.height,a=t.y+.85*t.height;return{x:t.x+.15*t.width,y:r,width:.7*t.width,height:Math.max(1,a-r)}}function we(n,t){let e=le(t),r=T(n,e);if(r.count===0)return null;let a=Math.min(Math.max(t.nose.x,e.x+1),e.x+e.width-1),o=T(n,{x:e.x,y:e.y,width:a-e.x,height:e.height}),u=T(n,{x:a,y:e.y,width:e.x+e.width-a,height:e.height}),s=u.mean>0?o.mean/u.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:r.mean,halfRatio:s,clipped:r.clipped}}function ve(n,t){let e=0,r=0;for(let a of[t.leftEyeBox,t.rightEyeBox]){let o=a.width*.15,u=a.height*.5,s=T(n,{x:a.x-o,y:a.y-u,width:a.width+2*o,height:a.height+2*u});e+=s.count,r+=s.clipped*s.count}return e===0?null:r/e}function Ce(n,t){let e=ne(t),{box:r}=t,a={x:r.x-.2*r.width,y:e.y,width:1.4*r.width,height:r.y+r.height-e.y},o=0,u=0,s=0;for(let m of[e.x,e.x+.8*e.width]){let c=T(n,{x:m,y:e.y+.04*e.height,width:.2*e.width,height:.25*e.height},a);o+=c.count,u+=c.mean*c.count,s+=(c.sd*c.sd+c.mean*c.mean)*c.count}if(o===0)return null;let d=u/o;return{luma:d,sd:Math.sqrt(Math.max(0,s/o-d*d)),count:o}}function Pe(n,t){let e=q(le(t),n),r=Math.max(1,Math.floor(Math.max(e.x1-e.x0,e.y1-e.y0)/be)),a=(m,c)=>n.data[c*n.width+m],o=0,u=0,s=0;for(let m=e.y0+r;m<e.y1-r;m+=r)for(let c=e.x0+r;c<e.x1-r;c+=r){let p=a(c,m-r)+a(c-r,m)+a(c+r,m)+a(c,m+r)-4*a(c,m);o+=1,u+=p,s+=p*p}if(o===0)return null;let d=u/o;return Math.min(1,Math.max(0,s/o-d*d)/xe)}function me(n,t){return{lighting:we(n,t),eyeSpecular:ve(n,t),background:Ce(n,t),sharpness:Pe(n,t)}}var ke="/models-v3",Me=640,Le=1600,Se=.92;function N(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function W(n,t){if(typeof document<"u"){let e=document.createElement("canvas");return e.width=n,e.height=t,e}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,t):null}function Fe(){let n=null;return(t,e)=>{let{width:r,height:a}=N(t);if(r===0||a===0)return null;let o=e===null?1:Math.min(1,e/Math.max(r,a)),u=Math.round(r*o),s=Math.round(a*o),d;e===null?d=W(u,s):((n===null||n.width!==u||n.height!==s)&&(n=W(u,s)),d=n);let m=d?.getContext("2d",{willReadFrequently:!0});if(d==null||m==null)return null;m.drawImage(t,0,0,u,s);let c=null;try{c=m.getImageData(0,0,u,s)}catch{c=null}return{source:d,width:u,height:s,pixels:c}}}async function Te(n,t,e,r){let a=Math.round(e*t.width/t.height),o=W(a,e),u=o?.getContext("2d");if(o==null||u==null)throw new Error("canvas unavailable");return u.fillStyle="#fff",u.fillRect(0,0,a,e),u.drawImage(n.source,t.x,t.y,t.width,t.height,0,0,a,e),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:r}):new Promise((s,d)=>{o.toBlob(m=>m===null?d(new Error("encode failed")):s(m),"image/jpeg",r)})}var Y=class extends Error{};function Ee(n,t,e){return new Promise((r,a)=>{let o=setTimeout(()=>{a(new Y(`init exceeded ${t}ms`)),n.then(e,()=>{})},t);n.then(u=>{clearTimeout(o),r(u)},u=>{clearTimeout(o),a(u)})})}function Ie(n){let t=$(n),e=t==="overconstrained"?"generic":t;return{kind:e,retryable:e!=="insecure"&&e!=="unsupported"}}function Re(n,t,e,r){let a=n.length===1?n[0]:void 0,o=a===void 0?null:G(a.landmarks,e,r),u=null;if(a!==void 0&&t.pixels!==null){let s=G(a.landmarks,t.width,t.height),d=se(t.pixels);s!==null&&(u=me(d,s))}return{frameWidth:e,frameHeight:r,faces:n.length,geometry:o,matrix:a?.matrix??null,blendshapes:a?.blendshapes??null,stats:u}}function Ke(n,t={},e=()=>"self"){let r=oe(n.tuning,n.tuningVersion),a=Z(),o=t.now??(()=>performance.now()),u=t.setTimer??((i,l)=>setTimeout(i,l)),s=t.clearTimer??(i=>clearTimeout(i)),d=t.grabFrame??Fe(),m=t.encodeRegion??Te,c=t.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),p=t.createLandmarker??ue,M=n.assetBaseUrl??ke,j=te({enabled:n.keepScreenAwake!==!1}),L=ae(r,{policy:n.policy??"reject"}),b=n.video,K=ce({tuning:r.backgroundCheck,assetBaseUrl:M,...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:o}),h="idle",C=null,x=null,E=null,B=!1,f=!1,g=0,z=0,A=[],w="user",O=!1,de=t.canChooseFacing??ee,S=i=>{h===i||f||(h=i,j.setActive(i==="starting"||i==="gating"),a.emit("state",i))},U=()=>{E!==null&&s(E),E=null},I=()=>{U();for(let i of C?.getTracks()??[])i.stop();C=null;try{b.srcObject=null}catch{}},H=i=>{I(),S("error"),a.emit("error",i)},X=()=>{let i=Math.max(o(),z+1);return z=i,i},he=async i=>{let l=d(b,null),{width:P,height:k}=l??N(b);if(l===null||x===null){L.reset();return}let y=x.detect(l.source,X()),v=(y.length===1?y:A.length===1?A:[])[0],F=v===void 0?null:G(v.landmarks,P,k);if(F===null){L.reset();return}let R=re(F,P,k,{margin:r.cropMargin,minWidth:r.resolution.minWidth,minHeight:r.resolution.minHeight}),V=Math.max(r.resolution.minHeight,Math.min(R.height,Le)),pe=await m(l,R,V,Se);if(f||i!==g)return;let J={image:pe,width:Math.round(V*R.width/R.height),height:V,gate:L.summary()};r.tuningVersion!==null&&(J.tuningVersion=r.tuningVersion),U(),S("captured"),a.emit("captured",J)},_=async i=>{if(!(f||i!==g||h!=="gating"||x===null)){if(!B){B=!0;try{let l=d(b,Me);if(l!==null){let{width:P,height:k}=N(b),y=x.detect(l.source,X());A=y;let v=Re(y,l,P||l.width,k||l.height);v.geometry!==null&&r.background.required&&(v.backgroundCheck=K.measure(l,v.geometry.box,P||l.width,k||l.height));let F=L.push(v,o());if(f||i!==g||(a.emit("gate",F),F.ready&&(await he(i),h!=="gating")))return}}catch{}finally{B=!1}}!f&&i===g&&h==="gating"&&(E=u(()=>{_(i)},1e3/r.cadenceHz))}},fe=()=>Ee(p(M),2e4,i=>i.close()),ge=async i=>{if(e()!=="assisted")return"user";let l=i??(O?void 0:n.facing);if(l!==void 0)return l;if(O)return w;try{return await de()?"environment":"user"}catch{return"user"}},D=async i=>{if(f||h==="starting"||h==="gating")return;g+=1;let l=g;L.reset(),S("starting");let P=await ge(i?.facing);if(f||l!==g)return;if(C!==null&&P!==w&&I(),w=P,O=!0,C===null&&t.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){H({kind:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported",retryable:!1});return}let k=x!==null?Promise.resolve(x):fe();k.catch(()=>{});try{if(C===null){let y=await c({video:{facingMode:w,width:{ideal:r.camera.width},height:{ideal:r.camera.height}},audio:!1});if(f||l!==g){for(let v of y.getTracks())v.stop();return}C=y,w=Q(y)??w,b.srcObject=C,b.muted=!0,b.playsInline=!0,await b.play().catch(()=>{})}}catch(y){!f&&l===g&&H(Ie(y));return}try{x=await k}catch{!f&&l===g&&H({kind:"generic",retryable:!0});return}f||l!==g||(S("gating"),_(l))};return{handle:{get state(){return h},get captureMode(){return e()},get facingMode(){return w},on:(i,l)=>a.on(i,l),start:D,retry:()=>{if(!f){if(C!==null&&x!==null&&h!=="error"){g+=1;let i=g;U(),L.reset(),S("gating"),_(i);return}h="idle",D()}},switchCamera:()=>{if(f||e()!=="assisted"||h!=="idle"&&h!=="starting"&&h!=="gating"&&h!=="error")return!1;let i=w==="user"?"environment":"user";return g+=1,I(),w=i,h="idle",D({facing:i}),!0},destroy:()=>{f||(g+=1,I(),j.setActive(!1),f=!0,x?.close(),x=null,K.close(),a.clear())}},setFlowState:i=>{(h==="captured"||h==="uploading"||h==="checking"||h==="done"&&i==="done")&&S(i)}}}function ze(){import("@mediapipe/tasks-vision").catch(()=>{})}export{ye as a,xe as b,se as c,T as d,we as e,ve as f,Ce as g,Pe as h,me as i,Me as j,Le as k,Se as l,Fe as m,Re as n,Ke as o,ze as p};
1
+ import{a as ie,d as ue}from"./chunk-CJHMFPL6.js";import{a as ce}from"./chunk-RI3E7GBN.js";import{a as G,e as ne,g as re,m as ae}from"./chunk-7ZCZY3ZP.js";import{b as oe}from"./chunk-BPE5NSQ2.js";import{a as Z,d as ee,e as te}from"./chunk-GT2ZLGF7.js";import{e as Q}from"./chunk-FUHDOEBP.js";import{d as $}from"./chunk-FHJ7HO3M.js";var ye=250,xe=180,be=96;function se(n){let{data:t,width:e,height:r}=n,a=new Uint8Array(e*r);for(let o=0,u=0;o<a.length;o+=1,u+=4)a[o]=Math.round(.299*(t[u]??0)+.587*(t[u+1]??0)+.114*(t[u+2]??0));return{data:a,width:e,height:r}}function q(n,t){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(t.width,Math.ceil(n.x+n.width)),y1:Math.min(t.height,Math.ceil(n.y+n.height))}}function T(n,t,e){let r=q(t,n),a=e===void 0?null:q(e,n),o=0,u=0,s=0,d=0;for(let c=r.y0;c<r.y1;c+=1)for(let p=r.x0;p<r.x1;p+=1){if(a!==null&&p>=a.x0&&p<a.x1&&c>=a.y0&&c<a.y1)continue;let M=n.data[c*n.width+p];o+=1,u+=M,s+=M*M,M>=ye&&(d+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let m=u/o;return{mean:m,sd:Math.sqrt(Math.max(0,s/o-m*m)),clipped:d/o,count:o}}function le(n){let{box:t}=n,r=(n.leftEye.y+n.rightEye.y)/2-.1*t.height,a=t.y+.85*t.height;return{x:t.x+.15*t.width,y:r,width:.7*t.width,height:Math.max(1,a-r)}}function we(n,t){let e=le(t),r=T(n,e);if(r.count===0)return null;let a=Math.min(Math.max(t.nose.x,e.x+1),e.x+e.width-1),o=T(n,{x:e.x,y:e.y,width:a-e.x,height:e.height}),u=T(n,{x:a,y:e.y,width:e.x+e.width-a,height:e.height}),s=u.mean>0?o.mean/u.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:r.mean,halfRatio:s,clipped:r.clipped}}function ve(n,t){let e=0,r=0;for(let a of[t.leftEyeBox,t.rightEyeBox]){let o=a.width*.15,u=a.height*.5,s=T(n,{x:a.x-o,y:a.y-u,width:a.width+2*o,height:a.height+2*u});e+=s.count,r+=s.clipped*s.count}return e===0?null:r/e}function Ce(n,t){let e=ne(t),{box:r}=t,a={x:r.x-.2*r.width,y:e.y,width:1.4*r.width,height:r.y+r.height-e.y},o=0,u=0,s=0;for(let m of[e.x,e.x+.8*e.width]){let c=T(n,{x:m,y:e.y+.04*e.height,width:.2*e.width,height:.25*e.height},a);o+=c.count,u+=c.mean*c.count,s+=(c.sd*c.sd+c.mean*c.mean)*c.count}if(o===0)return null;let d=u/o;return{luma:d,sd:Math.sqrt(Math.max(0,s/o-d*d)),count:o}}function Pe(n,t){let e=q(le(t),n),r=Math.max(1,Math.floor(Math.max(e.x1-e.x0,e.y1-e.y0)/be)),a=(m,c)=>n.data[c*n.width+m],o=0,u=0,s=0;for(let m=e.y0+r;m<e.y1-r;m+=r)for(let c=e.x0+r;c<e.x1-r;c+=r){let p=a(c,m-r)+a(c-r,m)+a(c+r,m)+a(c,m+r)-4*a(c,m);o+=1,u+=p,s+=p*p}if(o===0)return null;let d=u/o;return Math.min(1,Math.max(0,s/o-d*d)/xe)}function me(n,t){return{lighting:we(n,t),eyeSpecular:ve(n,t),background:Ce(n,t),sharpness:Pe(n,t)}}var ke="/models-v3",Me=640,Le=1600,Se=.92;function N(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function W(n,t){if(typeof document<"u"){let e=document.createElement("canvas");return e.width=n,e.height=t,e}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,t):null}function Fe(){let n=null;return(t,e)=>{let{width:r,height:a}=N(t);if(r===0||a===0)return null;let o=e===null?1:Math.min(1,e/Math.max(r,a)),u=Math.round(r*o),s=Math.round(a*o),d;e===null?d=W(u,s):((n===null||n.width!==u||n.height!==s)&&(n=W(u,s)),d=n);let m=d?.getContext("2d",{willReadFrequently:!0});if(d==null||m==null)return null;m.drawImage(t,0,0,u,s);let c=null;try{c=m.getImageData(0,0,u,s)}catch{c=null}return{source:d,width:u,height:s,pixels:c}}}async function Te(n,t,e,r){let a=Math.round(e*t.width/t.height),o=W(a,e),u=o?.getContext("2d");if(o==null||u==null)throw new Error("canvas unavailable");return u.fillStyle="#fff",u.fillRect(0,0,a,e),u.drawImage(n.source,t.x,t.y,t.width,t.height,0,0,a,e),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:r}):new Promise((s,d)=>{o.toBlob(m=>m===null?d(new Error("encode failed")):s(m),"image/jpeg",r)})}var Y=class extends Error{};function Ee(n,t,e){return new Promise((r,a)=>{let o=setTimeout(()=>{a(new Y(`init exceeded ${t}ms`)),n.then(e,()=>{})},t);n.then(u=>{clearTimeout(o),r(u)},u=>{clearTimeout(o),a(u)})})}function Ie(n){let t=$(n),e=t==="overconstrained"?"generic":t;return{kind:e,retryable:e!=="insecure"&&e!=="unsupported"}}function Re(n,t,e,r){let a=n.length===1?n[0]:void 0,o=a===void 0?null:G(a.landmarks,e,r),u=null;if(a!==void 0&&t.pixels!==null){let s=G(a.landmarks,t.width,t.height),d=se(t.pixels);s!==null&&(u=me(d,s))}return{frameWidth:e,frameHeight:r,faces:n.length,geometry:o,matrix:a?.matrix??null,blendshapes:a?.blendshapes??null,stats:u}}function Ke(n,t={},e=()=>"self"){let r=oe(n.tuning,n.tuningVersion),a=Z(),o=t.now??(()=>performance.now()),u=t.setTimer??((i,l)=>setTimeout(i,l)),s=t.clearTimer??(i=>clearTimeout(i)),d=t.grabFrame??Fe(),m=t.encodeRegion??Te,c=t.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),p=t.createLandmarker??ue,M=n.assetBaseUrl??ke,j=te({enabled:n.keepScreenAwake!==!1}),L=ae(r,{policy:n.policy??"reject"}),b=n.video,K=ce({tuning:r.backgroundCheck,assetBaseUrl:M,...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:o}),h="idle",C=null,x=null,E=null,B=!1,f=!1,g=0,z=0,A=[],w="user",O=!1,de=t.canChooseFacing??ee,S=i=>{h===i||f||(h=i,j.setActive(i==="starting"||i==="gating"),a.emit("state",i))},U=()=>{E!==null&&s(E),E=null},I=()=>{U();for(let i of C?.getTracks()??[])i.stop();C=null;try{b.srcObject=null}catch{}},H=i=>{I(),S("error"),a.emit("error",i)},X=()=>{let i=Math.max(o(),z+1);return z=i,i},he=async i=>{let l=d(b,null),{width:P,height:k}=l??N(b);if(l===null||x===null){L.reset();return}let y=x.detect(l.source,X()),v=(y.length===1?y:A.length===1?A:[])[0],F=v===void 0?null:G(v.landmarks,P,k);if(F===null){L.reset();return}let R=re(F,P,k,{margin:r.cropMargin,minWidth:r.resolution.minWidth,minHeight:r.resolution.minHeight}),V=Math.max(r.resolution.minHeight,Math.min(R.height,Le)),pe=await m(l,R,V,Se);if(f||i!==g)return;let J={image:pe,width:Math.round(V*R.width/R.height),height:V,gate:L.summary()};r.tuningVersion!==null&&(J.tuningVersion=r.tuningVersion),U(),S("captured"),a.emit("captured",J)},_=async i=>{if(!(f||i!==g||h!=="gating"||x===null)){if(!B){B=!0;try{let l=d(b,Me);if(l!==null){let{width:P,height:k}=N(b),y=x.detect(l.source,X());A=y;let v=Re(y,l,P||l.width,k||l.height);v.geometry!==null&&r.background.required&&(v.backgroundCheck=K.measure(l,v.geometry.box,P||l.width,k||l.height));let F=L.push(v,o());if(f||i!==g||(a.emit("gate",F),F.ready&&(await he(i),h!=="gating")))return}}catch{}finally{B=!1}}!f&&i===g&&h==="gating"&&(E=u(()=>{_(i)},1e3/r.cadenceHz))}},fe=()=>Ee(p(M),2e4,i=>i.close()),ge=async i=>{if(e()!=="assisted")return"user";let l=i??(O?void 0:n.facing);if(l!==void 0)return l;if(O)return w;try{return await de()?"environment":"user"}catch{return"user"}},D=async i=>{if(f||h==="starting"||h==="gating")return;g+=1;let l=g;L.reset(),S("starting");let P=await ge(i?.facing);if(f||l!==g)return;if(C!==null&&P!==w&&I(),w=P,O=!0,C===null&&t.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){H({kind:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported",retryable:!1});return}let k=x!==null?Promise.resolve(x):fe();k.catch(()=>{});try{if(C===null){let y=await c({video:{facingMode:w,width:{ideal:r.camera.width},height:{ideal:r.camera.height}},audio:!1});if(f||l!==g){for(let v of y.getTracks())v.stop();return}C=y,w=Q(y)??w,b.srcObject=C,b.muted=!0,b.playsInline=!0,await b.play().catch(()=>{})}}catch(y){!f&&l===g&&H(Ie(y));return}try{x=await k}catch{!f&&l===g&&H({kind:"generic",retryable:!0});return}f||l!==g||(S("gating"),_(l))};return{handle:{get state(){return h},get captureMode(){return e()},get facingMode(){return w},on:(i,l)=>a.on(i,l),start:D,retry:()=>{if(!f){if(C!==null&&x!==null&&h!=="error"){g+=1;let i=g;U(),L.reset(),S("gating"),_(i);return}h="idle",D()}},switchCamera:()=>{if(f||e()!=="assisted"||h!=="idle"&&h!=="starting"&&h!=="gating"&&h!=="error")return!1;let i=w==="user"?"environment":"user";return g+=1,I(),w=i,h="idle",D({facing:i}),!0},destroy:()=>{f||(g+=1,I(),j.setActive(!1),f=!0,x?.close(),x=null,K.close(),a.clear())}},setFlowState:i=>{(h==="captured"||h==="uploading"||h==="checking"||h==="done"&&i==="done")&&S(i)}}}function ze(){import("@mediapipe/tasks-vision").catch(()=>{})}export{ye as a,xe as b,se as c,T as d,we as e,ve as f,Ce as g,Pe as h,me as i,Me as j,Le as k,Se as l,Fe as m,Re as n,Ke as o,ze as p};
@@ -0,0 +1 @@
1
+ import{a as Q,d as Z,e as j}from"./chunk-GT2ZLGF7.js";import{w as $}from"./chunk-YZH5PR5R.js";import{c as q}from"./chunk-FUHDOEBP.js";import{f as G}from"./chunk-FHJ7HO3M.js";import{a as N,f as v}from"./chunk-OKWG3PVH.js";var ne=12e4,J=13e4,re=3e3,se=1200,P=Symbol.for("@sekyro/web.preload.v1");function f(){let e=globalThis;return e[P]??(e[P]=new Map),e[P]}function g(e){let n=(e??N).replace(/\/+$/,"");return n===""?"/":n}function X(e){let n=f(),r=n.get(e);return r===void 0&&(r={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},n.set(e,r)),r}function A(e,n){if(e.status!==n){e.status=n;for(let r of[...e.listeners])r(n)}}var x=e=>v({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:ne}),I=x;function ge(e){I=e??x}function he(){for(let e of f().values())e.detector?.destroy();f().clear(),I=x}function oe(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function ie(){return navigator.connection?.saveData===!0}function ae(e){let n=window;if(typeof n.requestIdleCallback=="function"){let s=n.requestIdleCallback(e,{timeout:re});return()=>n.cancelIdleCallback?.(s)}let r=setTimeout(e,se);return()=>clearTimeout(r)}function ce(e,n){let r,s=new Promise(o=>{r=o}),u=!1,l=()=>{},d={promise:s,settle:o=>{u||(u=!0,l(),e.scheduled===d&&(e.scheduled=null),r(o))}};return e.scheduled=d,l=ae(()=>{u||d.settle(R(e,n))}),s}function R(e,n){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;A(e,"loading");let r=new Promise(o=>o(I(n)));e.detectorPromise=r;let s,u=new Promise((o,h)=>{s=setTimeout(()=>{r.then(S=>S.destroy(),()=>{}),h(new Error(`detector preload exceeded ${J} ms`))},J)}),d=Promise.race([r,u]).then(o=>e.detectorPromise!==r?(o.destroy(),e.status):(e.detector=o,A(e,"ready"),"ready"),o=>(e.detectorPromise===r&&(e.detectorPromise=null,e.detector=null,A(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",o)),e.status)).finally(()=>clearTimeout(s));return e.promise=d,e.scheduled?.settle(d),d}function Se(e={}){if(!oe())return Promise.resolve("idle");let n=g(e.assetBaseUrl),r=X(n);return e.respectSaveData===!0&&ie()?Promise.resolve(r.status):(r.status==="loading"||r.status==="ready")&&r.promise!==null?r.promise:e.idle===!0?r.scheduled?.promise??ce(r,n):R(r,n)}function Ce(e){return f().get(g(e))?.status??"idle"}function Le(e,n){let r=X(g(n));return r.listeners.add(e),()=>{r.listeners.delete(e)}}function ye(e){let n=f().get(g(e));n!==void 0&&(n.scheduled?.settle("idle"),n.detector?.destroy(),n.detector=null,n.detectorPromise=null,n.promise=null,A(n,"idle"))}function de(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...n)=>e.detect(...n),destroy:()=>{}}}function Y(e){let n=g(e),r=f().get(n);if(!(r===void 0||r.detector===null&&r.detectorPromise===null&&r.scheduled===null))return async()=>{r.scheduled!==null&&R(r,n);let s=r.promise;for(;r.detector===null&&s!==null&&(await s,r.promise!==s);)s=r.promise;return r.detector!==null?de(r.detector):v({v3AssetBaseUrl:n})}}function ue(e){switch(e){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";default:return null}}function le(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function fe(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;default:{let n=e;return"generic"}}}function pe(e,n={},r,s=()=>"self",u=()=>{}){let l=n.now??(()=>performance.now()),d=n.canChooseFacing??Z,o="user",h=!1,S=t=>(t==="environment"&&!h&&(h=!0,console.warn('[@sekyro/web] facing "environment" ignored: this capture is a self capture (the person films themselves), which uses the front camera only. The back camera is for assisted capture, set in the flow.')),"user"),k=!1,p=s(),c=Q(),H=!G(),U=n.engineOptions,ee=U?.createDetector===void 0&&U?.createWorker===void 0?{createDetector:()=>{let t=Y(e.assetBaseUrl);return t!==void 0?t():v({v3AssetBaseUrl:e.assetBaseUrl})}}:{},B={video:e.video,mode:H?"photo":"clip",rankKeyframes:r,facingMode:void 0,v3AssetBaseUrl:e.assetBaseUrl,screenRamp:()=>p==="self"&&c.count("ramp")>0?u():void 0,...n.engineOptions??{},...ee},i=n.createEngine?.(B)??new $(B),C="idle",L=null,y=0,D=!1,M="full",E=null,b=null,_=0,F=0,K=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(_=e.video.videoWidth,F=e.video.videoHeight)},V=j({enabled:e.keepScreenAwake!==!1}),W=t=>{C=t,V.setActive(t==="starting"||t==="gating"||t==="recording"),c.emit("state",t)},O=()=>c.emit("gate",{progress:y,hint:L,faceDetected:D}),z=()=>{let t=i.animations??"full";t!==M&&(M=t,c.emit("profile",{animations:M}))},te=[i.on("statechange",({state:t})=>{let a=le(t);a==="starting"&&C!=="starting"&&(L=null,y=0,D=!1,E=null,b=null,_=0,F=0),W(a),z(),a==="recording"&&(K(),E=l(),L="hold",y=1,O())}),i.on("checks",t=>{K(),y=t.progress,D=t.factors.presence>0,O(),z()}),i.on("guidance",({key:t})=>{L=ue(t),O()}),i.on("frozen",({previewDataUrl:t})=>{b=l(),c.emit("frozen",{previewDataUrl:t})}),i.on("ramp",t=>c.emit("ramp",t)),i.on("artifacts",t=>{let a=q(),m=E!==null&&b!==null?Math.max(0,Math.round(b-E)):void 0;c.emit("captured",{keyframe:t.keyframe,...t.clip!==void 0?{clip:t.clip}:{},...t.clipMimeType!==void 0?{clipMime:t.clipMimeType}:{},width:e.video.videoWidth||_,height:e.video.videoHeight||F,...m!==void 0?{clipMs:m}:{},captureChannel:a==="desktop"?"desktop":"mobile",formFactor:a,...H?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:i.facingMode,mode:p,...t.timing,...t.screenRamp!==void 0?{screenRamp:t.screenRamp}:{},...t.provenance!==void 0?{provenance:t.provenance}:{}})}),i.on("error",({kind:t,retryable:a})=>{c.emit("error",{kind:fe(t),retryable:a})})];return{handle:{get state(){return C},get captureMode(){return s()},get facingMode(){return i.facingMode??o},on:(t,a)=>c.on(t,a),start:t=>{if(p=s(),p==="self")return S(e.facing),S(t?.facing),k=!0,o="user",i.start({facingMode:"user"});let a=!k;k=!0;let m=t?.facing??(a?e.facing:void 0),T=w=>(o=w,i.start({facingMode:w}));return m!==void 0?T(m):a?d().then(w=>T(w?"environment":"user"),()=>T("user")):i.start({})},retry:()=>i.retry(),switchCamera:()=>s()!=="assisted"?!1:(p="assisted",o=o==="user"?"environment":"user",i.switchCamera(),!0),destroy:()=>{for(let t of te)t();V.setActive(!1),i.destroy(),c.clear()}},setFlowState:t=>{C!==t&&W(t)}}}function Fe(e){return pe(e).handle}export{ne as a,J as b,ge as c,he as d,Se as e,Ce as f,Le as g,ye as h,Y as i,ue as j,le as k,fe as l,pe as m,Fe as n};
@@ -0,0 +1 @@
1
+ function y(){let e=new Map;return{on(i,n){let t=e.get(i);t===void 0&&(t=new Set,e.set(i,t));let r=n;return t.add(r),()=>{t?.delete(r)}},emit(i,n){let t=e.get(i);if(t!==void 0)for(let r of[...t])r(n)},count(i){return e.get(i)?.size??0},clear(){e.clear()}}}async function f(){try{return typeof navigator>"u"||typeof navigator.permissions?.query!="function"?null:await navigator.permissions.query({name:"camera"})}catch{return null}}function u(e){return e==="granted"||e==="prompt"||e==="denied"?e:"unknown"}async function g(){let e=await f();return e===null?"unknown":u(e.state)}function h(e){let i=!1,n=null,t=()=>{!i&&n!==null&&e(u(n.state))};return f().then(r=>{i||(n=r,e(r===null?"unknown":u(r.state)),r?.addEventListener?.("change",t))}),()=>{i=!0,n?.removeEventListener?.("change",t)}}async function b(){if(typeof navigator>"u")return!1;let e=String(navigator.userAgent??"");if(/Android|iPhone|iPad|iPod/i.test(e)||/Macintosh/.test(e)&&(navigator.maxTouchPoints??0)>1)return!0;try{return(await navigator.mediaDevices?.enumerateDevices?.()??[]).filter(n=>n.kind==="videoinput").length>=2}catch{return!1}}function v(){if(typeof navigator>"u"||!("wakeLock"in navigator))return null;let e=navigator.wakeLock;return typeof e?.request=="function"?e:null}function m(){return typeof document>"u"||document.visibilityState==="visible"}function p(e){try{e.release().catch(()=>{})}catch{}}function S(e={}){if(e.enabled===!1)return{setActive:()=>{}};let i=!1,n=null,t=!1,r=!1,l=()=>{if(!i||t||n!==null&&!n.released)return;let o=v();if(o===null||!m())return;let a;try{a=o.request("screen")}catch{return}t=!0,a.then(s=>{if(t=!1,!i){p(s);return}n=s,s.addEventListener?.("release",()=>{n===s&&(n=null)})},()=>{t=!1})},c=()=>{m()&&l()},d=o=>{typeof document>"u"||o===r||(r=o,o?document.addEventListener("visibilitychange",c):document.removeEventListener("visibilitychange",c))};return{setActive:o=>{if(i=o,o){if(v()===null)return;d(!0),l();return}if(d(!1),n!==null){let a=n;n=null,p(a)}}}}export{y as a,g as b,h as c,b as d,S as e};
@@ -0,0 +1 @@
1
+ import{c as b,d as x}from"./chunk-MUVEJRGK.js";var q=new Set(["no_face","media_unreadable","clip_too_short","no_face_source","side_missing","unreadable","registry_unavailable","otp_mismatch","otp_expired","otp_send_failed","document_type_not_accepted","age_unverifiable","nationality_unreadable","liveness_inconclusive","match_inconclusive","document_authenticity","probe_not_from_liveness","capture_back_camera","capture_not_upright","chip_read_failed","chip_access_denied","chip_parse_failed","icao_pose","icao_eyes","icao_mouth","icao_occlusion","icao_lighting","icao_background","icao_resolution","portrait_not_from_liveness","nni_recheck","device_integrity_failed","eid_identifier_invalid","eid_code_invalid","eid_code_expired","eid_unavailable","eid_resend_too_soon"]),U={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function f(e){return e.plan?.steps??[]}function M(e){return Math.max(0,e.attempts.max-e.attempts.used)}function Y(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}function pe(e){let t=Y(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(o=>U[o.service]).filter(o=>o!==void 0),i=t.options.find(o=>o.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}var D=new Set(["liveness","face_match"]);function v(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function A(e){return e.status!=="created"&&e.status!=="in_progress"}function P(e){let t=e.plan?.current,n=t==null?void 0:f(e).find(i=>i.id===t);return v(n)?n:void 0}function S(e,t){return f(e).find(n=>n.checkType===t)}function y(e){let t=f(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,o)=>o>n&&i.checkType==="face_match")}function H(e,t){let n=S(t,"liveness")?.state,i=y(t)?.state;return(y(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}function V(e,t){let n=new Map(f(e).map(i=>[i.id,i.state]));return f(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}function k(e,t){return t===void 0?{sessionId:e,status:"unavailable"}:{sessionId:e,status:"unavailable",reason:t}}function _(e,t,n){return n===void 0?{sessionId:e,status:t}:{sessionId:e,status:t,reason:n}}function me(e,t){let{sessionId:n}=e;switch(e.status){case"completed":case"failed":case"review_pending":return j(e,$(e));case"expired":return k(n);case"created":case"in_progress":break;default:{let i=e.status;throw new Error(`mapSessionResult: unhandled status ${i}`)}}return X(e,t)}var B=new Set([0,1,2,3]);function j(e,t){return B.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),typeof e.subjectId=="string"&&e.subjectId.length>0&&(t.subjectId=e.subjectId),t}function $(e){let{sessionId:t}=e;switch(e.status){case"completed":return e.outcome==="approved"?{sessionId:t,status:"approved"}:e.outcome==="review"?_(t,"review",h(e,"review")):_(t,"rejected",h(e,"failed"));case"failed":{let n=_(t,"rejected",e.failureReason??h(e,"failed"));return e.failureReason==="device_cooldown"&&e.retryAfter!==void 0&&(n.retryAfter=e.retryAfter),n}default:return _(t,"review",h(e,"review"))}}function z(e,t){if(t===void 0)return!1;let n=f(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}function X(e,t){let{sessionId:n}=e,i=f(e).find(s=>D.has(s.checkType)&&s.state==="input_required"&&s.reason!==void 0);if(i?.reason==="mobile_required")return k(n,"mobile_required");if(i?.reason!==void 0){let s=t.autoRetry&&M(i)>0&&(q.has(i.reason)||z(i,t.previous)),c={sessionId:n,status:s?"retry":"rejected",reason:i.reason,attemptsRemaining:M(i)};return i.retakeHint!==void 0&&(c.retakeHint=i.retakeHint),c}let o=P(e);return o===void 0&&f(e).some(s=>s.state==="review")?_(n,"review",h(e,"review")):o?.checkType==="portrait_icao"?k(n,"portrait_required"):k(n)}function h(e,t){let n=f(e).filter(i=>i.state===t&&i.reason!==void 0);return n[t==="failed"?n.length-1:0]?.reason}function I(e,t,n,i,o){return e.presignCapture!==void 0?e.presignCapture(t,n,i,o):e.presign(t,n,i)}function L(e){return{engine:e?.engine,durationMs:e?.clipMs}}var W=["video/webm","video/mp4"],T="image/jpeg",G=2,J=1e3,Q=1e4,Z=3,ee=10,te=30,ne=3,ie=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),oe=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path"]),g=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}};function se(e){let t=y(e);return S(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?v(t):e.capture?.livePhoto?.oneCapture===!0)}var w=class extends Error{constructor(t){super(t),this.name="AttestationError"}};async function F(e,t,n={}){let i=e.uuid(),o=!1,s=!1,c=0,u=0;for(;;)try{return await t(e.client,i)}catch(r){if(r instanceof w){if(s)throw r;s=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(r instanceof b))throw r;if(r.code==="consent_required"&&!o){o=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(r.code==="attestation_invalid"&&!s){s=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(r.code==="inference_unavailable"&&u<Z){u+=1;let a=Math.min(r.retryAfterSeconds??ee,te);e.onBusy?.({attempt:u,retryAfterSeconds:a}),await e.sleep(a*1e3),n.onAttestationInvalid?.(),i=e.uuid();continue}if(ie.has(r.code)&&c<G){c+=1;let a=r.retryAfterSeconds!==void 0?r.retryAfterSeconds*1e3:void 0;await e.sleep(a!==void 0?Math.min(a,Q):J);continue}throw r}}var re=new Set(["passed","review","processing","skipped"]);async function ge(e){let{artifacts:t}=e,n=t.clip,i=x(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!W.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let o=ae(e,t.keyframe),s=ce(e,n,i,o),c=ue(e,o),u=!1,r=new Set,a=!0,m=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let l=e.getView();if(A(l))return{kind:"settled"};let R=P(l),E=R?.checkType,C=E==="liveness"&&!u?"liveness":E==="face_match"&&!r.has(R?.id)&&r.size<2&&a?"face_match":null;if(C===null)return{kind:"settled"};if(C==="liveness"&&t.captureChannel==="desktop"&&S(l,"liveness")?.requiresMobile===!0)return{kind:"unavailable",reason:"mobile_required"};try{if(C==="liveness"){u=!0;let d=await s();if(e.isCancelled())return{kind:"cancelled"};H(l,d)&&r.add(y(d)?.id);for(let N of V(l,d))r.add(N);await e.applySubmit(d,"liveness");let p=S(e.getView(),"liveness")?.state;a=p===void 0||re.has(p)}else{r.add(R?.id);let d=await c();if(e.isCancelled())return{kind:"cancelled"};for(let p of V(l,d))r.add(p);await e.applySubmit(d,"face_match")}}catch(d){if(e.isCancelled()||d instanceof g)return{kind:"cancelled"};let p=fe(d);if(p.kind!=="resync"||m>=ne)return p;m+=1,await e.refreshView()}}}function ae(e,t){let n=null,i=null,o=()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let s=await I(e.client,"image",T,t.size,L(e.artifacts));return await e.client.uploadToSpaces(s.uploadUrl,t,T),n=(await e.client.completeMedia(s.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i);return{ensure:o,attempt:()=>o().catch(()=>null),current:()=>n}}function ce(e,t,n,i){let o=null,s,c=null;return()=>F(e,async(u,r)=>{if(o===null||s===void 0){if(e.isCancelled())throw new g;s===void 0&&!se(e.getView())&&(s=null),e.onPhase("uploading");let[a,m]=await Promise.all([o!==null?Promise.resolve(o):(async()=>{let l=await I(u,"clip",n,t.size,L(e.artifacts));return await u.uploadToSpaces(l.uploadUrl,t,n),(await u.completeMedia(l.key)).key})(),s!==void 0?Promise.resolve(s===null?null:s.imageKey):i.attempt()]);o=a,s===void 0&&(s=m===null?null:{imageKey:m})}if(c===null)try{c=await e.getAttestation()}catch(a){throw new w(a instanceof Error?a.message:String(a))}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:o,attestation:c,captureChannel:e.artifacts.captureChannel,capture:de(e.artifacts),...s!==null?{faceMatch:s}:{}},{idempotencyKey:r})},{onAttestationInvalid:()=>{c=null}})}function ue(e,t){return()=>F(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new g;e.onPhase("uploading")}let o=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:o},{idempotencyKey:i})})}function de(e){let t={width:e.width,height:e.height};for(let n of le)e[n]!==void 0&&(t[n]=e[n]);return t}var le=["engine","facingMode","mode","formFactor","clipMs","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function fe(e){if(e instanceof w)return{kind:"unavailable",reason:"attestation"};if(e instanceof b){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(oe.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var O=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},K=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}};function Re(e){let t=e?.capture;return t?.mode==="assisted"||t?.mode==="self"?t.mode:t?.cameraSwitch===!0?"assisted":"self"}export{Re as a,q as b,U as c,f as d,M as e,Y as f,pe as g,v as h,A as i,P as j,S as k,k as l,me as m,I as n,W as o,G as p,J as q,Z as r,ee as s,w as t,F as u,ge as v,O as w,K as x};
@@ -0,0 +1 @@
1
+ import{a as p}from"./chunk-4IVRXJR2.js";var _=["session_token_invalid","session_token_required","session_token_session_mismatch","session_not_found","rate_limit_exceeded","consent_required","session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_type_unsupported","force_outcome_forbidden","attestation_invalid","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_locked","document_nni_mismatch","media_content_type_not_allowed","media_too_large","media_key_invalid","media_key_forbidden","media_not_found","media_unreadable","media_session_invalid","idempotency_key_collision","idempotency_in_progress","idempotency_key_required","validation_error","internal_error","unknown_error","upload_failed","network_error","timeout","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active","sekyro_app_not_allowed","sekyro_app_unverified"];function v(s){return _.includes(s)}var d=class extends Error{constructor(e){super(e.message),this.name="HostedApiError",this.status=e.status,this.code=e.code,e.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds),e.details&&(this.details=e.details)}};var g=6e4,m=4,b=3e4,T=9e5,w=200,k=5,S=400;function l(s){return(s.split(";")[0]??"").trim()}var P={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},f=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(t,i)=>(n??globalThis.fetch).call(globalThis,t,i),this.requestTimeoutMs=e.requestTimeoutMs??b,this.retryAttempts=e.inProgressRetry?.attempts??k,this.retryDelayMs=e.inProgressRetry?.delayMs??S}async getSession(){let e=await this.api("GET","/hosted/session");return this.sessionId=e.sessionId,e}async recordConsent(e){return this.api("POST","/hosted/consent",{body:{locale:e}})}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async choose(e,n){let t=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n}});return this.sessionId=t.sessionId,t}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,n,t){let i=await this.ensureSessionId(),o={kind:e,contentType:l(n),contentLength:t};return this.api("POST",`/sessions/${i}/media`,{body:o})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,t,i={}){let o=await this.ensureSessionId(),r=await this.takeCaptureNonce(),c=r===void 0?void 0:{nonce:r,...i.engine!==void 0?{engine:i.engine.slice(0,32)}:{},...i.durationMs!==void 0&&Number.isFinite(i.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(i.durationMs)))}:{}},a={kind:e,contentType:l(n),contentLength:t,capture:c};return this.api("POST",`/sessions/${o}/media`,{body:a})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(t=>t.expiresAt-g>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let t=e();if(t!==void 0)return t;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),t=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(m,Math.max(1,e))}}),i=Date.now()+Math.max(0,t.expiresIn)*1e3;for(let o of Array.isArray(t.nonces)?t.nonces:[])typeof o=="string"&&o.length>0&&this.captureNonces.push({nonce:o,expiresAt:i});this.captureNonces=this.captureNonces.slice(-m)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,t){let i;try{i=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(t)},body:n,signal:AbortSignal.timeout(T)})}catch(o){throw y(o)}if(!i.ok){let o=(await i.text().catch(()=>"")).slice(0,w);throw new d({status:i.status,code:"upload_failed",message:`media upload failed (HTTP ${i.status})${o?`: ${o}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,t={}){let i=await this.ensureSessionId(),o={input:n,forceOutcome:t.forceOutcome};return this.api("POST",`/sessions/${i}/checks/${e}`,{body:o,idempotencyKey:t.idempotencyKey})}async uploadAndSubmit(e,n,t,i={}){let o=l(n.contentType),r=await this.presign(n.kind,o,n.blob.size);await this.uploadToSpaces(r.uploadUrl,n.blob,o);let c=await this.completeMedia(r.key),a={...t,[P[e]]:c.key};return this.submitCheck(e,a,i)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(e,n,t={}){let i=`${this.apiOrigin}/api/v2${n}`,o={"x-session-token":this.sessionToken};t.body!==void 0&&(o["content-type"]="application/json"),t.idempotencyKey!==void 0&&(o["x-idempotency-key"]=t.idempotencyKey);try{let r=p.timezone();r!==void 0&&(o["sekyro-client-timezone"]=r)}catch{}try{let r=await p.deviceHeader();r!==void 0&&(o["sekyro-client-device"]=r)}catch{}for(let r=0;;r++){let c;try{c=await this.fetchImpl(i,{method:e,headers:o,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(u){throw y(u)}if(c.ok){if(t.blob===!0)try{return await c.blob()}catch(h){throw y(h)}let u;try{u=await c.json()}catch{throw new d({status:c.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${c.status})`})}return C(u)}let a=await I(c);if(a.code==="idempotency_in_progress"&&r<this.retryAttempts){this.retryDelayMs>0&&await M(this.retryDelayMs);continue}throw a}}};function y(s){if((typeof s=="object"&&s!==null?s.name:void 0)==="TimeoutError")return new d({status:0,code:"timeout",message:"request timed out"});let n=s instanceof Error?s.message:String(s);return new d({status:0,code:"network_error",message:`network request failed: ${n}`})}function C(s){return s!==null&&typeof s=="object"&&"success"in s&&"data"in s?s.data:s}async function I(s){let e="unknown_error",n=`request failed (HTTP ${s.status})`,t=Number.NaN,i;try{let c=await s.json();if(c!==null&&typeof c=="object"){let a=c;typeof a.code=="string"&&a.code.length>0&&(e=a.code),typeof a.message=="string"&&a.message.length>0&&(n=a.message),typeof a.retryAfterSeconds=="number"&&(t=a.retryAfterSeconds),Array.isArray(a.details?.issues)&&(i=a.details)}}catch{}let o=s.headers.get("retry-after"),r=o===null?Math.floor(t):Number.parseInt(o,10);return new d({status:s.status,code:e,message:n,...Number.isFinite(r)&&r>=0?{retryAfterSeconds:r}:{},details:i})}function M(s){return new Promise(e=>setTimeout(e,s))}function N(s){let e=s?.portrait,n=e?.icao,t=e?.purpose==="id_document";return n==null?t?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"&&!t?"alert":"reject",profile:t||n.profile==="id_document"?"id_document":"selfie"}}function H(s){return{...s.baselineEyeOpenness!==void 0?{baselineEyeOpenness:s.baselineEyeOpenness}:{},criteria:s.verdict??{},...s.backgroundCheck!==void 0?{backgroundCheck:s.backgroundCheck}:{}}}export{_ as a,v as b,d as c,l as d,f as e,N as f,H as g};