@sekyro/web 0.1.0-rc.1 → 0.1.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +213 -0
- package/LICENSE +25 -16
- package/README.md +105 -61
- package/THIRD-PARTY-NOTICES.txt +154 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/capture-constraints-B5omafmk.d.cts +44 -0
- package/dist/capture-constraints-B5omafmk.d.ts +44 -0
- package/dist/capture-session-doc-GK6G7JOI.js +1 -0
- package/dist/{capture-session-v3-CAoWM8iT.d.cts → capture-session-v3-CmJw_bK0.d.cts} +141 -13
- package/dist/{capture-session-v3-BJ8ciaWl.d.ts → capture-session-v3-DGG2stO6.d.ts} +141 -13
- package/dist/chunk-3MSUJYBO.js +1 -0
- package/dist/chunk-7ZCZY3ZP.js +1 -0
- package/dist/chunk-A3FUGHAH.js +2 -0
- package/dist/chunk-BAGSM67V.js +1 -0
- package/dist/chunk-BPE5NSQ2.js +1 -0
- package/dist/chunk-CJHMFPL6.js +1 -0
- package/dist/chunk-DFTCAWMP.js +1 -0
- package/dist/chunk-DK5YPBDQ.js +1 -0
- package/dist/chunk-ETY6SAAZ.js +1 -0
- package/dist/chunk-FFDB6LQN.js +1 -0
- package/dist/chunk-FHJ7HO3M.js +1 -0
- package/dist/chunk-FPXL63KZ.js +1 -0
- package/dist/chunk-FUHDOEBP.js +1 -0
- package/dist/chunk-G6LKLN4U.js +1 -0
- package/dist/chunk-GI3UFGRQ.js +1 -0
- package/dist/chunk-HAO6EQTH.js +1 -0
- package/dist/chunk-HWAXEQD5.js +1 -0
- package/dist/chunk-MXWLCDFX.js +1 -0
- package/dist/chunk-O5WKNZ2C.js +1 -0
- package/dist/chunk-OKWG3PVH.js +1 -0
- package/dist/chunk-POIQGEZM.js +1 -0
- package/dist/chunk-RI3E7GBN.js +1 -0
- package/dist/chunk-SEC64KZ3.js +1 -0
- package/dist/chunk-SMKCBUJL.js +1 -0
- package/dist/chunk-SXZCL5NO.js +1 -0
- package/dist/chunk-SZ7YGNUZ.js +1 -0
- package/dist/chunk-TDLIXFDT.js +1 -0
- package/dist/chunk-UGMHAFEY.js +1 -0
- package/dist/chunk-WKJJEPWA.js +1 -0
- package/dist/chunk-XR64UFLK.js +1 -0
- package/dist/client/index.cjs +1 -357
- package/dist/client/index.d.cts +35 -3
- package/dist/client/index.d.ts +35 -3
- package/dist/client/index.js +1 -15
- package/dist/core/index.cjs +1 -1605
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -139
- package/dist/core/ocr/worker.bundle.js +42 -0
- package/dist/core/ocr/worker.cjs +42 -0
- package/dist/core/ocr/worker.d.cts +84 -0
- package/dist/core/ocr/worker.d.ts +84 -0
- package/dist/core/ocr/worker.js +41 -0
- package/dist/core/v3/detect-worker.cjs +1 -392
- package/dist/core/v3/detect-worker.d.cts +1 -1
- package/dist/core/v3/detect-worker.d.ts +1 -1
- package/dist/core/v3/detect-worker.js +1 -13
- package/dist/create-document-capture-IGUQP2NS.js +1 -0
- package/dist/create-portrait-capture-RJSFY37D.js +1 -0
- package/dist/create-verification-Bb20j6zk.d.ts +2968 -0
- package/dist/create-verification-CtqF4A9W.d.cts +2968 -0
- package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
- package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
- package/dist/detector-scanic-YCDNLCGV.js +1 -0
- package/dist/icao-gate-PWBMKRGC.js +1 -0
- package/dist/icao-gate-terzKYD7.d.cts +1770 -0
- package/dist/icao-gate-terzKYD7.d.ts +1770 -0
- package/dist/icao-tuning-4GGVX6B4.js +1 -0
- package/dist/index.cjs +1 -2580
- package/dist/index.d.cts +73 -5
- package/dist/index.d.ts +73 -5
- package/dist/index.js +1 -28
- package/dist/internal/index.cjs +1 -4110
- package/dist/internal/index.d.cts +353 -322
- package/dist/internal/index.d.ts +353 -322
- package/dist/internal/index.js +1 -647
- package/dist/keyframe-rank-YAJLYJYF.js +1 -0
- package/dist/landmarker-KB7LVXAU.js +1 -0
- package/dist/mrz-band-VYHOTDHY.js +1 -0
- package/dist/plan-runner-QCK2SOGS.js +1 -0
- package/dist/popup/index.cjs +1 -76
- package/dist/popup/index.js +1 -11
- package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
- package/dist/segmenter-USLNBX65.js +1 -0
- package/dist/turnstile-FATNZ4AG.js +1 -0
- package/package.json +25 -10
- package/sbom.cdx.json +195 -0
- package/dist/capture-constraints-BujkZcfb.d.cts +0 -21
- package/dist/capture-constraints-BujkZcfb.d.ts +0 -21
- package/dist/chunk-LOTAJDRE.js +0 -1094
- package/dist/chunk-LOTAJDRE.js.map +0 -1
- package/dist/chunk-MWNFSNMP.js +0 -52
- package/dist/chunk-MWNFSNMP.js.map +0 -1
- package/dist/chunk-NILNKLK6.js +0 -50
- package/dist/chunk-NILNKLK6.js.map +0 -1
- package/dist/chunk-NU4YOLCN.js +0 -796
- package/dist/chunk-NU4YOLCN.js.map +0 -1
- package/dist/chunk-NWF46H7K.js +0 -359
- package/dist/chunk-NWF46H7K.js.map +0 -1
- package/dist/chunk-WY6U7AIK.js +0 -193
- package/dist/chunk-WY6U7AIK.js.map +0 -1
- package/dist/chunk-YVFF4Q4G.js +0 -327
- package/dist/chunk-YVFF4Q4G.js.map +0 -1
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/v3/detect-worker.cjs.map +0 -1
- package/dist/core/v3/detect-worker.js.map +0 -1
- package/dist/create-verification--ldwakXV.d.cts +0 -341
- package/dist/create-verification-BlAPWeW5.d.ts +0 -341
- package/dist/detector-scanic-4C6IEW2K.js +0 -787
- package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
- package/dist/hosted-client-BpvBqu9f.d.cts +0 -408
- package/dist/hosted-client-BpvBqu9f.d.ts +0 -408
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/index.cjs.map +0 -1
- package/dist/internal/index.js.map +0 -1
- package/dist/popup/index.cjs.map +0 -1
- package/dist/popup/index.js.map +0 -1
- package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
- package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-
|
|
1
|
+
import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-DclNxkZT.js';
|
|
2
2
|
|
|
3
3
|
/** MP4-first ladder: one container (H.264 MP4) covers iOS/macOS Safari + Chrome 130+.
|
|
4
4
|
* WebM/VP9→VP8 only as the Firefox/older-Chromium fallback. */
|
|
@@ -105,16 +105,35 @@ interface GateChecks {
|
|
|
105
105
|
goodQuality: boolean;
|
|
106
106
|
stable: boolean;
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Client-side capture timing (face-capture duration, 2026-10-17), measured
|
|
110
|
+
* by the engine with its monotonic clock (`performance.now()` by default) and
|
|
111
|
+
* rounded to whole milliseconds. All fields are optional: a phase that never
|
|
112
|
+
* happened (e.g. no face ever detected before a retry) is simply absent.
|
|
113
|
+
*/
|
|
114
|
+
interface CaptureTiming {
|
|
115
|
+
/** `getUserMedia` call → stream attached and the preview playing. */
|
|
116
|
+
cameraReadyMs?: number;
|
|
117
|
+
/** Camera ready → the first tick on which the GATE accepted the face
|
|
118
|
+
* (present + size / centering / quality good enough to make progress —
|
|
119
|
+
* not merely detected). */
|
|
120
|
+
faceAcquireMs?: number;
|
|
121
|
+
/** FIRST accepted face → gate progress 100 % (capture complete, BEFORE the
|
|
122
|
+
* clip window / upload). A face lost and re-acquired keeps the first start. */
|
|
123
|
+
captureMs?: number;
|
|
124
|
+
}
|
|
108
125
|
/** Capture output. Upload is NOT the engine's job — hosts submit these themselves. */
|
|
109
126
|
interface CaptureArtifacts {
|
|
110
127
|
/** Absent in photo mode. */
|
|
111
128
|
clip?: Blob;
|
|
112
129
|
/** Container mime the clip finalized with. Absent in photo mode. */
|
|
113
130
|
clipMimeType?: string;
|
|
114
|
-
/**
|
|
131
|
+
/** JPEG keyframe (captureMirroredKeyframe): mirrored on the front camera, as the sensor sees it on the back one. */
|
|
115
132
|
keyframe: Blob;
|
|
116
133
|
/** JPEG data URL of the keyframe canvas (v1 preview, quality 0.92). */
|
|
117
134
|
previewDataUrl: string;
|
|
135
|
+
/** Capture-phase timing of the attempt that produced these artifacts. */
|
|
136
|
+
timing?: CaptureTiming;
|
|
118
137
|
}
|
|
119
138
|
interface CaptureSessionEvents {
|
|
120
139
|
statechange: {
|
|
@@ -167,12 +186,13 @@ interface V3GateThresholds {
|
|
|
167
186
|
/** Velocities at/below this (IOD/s) count as stillness — absorbs detector
|
|
168
187
|
* box jitter (largest on LOW's 128px input) before it reaches the EMA. */
|
|
169
188
|
MOTION_DEADBAND_IOD_PER_S: number;
|
|
170
|
-
/** ready = p ≥ 1 AND
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
189
|
+
/** ready = p ≥ 1 AND no bad tick (q < Q_GOOD) left in this window after
|
|
190
|
+
* TRIMMING: with ≥3 samples the single worst is dropped, so one flaky tick
|
|
191
|
+
* (5 Hz LOW cadence = only 2–3 samples per window) cannot veto an
|
|
192
|
+
* otherwise-ready user, while a SECOND bad tick (a real sustained wobble)
|
|
193
|
+
* still blocks. The readiness bar is Q_GOOD itself — the level the
|
|
194
|
+
* integrator rises on — so any input that fills the ring also fires it. */
|
|
174
195
|
READY_WINDOW_MS: number;
|
|
175
|
-
READY_MEAN_Q: number;
|
|
176
196
|
/** Per-factor guidance trigger levels (lowest failing factor speaks). */
|
|
177
197
|
GUIDE_SIZE: number;
|
|
178
198
|
GUIDE_CENTERING: number;
|
|
@@ -215,8 +235,12 @@ interface V3GateTick {
|
|
|
215
235
|
factors: Record<V3GateFactor, number>;
|
|
216
236
|
/** fcv3.* message key for the lowest failing factor (host translates). */
|
|
217
237
|
guidanceKey: string;
|
|
218
|
-
/** Fire signal: p ≥ 1 AND
|
|
238
|
+
/** Fire signal: p ≥ 1 AND no second bad tick (q < Q_GOOD) in READY_WINDOW_MS. */
|
|
219
239
|
ready: boolean;
|
|
240
|
+
/** The face on THIS tick is ACCEPTED by the gate — present and every factor
|
|
241
|
+
* (size, centering, pose, sharpness, exposure, motion) good enough that the
|
|
242
|
+
* integrator RISES (q ≥ Q_GOOD). The engine's "first accepted face" mark. */
|
|
243
|
+
accepted: boolean;
|
|
220
244
|
}
|
|
221
245
|
declare class FaceGateV3 {
|
|
222
246
|
private readonly t;
|
|
@@ -288,6 +312,41 @@ declare class DeviceProfiler {
|
|
|
288
312
|
record(detectMs: number): DeviceClass;
|
|
289
313
|
}
|
|
290
314
|
|
|
315
|
+
/** Why a gate tick did not advance: no face, or the weakest gate check. */
|
|
316
|
+
type GateBlockReason = "no_face" | Exclude<V3GateFactor, "presence">;
|
|
317
|
+
interface GateBlockEntry {
|
|
318
|
+
/** Ticks blocked by this reason. */
|
|
319
|
+
count: number;
|
|
320
|
+
/** Wall time (whole ms) those ticks covered. */
|
|
321
|
+
ms: number;
|
|
322
|
+
}
|
|
323
|
+
interface GateBlockSummary {
|
|
324
|
+
/** Only the reasons that blocked at least once. */
|
|
325
|
+
blocked: Partial<Record<GateBlockReason, GateBlockEntry>>;
|
|
326
|
+
/** Wall time (whole ms) of ticks the gate accepted (progress rising). */
|
|
327
|
+
acceptedMs: number;
|
|
328
|
+
/** Total ticks seen. */
|
|
329
|
+
ticks: number;
|
|
330
|
+
}
|
|
331
|
+
/** The reason one tick was held back, or null when the gate accepted it. */
|
|
332
|
+
declare function blockReasonOf(tick: Pick<V3GateTick, "accepted" | "factors">): GateBlockReason | null;
|
|
333
|
+
declare class GateBlockStats {
|
|
334
|
+
private blocked;
|
|
335
|
+
private acceptedMs;
|
|
336
|
+
private ticks;
|
|
337
|
+
private lastAt;
|
|
338
|
+
/** Record one gate tick; the time since the previous tick is charged to THIS tick's state. */
|
|
339
|
+
record(tick: Pick<V3GateTick, "at" | "accepted" | "factors">): void;
|
|
340
|
+
summary(): GateBlockSummary;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** A non-final `gate` telemetry snapshot at most this often while positioning
|
|
344
|
+
* (so an abandoned attempt still reports where its time went). */
|
|
345
|
+
declare const GATE_SNAPSHOT_MS = 1000;
|
|
346
|
+
/** Guidance key while a phone shows a landscape camera frame (the upright guard). */
|
|
347
|
+
declare const HOLD_UPRIGHT_KEY = "fcv3.hold_upright";
|
|
348
|
+
/** How often the upright guard re-reads the frame size while the clip records (plus every `resize` event). */
|
|
349
|
+
declare const UPRIGHT_WATCH_MS = 200;
|
|
291
350
|
/** Best-of-N keyframe window: up to 4 candidates over the first 600ms. */
|
|
292
351
|
declare const KEYFRAME_CANDIDATES = 4;
|
|
293
352
|
declare const KEYFRAME_WINDOW_MS = 600;
|
|
@@ -339,10 +398,39 @@ type V3TelemetryEvent = {
|
|
|
339
398
|
timeToGateMs: number;
|
|
340
399
|
degradeCount: number;
|
|
341
400
|
meanDetectMs: number;
|
|
342
|
-
}
|
|
401
|
+
}
|
|
402
|
+
/** Where the attempt's gate time went (see gate-blocking.ts): per-reason
|
|
403
|
+
* blocked tick counts + ms, accepted ms, and the ACTIVE device class /
|
|
404
|
+
* cadence after any dynamic profile adjustment. `final` on the attempt's
|
|
405
|
+
* end (fired / error / retry / destroy); throttled snapshots before it. */
|
|
406
|
+
| ({
|
|
407
|
+
type: "gate";
|
|
408
|
+
final: boolean;
|
|
409
|
+
activeClass: DeviceClass;
|
|
410
|
+
cadenceHz: number;
|
|
411
|
+
} & GateBlockSummary) | {
|
|
343
412
|
type: "error";
|
|
344
413
|
kind: CaptureErrorKind;
|
|
345
414
|
fallbackReason?: string;
|
|
415
|
+
}
|
|
416
|
+
/** Keyframe ranking (SDK spec §4.8a; only when `rankKeyframes` is on): the
|
|
417
|
+
* rank numbers of every candidate (never an image), the chosen index, the
|
|
418
|
+
* index sharpness alone would have chosen, and the extra detector time. */
|
|
419
|
+
| {
|
|
420
|
+
type: "keyframe";
|
|
421
|
+
tier: Detector["tier"] | null;
|
|
422
|
+
chosen: number;
|
|
423
|
+
sharpest: number;
|
|
424
|
+
detectMs: number;
|
|
425
|
+
candidates: Array<{
|
|
426
|
+
face: boolean;
|
|
427
|
+
frontal: number;
|
|
428
|
+
yaw?: number;
|
|
429
|
+
roll?: number;
|
|
430
|
+
eyes?: number;
|
|
431
|
+
score: number;
|
|
432
|
+
sharpness: number;
|
|
433
|
+
}>;
|
|
346
434
|
};
|
|
347
435
|
interface KeyframeCandidate {
|
|
348
436
|
blob: Blob;
|
|
@@ -381,7 +469,7 @@ interface CaptureSessionV3Options {
|
|
|
381
469
|
createRecorder?: () => Pick<ClipRecorder, "record" | "stop">;
|
|
382
470
|
/** (navigator.mediaDevices.getUserMedia) */
|
|
383
471
|
getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
|
|
384
|
-
/** (
|
|
472
|
+
/** (canvas keyframe, mirrored on the front camera only, + downscaled Laplacian sharpness) */
|
|
385
473
|
captureKeyframe?: (video: HTMLVideoElement) => Promise<KeyframeCandidate>;
|
|
386
474
|
/** (downscaled face-crop sharpness/exposure via canvas) */
|
|
387
475
|
measureQuality?: (video: HTMLVideoElement, box: {
|
|
@@ -398,13 +486,28 @@ interface CaptureSessionV3Options {
|
|
|
398
486
|
* worker-side through WorkerDetectorProxy. Hosts own Worker construction
|
|
399
487
|
* (bundler-specific `new Worker(new URL(...))`). */
|
|
400
488
|
createWorker?: () => WorkerLike;
|
|
489
|
+
/** Keyframe ranking switch (SDK spec §4.8a; server tuning
|
|
490
|
+
* `capture.liveness.keyframe.rank`, default off): read when positioning
|
|
491
|
+
* starts (prefetches the lazy ranker) and again when the capture fires.
|
|
492
|
+
* Off → today's sharpest-of-N, byte for byte. */
|
|
493
|
+
rankKeyframes?: () => boolean;
|
|
401
494
|
/** INERT (Phase 3 escalation seam — see EscalationHook). Accepted and
|
|
402
495
|
* retained, never called in Phases 1–2. */
|
|
403
496
|
escalation?: EscalationHook;
|
|
497
|
+
/** Upright guard (spec 2026-10-28 §4.2): the device is a phone, so a landscape frame (videoWidth > videoHeight)
|
|
498
|
+
* holds the gate and drops a clip being recorded (or the keyframes of a photo-mode capture). Read at each attempt
|
|
499
|
+
* start. (detectFormFactor() === 'phone' — desktop webcams are landscape by nature, and a tablet may stand in
|
|
500
|
+
* landscape on a stand: neither is ever guarded) */
|
|
501
|
+
isPhone?: () => boolean;
|
|
404
502
|
/** (performance.now) */
|
|
405
503
|
now?: () => number;
|
|
406
504
|
}
|
|
407
505
|
type Handler<K extends keyof CaptureSessionV3Events> = (payload: CaptureSessionV3Events[K]) => void;
|
|
506
|
+
/** Per-start options (the public handle's `start({ facing })`). */
|
|
507
|
+
interface CaptureSessionV3StartOptions {
|
|
508
|
+
/** Camera for this attempt AND later retries; absent → keep the current one. */
|
|
509
|
+
facingMode?: "user" | "environment";
|
|
510
|
+
}
|
|
408
511
|
declare class CaptureSessionV3 {
|
|
409
512
|
private readonly options;
|
|
410
513
|
private readonly handlers;
|
|
@@ -418,14 +521,25 @@ declare class CaptureSessionV3 {
|
|
|
418
521
|
private profiler;
|
|
419
522
|
private lastGuidanceKey;
|
|
420
523
|
private positioningStartedAt;
|
|
524
|
+
private cameraRequestedAt;
|
|
525
|
+
private cameraReadyAt;
|
|
526
|
+
private faceAcquiredAt;
|
|
527
|
+
private captureCompleteAt;
|
|
421
528
|
private fired;
|
|
422
529
|
private carriedDegrade;
|
|
423
530
|
private carriedMeans;
|
|
531
|
+
private blockStats;
|
|
532
|
+
private lastGateSnapshotAt;
|
|
533
|
+
/** The upright guard applies to this attempt (a phone). */
|
|
534
|
+
private uprightGuard;
|
|
424
535
|
constructor(options: CaptureSessionV3Options);
|
|
425
536
|
get state(): CaptureState;
|
|
426
537
|
on<K extends keyof CaptureSessionV3Events>(event: K, handler: Handler<K>): () => void;
|
|
427
538
|
private emit;
|
|
428
|
-
start(): Promise<void>;
|
|
539
|
+
start(options?: CaptureSessionV3StartOptions): Promise<void>;
|
|
540
|
+
/** The camera of the current attempt: the one its track reports once the stream is live, else the requested one
|
|
541
|
+
* (start option, switchCamera toggles). */
|
|
542
|
+
get facingMode(): "user" | "environment";
|
|
429
543
|
/** Full reset + camera restart — the documented recovery path (v1 parity). */
|
|
430
544
|
retry(): void;
|
|
431
545
|
switchCamera(): void;
|
|
@@ -436,10 +550,22 @@ declare class CaptureSessionV3 {
|
|
|
436
550
|
private startScheduler;
|
|
437
551
|
private detectTick;
|
|
438
552
|
private fire;
|
|
439
|
-
/**
|
|
553
|
+
/** A phone showing a landscape frame: the guard holds the gate. */
|
|
554
|
+
private isLandscape;
|
|
555
|
+
/** Positioning on a sideways phone: no detection, the gate restarts from zero and the coaching says why. */
|
|
556
|
+
private holdUpright;
|
|
557
|
+
/** While the clip records (or, `recorder` null, the photo-mode keyframes are taken): a rotation to landscape aborts
|
|
558
|
+
* it. Returns the unwatch function. */
|
|
559
|
+
private watchRotation;
|
|
560
|
+
/** Drop the clip being recorded (or the photo-mode keyframes being taken; same stream, same detector) and go back to
|
|
561
|
+
* positioning with the upright coaching. */
|
|
562
|
+
private abortRecording;
|
|
563
|
+
/** Up to KEYFRAME_CANDIDATES frames (mirrored on the front camera) over KEYFRAME_WINDOW_MS —
|
|
440
564
|
* sharpest wins (reuses frame-quality.sharpness via the capture seam). */
|
|
441
565
|
private collectKeyframes;
|
|
442
566
|
private finishCapture;
|
|
567
|
+
/** The attempt's capture-phase timing (whole ms, ≥ 0); undefined when no mark landed. */
|
|
568
|
+
private captureTiming;
|
|
443
569
|
private defaultKeyframe;
|
|
444
570
|
/** Reused downscale canvas — falls back to the raw video where canvas 2D
|
|
445
571
|
* is unavailable (jsdom) so tests and exotic hosts keep detecting. */
|
|
@@ -448,10 +574,12 @@ declare class CaptureSessionV3 {
|
|
|
448
574
|
private defaultQuality;
|
|
449
575
|
private centerSharpness;
|
|
450
576
|
private teardownAttempt;
|
|
577
|
+
/** Emit the attempt's gate breakdown; a final report closes it (exactly once). */
|
|
578
|
+
private reportGate;
|
|
451
579
|
private stopTracks;
|
|
452
580
|
private fail;
|
|
453
581
|
private setState;
|
|
454
582
|
private now;
|
|
455
583
|
}
|
|
456
584
|
|
|
457
|
-
export {
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Q,c as M,d as H,e as N,f as ge,g as E,h as B,i as P,j as U,k as x,l as v,m as V,u as Ce,v as _e}from"./chunk-XR64UFLK.js";import{m as Se}from"./chunk-ETY6SAAZ.js";import{a as me}from"./chunk-HAO6EQTH.js";import{d as J}from"./chunk-FUHDOEBP.js";import{c as he,e as ye,f as F}from"./chunk-HWAXEQD5.js";var Fe="https://api.sekyro.ai",Ge=5e3,Ke=1500,qe=10;function Ye(e){return new Promise(t=>setTimeout(t,e))}function We(){let e=globalThis.crypto;if(e!==void 0&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e!==void 0&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let o=0;o<16;o+=1)t[o]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let i=[...t].map(o=>o.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}function Rt(e){return Ze(e,{})}function Ze(e,t){let i=e.apiOrigin??Fe,o=e.autoRetry??!0,r=e.rearm??"auto",a=t.client??new ye({apiOrigin:i,sessionToken:e.clientToken,fetch:e.fetch}),l=t.sleep??Ye,s=t.uuid??We,S=t.getTurnstileToken??((n,c)=>import("./turnstile-FATNZ4AG.js").then(d=>d.executeTurnstile(n,c))),f=me(),p=null,h=null,u=!1,w=new AbortController,m=null,G=null,R=n=>{m=n,f.emit("view",n),p?.onView(n)},C=()=>m!==null?Promise.resolve(m):(G??(G=a.getSession().then(n=>(R(n),n)).finally(()=>{G=null})),G),I=async()=>{let n=await a.getSession();return R(n),n},K=async(n,c)=>{n.plan!==void 0?R(n):await I()},q=null,ee=async n=>{let c=await C();if(!n&&c.consentRecorded)return;let d=await a.recordConsent(e.locale);d.plan!==void 0?R(d):m!==null&&R({...m,consentRecorded:!0})},O=n=>n?.force===!0?ee(!0):(q??(q=ee(!1).finally(()=>{q=null})),q),Y={client:a,ensureConsent:n=>O(n),sleep:l,uuid:s,onBusy:n=>{u||f.emit("busy",n)}},te=!1,ne=null,W=n=>{if(n.status==="approved"||n.status==="rejected"||n.status==="review"){if(te)return;te=!0}ne=JSON.stringify(n),f.emit("result",n)},ve=n=>{ne!==JSON.stringify(n)&&W(n)},ie=async n=>{let c=m;n&&(c=await I().catch(()=>m));let d=c===null?null:E(c);return d!==null&&!u&&f.emit("method",d),d!==null},oe=null,re=!1,se=!1,ae=()=>Ce(Y,(n,c)=>n.submitCheck("population_registry",{},{idempotencyKey:c})),ce=n=>n.nniBound===!0||x(n,"population_registry")?.nniFromDocument===!0,Ee=async()=>{try{let n=await C();if(P(n)||E(n)!==null||U(n)?.checkType!=="population_registry")return;if(!ce(n)&&x(n,"population_registry")?.nniFromDocument===void 0&&(n=await I()),!ce(n)){se=!0;return}await O(),await K(await ae(),"population_registry");let c=m===null?void 0:x(m,"population_registry");if(c?.state==="input_required"&&c.reason==="registry_unavailable"&&N(c)>0){if(await l(Ge),u)return;await K(await ae(),"population_registry")}}catch(n){if(n instanceof he&&(n.code==="check_not_active"||n.code==="step_not_on_path")){await I().catch(()=>{});return}re=!0;return}m!==null&&P(m)&&W(V(m,{autoRetry:o}))},le=()=>(oe??(oe=Ee()),oe),we=async()=>{let c=(await C()).turnstileSiteKey;return c===null?{sandbox:!0}:{channel:"hosted_web",siteKey:c,turnstileToken:await S(c,{signal:w.signal})}},k=null,ue=Promise.resolve(),T=0,Oe=async()=>{let n=await C();for(let c=0;c<qe&&!u&&!P(n)&&U(n)===void 0&&H(n).some(d=>d.state==="processing")&&(await l(Ke),!u);c+=1)n=await I();return n},Te=async(n,c,d)=>{let{capture:_}=n,g=()=>u,L=()=>n.alive&&n.attempt===d,fe=y=>{L()&&_.setFlowState(y)},A=y=>{if(!g()&&(W(y),!!L())){if(y.status==="retry"&&r==="auto"){_.handle.retry();return}_.setFlowState("done")}};if(c.degraded==="NO_RECORDER"){let y=m?.sessionId??(await C().catch(()=>null))?.sessionId??"";A(v(y,"no_recorder"));return}fe("uploading");try{if(await le(),g())return;let y=await C();if(!P(y)&&E(y)!==null){await ie(!1),A(v(y.sessionId,"method_required"));return}if(!P(y)){if(U(y)?.checkType==="population_registry"){A(v(y.sessionId,se?"nni_unbound":re?"network":"registry_unavailable"));return}if(await O(),g())return;let Z=await _e({...Y,artifacts:c,getAttestation:we,getView:()=>m??y,refreshView:I,applySubmit:K,onPhase:fe,isCancelled:g,onKeyframePromoted:Ue=>{h=Ue}});if(g())return;if(Z.kind==="unavailable"){A(v(y.sessionId,Z.reason));return}if(Z.kind==="resync"&&await I(),m!==null&&E(m)!==null){await ie(!1),A(v(y.sessionId,"method_required"));return}y=await Oe()}A(V(y,{autoRetry:o}))}catch{if(g())return;A(v(m?.sessionId??"","network"))}},Me=(n,c)=>{let d=n.attempt;T>0&&n.alive&&n.capture.setFlowState("uploading"),T+=1,ue=ue.then(()=>Te(n,c,d)).finally(()=>{T-=1,T===0&&p?.onChainIdle()}).catch(()=>{})},de=n=>{k?.capture.handle.destroy(),k!==null&&(k.alive=!1);let c=Se(n,p?.captureInternals?.(n)??t.capture,()=>m?.capture?.liveness?.keyframe?.rank===!0,()=>Q(m)),d={capture:c,alive:!0,attempt:0};k=d,c.handle.on("state",g=>{g==="starting"&&(d.attempt+=1)}),c.handle.on("captured",g=>{Promise.resolve().then(()=>Me(d,g))});let _=c.handle;return{get state(){return _.state},get captureMode(){return _.captureMode},get facingMode(){return _.facingMode},on:(g,L)=>_.on(g,L),start:async g=>{if(m===null&&await C().catch(()=>{}),!!d.alive)return _.start(g)},retry:()=>_.retry(),switchCamera:()=>_.switchCamera(),destroy:()=>{d.alive=!1,k===d&&(k=null),_.destroy()}}},Ve=async()=>{if(u)return null;try{let n=await C();return u?null:E(n)}catch{return null}},De=async()=>{if(u)return"self";try{let n=await C();return u?"self":Q(n)}catch{return"self"}},Le=async()=>{if(u)return!1;try{let n=await C();if(u||P(n))return!1;let c=x(n,"liveness");return B(c)&&c?.requiresMobile===!0&&!J()}catch{return!1}},He=async()=>{if(u)return!1;try{let n=await C();return!u&&n.returning===!0}catch{return!1}},Ne=async n=>{let c=(await C()).plan?.choice,d=c?.options.find(g=>M[g.service]===n);if(!d)throw new RangeError(`method ${String(n)} is not offered`);let _=await a.choose(c.nodeId,d.id);u||R(_)},pe=null,Be=()=>(pe??(pe=import("./plan-runner-QCK2SOGS.js").then(n=>{let c=n.createPlanRunner({runtime:Y,currentView:()=>m,ensureView:C,refreshView:I,ensureConsent:()=>O(),liveness:de,chainBusy:()=>T>0,destroyed:()=>u,sleep:l,isMobile:J,now:t.now??Date.now,keptFaceKey:()=>h,setView:R,baseCapture:t.capture,emitStep:d=>{u||f.emit("step",d)},emitResult:ve,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto});return p=c,c})),pe);return{consent:()=>O(),startRegistry:le,methodChoice:Ve,selectMethod:Ne,mobileRequired:Le,captureMode:De,returning:He,liveness:de,run:async()=>{if(u)throw new Error("verification destroyed");return(await Be()).run()},currentStep:()=>p?.current()??null,voiceClips:async()=>{if(u)return null;try{let n=await C();return u?null:n.voice??null}catch{return null}},on:(n,c)=>f.on(n,c),destroy:()=>{u=!0,w.abort(),p?.destroy(),k!==null&&(k.alive=!1,k.capture.handle.destroy(),k=null),f.clear()}}}var ke=["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 Je=["carte_identite","passport","residence_permit"];function Qe(e,t){let i=e.byIssuer?.[t]??e.default;return Je.filter(o=>i==="*"||i.includes(o))}function wt(e,t=ke){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(o=>Qe(e,o).length>0).sort()}function Pe(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function Ot(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var Lt=["national_number","document_photo","national_eid"],je=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","face_match","aml_screening","face_dedup"]),$e=new Set(["supplied_identity","aml_screening","face_dedup"]),$=["document","population_registry","national_eid"],X=["phone_otp","email_otp"],Ie={identity_method:$,contact:X},Xe=["population_registry","document"],be="platform_unsupported",ze=new Set(["prefilled","user_entered","prefilled_or_entered"]),et={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 b(e){return e.section??et[e.checkType]??null}function tt(e,t){let i=e.plan?.choice;if(i===void 0||i.locked)return;let o=i.options.find(r=>r.id!==i.selected&&r.available!==!1&&t.includes(r.service));return o===void 0?void 0:{nodeId:i.nodeId,option:o}}function z(e){let t=e.plan,i=t?.choice;if(t===void 0||i===void 0||i.locked||t.current===null||t.current===i.nodeId||P(e))return null;let o=Ie[i.kind]??[...$,...X],r=i.options.flatMap(s=>s.available===!1||!o.includes(s.service)?[]:[s.nationalEid!=null?{id:s.id,service:s.service,nationalEid:s.nationalEid}:{id:s.id,service:s.service}]),a=t.steps.find(s=>s.id===t.current)?.service,l=i.selected??r.find(s=>s.service===a)?.id??null;return r.some(s=>s.id!==l)?{nodeId:i.nodeId,kind:i.kind,current:l,options:r}:null}function Re(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function nt(e){let t=(e.plan?.sections??[]).map(r=>({id:r.id,state:r.state})),i={sessionId:e.sessionId,orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(r=>r.id),progress:t};e.branding!==void 0&&(i.branding=e.branding);let o=z(e);return o!==null&&(i.switchable=o),i}function it(e){let t={attemptsRemaining:N(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(t.reason=e.reason),t}var Ae={phone_otp:"phone",email_otp:"email"};function ot(e,t){let i=tt(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return i===void 0?void 0:Ae[i.option.service]}function rt(e,t,i,o){let r=t.checkType==="email_otp",a=(r?t.emailOtp:t.otp)??{},l=r?t.emailOtp?.emailSource:t.otp?.numberSource,s=l!==void 0&&ze.has(l)?l:r?"prefilled_or_entered":"user_entered",S=typeof a.sentToMasked=="string"&&a.sentToMasked.length>0,f=ot(e,r?"email_otp":"phone_otp"),p={key:t.checkType,context:i,section:b(t),phase:S?"verify":"send",canSwitch:f!==void 0,...o},h=r?{kind:"email_otp",...p,emailSource:s,needsEmail:s!=="prefilled"}:{kind:"phone_otp",...p,numberSource:s,needsPhone:s!=="prefilled",channels:(t.otp?.channels??[]).filter(u=>u==="whatsapp"||u==="sms")};return f!==void 0&&(h.switchChannel=f),S&&(h.sentToMasked=a.sentToMasked),!r&&t.otp?.channel!==void 0&&(h.channel=t.otp.channel),a.expiresAt!==void 0&&(h.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(h.resendAvailableAt=a.resendAvailableAt),h}function st(e,t,i,o){let r=e.nniBound===!0?"bound":t.nniFromDocument===!0?"document":"typed",a=r==="typed"&&t.state==="input_required"&&t.reason==="nni_recheck",l=Re(z(e)),s=!o.attemptsExhausted&&l.length===1&&l[0]?.service==="document";return{kind:"registry",key:"registry",context:i,section:b(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:a,canUseDocument:s,...o}}function at(e,t,i,o){let r=[...t.acceptedSides??[]];return{kind:"document",key:"document",context:i,section:b(t),side:r.includes("recto")?"verso":"recto",acceptedSides:r,documents:Pe(e),...o}}function ct(e){let t=x(e,"liveness");return t?.state==="passed"||t?.state==="review"}function xe(e,t,i,o,r){let a=t.icao?.report;return{kind:"portrait",key:`portrait:${r}`,context:i,section:b(t),phase:r,report:Array.isArray(a)?a:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:F(e),retakeOnly:r==="capture"&&t.state==="input_required"&&e.capture?.livePhoto?.oneCapture===!0&&ct(e),...o}}var j={minLongSidePx:1280,jpegQuality:.95};function lt(e,t){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let o=x(e,"portrait_icao"),r=i.still??j;return{icao:t==="liveness"&&F(e)!==null&&o!==void 0&&o.state==="pending"&&o.reason===void 0,still:{minLongSidePx:r.minLongSidePx??j.minLongSidePx,jpegQuality:r.jpegQuality??j.jpegQuality}}}function ut(e,t,i,o){let r=t.eid,a=b(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:i,section:a,checkType:"eid_auth",reason:"update_required"};let l=Re(z(e)),s=l.length===1&&Xe.includes(l[0]?.service??"")?l[0]:void 0,S=s===void 0?void 0:M[s.service],f=S!==void 0,p={kind:"eid",key:"eid",context:i,section:a,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:f,afterPass:r.afterPass==="continue"?"continue":"end",...o};return f&&(p.cameraMethod=S),r.expiresAt!==void 0&&(p.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(p.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(p.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(p.codeAttemptsRemaining=r.codeAttemptsRemaining),p}function dt(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let i=x(e,"portrait_icao");return i!==void 0&&(i.state==="passed"||i.state==="review")?i:null}function pt(e){return H(e).filter(t=>t.state==="failed").pop()?.attemptsExhausted===!0}function ft(e,t){let i=e.failureReason,o;i===be?o="platform_unsupported":e.status==="expired"?o="expired":e.status==="review_pending"?o="review":e.status==="completed"&&e.outcome==="approved"?o="approved":e.status==="completed"&&e.outcome==="review"?o="review":i==="device_cooldown"?o="cooldown":i!==void 0?o="policy_stop":pt(e)?o="attempts_exhausted":o="rejected";let r=o==="platform_unsupported"?{sessionId:e.sessionId,status:"unavailable"}:V(e,{autoRetry:!1}),a={kind:"result",key:"result",context:t,section:null,display:o,result:r};return i!==void 0&&(a.failureReason=i),e.retryAfter!==void 0&&(a.retryAfter=e.retryAfter),a}function mt(e,t,i){let o=e.identitySummary;if(o==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:i??"identity",summaryKind:o.kind==="partial"?"partial":o.kind??"full",source:o.source,portraitAvailable:o.portrait?.available===!0,retakeAvailable:o.retakeAvailable===!0};for(let a of St){let l=o[a];typeof l=="string"&&l!==""&&(r[a]=l)}return r}var St=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","nniMasked","expiryDate","retakeTarget"];function D(e,t,i,o){return{kind:"unsupported",key:`unsupported:${i}`,context:e,section:t,checkType:i,reason:o}}function ht(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function yt(e,t){let i=Ie[e.kind]??[...$,...X],o=ht(e),r=e.options.flatMap(l=>{if(l.available===!1||!i.includes(l.service))return[];let s={id:l.id,service:l.service};return l.nationalEid!=null&&(s.nationalEid=l.nationalEid),[s]});if(r.length===0){let l=e.options.length>0&&e.options.every(s=>s.service==="nfc");return D(t,o,"choice",l?"platform_unsupported":"update_required")}let a={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let l={kind:"method",key:"method",context:t,section:o,options:r.map(S=>M[S.service]),choice:a},s=r.find(S=>S.nationalEid!==void 0)?.nationalEid;return s!==void 0&&(l.nationalEid=s),l}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:o,options:r.map(l=>Ae[l.service]),selected:null,locked:!1,choice:a}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:o,choice:a}}function Ht(e,t={}){let i=nt(e);if(P(e)||e.failureReason===be)return ft(e,i);let o=e.plan;if(o===void 0||!Array.isArray(o.sections))return D(i,null,"plan","update_required");let r=ge(e);if(r!==null)return yt(r,i);let a=o.current===null?void 0:o.steps.find(h=>h.id===o.current),l=h=>({kind:"processing",key:"processing",context:i,section:h!==void 0?b(h):o.sections.find(u=>u.state==="current")?.id??null,stalled:!1});if(o.current===null)return l(o.steps.find(h=>h.state==="processing"));if(a===void 0||!je.has(a.service))return D(i,a===void 0?null:b(a),a?.service??"step","update_required");if($e.has(a.service)||!B(a))return l(a);let s=a,S=it(s),f=s.checkType,p=b(s);switch(f){case"phone_otp":case"email_otp":return rt(e,s,i,S);case"population_registry":return st(e,s,i,S);case"eid_auth":return ut(e,s,i,S);case"doc_ocr":return at(e,s,i,S);case"identity_confirm":return mt(e,i,p)??l(s);case"portrait_icao":return xe(e,s,i,S,"capture");case"liveness":case"face_match":{let h=dt(e,s);if(h!==null)return xe(e,h,i,S,"match");let u=s.requiresMobile===!0,w=F(e);return u&&t.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:i,section:p,checkType:f}:{kind:"liveness",key:"biometric",context:i,section:p,mode:f==="face_match"?"selfie":"liveness",requiresMobile:u,instructions:w===null?"standard":"icao",icao:w,livePhoto:lt(e,f),...S}}case"nfc_chip":return D(i,p,f,"platform_unsupported");default:return D(i,p,f,"update_required")}}export{Fe as a,Ge as b,Ke as c,qe as d,We as e,Rt as f,Ze as g,ke as h,Je as i,Qe as j,wt as k,Pe as l,Ot as m,Lt as n,be as o,b as p,z as q,Re as r,dt as s,Ht as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var w=[468,473],K=[[33,133],[362,263]],V=[[33,7,163,144,145,153,154,155,133,173,157,158,159,160,161,246],[362,382,381,380,374,373,390,249,263,466,388,387,386,385,384,398]],D=1;function S(e){let n=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let r of e)r.x<n&&(n=r.x),r.y<o&&(o=r.y),r.x>t&&(t=r.x),r.y>s&&(s=r.y);return e.length===0?{x:0,y:0,width:0,height:0}:{x:n,y:o,width:t-n,height:s-o}}var _=(e,n)=>({x:(e.x+n.x)/2,y:(e.y+n.y)/2});function $(e,n,o){if(e.length<468)return null;let t=l=>{let i=e[l];return{x:i.x*n,y:i.y*o}},s=[0,1].map(l=>{let i=e.length>w[1]?t(w[l]):null,[c,p]=K[l];return i??_(t(c),t(p))}),r=V.map(l=>S(l.map(t))),h=[];for(let l=0;l<Math.min(e.length,468);l+=1)h.push(t(l));let[d,m]=s,u=d.x>m.x,b=u?m:d,f=u?d:m;return{leftEye:b,rightEye:f,iod:Math.hypot(f.x-b.x,f.y-b.y),box:S(h),nose:t(D),leftEyeBox:u?r[1]:r[0],rightEyeBox:u?r[0]:r[1]}}var R=180/Math.PI;function F(e,n="column"){if(e.length<16||e.some(l=>!Number.isFinite(l)))return null;let o=(l,i)=>n==="column"?e[i*4+l]:e[l*4+i],t=Math.hypot(o(0,0),o(1,0),o(2,0))||1,s=o(0,0)/t,r=o(1,0)/t,h=o(2,0)/t,d=o(2,1)/t,m=o(2,2)/t,u=Math.asin(Math.max(-1,Math.min(1,-h)))*R,b=Math.atan2(d,m)*R,f=Math.atan2(r,s)*R;return{yaw:u,pitch:b,roll:f}}function B(e){return Math.atan2(e.rightEye.y-e.leftEye.y,e.rightEye.x-e.leftEye.x)*R}var E={width:480,height:640,eyeX:240,eyeY:289,iodMin:120,iodMax:160};function G(e){let n=E,o=e.iod>=n.iodMin&&e.iod<=n.iodMax?1:n.iodMin/Math.max(e.iod,1e-6),t=n.width/o,s=n.height/o,r=_(e.leftEye,e.rightEye);return{x:r.x-n.eyeX/n.width*t,y:r.y-n.eyeY/n.height*s,width:t,height:s}}function N(e,n,o){let t=Math.max(0,-e.x),s=Math.max(0,-e.y),r=Math.max(0,e.x+e.width-n),h=Math.max(0,e.y+e.height-o);return Math.max((t+r)/e.width,(s+h)/e.height)}function ee(e,n,o,t){let s=G(e),r=s.x+s.width/2,h=s.y+s.height/2,d=E.width/E.height,m=Math.max(s.height*t.margin,t.minHeight,t.minWidth/d);m=Math.min(m,o,n/d);let u=m*d,b=Math.min(Math.max(r-u/2,0),Math.max(0,n-u)),f=Math.min(Math.max(h-m/2,0),Math.max(0,o-m));return{x:Math.round(b),y:Math.round(f),width:Math.round(u),height:Math.round(m)}}var v=["face","framing","pose","eyes","mouth","glare","lighting","background","resolution","sharpness"],H=new Set(["glare","background"]),x=e=>({pass:!0,value:e,coach:null}),y=(e,n)=>({pass:!1,value:e,coach:n}),I=(e,n)=>({pass:e,value:null,coach:e?null:n,none:!0});function X(e,n){let o=e.pose,t;if(o!==null){let c=o.pitch-n.pitchOffsetDeg,p=Math.max(Math.abs(o.yaw),Math.abs(c),Math.abs(o.roll));t=Math.abs(o.yaw)<=n.yawDeg&&Math.abs(c)<=n.pitchDeg&&Math.abs(o.roll)<=n.rollDeg?x(p):y(p,"pose")}else t={...I(!1,"pose"),value:e.eyeLineRoll??null};let s=I(!1,"eyes");if(e.eyes!==null){let c=e.baseline,p=Math.min(e.eyes.left,e.eyes.right),M=Math.max(1-n.eyes.blinkMax,c!==null&&c>0&&c<=1?n.eyes.relativeMin*c:0),g=c!==null&&c>0?p/c:null;s=p>=M-1e-9?x(g):y(g,"eyes")}let r=I(!1,"mouth");if(e.mouth!==null){let{jawOpen:c,smile:p,pucker:M}=e.mouth,g=Math.max(c/n.mouth.jawOpenMax,p/n.mouth.smileMax,M/n.mouth.puckerMax);r=c<=n.mouth.jawOpenMax&&p<=n.mouth.smileMax&&M<=n.mouth.puckerMax?x(g):y(g,"mouth")}let h=e.lighting,d=I(!0,"lighting");if(h!==null){let[c,p]=n.lighting.faceLuma,[M,g]=n.lighting.halfRatio;d=h.faceLuma<c||h.faceLuma>p||h.clipped>n.lighting.clippedMax?y(h.faceLuma,"lighting"):h.halfRatio<M||h.halfRatio>g?y(h.halfRatio,"lighting_side"):x(h.faceLuma)}let m=e.uniformity,u=e.background,b=n.background.required?m!=null&&n.backgroundCheck.enabled?m.uniform?x(m.colorStd):y(m.colorStd,"background"):u===null?I(!0,"background"):u.luma>=n.background.lumaMin&&u.sd<=n.background.lumaSdMax?x(u.luma):y(u.luma,"background"):I(!0,"background"),f=n.resolution,l=Math.min(e.frameWidth,e.frameHeight)>=f.minWidth&&Math.max(e.frameWidth,e.frameHeight)>=f.minHeight,i=e.iod>=f.minIodPx&&l?x(e.iod):y(e.iod,"resolution");return{pose:t,eyes:s,mouth:r,lighting:d,background:b,resolution:i}}function L(e){let n=e?.eyeBlinkLeft,o=e?.eyeBlinkRight;return typeof n!="number"||typeof o!="number"?null:{left:1-n,right:1-o,blinkLeft:n,blinkRight:o}}function q(e,n){if(e.length===0)return null;let o=[...e].sort((s,r)=>s-r),t=Math.min(o.length-1,Math.max(0,Math.ceil(n*o.length)-1));return o[t]}function T(e,n,o){let t={},s=e.geometry;if(e.faces!==1||s===null){let c=e.faces>1?y(e.faces,"multiple_faces"):y(e.faces,"no_face");for(let p of v)t[p]=p==="face"?c:I(!1,"no_face");return{results:t,pose:null}}t.face=x(1);let r=G(s),h=N(r,e.frameWidth,e.frameHeight);t.framing=r.height>e.frameHeight*1.02||r.width>e.frameWidth*1.02?y(h,"too_close"):h>.02?y(h,"center"):x(h);let d=e.matrix!=null?F(e.matrix):null,m=L(e.blendshapes),u=e.blendshapes,b=e.stats??null,f=X({pose:d,eyeLineRoll:Math.abs(B(s)),eyes:m,baseline:o,mouth:u==null?null:{jawOpen:u.jawOpen??0,smile:Math.max(u.mouthSmileLeft??0,u.mouthSmileRight??0),pucker:u.mouthPucker??0},lighting:b?.lighting??null,background:b?.background??null,uniformity:e.backgroundCheck??null,iod:s.iod,frameWidth:e.frameWidth,frameHeight:e.frameHeight},n);Object.assign(t,f);let l=b?.eyeSpecular??null;t.glare=l===null?I(!0,"glare"):l<=n.glare.specularMax?x(l):y(l,"glare");let i=b?.sharpness??null;return t.sharpness=i===null||i>=n.sharpnessMin?x(i):y(i,"hold_still"),{results:t,pose:d}}var J={pose:"pose",eyes:"eyes",mouth:"mouth",glare:"glare",lighting:"lighting",background:"background",framing:"resolution",resolution:"resolution"};function oe(e,n={}){let o=n.policy==="alert",t=new Map,s=0,r=null,h=null,d={},m=[],u=null,b=null,f=l=>{if(m=m.filter(c=>l-c.at<=e.baseline.windowMs),m.length<e.baseline.minSamples)return null;let i=q(m.map(c=>c.open),e.baseline.percentile);return i===null||i<=0?null:Math.min(1,i)};return{push(l,i){let c=T(l,e,null),p=L(l.blendshapes);p!==null&&c.results.face.pass&&c.results.pose.pass&&m.push({at:i,open:(p.left+p.right)/2});let M=f(i),{results:g,pose:A}=T(l,e,M);for(let a of v)g[a].pass&&(a!=="eyes"||M!==null)?t.has(a)||t.set(a,i):t.delete(a);let P=a=>{let C=t.get(a);return C!==void 0&&i-C>=e.holdMs};v.filter(a=>!H.has(a)).every(P)?r??(r=i):r=null;let W=a=>a==="background"&&l.backgroundCheck!=null?e.backgroundCheck.timeoutMs:e.softGraceMs,U=a=>H.has(a)&&!g[a].pass&&r!==null&&i-r>=W(a),k=v.map(a=>({criterion:a,pass:g[a].pass,held:P(a),waived:U(a),value:g[a].value,coach:g[a].pass?null:g[a].coach}));s=k.every(a=>a.pass||a.waived)?s+1:0;let O=k.find(a=>!a.pass&&!a.waived)??null,j=k.filter(a=>a.held||a.waived).length;g.face.pass&&g.framing.pass?h??(h=i):h=null;let Y=k.every(a=>a.held||a.waived)&&s>=e.holdFrames||o&&h!==null&&i-h>=e.alertGraceMs;d={};for(let a of v){let C=J[a];C!==void 0&&g[a].none!==!0&&(d[C]=(d[C]??!0)&&g[a].pass)}return b=l.backgroundCheck??null,u={criteria:k,coach:O?.coach??"hold",failing:O?.criterion??null,progress:j/k.length,ready:Y,baseline:M,pose:A},u},last:()=>u,summary(){let l={criteria:{}};if(u===null)return l;l.verdict={...d},u.baseline!==null&&Math.round(u.baseline*1e3)>0&&(l.baselineEyeOpenness=Math.round(u.baseline*1e3)/1e3);for(let i of u.criteria){let c=i.value===null||!Number.isFinite(i.value)?null:Math.round(i.value*1e3)/1e3;l.criteria[i.criterion]=i.waived?{pass:i.pass,value:c,waived:!0}:{pass:i.pass,value:c}}if(b!==null&&e.background.required){let{pixels:i,...c}=b;l.backgroundCheck=c}return l},reset(){t.clear(),s=0,r=null,h=null,d={},u=null,b=null}}}export{$ as a,F as b,B as c,E as d,G as e,N as f,ee as g,v as h,X as i,L as j,q as k,T as l,oe as m};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as o}from"./chunk-DFTCAWMP.js";var A="sekyro-mrz-1";function w(e){return Array.from(new Uint8Array(e),t=>t.toString(16).padStart(2,"0")).join("")}async function m(e){return w(await crypto.subtle.digest("SHA-256",e))}function x(e,t){return m(new TextEncoder().encode(`${A}\0${e}\0${t.join(`
|
|
2
|
+
`)}`))}var i=class extends Error{constructor(t){super(t),this.name="AssetFailure",this.reason=t}},B=Object.keys(o.files).filter(e=>o.files[e].tier==="live"),N=Object.keys(o.files).filter(e=>o.files[e].tier==="lazy");function g(e,t){return`${e.replace(/\/+$/,"")}/${o.fp12}/${t}`}async function b(e,t,d,p=fetch,n=()=>performance.now()){let c=o.files[t],y=n(),f=async s=>{try{let r=await p(g(e,t),{cache:s,signal:d,credentials:"omit"});if(!r.ok)throw new i("download");return await r.arrayBuffer()}catch(r){throw r instanceof i?r:new i("download")}},l=async s=>s.byteLength===c.bytes&&await m(s)===c.sha256,a=await f("force-cache");if(!await l(a)&&(a=await f("reload"),!await l(a)))throw new i("integrity");return{bytes:a,ms:n()-y}}async function T(e,t,d,p=fetch,n=()=>performance.now()){let c=new AbortController,y=new Map,f=t.reduce((r,u)=>r+o.files[u].bytes,0),l=n(),a=!0,s=0;for(let r of t){let u=await b(e,r,c.signal,p,n);y.set(r,u.bytes),u.ms>=50&&(a=!1),s+=u.bytes.byteLength;let h=n()-l;if(s<f&&h>0&&h*f/s>d)throw c.abort(),new i("download")}return{files:y,downloadMs:Math.round(n()-l),cached:a}}function _(e,t){return e==="hosted"?"/models-ocr":t==="live"?"https://assets.sekyro.ai/sdk/web/ocr":"https://assets-staging.sekyro.ai/sdk/web/ocr"}export{x as a,i as b,B as c,T as d,_ as e};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as M,c as p}from"./chunk-GI3UFGRQ.js";var f={id_document:{pose:{yawDeg:7,pitchDeg:7,rollDeg:5,pitchOffsetDeg:4},eyes:{relativeMin:.62,blinkMax:.48},mouth:{jawOpenMax:.13,smileMax:.28,puckerMax:.28},lighting:{faceLuma:[95,185],halfRatio:[.77,1.31],clippedMax:.015},background:{required:!0,lumaMin:165,lumaSdMax:20},resolution:{minIodPx:110,minWidth:480,minHeight:640}},selfie:{pose:{yawDeg:7,pitchDeg:7,rollDeg:7,pitchOffsetDeg:4},eyes:{relativeMin:.62,blinkMax:.48},mouth:{jawOpenMax:.13,smileMax:.28,puckerMax:.28},lighting:{faceLuma:[95,185],halfRatio:[.77,1.31],clippedMax:.015},background:{required:!1,lumaMin:165,lumaSdMax:20},resolution:{minIodPx:100,minWidth:480,minHeight:640}}};function k(a){let i=f[a];return{profile:a,backgroundCheck:M,...i.pose,holdMs:500,alertGraceMs:3e3,eyes:{...i.eyes},mouth:{...i.mouth},lighting:{...i.lighting,faceLuma:[i.lighting.faceLuma[0],i.lighting.faceLuma[1]],halfRatio:[i.lighting.halfRatio[0],i.lighting.halfRatio[1]]},background:{...i.background},resolution:{...i.resolution},holdFrames:3,cadenceHz:10,baseline:{windowMs:3e3,minSamples:6,percentile:.8},sharpnessMin:.25,glare:{specularMax:.01},softGraceMs:4e3,cropMargin:1.25,camera:{width:1920,height:1080}}}var I=k("id_document"),D=/^[A-Za-z0-9._-]{1,64}$/;function n(a,i,r,u){return typeof a=="number"&&Number.isFinite(a)&&a>=r&&a<=u?a:i}function x(a,i,r,u){if(!Array.isArray(a)||a.length!==2)return[i[0],i[1]];let[e,l]=a,t=n(e,Number.NaN,r,u),m=n(l,Number.NaN,r,u);return Number.isNaN(t)||Number.isNaN(m)||t>m?[i[0],i[1]]:[t,m]}function o(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)?a:{}}function R(a,i){let r=o(a),u=r.profile==="selfie"?"selfie":"id_document",e=u==="selfie"?k(u):I,l=o(r.eyes),t=o(r.mouth),m=o(r.lighting),c=o(r.background),s=o(r.resolution),g=o(r.baseline),w=o(r.glare),b=o(r.camera),h=typeof c.required=="boolean"?c.required:e.background.required,d=p(r.backgroundCheck);return{profile:u,yawDeg:n(r.yawDeg,e.yawDeg,1,45),pitchDeg:n(r.pitchDeg,e.pitchDeg,1,45),pitchOffsetDeg:n(r.pitchOffsetDeg,e.pitchOffsetDeg,-20,20),rollDeg:n(r.rollDeg,e.rollDeg,1,45),holdMs:n(r.holdMs,e.holdMs,0,5e3),alertGraceMs:n(r.alertGraceMs,e.alertGraceMs,0,6e4),eyes:{relativeMin:n(l.relativeMin,e.eyes.relativeMin,0,1),blinkMax:n(l.blinkMax,e.eyes.blinkMax,0,1)},mouth:{jawOpenMax:n(t.jawOpenMax,e.mouth.jawOpenMax,0,1),smileMax:n(t.smileMax,e.mouth.smileMax,0,1),puckerMax:n(t.puckerMax,e.mouth.puckerMax,0,1)},lighting:{faceLuma:x(m.faceLuma,e.lighting.faceLuma,0,255),halfRatio:x(m.halfRatio,e.lighting.halfRatio,0,10),clippedMax:n(m.clippedMax,e.lighting.clippedMax,0,1)},background:{required:h,lumaMin:n(c.lumaMin,e.background.lumaMin,0,255),lumaSdMax:n(c.lumaSdMax,e.background.lumaSdMax,0,255)},resolution:{minIodPx:n(s.minIodPx,e.resolution.minIodPx,1,2e3),minWidth:n(s.minWidth,e.resolution.minWidth,1,8e3),minHeight:n(s.minHeight,e.resolution.minHeight,1,8e3)},holdFrames:Math.round(n(r.holdFrames,e.holdFrames,1,60)),cadenceHz:n(r.cadenceHz,e.cadenceHz,1,30),baseline:{windowMs:n(g.windowMs,e.baseline.windowMs,200,3e4),minSamples:Math.round(n(g.minSamples,e.baseline.minSamples,1,300)),percentile:n(g.percentile,e.baseline.percentile,.5,1)},sharpnessMin:n(r.sharpnessMin,e.sharpnessMin,0,1),glare:{specularMax:n(w.specularMax,e.glare.specularMax,0,1)},softGraceMs:n(r.softGraceMs,e.softGraceMs,0,6e4),cropMargin:n(r.cropMargin,e.cropMargin,1,2),camera:{width:Math.round(n(b.width,e.camera.width,320,4096)),height:Math.round(n(b.height,e.camera.height,240,4096))},backgroundCheck:h?d:{...d,enabled:!1},tuningVersion:typeof i=="string"&&D.test(i)?i:null}}export{I as a,R as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=2e4,m="face_landmarker.task";function d(a){let r=[],n=a.faceLandmarks??[];for(let e=0;e<n.length;e+=1){let o=n[e]??[],c=a.faceBlendshapes?.[e]?.categories,t=null;if(c!==void 0){t={};for(let s of c)t[s.categoryName]=s.score}let i=a.facialTransformationMatrixes?.[e]?.data;r.push({landmarks:o.map(s=>({x:s.x,y:s.y})),blendshapes:t,matrix:i!==void 0&&i.length>=16?[...i]:null})}return r}async function u(a){let r=a.replace(/\/+$/,""),n=await import("@mediapipe/tasks-vision"),e=await n.FilesetResolver.forVisionTasks(r),o=await n.FaceLandmarker.createFromOptions(e,{baseOptions:{modelAssetPath:`${r}/${m}`,delegate:"CPU"},runningMode:"VIDEO",numFaces:2,outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0});return{detect(c,t){try{return d(o.detectForVideo(c,t))}catch{return[]}},close(){try{o.close()}catch{}}}}export{l as a,m as b,d as c,u as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={fp12:"08390000c48a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro-ocr.wasm":{bytes:3550608,sha256:"c15968a6de3d2225e2fdbf36d71a9214c2910419056c6878444fd2d0567bb748",tier:"live",contentType:"application/wasm"},"sekyro-ocr.mjs":{bytes:4270,sha256:"209a78d96ca53344996a0c2300aed4ff8a5c69e142713216975a2840eec08cac",tier:"bundled",contentType:"text/javascript"},"det.param":{bytes:24252,sha256:"c39ba0b1195e8ad37cfc5bdd7acedcfc1d9cb901e7b8eb1c9c4f6e5a66c04eb3",tier:"live",contentType:"text/plain"},"det.bin":{bytes:4685856,sha256:"652bafe366565109a1a5766caf482bc46f01481f8044d3a785bd9a1be67c63bb",tier:"live",contentType:"application/octet-stream"},"mrz-rec.param":{bytes:3510,sha256:"bc69b1b9683e35f6605b21001fadeb81468063459c00c0fc83c67c139f23df01",tier:"live",contentType:"text/plain"},"mrz-rec.bin":{bytes:494196,sha256:"de93a2aa2f08670cc7dedd17ba378d2f5d7cf6ae409054a9eac863a02c2febae",tier:"live",contentType:"application/octet-stream"},"mrz_dict.txt":{bytes:73,sha256:"b19858a4de2ccbbbdd4b53982188ea2c7664013183bbd1ae9d20ab52c661f97f",tier:"live",contentType:"text/plain"},"latin-rec.param":{bytes:19602,sha256:"2ae30dfdc7ee482c6cbbc0419c16ee125e880e9eaf69053d61953694bb0fcf4c",tier:"lazy",contentType:"text/plain"},"latin-rec.bin":{bytes:10750388,sha256:"f91ebdcf4d6b58c58a87704160e59d07ae56bc2d5021eae09d095c5a20bf7525",tier:"lazy",contentType:"application/octet-stream"},"ppocr_keys_v1.txt":{bytes:26249,sha256:"28b2362ad4ab2dc38769aa72feb535e3a9ddb3fd2a7585a05920e6393b1dc7f7",tier:"lazy",contentType:"text/plain"},"arabic-rec.param":{bytes:9858,sha256:"4e5cc85667dfaaa0c67d3f308400645a578c08bd43f952cab6c55b7bce143ea9",tier:"lazy",contentType:"text/plain"},"arabic-rec.bin":{bytes:8853572,sha256:"5acc3265a1738dc31316258383830d5dbdfa5e8ebc2e710f9001f832ecfbffb0",tier:"lazy",contentType:"application/octet-stream"},"arabic_dict.txt":{bytes:405,sha256:"637c27c88512c22089bef927b34ada08f748dc132ac70facd68d8202384c2726",tier:"lazy",contentType:"text/plain"}}};export{e as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function y(a,r){let o=a.lineBoxes;if(o.length===0)return{lineCount:0,detected:!1,fill:0,offsetX:0,offsetY:0,centers:[]};let s=Math.min(...o.map(n=>n[0])),e=Math.max(...o.map(n=>n[0]+n[2])),t=Math.min(...o.map(n=>n[1])),l=Math.max(...o.map(n=>n[1]+n[3]));return{lineCount:o.length,detected:o.length>=r.minLines,fill:e-s,offsetX:(s+e)/2-.5,offsetY:(t+l)/2-.5,centers:o.map(n=>[n[0]+n[2]/2,n[1]+n[3]/2])}}function x(a,r){if(a.centers.length===0||r.centers.length===0)return Number.POSITIVE_INFINITY;let o=0;for(let[s,e]of r.centers){let t=Number.POSITIVE_INFINITY;for(let[l,n]of a.centers)t=Math.min(t,Math.hypot(s-l,e-n));o+=t}return o/r.centers.length}var c=class{constructor(r=h){this.t=r;this.last=null;this.goodSince=null;this.steadySince=null;this.frames=0}offer(r,o,s={glareOk:!0,sharpOk:!0}){let e=this.t,t=y(r,e),l=this.last;this.last=t;let n=t.fill>=e.fillMin&&t.fill<=e.fillMax,i=Math.abs(t.offsetX)<=e.offsetMax&&Math.abs(t.offsetY)<=e.offsetMax,m=l!==null&&l.detected&&Math.abs(t.lineCount-l.lineCount)<=e.lineCountDelta&&x(l,t)<=e.layoutShiftMax,f=t.detected&&s.glareOk&&s.sharpOk&&n&&m&&l!==null&&Math.abs(t.fill-l.fill)<=e.steadyFillDelta&&Math.abs(t.offsetX-l.offsetX)<=e.steadyOffsetDelta&&Math.abs(t.offsetY-l.offsetY)<=e.steadyOffsetDelta,d=f&&i,u=t.detected?s.glareOk?t.fill<e.fillMin?"closer":t.fill>e.fillMax?"farther":i?s.sharpOk?void 0:"blurry":"center":"glare":void 0;return f?(this.frames++,this.steadySince??(this.steadySince=o),this.goodSince=d?this.goodSince??o:null,(this.goodSince!==null&&o-this.goodSince>=e.lockMs||o-this.steadySince>=e.steadyMs)&&this.frames>=e.minFrames?{state:"locked"}:{state:"locking",...u?{hint:u}:{}}):(this.goodSince=null,this.steadySince=null,this.frames=t.detected?1:0,{state:t.detected?"locking":"searching",...u?{hint:u}:{}})}reset(){this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}};function M(a,r,o){let s=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;return a.map(e=>{let t=[e[0],e[2],e[4],e[6]],l=[e[1],e[3],e[5],e[7]],n=Math.min(...t),i=Math.min(...l);return[s(n/r),s(i/o),s((Math.max(...t)-n)/r),s((Math.max(...l)-i)/o)]}).sort((e,t)=>e[1]-t[1]||e[0]-t[0])}export{h as a,c as b,M as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as $,d as Q,e as Z}from"./chunk-HAO6EQTH.js";import{r as N}from"./chunk-SZ7YGNUZ.js";import{c as z}from"./chunk-FUHDOEBP.js";import{f as q}from"./chunk-FHJ7HO3M.js";import{a as G,f as v}from"./chunk-OKWG3PVH.js";var te=12e4,j=13e4,se=3e3,re=1200,P=Symbol.for("@sekyro/web.preload.v1");function l(){let e=globalThis;return e[P]??(e[P]=new Map),e[P]}function g(e){let t=(e??G).replace(/\/+$/,"");return t===""?"/":t}function J(e){let t=l(),s=t.get(e);return s===void 0&&(s={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},t.set(e,s)),s}function A(e,t){if(e.status!==t){e.status=t;for(let s of[...e.listeners])s(t)}}var T=e=>v({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:te}),x=T;function ve(e){x=e??T}function ge(){for(let e of l().values())e.detector?.destroy();l().clear(),x=T}function ne(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function oe(){return navigator.connection?.saveData===!0}function ie(e){let t=window;if(typeof t.requestIdleCallback=="function"){let n=t.requestIdleCallback(e,{timeout:se});return()=>t.cancelIdleCallback?.(n)}let s=setTimeout(e,re);return()=>clearTimeout(s)}function ae(e,t){let s,n=new Promise(i=>{s=i}),d=!1,f=()=>{},a={promise:n,settle:i=>{d||(d=!0,f(),e.scheduled===a&&(e.scheduled=null),s(i))}};return e.scheduled=a,f=ie(()=>{d||a.settle(I(e,t))}),n}function I(e,t){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;A(e,"loading");let s=new Promise(i=>i(x(t)));e.detectorPromise=s;let n,d=new Promise((i,h)=>{n=setTimeout(()=>{s.then(p=>p.destroy(),()=>{}),h(new Error(`detector preload exceeded ${j} ms`))},j)}),a=Promise.race([s,d]).then(i=>e.detectorPromise!==s?(i.destroy(),e.status):(e.detector=i,A(e,"ready"),"ready"),i=>(e.detectorPromise===s&&(e.detectorPromise=null,e.detector=null,A(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",i)),e.status)).finally(()=>clearTimeout(n));return e.promise=a,e.scheduled?.settle(a),a}function he(e={}){if(!ne())return Promise.resolve("idle");let t=g(e.assetBaseUrl),s=J(t);return e.respectSaveData===!0&&oe()?Promise.resolve(s.status):(s.status==="loading"||s.status==="ready")&&s.promise!==null?s.promise:e.idle===!0?s.scheduled?.promise??ae(s,t):I(s,t)}function Se(e){return l().get(g(e))?.status??"idle"}function Le(e,t){let s=J(g(t));return s.listeners.add(e),()=>{s.listeners.delete(e)}}function Ce(e){let t=l().get(g(e));t!==void 0&&(t.scheduled?.settle("idle"),t.detector?.destroy(),t.detector=null,t.detectorPromise=null,t.promise=null,A(t,"idle"))}function ce(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...t)=>e.detect(...t),destroy:()=>{}}}function X(e){let t=g(e),s=l().get(t);if(!(s===void 0||s.detector===null&&s.detectorPromise===null&&s.scheduled===null))return async()=>{s.scheduled!==null&&I(s,t);let n=s.promise;for(;s.detector===null&&n!==null&&(await n,s.promise!==n);)n=s.promise;return s.detector!==null?ce(s.detector):v({v3AssetBaseUrl:t})}}function de(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 ue(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function le(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;default:{let t=e;return"generic"}}}function fe(e,t={},s,n=()=>"self"){let d=t.now??(()=>performance.now()),f=t.canChooseFacing??Q,a="user",i=!1,h=r=>(r==="environment"&&!i&&(i=!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"),p=!1,S=n(),u=$(),H=!q(),U=t.engineOptions,Y=U?.createDetector===void 0&&U?.createWorker===void 0?{createDetector:()=>{let r=X(e.assetBaseUrl);return r!==void 0?r():v({v3AssetBaseUrl:e.assetBaseUrl})}}:{},B={video:e.video,mode:H?"photo":"clip",rankKeyframes:s,facingMode:void 0,v3AssetBaseUrl:e.assetBaseUrl,...t.engineOptions??{},...Y},o=t.createEngine?.(B)??new N(B),L="idle",C=null,y=0,k=!1,D="full",E=null,b=null,M=0,_=0,R=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(M=e.video.videoWidth,_=e.video.videoHeight)},K=Z({enabled:e.keepScreenAwake!==!1}),V=r=>{L=r,K.setActive(r==="starting"||r==="gating"||r==="recording"),u.emit("state",r)},F=()=>u.emit("gate",{progress:y,hint:C,faceDetected:k}),W=()=>{let r=o.animations??"full";r!==D&&(D=r,u.emit("profile",{animations:D}))},ee=[o.on("statechange",({state:r})=>{let c=ue(r);c==="starting"&&L!=="starting"&&(C=null,y=0,k=!1,E=null,b=null,M=0,_=0),V(c),W(),c==="recording"&&(R(),E=d(),C="hold",y=1,F())}),o.on("checks",r=>{R(),y=r.progress,k=r.factors.presence>0,F(),W()}),o.on("guidance",({key:r})=>{C=de(r),F()}),o.on("frozen",({previewDataUrl:r})=>{b=d(),u.emit("frozen",{previewDataUrl:r})}),o.on("artifacts",r=>{let c=z(),m=E!==null&&b!==null?Math.max(0,Math.round(b-E)):void 0;u.emit("captured",{keyframe:r.keyframe,...r.clip!==void 0?{clip:r.clip}:{},...r.clipMimeType!==void 0?{clipMime:r.clipMimeType}:{},width:e.video.videoWidth||M,height:e.video.videoHeight||_,...m!==void 0?{clipMs:m}:{},captureChannel:c==="desktop"?"desktop":"mobile",formFactor:c,...H?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:o.facingMode,mode:S,...r.timing})}),o.on("error",({kind:r,retryable:c})=>{u.emit("error",{kind:le(r),retryable:c})})];return{handle:{get state(){return L},get captureMode(){return n()},get facingMode(){return o.facingMode??a},on:(r,c)=>u.on(r,c),start:r=>{if(S=n(),S==="self")return h(e.facing),h(r?.facing),p=!0,a="user",o.start({facingMode:"user"});let c=!p;p=!0;let m=r?.facing??(c?e.facing:void 0),O=w=>(a=w,o.start({facingMode:w}));return m!==void 0?O(m):c?f().then(w=>O(w?"environment":"user"),()=>O("user")):o.start({})},retry:()=>o.retry(),switchCamera:()=>n()!=="assisted"?!1:(S="assisted",a=a==="user"?"environment":"user",o.switchCamera(),!0),destroy:()=>{for(let r of ee)r();K.setActive(!1),o.destroy(),u.clear()}},setFlowState:r=>{L!==r&&V(r)}}}function _e(e){return fe(e).handle}export{te as a,j as b,ve as c,ge as d,he as e,Se as f,Le as g,Ce as h,X as i,de as j,ue as k,le as l,fe as m,_e as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as j,h as be,i as he,j as ye,l as Se}from"./chunk-G6LKLN4U.js";import{f as ge}from"./chunk-TDLIXFDT.js";import{l as fe}from"./chunk-ETY6SAAZ.js";import{a as me,e as pe}from"./chunk-HAO6EQTH.js";var Ge={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function qe(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:l}=e,s=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,u=t!=null&&t<=2,c=n==="4g"||i!=null&&i>=5,f=t!=null&&t>=6,p;s||u?p="low":c&&f?p="good":p="mid";let b=Ge[p],S=l&&l>0?Math.min(b.maxLongEdge,l):b.maxLongEdge;return{tier:p,...b,maxLongEdge:S}}function Me(e){let t={};try{let n=navigator;typeof n.deviceMemory=="number"&&(t.deviceMemory=n.deviceMemory);let r=n.connection;r&&(t.effectiveType=r.effectiveType,t.saveData=r.saveData,t.downlinkMbps=r.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),qe(t)}function He(e,t,n){let r=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),i=(t+n)/2;return Math.max(t,n-r*(n-i))}function Xe(e,t,n){let r=Math.max(e,t),i=r>0?Math.min(1,n/r):1;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}async function Ve(e,t){let n=t.startQ,r=await e(n);for(let i=0;i<4&&!(r.size<=t.budgetBytes||n<=t.qMin);i++)n=Math.max(t.qMin,n-.08),r=await e(n);return{blob:r,quality:n}}async function ke(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:l,height:s}=Xe(t,n,r.maxLongEdge),u=document.createElement("canvas");u.width=l,u.height=s;let c=u.getContext("2d");if(!c)return null;c.drawImage(e,0,0,l,s);let f=I=>new Promise((h,w)=>{u.toBlob(d=>d?h(d):w(new Error("canvas toBlob returned null")),"image/jpeg",I)}),p=He(i,r.qMin,r.qMax),{blob:b,quality:S}=await Ve(f,{startQ:p,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{u.width=0,u.height=0});if(b.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:b,quality:S,width:l,height:s}}async function $(e){let t=Me(Math.max(e.width,e.height)),n=await ke(e,e.width,e.height,t,.5);if(n===null)throw new Error("canvas encode unavailable");return{blob:n.blob,width:n.width,height:n.height}}async function dt(e){let t=await createImageBitmap(e);try{return await $(t)}finally{t.close()}}var pt=250,ft=.6,gt=1800,bt=6e3,ht=2e3,De=.16;function Z(e,t){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1}}var we=e=>e==="recto"?"verso":"recto",Ce=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",ee=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function J(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}function Ye(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let r=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:l}=e;r&&(l=l??n),l!==void 0&&n-l>=250&&(i=!0),r||(l=void 0);let s=e.flipTimeoutSpent&&!(i&&!e.flipped),u={...e,lastReportAt:n,flipped:i,awaySince:l,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!Ce(e))return u;if(e.needFlip&&!i){if(!t.ready)return{...u,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...u,goodSince:void 0,phase:e.restPhase};let f=e.goodSince??n;return n-f>=1800?{...u,goodSince:f,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...u,goodSince:f,phase:e.restPhase}}return t.ready?{...u,phase:"capturing",goodSince:e.goodSince??n}:{...u,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function Qe(e,t){if(!Ce(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function Ke(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,l=r?[]:[...e.pending,t],s={...e,captured:i,pending:l,lastShot:t,lastCaptureAt:n,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return r||ee({captured:i,pending:l})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function Re(e,t,n){return e.pending.includes(t)?{...e,pending:e.pending.filter(r=>r!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:we(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function je(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return Re(e,t,n);let r=e.pending.filter(c=>c!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(ee(i)!==1||e.layout==="singlePage")return i;let l=we(n),s=l==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",u=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:s,current:l,phase:u?s:e.phase}}function $e(e,t){let n=t.id??e.captured[t.side],r={...e.captured};(t.id===void 0||r[t.side]===t.id)&&delete r[t.side];let i=e.pending.filter(f=>f!==n),l=e.layout==="twoSided"&&ee({captured:r,pending:i})>0,s=e.lastShotByTimeout||n===e.lastShot!==e.flipped,u=l&&!s,c=u?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(f=>f!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:c,restPhase:c,current:t.side,needFlip:u,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function xe(e,t){switch(t.type){case"report":return Ye(J(e,t.at),t.report,t.at);case"tick":return Qe(J(e,t.at),t.at);case"captured":return Ke(J(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return je(e,t.id,t.side);case"duplicate":return Re(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(l=>e.captured[l]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(l=>n.includes(l));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return $e(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...Z(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function Je(e,t,n=!1){let r=e(t);return r===null?"recto":!n||r.y+r.height/2>=t.height/2?"verso":"recto"}async function Ze(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return Je(n,e,t)}async function te(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},l=Math.max(1,Math.round(i.height/i.width*t)),s=document.createElement("canvas");s.width=t,s.height=l;try{let u=s.getContext("2d");return u===null?"recto":(u.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,l),await Ze(u.getImageData(0,0,t,l),r))}finally{s.width=0,s.height=0}}async function St(e,t=480){try{let n=await createImageBitmap(e),r=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=r;let l=i.getContext("2d");return l===null?(n.close(),null):(l.drawImage(n,0,0,t,r),n.close(),l.getImageData(0,0,t,r))}catch{return null}}var ne=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),V=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function ve(e,t,n,r){let i=r.decode??(c=>createImageBitmap(c)),l=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),s;try{s=await l()}catch{try{await new Promise(c=>setTimeout(c,r.retryMs??300)),s=await l()}catch{return null}}let u=s.mrzBox;return u===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:ne(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===n.digest,band:[V(u[0]),V(u[1]),V(Math.min(u[2],1-u[0])),V(Math.min(u[3],1-u[1]))],digest:n.digest,framesToValid:ne(n.framesToValid,1,1e3),msToValid:ne(n.msToValid,0,12e4)}}function kt(e){let t=null;return e?.then(n=>{t=n}),()=>t}var et=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),tt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function Le(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,et)||!n.call(t.WebAssembly,tt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let r=t.navigator?.deviceMemory;return typeof r=="number"&&r<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}function _e(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var T=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function Te(){let e=t=>(t.close(),Promise.reject(new T("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Ee(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return Te()}catch{return Te()}let n=new Map,r=0,i=!1,l=!1,s=!1;t.addEventListener("message",d=>{let g=d.data,C=n.get(g.id);C&&(n.delete(g.id),C.resolve(g))});let u=()=>{for(let d of n.values())d.reject(new T("error"));n.clear(),f()};t.addEventListener("error",u),t.addEventListener("messageerror",u);function c(d,g=[]){if(i)return Promise.reject(new T("disposed"));let C=++r;return new Promise((B,O)=>{n.set(C,{resolve:B,reject:O});try{t.postMessage({...d,id:C},g)}catch{n.delete(C),O(new T("error"))}})}function f(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let d of n.values())d.reject(new T("disposed"));n.clear()}}let p=(async()=>{let d=await c({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(d.kind==="failed")return d.reason;if(d.kind!=="ready")return"error";let g=await c({kind:"warmup"});return g.kind!=="ready"?"error":{warmupMs:g.warmupMs,downloadMs:d.downloadMs,cached:d.cached}})().catch(()=>"error"),b,S=new Promise(d=>{b=setTimeout(()=>d("timeout"),e.tuning.loadTimeoutMs)}),I=Promise.race([p,S]).then(d=>(clearTimeout(b),typeof d=="string"?f():s=!0,i&&typeof d!="string"?"error":d));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",f,{once:!0});async function w(d,g,C){if(i)throw g.close(),new T("disposed");if(!s)throw g.close(),new T("not_ready");if(l)throw g.close(),new T("busy");l=!0;let B;try{let O=new Promise((M,A)=>{B=setTimeout(()=>{A(new T("timeout")),f()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([c(d,[g]),O]);if(P.kind===C){let{id:M,...A}=P;return A}throw new T(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(B),l=!1}}return{ready:I,get busy(){return l},bandRead:(d,g=e.tuning.detectorLimit)=>w({kind:"band",bitmap:d,detectorLimit:g},d,"band"),stillRead:(d,g,C=e.tuning.detectorLimit)=>w({kind:"still",bitmap:d,region:g,detectorLimit:C},d,"band"),layoutRead:(d,g)=>w({kind:"layout",bitmap:d,detectorLimit:g},d,"layout"),dispose:f}}var U="sekyro-ocr-1",re=e=>e!==null&&typeof e=="object"?e:{},v=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Oe=(e,t)=>typeof e=="boolean"?e:t,Pe=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function Ae(e,t={}){let n=re(e),r=re(n.liveMrz),i=re(n.frontLock),l=Pe(t.engine??U),s=t.mode==="off",u=d=>d.enabled===!0?d.arm==="live"?"live":"control":null,c=u(r),f=u(i),p=(d,g)=>!s&&g==="live"&&Pe(d.minEngine??U)<=l,b=ye,S=p(r,c)?{detectorLimit:v(r.detectorLimit,320,1600,b.detectorLimit),bandMaxWidthPx:v(r.bandMaxWidthPx,320,4096,b.bandMaxWidthPx),minBandWidthPx:v(r.minBandWidthPx,0,4096,b.minBandWidthPx),bandTop:v(r.bandTop,0,.95,b.bandTop),minIntervalMs:v(r.minIntervalMs,0,5e3,b.minIntervalMs),stableReads:Math.round(v(r.stableReads,1,10,b.stableReads)),profileReads:Math.round(v(r.profileReads,1,100,b.profileReads)),maxReadMs:v(r.maxReadMs,50,6e4,b.maxReadMs),searchTimeoutMs:v(r.searchTimeoutMs,1e3,12e4,b.searchTimeoutMs),hint:Oe(r.hint,!0),stillConfirm:Oe(r.stillConfirm,!0)}:null,I=he,h=(d,g,C)=>v(i[d],g,C,I[d]),w=p(i,f)?{minLines:Math.round(h("minLines",1,50)),fillMin:h("fillMin",0,1),fillMax:h("fillMax",0,2),offsetMax:h("offsetMax",0,1),steadyFillDelta:h("steadyFillDelta",0,1),steadyOffsetDelta:h("steadyOffsetDelta",0,1),layoutShiftMax:h("layoutShiftMax",0,1),lineCountDelta:Math.round(h("lineCountDelta",0,50)),lockMs:h("lockMs",0,3e4),steadyMs:h("steadyMs",0,3e4),minFrames:Math.round(h("minFrames",1,100)),minIntervalMs:h("minIntervalMs",0,5e3),maxWidthPx:h("maxWidthPx",160,2048),detectorLimit:h("detectorLimit",320,1600),searchTimeoutMs:h("searchTimeoutMs",1e3,12e4)}:null;return{enabled:S!==null||w!==null,liveMrz:S,textLock:w,liveMrzArm:c,frontLockArm:f,load:{detectorLimit:S?.detectorLimit??w?.detectorLimit??b.detectorLimit,loadTimeoutMs:v(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:v(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:v(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:v(r.reportSampleRate,0,1,1)}}function Be(e,t){return e.enabled?!(t.probe??Le)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??_e)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Ee({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}function nt(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}var W=e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),oe=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function Ie(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,r=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:r==="unsupported"||r==="download"||r==="integrity"?r:r==="error"||r==="timeout"?"error":"off",l={kind:"live_mrz",platform:"web",engine:e.engine??U,arm:e.arm,capture:e.capture,outcome:i,reads:oe(t?.reads??0,0,1e4)??0,browser:e.browser??nt()},s=(u,c)=>{c!==void 0&&(l[u]=c)};return s("format",t?.format),s("framesToValid",oe(t?.framesToValid,1,1e4)),s("msToValid",W(t?.msToValid)),s("framesToLock",oe(t?.framesToLock,1,1e4)),s("msToLock",W(t?.msToLock)),s("msToCapture",W(e.msToCapture)),s("readP50Ms",W(t?.readP50Ms)),s("readP90Ms",W(t?.readP90Ms)),s("deviceClass",t?.deviceClass),n!==null&&(s("warmupMs",W(n.warmupMs)),s("downloadMs",W(n.downloadMs)),s("cached",n.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),l}function ae(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var rt=2;async function ot(e){let t=await import("./capture-session-doc-GK6G7JOI.js");return new t.CaptureSessionDoc(e)}function at(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}function it(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let l=0;l<r.length;l+=1){let s=r[l],u=r[(l+1)%r.length];i+=s.x*u.y-u.x*s.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function Nt(){import("./capture-session-doc-GK6G7JOI.js").then(e=>e.warmDocDetector()).catch(()=>{})}function Ut(e){return st(e,{}).handle}function st(e,t){let n=me(),r=pe({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),l=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),u=e.documentType==="passport"||e.side==="single",c=Z(u?"singlePage":"twoSided",s());if(!u&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";c={...c,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let f="idle",p=null,b=null,S=!0,I=0,h=0,w=!1,d=!1,g="",C=null,B,O=null,P=[],M=t.webOcr!==void 0?Ae(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,A=null,F=M===null||!M.enabled?"off":null,G=null,q=null,ie=new WeakMap,Y="";if(M!==null&&M.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Be(M,{baseUrl:e.liveMrz?.assetBaseUrl??o.baseUrl,salt:o.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...o.createWorker!==void 0?{createWorker:o.createWorker}:{}});if(a.ok){A=a.engine;let m=new Se({textLock:M.textLock,liveMrz:M.liveMrz});G=m;let y=a.engine;y.ready.then(L=>{F=L,typeof L!="string"&&S&&m.setEngine(y)})}else F=a.reason}let z=o=>{let a=JSON.stringify(o);a!==Y&&(Y=a,n.emit("mrz",o))},se=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||M===null||o===void 0)return;let y=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=y!=="recto"?M.liveMrzArm??M.frontLockArm:M.frontLockArm;if(L===null||Math.random()>=M.reportSampleRate)return;let _=o.via==="live_mrz"?q:null,x=()=>{let E=_?.value??null;m([Ie({arm:L,capture:y,assist:o.ocr??null,load:L==="control"?"off":F,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...E!==null&&E.stillConfirmed!==void 0?{stillConfirmed:E.stillConfirmed}:{},...a!==void 0?{typeMismatch:ae(a.format,e.documentType==="passport"?"passport":"card")}:{}})])};_!==null&&_.value===null?Promise.race([_.promise,new Promise(E=>setTimeout(E,3e3))]).then(x):x()},N=o=>{!S||o===f||(f=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},We=(o,a)=>a===void 0?null:u?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,Fe=o=>({phase:o.phase,captured:u?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:u?null:o.current??null,notice:o.notice??null,lastShot:We(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:p?.torchAvailable()??!1,torch:d}),ue=()=>{let o=p;o!==null&&o.captureNow().catch(()=>R({type:"captureFailed",at:s()}))};function R(o){if(!S)return;let a=c;c=xe(c,o),c.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(ue),c.phase==="result"&&a.phase!=="result"&&(N("done"),le());let m=Fe(c),y=JSON.stringify(m);y!==g&&(g=y,n.emit("scan",m))}function le(){O!==null&&clearInterval(O),O=null;for(let o of P.splice(0))o();p?.destroy(),p=null,r.setActive(!1)}let ce=()=>p?.captureReport?.(),Q=!1,de=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},H=o=>{Y="",!(p===null||c.phase==="reading"||c.phase==="result")&&(Q=!1,p.rearm(u?"single":c.current??o))},ze=async(o,a,m,y)=>{if(q=null,y!==void 0&&A!==null&&M?.liveMrz?.hint===!0){let D={promise:ve(A,o,y,{engine:U,detectorLimit:M.liveMrz.detectorLimit}).catch(()=>null),value:null};D.promise.then(k=>{D.value=k}),q=D}y!==void 0&&ae(y.format,e.documentType==="passport"?"passport":"card")&&z({state:"mismatch",format:y.format});let L=ce();de(L,"captured"),Q=!0,se(L,y);let _=m===void 0?C:m===null?null:{quad:at(m),frameWidth:0,frameHeight:0,inStill:!0},x={decoded:null},E=()=>(x.decoded??(x.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),x.decoded);try{await Ne(o,a,_,E,q)}finally{x.decoded!==null&&(await x.decoded)?.close()}},Ne=async(o,a,m,y,L)=>{let _=`shot-${I+=1}`;if(R({type:"captured",id:_,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!w&&l>0){let D=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):y().then(k=>k===null?-1:be(k,j(m?.quad??null,m?.inStill===!0?k:{width:m?.frameWidth??0,height:m?.frameHeight??0},k)))).catch(()=>-1);if(!S)return;if(Number.isFinite(D)&&D>=0&&D<l){w=!0;let k=u?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:k,id:_,issue:"blurry"}),H(k);return}}w=!1;let x;if(u)x="single";else{let D=c.current,k=await(t.classify!==void 0?t.classify(o):y().then(X=>X===null?D??"recto":m?.inStill===!0?te(X,480,null,!0):te(X,480,j(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},X)))).catch(()=>D??"recto");if(!S)return;if(c.captured[k]!==void 0&&h<rt){h+=1,R({type:"duplicate",id:_,side:k}),H(k==="recto"?"verso":"recto");return}x=c.captured[k]!==void 0&&D!==void 0?D:k,h=0,R({type:"classified",id:_,side:x})}let E=x==="verso"?"verso":"recto";try{let D=t.encode!==void 0?await t.encode(o):await y().then(k=>{if(k===null)throw new Error("the still could not be decoded");return $(k)});if(!S)return;L!==null&&ie.set(D.blob,L),n.emit("captured",{image:D.blob,side:x,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:D.width,height:D.height,previewDataUrl:a}),t.deferRead!==!0&&R({type:"readOk",side:E})}catch{R({type:"readFailed",side:E,id:_,issue:"technical"}),n.emit("error",{kind:"generic",retryable:!0})}H(E==="recto"?"verso":"recto")},Ue=o=>{P.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?N("starting"):a==="positioning"?N("scanning"):a==="captured"?N("captured"):a==="error"&&N("error")}),o.on("feedback",({key:a,reticle:m})=>n.emit("feedback",{key:a,reticle:m})),o.on("checks",a=>{n.emit("gate",{progress:a.p,quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight,...a.guide!==void 0?{guide:{detected:a.guide.detected,fill:a.guide.fill,offsetX:a.guide.offsetX??0,offsetY:a.guide.offsetY??0}}:{}});let m=a.ocr?.mrz;m!==void 0&&(m.state==="fallback"?z({state:"fallback",reason:m.reason}):m.state==="valid"?z({state:"valid",format:m.format}):m.state==="reading"?z({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):z({state:"searching"}));let y=a.quad===null?0:it(a.quad,a.frameWidth,a.frameHeight);C=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},R({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:y},at:s()})}),o.on("error",({kind:a,retryable:m})=>n.emit("error",{kind:fe(a),retryable:m})),o.on("artifacts",a=>{ze(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},K=()=>(b??(b=(async()=>{if(S){if(p===null){let o=await(t.createEngine??ot)({...t.engineOptions??{},...B!==void 0?{guide:B}:{},video:e.video,format:ge(e.documentType),side:u?"single":e.side??"recto",autoCapture:!1,...G!==null?{ocr:G}:{}});if(!S){o.destroy();return}p=o,Ue(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>R({type:"tick",at:s()}),a))}R({type:"clockRestart"}),M!==null&&M.liveMrzArm==="live"&&(F==="unsupported"||F==="off")&&z({state:"fallback",reason:F}),await p.start()}})().finally(()=>{b=null})),b);return{handle:{get state(){return f},on:(o,a)=>n.on(o,a),start:K,retry:()=>{if(p===null&&c.phase==="result"){R({type:"retake"}),h=0,w=!1,K();return}if(p!==null&&f!=="error"){R({type:"retake"}),h=0,w=!1,p.rearm(u?"single":void 0);return}K()},setSide:o=>{u||o==="single"||(c.current!==o&&(c={...c,current:o}),R({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&p?.rearm(o))},shutter:ue,focusAt:(o,a)=>{p?.focusAt?.(o,a)},setGuide:o=>{B=o,p?.setGuide?.(o)},setTorch:o=>{d=o,p?.setTorch(o),R({type:"tick",at:s()})},destroy:()=>{if(S&&p!==null&&f!=="done"){let o=ce();!Q&&o!==void 0&&o.ticks>0&&de(o,"abandoned"),se(o,void 0)}S=!1,le(),G?.setEngine(null),A?.dispose(),A=null,n.clear()}},setFlowState:o=>{(c.phase==="reading"||c.phase==="result")&&N(o==="done"&&c.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";R(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||H(m)},takeDeviceRead:o=>ie.get(o.image)?.value??null}}export{dt as a,pt as b,ft as c,gt as d,bt as e,ht as f,De as g,Z as h,xe as i,Je as j,Ze as k,St as l,ve as m,kt as n,U as o,Ae as p,Be as q,nt as r,Ie as s,ae as t,rt as u,Nt as v,Ut as w,st as x};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=avc1.42E01E","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp9","video/webm;codecs=vp8,opus","video/webm;codecs=vp8","video/webm"];function m(){let e=globalThis.MediaRecorder;return!e||typeof e.isTypeSupported!="function"?"":c.find(o=>e.isTypeSupported(o))??""}var d="video/webm";function f(e){if(e instanceof TypeError)return"insecure";switch(e?.name??""){case"NotAllowedError":case"PermissionDeniedError":return"permission";case"NotFoundError":case"DevicesNotFoundError":return"notfound";case"NotReadableError":case"TrackStartError":return"inuse";case"OverconstrainedError":case"ConstraintNotSatisfiedError":return"overconstrained";default:return"generic"}}function w(){let e=globalThis;if(typeof e.window<"u"&&e.window.isSecureContext===!1)return"INSECURE_CONTEXT";let o=e.navigator?.mediaDevices;return!o||typeof o.getUserMedia!="function"?"UNSUPPORTED":"OK"}function E(){let e=globalThis.MediaRecorder;return typeof e<"u"&&typeof e.isTypeSupported=="function"}var u=8*1024*1024;function l(e){return e.size>u}function p(e){let o=(e||"").toLowerCase();return o.startsWith("image/jpeg")?"jpg":o.startsWith("video/mp4")?"mp4":(o.startsWith("video/webm"),"webm")}function v(e){let{token:o,clip:n,keyframe:t}=e,i=e.ts??Date.now(),s=n.type||d,a=t.type||"image/jpeg",r=new FormData;return r.append("token",o),r.append("clip",new File([n],`liveness-${i}.${p(s)}`,{type:s})),r.append("keyframe",new File([t],`keyframe-${i}.${p(a)}`,{type:a})),r}export{c as a,m as b,d as c,f as d,w as e,E as f,u as g,l as h,p as i,v as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=180,g=[100,190],x=64;function f(r,n){return .299*(r[n]??0)+.587*(r[n+1]??0)+.114*(r[n+2]??0)}function b(r){let{data:n,width:e,height:o}=r,t=e*o;if(t===0)return 0;let u=0;for(let s=0;s<t;s+=1)u+=f(n,s*4);return u/t}function E(r){let{data:n,width:e,height:o}=r;if(e<3||o<3)return 0;let t=new Float32Array(e*o);for(let a=0;a<t.length;a+=1)t[a]=f(n,a*4);let u=0,s=0,c=0;for(let a=1;a<o-1;a+=1)for(let i=1;i<e-1;i+=1){let m=a*e+i,l=(t[m-e]??0)+(t[m-1]??0)+(t[m+1]??0)+(t[m+e]??0)-4*(t[m]??0);u+=l,s+=l*l,c+=1}if(c===0)return 0;let h=u/c,p=s/c-h*h;return Math.min(1,Math.max(0,p)/180)}function F(r){let n=b(r),[e,o]=g,t=n<e?e-n:n>o?n-o:0;return Math.max(0,1-t/x)}export{A as a,g as b,b as c,E as d,F as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function c(t,n){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:n,frameRate:{ideal:24,max:30}},audio:!1}}var o=600;function r(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(t))return"phone";if(/iPad/i.test(t))return"tablet";if(/Android/i.test(t))return/Mobile/i.test(t)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(t))return"phone";if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(t))return"tablet";if(!a())return"desktop";let e=i();return e>0&&e<o?"phone":"tablet"}function s(){return r()!=="desktop"}function i(){try{let t=window.screen,n=Number(t?.width??0),e=Number(t?.height??0);return n>0&&e>0?Math.min(n,e):0}catch{return 0}}function u(t){try{let e=t?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return e==="user"||e==="environment"?e:null}catch{return null}}function a(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var d=.45,f=.9,h=.4;export{c as a,o as b,r as c,s as d,u as e,d as f,f as g,h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as T,b as R}from"./chunk-DK5YPBDQ.js";var N=1e3,_=[[1,0],[0,1],[1,1],[1,-1]];function w(i){let{width:t,height:e,data:r}=i;if(t<16||e<16)return-1;let s=new Uint8Array(t*e);for(let n=0,a=0;n<s.length;n+=1,a+=4)s[n]=Math.round(.299*(r[a]??0)+.587*(r[a+1]??0)+.114*(r[a+2]??0));let o=-1;for(let[n,a]of _){let l=new Uint32Array(256),c=new Float64Array(256),p=0;for(let h=1;h<e-1;h+=1){let u=h*t,S=(h+a)*t,A=(h-a)*t;for(let g=1;g<t-1;g+=1){let y=s[S+g+n]??0,z=s[A+g-n]??0,v=Math.abs(y-z);l[v]=(l[v]??0)+1,c[v]=(c[v]??0)+Math.abs(y+z-2*(s[u+g]??0)),p+=1}}let M=Math.max(1,Math.floor(p/20)),m=0,d=0,f=0;for(let h=255;h>=0&&m<M;h-=1){let u=l[h]??0;m+=u,d+=u*h,f+=c[h]??0}if(d===0)return 0;let b=f/d;o=o<0?b:Math.min(o,b)}return o}var I=.06;function P(i,t,e,r=I){if(i===null||t.width<=0||t.height<=0)return null;let s=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft],o=e.width/t.width,n=e.height/t.height,a=Math.min(...s.map(u=>u.x))*o,l=Math.max(...s.map(u=>u.x))*o,c=Math.min(...s.map(u=>u.y))*n,p=Math.max(...s.map(u=>u.y))*n,M=(l-a)*r,m=(p-c)*r,d=Math.max(0,Math.floor(a-M)),f=Math.max(0,Math.floor(c-m)),b=Math.min(e.width,Math.ceil(l+M)),h=Math.min(e.height,Math.ceil(p+m));return b-d<16||h-f<16?null:{x:d,y:f,width:b-d,height:h-f}}function F(i,t){let e=new Uint8ClampedArray(t.width*t.height*4);for(let r=0;r<t.height;r+=1)for(let s=0;s<t.width*4;s+=1)e[r*t.width*4+s]=i.data[((t.y+r)*i.width+t.x)*4+s]??0;return{data:e,width:t.width,height:t.height}}function E(i,t=1e3){let e=t/Math.max(i.width,i.height);if(e>=1)return i;let r=Math.max(1,Math.round(i.width*e)),s=Math.max(1,Math.round(i.height*e)),o=new Uint8ClampedArray(r*s*4);for(let n=0;n<s;n+=1){let a=Math.floor(n/e),l=Math.min(i.height,Math.max(a+1,Math.floor((n+1)/e)));for(let c=0;c<r;c+=1){let p=Math.floor(c/e),M=Math.min(i.width,Math.max(p+1,Math.floor((c+1)/e)));for(let m=0;m<3;m+=1){let d=0;for(let f=a;f<l;f+=1)for(let b=p;b<M;b+=1)d+=i.data[(f*i.width+b)*4+m]??0;o[(n*r+c)*4+m]=d/((l-a)*(M-p))}o[(n*r+c)*4+3]=255}}return{data:o,width:r,height:s}}function V(i,t){return w(E(t===null?i:F(i,t)))}function B(i,t){let e=t??{x:0,y:0,width:i.width,height:i.height},r=Math.min(1,1e3/Math.max(e.width,e.height)),s=Math.max(1,Math.round(e.width*r)),o=Math.max(1,Math.round(e.height*r)),n=document.createElement("canvas");n.width=s,n.height=o;try{let a=n.getContext("2d",{willReadFrequently:!0});return a===null?-1:(a.imageSmoothingQuality="high",a.drawImage(i,e.x,e.y,e.width,e.height,0,0,s,o),w(a.getImageData(0,0,s,o)))}catch{return-1}finally{n.width=0,n.height=0}}var k=class{constructor(t=2){this.stableReads=t;this.last=null;this.run=0}offer(t){return t===null?(this.reset(),!1):(this.run=t===this.last?this.run+1:1,this.last=t,this.run>=this.stableReads)}reset(){this.last=null,this.run=0}};var D=Object.freeze({...T,minIntervalMs:150,maxWidthPx:480,detectorLimit:960,searchTimeoutMs:12e3}),O=Object.freeze({detectorLimit:960,bandMaxWidthPx:1280,minBandWidthPx:900,bandTop:.55,minIntervalMs:150,stableReads:2,profileReads:5,maxReadMs:1200,searchTimeoutMs:12e3}),C=(i,t,e)=>createImageBitmap(i,Math.round(t.x),Math.round(t.y),Math.max(1,Math.round(t.w)),Math.max(1,Math.round(t.h)),{resizeWidth:Math.max(1,Math.round(Math.min(t.w,e))),resizeQuality:"high"}),x=(i,t)=>{if(i.length===0)return 0;let e=[...i].sort((r,s)=>r-s);return e[Math.min(e.length-1,Math.floor(e.length*t))]};function G(i){return i<=250?"fast":i<=600?"mid":"slow"}function Y(i,t,e){let r=i.y+i.h*t,s=Math.min(e,i.y+i.h*1.05);return{x:i.x,y:r,w:i.w,h:Math.max(1,s-r)}}var L=class{constructor(t){this.o=t;this.engine=null;this.gen=0;this.inFlight=!1;this.lastReadAt=Number.NEGATIVE_INFINITY;this.firstSeen=null;this.reads=0;this.times=[];this.mrzState={state:"searching"};this.lockState={state:"searching"};this.fallback=null;this.lockOff=!1;this.lockError=!1;this.fired=null;this.valid=null;this.faceMode="off";this.disabled=!1;this.crop=t.crop??C,this.mrzGate=new k(t.liveMrz?.stableReads??2),this.lockGate=new R(t.textLock??D)}setEngine(t){this.engine=t}get bandTop(){return this.o.liveMrz?.bandTop??O.bandTop}get hasEngine(){return this.engine!==null&&!this.disabled}reset(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.firstSeen=null,this.reads=0,this.times=[],this.mrzGate.reset(),this.lockGate.reset(),this.mrzState={state:"searching"},this.lockState={state:"searching"},this.fallback=null,this.lockOff=!1,this.lockError=!1,this.fired=null,this.valid=null,this.faceMode="off"}rearmFace(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.mrzGate.reset(),this.lockGate.reset(),this.fired=null,this.valid=null,this.fallback===null&&(this.mrzState={state:"searching"}),this.lockOff||(this.lockState={state:"searching"})}liveCapture(){return this.fired?.via==="live_mrz"?this.valid:null}modeFor(t){return this.engine===null||this.disabled?"off":t.mrzFace&&this.o.liveMrz!==null&&this.fallback===null?"live_mrz":this.o.textLock!==null&&!this.lockOff?"text_lock":"off"}tick(t){let e=this.modeFor(t);return e!=="off"&&(this.faceMode=e),this.fired!==null?{ready:!0,via:this.fired.via,suspendQuality:this.fired.via==="live_mrz",mode:e,...this.states()}:e==="live_mrz"?this.liveTick(t,this.o.liveMrz):e==="text_lock"?this.lockTick(t,this.o.textLock):{ready:!1,suspendQuality:!1,mode:e,...this.states()}}states(){return{...this.faceMode==="live_mrz"||this.fallback!==null?{mrz:this.fallback!==null?{state:"fallback",reason:this.fallback}:this.mrzState}:{},...this.faceMode==="text_lock"?{lock:this.lockState}:{}}}canRead(t,e){let r=this.engine;return r!==null&&!this.inFlight&&!r.busy&&t-this.lastReadAt>=e}fall(t){this.fallback=t,this.mrzGate.reset()}liveTick(t,e){let r=()=>this.fallback!==null?{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:{state:"fallback",reason:this.fallback}}:{ready:!1,suspendQuality:!0,mode:"live_mrz",mrz:this.mrzState};if(!t.present||t.band===null)return this.mrzGate.reset(),this.mrzState={state:"searching"},r();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.fall("timeout"),r();if(t.band.w<e.minBandWidthPx)return t.card!==null&&t.card.w<e.minBandWidthPx?(this.fall("unsupported"),r()):(this.mrzState={state:"reading",coach:t.portrait?"turnSideways":"moveCloser"},{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:this.mrzState});if(!this.canRead(t.atMs,e.minIntervalMs))return r();this.inFlight=!0,this.lastReadAt=t.atMs;let s=this.gen,o=this.engine,n=t.glareOk?t.sharpOk?void 0:"holdStill":"glare";return this.crop(t.video,t.band,e.bandMaxWidthPx).then(a=>o.bandRead(a,e.detectorLimit)).then(a=>{if(s===this.gen){if(this.reads++,this.times.push(a.ms),this.times.length>8&&this.times.shift(),this.reads>=e.profileReads&&x(this.times,.5)>e.maxReadMs)return this.fall("slow");if(this.mrzGate.offer(a.valid?a.digest??null:null)&&a.format&&a.digest){this.valid={format:a.format,...a.documentCode!==void 0?{documentCode:a.documentCode}:{},digest:a.digest,lineCount:a.lineCount,framesToValid:this.reads,msToValid:Math.round(t.atMs-(this.firstSeen??t.atMs))},this.mrzState={state:"valid",format:a.format},this.fired={via:"live_mrz",at:t.atMs};return}this.mrzState={state:"reading",...n?{coach:n}:{},...a.format?{format:a.format}:{}}}}).catch(()=>{s===this.gen&&this.fall("error")}).finally(()=>{s===this.gen&&(this.inFlight=!1)}),r()}lockTick(t,e){let r=()=>({ready:!1,suspendQuality:!1,mode:"text_lock",lock:this.lockState,...this.fallback!==null?{mrz:{state:"fallback",reason:this.fallback}}:{}});if(!t.present||t.card===null)return this.lockGate.reset(),this.lockState={state:"searching"},r();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.lockOff=!0,r();if(!this.canRead(t.atMs,e.minIntervalMs))return r();this.inFlight=!0,this.lastReadAt=t.atMs;let s=this.gen,o=this.engine,n={glareOk:t.glareOk,sharpOk:t.sharpOk};return this.crop(t.video,t.card,e.maxWidthPx).then(a=>o.layoutRead(a,e.detectorLimit)).then(a=>{if(s!==this.gen)return;this.reads++,this.times.push(a.ms),this.times.length>8&&this.times.shift();let l=this.lockGate.offer(a,t.atMs,n);this.lockState=l.state==="locked"?{state:"locked"}:{state:l.state,...l.hint?{hint:l.hint}:{}},l.state==="locked"&&(this.fired={via:"text_lock",at:t.atMs})}).catch(()=>{s===this.gen&&(this.lockOff=!0,this.lockError=!0)}).finally(()=>{s===this.gen&&(this.inFlight=!1)}),r()}disable(){this.disabled=!0,this.reset()}report(t,e,r){let s=this.faceMode;if(s==="off")return null;let o=x(this.times,.5),n={capture:t,mode:s,reads:this.reads,...this.times.length>0?{readP50Ms:Math.round(o),readP90Ms:Math.round(x(this.times,.9)),deviceClass:G(o)}:{}};return s==="live_mrz"?this.fired?.via==="live_mrz"&&this.valid!==null&&e==="live_mrz"?{...n,outcome:"valid",format:this.valid.format,framesToValid:this.valid.framesToValid,msToValid:this.valid.msToValid}:this.fallback!==null?{...n,outcome:this.fallback}:{...n,outcome:r-(this.firstSeen??r)>=(this.o.liveMrz?.searchTimeoutMs??1/0)?"timeout":"off"}:this.fired?.via==="text_lock"?{...n,outcome:"locked",framesToLock:Math.max(1,this.reads),msToLock:Math.round(this.fired.at-(this.firstSeen??this.fired.at))}:{...n,outcome:this.lockError?"error":this.lockOff?"timeout":"off"}}};export{N as a,w as b,I as c,P as d,F as e,E as f,V as g,B as h,D as i,O as j,Y as k,L as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var K={enabled:!0,hz:3,segmenterTimeoutMs:8e3,segmenterBudgetMs:120,maskThreshold:.5,maxColorStd:28,maxEdgeDensity:.08,edgeLuma:24,maxGradient:.18,minPixels:300,timeoutMs:4e3},V=12e3,b=(n,o,t)=>Math.min(t,Math.max(o,Math.round(n)));function W(n,o,t){let{x:r,y:m,width:a,height:u}=n;if(t)return[{x:r-1.5*a,y:m-.8*u,width:4*a,height:2.8*u}];let d=m-.4*u,p=1.4*u;return[{x:r-.9*a,y:d,width:.75*a,height:p},{x:r+1.15*a,y:d,width:.75*a,height:p}].map(h=>{let M=Math.max(0,h.x),l=Math.min(o.width,h.x+h.width);return{x:M,y:h.y,width:Math.max(0,l-M),height:h.height}})}function Z(n,o,t,r=K){let m=t!==null&&t.width>0&&t.height>0,a=W(o,n,m),u=a.reduce((e,s)=>e+Math.max(0,s.width)*Math.max(0,s.height),0);if(u<=0)return null;let d=Math.max(1,Math.floor(Math.sqrt(u/V))),p=m?t.data instanceof Float32Array?1:1/255:1,h=(e,s)=>{if(!m)return!1;let w=b(e/n.width*t.width-.5,0,t.width-1),C=b(s/n.height*t.height-.5,0,t.height-1);return t.data[C*t.width+w]*p>=r.maskThreshold},M=e=>.299*n.data[e]+.587*n.data[e+1]+.114*n.data[e+2],l=0,B=[0,0,0],S=[0,0,0],k=0,T=0,D=0,_=0,P=0,A=0,E=0,L=0,F=0,G=0,O=Math.min(...a.map(e=>e.x)),j=Math.max(...a.map(e=>e.x+e.width)),H=Math.min(...a.map(e=>e.y)),I=Math.max(...a.map(e=>e.y+e.height)),J=(O+j)/2,Q=(H+I)/2;for(let e of a){let s=b(e.x,0,n.width),w=b(e.x+e.width,0,n.width),C=b(e.y,0,n.height),q=b(e.y+e.height,0,n.height);for(let c=C;c<q;c+=d)for(let g=s;g<w;g+=d){if(h(g,c))continue;let Y=(c*n.width+g)*4;for(let i=0;i<3;i+=1){let x=n.data[Y+i];B[i]=B[i]+x,S[i]=S[i]+x*x}l+=1;let y=M(Y);g<J?(D+=y,_+=1):(P+=y,A+=1),c<Q?(E+=y,L+=1):(F+=y,G+=1);for(let[i,x]of[[g+d,c],[g,c+d]])i>=w||x>=q||h(i,x)||(k+=1,Math.abs(M((x*n.width+i)*4)-y)>r.edgeLuma&&(T+=1))}}if(l<r.minPixels)return null;let U=0;for(let e=0;e<3;e+=1){let s=B[e]/l;U+=Math.max(0,S[e]/l-s*s)}let N=Math.sqrt(U/3),z=k===0?0:T/k,f=(e,s)=>s===0?null:e/s,R=(e,s)=>e===null||s===null?0:Math.abs(e-s)/255,X=Math.max(R(f(D,_),f(P,A)),R(f(E,L),f(F,G)));return{method:m?"segmenter":"strip",uniform:N<=r.maxColorStd&&z<=r.maxEdgeDensity&&X<=r.maxGradient,colorStd:Math.round(N*10)/10,edgeDensity:Math.round(z*1e3)/1e3,gradient:Math.round(X*1e3)/1e3,pixels:l}}function $(n){let o=n!==null&&typeof n=="object"?n:{},t=K,r=(m,a,u,d)=>typeof m=="number"&&Number.isFinite(m)&&m>=u&&m<=d?m:a;return{enabled:typeof o.enabled=="boolean"?o.enabled:t.enabled,hz:r(o.hz,t.hz,.5,15),segmenterTimeoutMs:r(o.segmenterTimeoutMs,t.segmenterTimeoutMs,0,6e4),segmenterBudgetMs:r(o.segmenterBudgetMs,t.segmenterBudgetMs,1,2e3),maskThreshold:r(o.maskThreshold,t.maskThreshold,0,1),maxColorStd:r(o.maxColorStd,t.maxColorStd,0,255),maxEdgeDensity:r(o.maxEdgeDensity,t.maxEdgeDensity,0,1),edgeLuma:r(o.edgeLuma,t.edgeLuma,0,255),maxGradient:r(o.maxGradient,t.maxGradient,0,1),minPixels:r(o.minPixels,t.minPixels,1,1e6),timeoutMs:r(o.timeoutMs,t.timeoutMs,0,6e4)}}export{K as a,Z as b,$ as c};
|
|
@@ -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)},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 h(){let e=await f();return e===null?"unknown":u(e.state)}function g(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 S(){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 E(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 a=v();if(a===null||!m())return;let o;try{o=a.request("screen")}catch{return}t=!0,o.then(s=>{if(t=!1,!i){p(s);return}n=s,s.addEventListener?.("release",()=>{n===s&&(n=null)})},()=>{t=!1})},c=()=>{m()&&l()},d=a=>{typeof document>"u"||a===r||(r=a,a?document.addEventListener("visibilitychange",c):document.removeEventListener("visibilitychange",c))};return{setActive:a=>{if(i=a,a){if(v()===null)return;d(!0),l();return}if(d(!1),n!==null){let o=n;n=null,p(o)}}}}export{y as a,h as b,g as c,S as d,E as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk-BAGSM67V.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"];function E(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 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,E as b,d as c,l as d,f as e,N as f,H as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as x}from"./chunk-TDLIXFDT.js";import{b}from"./chunk-FPXL63KZ.js";var T=480,y=Object.freeze({MIN_AREA_FRAC:.15,EDGE_CLIP_MARGIN_PX:4,STABLE_TICKS:3,IOU_STABLE_MIN:.85,RISE_PER_S:.9,FALL_PER_S:.25,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,ID3_BAND_MIN_WIDTH_FRAC:.55,ID3_BAND_ASPECT_MIN:4,ID3_BAND_ASPECT_MAX:40}),p=e=>Math.min(1,Math.max(0,e));function E(e,o,t){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let s=0;s<4;s++){let r=n[s],c=n[(s+1)%4];i+=r.x*c.y-c.x*r.y}let a=o*t;return a>0?Math.abs(i/2)/a:0}function I(e,o){let t=D(e),n=D(o),i=Math.max(t.x1,n.x1),a=Math.max(t.y1,n.y1),s=Math.min(t.x2,n.x2),r=Math.min(t.y2,n.y2),c=Math.max(0,s-i)*Math.max(0,r-a),u=(t.x2-t.x1)*(t.y2-t.y1),_=(n.x2-n.x1)*(n.y2-n.y1),m=u+_-c;return m>0?c/m:0}function R(e){let o=D(e);return{width:o.x2-o.x1,height:o.y2-o.y1}}function D(e){let o=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];return{x1:Math.min(...o.map(t=>t.x)),y1:Math.min(...o.map(t=>t.y)),x2:Math.max(...o.map(t=>t.x)),y2:Math.max(...o.map(t=>t.y))}}function M(e){let o=Math.hypot(e.topRight.x-e.topLeft.x,e.topRight.y-e.topLeft.y),t=Math.hypot(e.bottomRight.x-e.bottomLeft.x,e.bottomRight.y-e.bottomLeft.y),n=Math.hypot(e.bottomLeft.x-e.topLeft.x,e.bottomLeft.y-e.topLeft.y),i=Math.hypot(e.bottomRight.x-e.topRight.x,e.bottomRight.y-e.topRight.y),a=(o+t)/2,s=(n+i)/2;return a<=0||s<=0?0:Math.max(a,s)/Math.min(a,s)}var d=class{constructor(o,t={}){this.p=0;this.lastTickAt=null;this.lastQuad=null;this.streak=0;this.format=o,this.t={...y,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0}tick(o){let{quad:t,quality:n,timestampMs:i}=o,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s=null;if(t===null)s="dcv1.no_doc";else if(this.format==="ID-3"){let h=R(t),f=h.height>0?h.width/h.height:0;h.width<this.t.ID3_BAND_MIN_WIDTH_FRAC*o.frameWidth?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":(f<this.t.ID3_BAND_ASPECT_MIN||f>this.t.ID3_BAND_ASPECT_MAX)&&(s="dcv1.wrong_shape")}else E(t,o.frameWidth,o.frameHeight)<this.t.MIN_AREA_FRAC?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":x(this.format,M(t))||(s="dcv1.wrong_shape");let r=s===null,c=p(n.exposure)>=this.t.GUIDE_EXPOSURE,u=p(n.sharpness)>=this.t.GUIDE_SHARPNESS,_=c&&u;if(r&&_&&t!==null){let h=this.lastQuad===null||I(t,this.lastQuad)>=this.t.IOU_STABLE_MIN;this.streak=h?this.streak+1:1}else this.streak=0;this.lastQuad=t;let m=r&&_;this.p=p(this.p+(m?this.t.RISE_PER_S:-this.t.FALL_PER_S)*a);let A=m&&this.streak>=this.t.STABLE_TICKS,l;if(s!==null)l=s;else if(c)u?l="dcv1.hold_still":l="dcv1.steady";else{let h=(b[0]+b[1])/2;l=n.meanLuma<h?"dcv1.more_light":"dcv1.too_bright"}return{at:i,quad:t,plausible:r,p:this.p,guidanceKey:l,ready:A,stableTicks:this.streak}}edgeClipped(o,t,n){let i=this.t.EDGE_CLIP_MARGIN_PX;return[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft].some(s=>s.x<=i||s.y<=i||s.x>=t-i||s.y>=n-i)}};export{T as a,y as b,E as c,I as d,R as e,d as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f="https://challenges.cloudflare.com/turnstile/v0/api.js",g=3e4;function p(){return window.turnstile}var o=null;function w(){o=null}function E(){return o??(o=new Promise((s,t)=>{let r=p();if(r){s(r);return}let e=document.createElement("script");e.src=f,e.async=!0,e.onload=()=>{let n=p();n?s(n):(o=null,t(new Error("Turnstile script loaded but exposed no API")))},e.onerror=()=>{o=null,e.remove(),t(new Error("Turnstile script failed to load"))},document.head.appendChild(e)})),o}function d(){return new Error("Turnstile challenge aborted")}async function x(s,t={}){let r=t.timeoutMs??3e4,e=t.signal;if(e?.aborted)throw d();let n=await E();if(e?.aborted)throw d();let a=document.createElement("div");document.body.appendChild(a);let i,c,u;try{return await new Promise((m,l)=>{if(c=setTimeout(()=>l(new Error(`Turnstile challenge timed out (${r} ms)`)),r),e!==void 0&&(u=()=>l(d()),e.addEventListener("abort",u,{once:!0})),i=n.render(a,{sitekey:s,execution:"execute",appearance:"execute",callback:m,"error-callback":T=>{l(new Error(`Turnstile challenge failed${T?` (${T})`:""}`))}}),i===void 0){l(new Error("Turnstile render returned no widget id"));return}n.execute(i)})}finally{if(clearTimeout(c),e!==void 0&&u!==void 0&&e.removeEventListener("abort",u),i!==void 0)try{n.remove(i)}catch{}a.remove()}}export{f as a,g as b,w as c,E as d,x as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=1e4,u=class t{constructor(e,i){this.tier="blaze";this.inner=e,i!==void 0&&(this.fallbackReason=i)}static async create(e,i){let o=await import("@mediapipe/tasks-vision"),n=await o.FilesetResolver.forVisionTasks(e),r=await o.FaceDetector.createFromOptions(n,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(r,i)}async detect(e,i,o){let n;try{n=this.inner.detect(e).detections}catch{return null}let r=O(n);if(r?.boundingBox===void 0)return null;let a=g(e),s=w(r.keypoints,a),c=r.keypoints?.[2],b={box:{x:r.boundingBox.originX,y:r.boundingBox.originY,width:r.boundingBox.width,height:r.boundingBox.height},...s!==void 0?{eyes:s}:{},...c!==void 0?{nose:{x:c.x*a.width,y:c.y*a.height}}:{},score:r.categories[0]?.score??0};return l(b,e,i,o)}destroy(){try{this.inner.close()}catch{}}};function O(t){let e,i=-1;for(let o of t){let n=o.categories[0]?.score??0;n>i&&(e=o,i=n)}return e}function w(t,e){let i=t?.[0],o=t?.[1];if(i===void 0||o===void 0)return;let n=s=>({x:s.x*e.width,y:s.y*e.height}),[r,a]=[n(i),n(o)];return r.x<=a.x?{left:r,right:a}:{left:a,right:r}}function R(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}async function x(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:1});return await e.detect(R()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var m=class{constructor(e,i){this.tier="native";this.inner=e,i!==void 0&&(this.fallbackReason=i)}async detect(e,i,o){let n;try{n=await this.inner.detect(e)}catch{return null}let r=n[0];if(r===void 0)return null;let a=T(r.landmarks),s={box:{x:r.boundingBox.x,y:r.boundingBox.y,width:r.boundingBox.width,height:r.boundingBox.height},...a!==void 0?{eyes:a}:{},score:1};return l(s,e,i,o)}destroy(){}};function T(t){if(t===void 0)return;let e=t.filter(n=>n.type==="eye").map(n=>n.locations[0]).filter(n=>n!==void 0),[i,o]=e;if(!(i===void 0||o===void 0))return i.x<=o.x?{left:i,right:o}:{left:o,right:i}}var F="/models-v3",I=["native","blaze"],y=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function g(t){let e=t;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let i=typeof e.width=="number"?e.width:0,o=typeof e.height=="number"?e.height:0;return{width:i,height:o}}function l(t,e,i,o){let n=g(e),r=n.width>0?i/n.width:1,a=n.height>0?o/n.height:1,s=c=>({x:c.x*r,y:c.y*a});return{box:{x:t.box.x*r,y:t.box.y*a,width:t.box.width*r,height:t.box.height*a},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},...t.nose!==void 0?{nose:s(t.nose)}:{},score:t.score}}function E(t){return t instanceof Error?t.message:String(t)}async function k(t){let e=t.preferred??I,i=[];for(let o of e){if(o==="native"){let n=await x();if(n.ok)return new m(n.instance,h(i));i.push(`native:${n.reason}`);continue}try{return await S(u.create(t.v3AssetBaseUrl??F,h(i)),t.blazeInitTimeoutMs??v)}catch(n){i.push(n instanceof f?"blaze:blaze_init_timeout":`blaze:${E(n)}`)}}throw new y(h(i)??"no_tier_available")}function h(t){return t.length>0?t.join("; "):void 0}var f=class extends Error{};function S(t,e){return new Promise((i,o)=>{let n=setTimeout(()=>{o(new f(`init exceeded ${e}ms`)),t.then(r=>r.destroy(),()=>{})},e);t.then(r=>{clearTimeout(n),i(r)},r=>{clearTimeout(n),o(r)})})}var d=1;function A(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function M(t,e={}){let i=e.createDetector??k,o=null;t.onmessage=n=>{let r=n.data;if(r.v!==d){r.bitmap?.close?.();return}if(r.type==="init"){i(r.options).then(a=>{o=a;let s={v:d,type:"ready",tier:a.tier,...a.fallbackReason!==void 0?{fallbackReason:a.fallbackReason}:{}};t.postMessage(s)});return}if(r.type==="detect"){let a=s=>{let c={v:d,type:"result",id:r.id,observation:s};t.postMessage(c),r.bitmap.close?.()};if(o===null){a(null);return}o.detect(r.bitmap,r.streamWidth,r.streamHeight).then(a,()=>a(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&M(self);var D=class t{constructor(e,i){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=i.tier,i.fallbackReason!==void 0&&(this.fallbackReason=i.fallbackReason),e.addEventListener("message",o=>{let n=o.data;if(n.v!==d||n.type!=="result")return;let r=this.pending.get(n.id);this.pending.delete(n.id),r?.(n.observation)})}static create(e,i,o=1e4){return new Promise((n,r)=>{let a=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),r(new Error(`worker detector not ready within ${o}ms`))},o),s=b=>{let p=b.data;p.v!==d||p.type!=="ready"||(clearTimeout(a),e.removeEventListener("message",s),n(new t(e,p)))};e.addEventListener("message",s);let c={v:d,type:"init",options:i};e.postMessage(c)})}async detect(e,i,o){let n;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n=e:typeof createImageBitmap=="function"?n=await createImageBitmap(e):n=e}catch{return null}let r=this.nextId;return this.nextId+=1,new Promise(a=>{this.pending.set(r,a);let s={v:d,type:"detect",id:r,bitmap:n,streamWidth:i,streamHeight:o};this.worker.postMessage(s,[n])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};export{F as a,I as b,y as c,g as d,l as e,k as f,d as g,A as h,M as i,D as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),u=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function o(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(u)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function l(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var n=["LOW","MID","HIGH"],i=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return a[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let s=this.samples.reduce((r,c)=>r+c,0)/this.samples.length;if(s>70)this.current="LOW";else if(s<25){let r=n.indexOf(this.current);this.current=n[Math.min(n.length-1,r+1)]??this.current}return this.current}};export{a,o as b,l as c,i as d};
|