@sekyro/web 0.1.0-rc.4 → 0.1.0-rc.40
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 +491 -0
- package/LICENSE +25 -16
- package/README.md +158 -62
- package/THIRD-PARTY-NOTICES.txt +154 -0
- package/dist/assets.generated-DpkbvoII.d.cts +249 -0
- package/dist/assets.generated-DpkbvoII.d.ts +249 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/barcode-detect-C5IOXMKI.js +1 -0
- package/dist/camera-trait-DELAK3YN.js +1 -0
- package/dist/capture-constraints-CVqpMNGA.d.cts +48 -0
- package/dist/capture-constraints-CVqpMNGA.d.ts +48 -0
- package/dist/capture-session-doc-DFLSX6BB.js +1 -0
- package/dist/{capture-session-v3-uXJr1Wlm.d.ts → capture-session-v3-C-9FB_vX.d.cts} +232 -13
- package/dist/{capture-session-v3-DEInCOUg.d.cts → capture-session-v3-DEpGJ_fI.d.ts} +232 -13
- package/dist/challenge-frame-YBTLAQ5G.js +1 -0
- package/dist/chunk-22AW4NJD.js +1 -0
- package/dist/chunk-33KKMPJ5.js +1 -0
- package/dist/chunk-3WQJI7UL.js +1 -0
- package/dist/chunk-4NO6MQPH.js +1 -0
- package/dist/chunk-53POX7U4.js +1 -0
- package/dist/chunk-7QZWBDI5.js +1 -0
- package/dist/chunk-BD4KIQQD.js +1 -0
- package/dist/chunk-BPAGOPYL.js +1 -0
- package/dist/chunk-BRLQIJYF.js +1 -0
- package/dist/chunk-CJHMFPL6.js +1 -0
- package/dist/chunk-CPUECYAJ.js +1 -0
- package/dist/chunk-FPXL63KZ.js +1 -0
- package/dist/chunk-FSSMUAKC.js +1 -0
- package/dist/chunk-FYU7J2DC.js +1 -0
- package/dist/chunk-GFJATPUR.js +1 -0
- package/dist/chunk-GI3UFGRQ.js +1 -0
- package/dist/chunk-JLVZ35QK.js +2 -0
- package/dist/chunk-L3TNFMQK.js +1 -0
- package/dist/chunk-M3637QGB.js +1 -0
- package/dist/chunk-MQHTFHSN.js +1 -0
- package/dist/chunk-POIQGEZM.js +1 -0
- package/dist/chunk-QB62OPX5.js +1 -0
- package/dist/chunk-QZUFICG3.js +1 -0
- package/dist/chunk-RI3E7GBN.js +1 -0
- package/dist/chunk-SJ5OJ677.js +1 -0
- package/dist/chunk-SMKCBUJL.js +1 -0
- package/dist/chunk-SX7TUC3V.js +1 -0
- package/dist/chunk-TSA6GHUG.js +1 -0
- package/dist/chunk-U5TL63CG.js +1 -0
- package/dist/chunk-VSLJZ7GH.js +1 -0
- package/dist/chunk-VWGKUQ3C.js +1 -0
- package/dist/chunk-W357WDNU.js +1 -0
- package/dist/chunk-WNBEOK5Q.js +1 -0
- package/dist/chunk-Y5GRT27C.js +3 -0
- package/dist/chunk-ZVD6VHM2.js +1 -0
- package/dist/client/index.cjs +1 -357
- package/dist/client/index.d.cts +6 -37
- package/dist/client/index.d.ts +6 -37
- package/dist/client/index.js +1 -15
- package/dist/clip-inspect-DLJXVKV6.js +1 -0
- package/dist/core/index.cjs +1 -1634
- package/dist/core/index.d.cts +5 -4
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.js +1 -139
- package/dist/core/ocr/worker.bundle.js +41 -0
- package/dist/core/ocr/worker.cjs +41 -0
- package/dist/core/ocr/worker.d.cts +97 -0
- package/dist/core/ocr/worker.d.ts +97 -0
- package/dist/core/ocr/worker.js +40 -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-4ZOSBL3Y.js +1 -0
- package/dist/create-portrait-capture-5VGYZUOK.js +1 -0
- package/dist/create-verification-B8c9xBnz.d.ts +3871 -0
- package/dist/create-verification-BadlGBh3.d.cts +3871 -0
- package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-CHqsPJoM.d.cts} +25 -2
- package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-CHqsPJoM.d.ts} +25 -2
- package/dist/detector-scanic-P2RTEQUV.js +1 -0
- package/dist/icao-gate-BqXxEAq6.d.cts +610 -0
- package/dist/icao-gate-C7D7Lce7.d.ts +610 -0
- package/dist/icao-gate-T3BTOKFJ.js +1 -0
- package/dist/icao-policy-Bo7TQyTd.d.ts +80 -0
- package/dist/icao-policy-CgSI4oFo.d.cts +80 -0
- package/dist/icao-tuning-4ETMF53W.js +1 -0
- package/dist/index.cjs +3 -2698
- package/dist/index.d.cts +138 -5
- package/dist/index.d.ts +138 -5
- package/dist/index.js +1 -28
- package/dist/internal/index.cjs +3 -4228
- package/dist/internal/index.d.cts +306 -371
- package/dist/internal/index.d.ts +306 -371
- 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-3BLEJWHF.js +1 -0
- package/dist/popup/index.cjs +1 -76
- package/dist/popup/index.d.cts +9 -3
- package/dist/popup/index.d.ts +9 -3
- package/dist/popup/index.js +1 -11
- package/dist/print-DCYX3CZD.js +1 -0
- package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
- package/dist/segmenter-USLNBX65.js +1 -0
- package/dist/types-BAAj6TOZ.d.cts +2230 -0
- package/dist/types-BAAj6TOZ.d.ts +2230 -0
- package/dist/upload-file-EGXXM6TQ.js +1 -0
- package/package.json +30 -11
- package/sbom.cdx.json +349 -0
- package/dist/capture-constraints-BujkZcfb.d.cts +0 -21
- package/dist/capture-constraints-BujkZcfb.d.ts +0 -21
- package/dist/chunk-EWRNPKTR.js +0 -1123
- package/dist/chunk-EWRNPKTR.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-NWF46H7K.js +0 -359
- package/dist/chunk-NWF46H7K.js.map +0 -1
- package/dist/chunk-TBANUT3X.js +0 -885
- package/dist/chunk-TBANUT3X.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-Ce1y5kJR.d.ts +0 -371
- package/dist/create-verification-Dkb2tXuY.d.cts +0 -371
- package/dist/detector-scanic-4C6IEW2K.js +0 -787
- package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
- package/dist/hosted-client-DWzCRYJK.d.cts +0 -421
- package/dist/hosted-client-DWzCRYJK.d.ts +0 -421
- 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,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bu as ScreenRampReport, bl as CaptureProvenance, br as ScreenRampChallenge, bs as ScreenRampPaint } from './types-BAAj6TOZ.js';
|
|
2
|
+
import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-CHqsPJoM.js';
|
|
2
3
|
|
|
3
4
|
/** MP4-first ladder: one container (H.264 MP4) covers iOS/macOS Safari + Chrome 130+.
|
|
4
5
|
* WebM/VP9→VP8 only as the Firefox/older-Chromium fallback. */
|
|
@@ -28,19 +29,60 @@ declare function buildLivenessV2FormData(args: {
|
|
|
28
29
|
ts?: number;
|
|
29
30
|
}): FormData;
|
|
30
31
|
|
|
32
|
+
interface ClipStats {
|
|
33
|
+
container: "mp4" | "webm";
|
|
34
|
+
/** Video frames (samples / blocks) in the clip. */
|
|
35
|
+
frames: number;
|
|
36
|
+
/** Video duration in ms: the sample durations (MP4), or the first-to-last frame span plus one frame (WebM). */
|
|
37
|
+
durationMs: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
31
40
|
declare const CLIP_MS = 2500;
|
|
32
41
|
declare const TIMESLICE_MS = 1000;
|
|
33
42
|
declare const STOP_GRACE_MS = 1500;
|
|
34
43
|
declare const VIDEO_BPS = 2500000;
|
|
44
|
+
/** After the frame clock has covered the window: time for the encoder to hand over the last frames before stop(). */
|
|
45
|
+
declare const ENCODER_TAIL_MS = 100;
|
|
46
|
+
/** Hard cap past `clipMs` (from start()) when the frame clock is slow or stalls. */
|
|
47
|
+
declare const MAX_OVERRUN_MS = 700;
|
|
48
|
+
/** How often the frame clock is read while recording. */
|
|
49
|
+
declare const FRAME_POLL_MS = 20;
|
|
50
|
+
/** How long a finished clip waits for the container reader chunk before it ships unmeasured. */
|
|
51
|
+
declare const INSPECT_WAIT_MS = 1500;
|
|
52
|
+
/** The preview's frame clock: the latest presented frame (`performance.now()` domain), null before the first. */
|
|
53
|
+
interface FrameClock {
|
|
54
|
+
latest(): {
|
|
55
|
+
presentationTimeMs: number;
|
|
56
|
+
} | null;
|
|
57
|
+
}
|
|
35
58
|
type ClipErrorKind = CameraErrorKind | "cliptoolarge";
|
|
36
59
|
declare class ClipError extends Error {
|
|
37
60
|
kind: ClipErrorKind;
|
|
61
|
+
/** The type the recorder was asked for when it failed (set by record()). */
|
|
62
|
+
requestedMimeType?: string;
|
|
38
63
|
constructor(kind: ClipErrorKind, msg?: string);
|
|
39
64
|
}
|
|
65
|
+
/** A clip this much shorter than its window is recorded again (once). */
|
|
66
|
+
declare const SHORT_CLIP_TOLERANCE_MS = 100;
|
|
67
|
+
/** A measured clip under `windowMs - SHORT_CLIP_TOLERANCE_MS`, or one whose container could not be read. An
|
|
68
|
+
* unmeasured clip (`stats` absent: a host-supplied recorder) never is. Low frame rate alone is not a reason:
|
|
69
|
+
* a second take on the same encoder would not raise it. */
|
|
70
|
+
declare function needsRetake(clip: Pick<ClipResult, "stats">, windowMs: number): boolean;
|
|
71
|
+
/** `candidate` is the better clip: readable over unreadable, then the longer one. */
|
|
72
|
+
declare function betterTake(candidate: Pick<ClipResult, "stats">, current: Pick<ClipResult, "stats">): boolean;
|
|
40
73
|
interface ClipResult {
|
|
41
74
|
blob: Blob;
|
|
42
75
|
/** Container mime the clip was finalized with (recorder.mimeType || picked || DEFAULT_CLIP_MIME). */
|
|
43
76
|
mimeType: string;
|
|
77
|
+
/** The type the recorder was asked for ("" = the browser default): what a failed take notes as failed. */
|
|
78
|
+
requestedMimeType?: string;
|
|
79
|
+
/** Frames and duration read from the finished container; `null` when it could not be read (a broken clip),
|
|
80
|
+
* absent when the clip was not measured (a host-supplied recorder). */
|
|
81
|
+
stats?: ClipStats | null;
|
|
82
|
+
}
|
|
83
|
+
interface ClipRecorderOptions {
|
|
84
|
+
/** Clock in the frame clock's domain (default `performance.now()`); tests inject it. */
|
|
85
|
+
now?: () => number;
|
|
44
86
|
}
|
|
45
87
|
declare class ClipRecorder {
|
|
46
88
|
private recorder;
|
|
@@ -49,7 +91,10 @@ declare class ClipRecorder {
|
|
|
49
91
|
private bytes;
|
|
50
92
|
private hardStopTimer;
|
|
51
93
|
private graceTimer;
|
|
94
|
+
private pollTimer;
|
|
52
95
|
private settled;
|
|
96
|
+
private readonly now;
|
|
97
|
+
constructor(options?: ClipRecorderOptions);
|
|
53
98
|
private clearTimers;
|
|
54
99
|
/** Records CLIP_MS of the stream. Resolves with the clip blob + its container mime;
|
|
55
100
|
* rejects with ClipError. Behavior contract is the v1 hook's `start`, verbatim
|
|
@@ -67,8 +112,20 @@ declare class ClipRecorder {
|
|
|
67
112
|
* instead of waiting for the blob. PURE NOTIFICATION — it does not touch
|
|
68
113
|
* timers, chunks, or the finalize path, so it is calibration-neutral (no
|
|
69
114
|
* effect on clip bytes). Never fires on a rejected capture (error /
|
|
70
|
-
* cliptoolarge settle before the hard-stop and clear the timer).
|
|
71
|
-
|
|
115
|
+
* cliptoolarge settle before the hard-stop and clear the timer).
|
|
116
|
+
*
|
|
117
|
+
* `onStarted` (optional, liveness v7 §4.4) fires ONCE on the recorder's
|
|
118
|
+
* `start` event: the zero of the clip's own timeline, which the screen ramp
|
|
119
|
+
* stamps its colour changes against. PURE NOTIFICATION as well (the
|
|
120
|
+
* `onstart` handler was unset before; nothing else changes), so it is
|
|
121
|
+
* calibration-neutral. Never fires when construction or `start()` failed.
|
|
122
|
+
*
|
|
123
|
+
* `clipMs` (optional) is the recording window, CLIP_MS (2.5 s) by default; a screen-ramp capture passes the
|
|
124
|
+
* challenge's `clipMs` (same 4th parameter as the ramp-v2 change). `frames` (optional) is the preview's frame
|
|
125
|
+
* clock: with it the window is measured on presented frames from the recorder's start (see the header), without
|
|
126
|
+
* it the v1 wall-clock stop at `clipMs` applies. The resolved clip carries its measured `stats`. */
|
|
127
|
+
record(stream: MediaStream, onStopped?: () => void, onStarted?: () => void, clipMs?: number, frames?: FrameClock): Promise<ClipResult>;
|
|
128
|
+
private recordRaw;
|
|
72
129
|
/** Idempotent teardown: stop recorder + ALL tracks (v1 `stopAndCleanup` + the unmount
|
|
73
130
|
* effect). Optional `stream` override mirrors v1's `stopAndCleanup(stream?)`.
|
|
74
131
|
*
|
|
@@ -95,8 +152,10 @@ type CaptureState = "idle" | "preflight" | "acquiring" | "positioning" | "record
|
|
|
95
152
|
* - 'cliptoolarge' the 8 MB clip cap (shared with the liveness API contract)
|
|
96
153
|
* - 'recorder' MediaRecorder failed mid-clip. ClipRecorder's v1-verbatim kind for
|
|
97
154
|
* this is 'generic'; CaptureSession REMAPS it to 'recorder' so hosts
|
|
98
|
-
* can distinguish recorder failure from camera 'generic'.
|
|
99
|
-
|
|
155
|
+
* can distinguish recorder failure from camera 'generic'.
|
|
156
|
+
* - 'backcamera' the back camera was asked for (assisted capture) and only the front
|
|
157
|
+
* one opened: nothing is recorded (the server refuses such a clip). */
|
|
158
|
+
type CaptureErrorKind = CameraErrorKind | "models" | "cliptoolarge" | "recorder" | "backcamera";
|
|
100
159
|
/** The five v1 gate checks (hysteresis-smoothed statuses). */
|
|
101
160
|
interface GateChecks {
|
|
102
161
|
faceDetected: boolean;
|
|
@@ -128,12 +187,20 @@ interface CaptureArtifacts {
|
|
|
128
187
|
clip?: Blob;
|
|
129
188
|
/** Container mime the clip finalized with. Absent in photo mode. */
|
|
130
189
|
clipMimeType?: string;
|
|
131
|
-
/**
|
|
190
|
+
/** The clip's frames and duration read from its container (absent when unread or in photo mode). */
|
|
191
|
+
clipStats?: ClipStats;
|
|
192
|
+
/** Silent re-recordings this clip took (0 or 1; absent in photo mode). */
|
|
193
|
+
clipRetakes?: number;
|
|
194
|
+
/** JPEG keyframe (captureMirroredKeyframe): mirrored on the front camera, as the sensor sees it on the back one. */
|
|
132
195
|
keyframe: Blob;
|
|
133
196
|
/** JPEG data URL of the keyframe canvas (v1 preview, quality 0.92). */
|
|
134
197
|
previewDataUrl: string;
|
|
135
198
|
/** Capture-phase timing of the attempt that produced these artifacts. */
|
|
136
199
|
timing?: CaptureTiming;
|
|
200
|
+
/** Liveness v7 §4.4: the screen ramp rendered against the session's issued challenge (clip mode, a challenge issued, a host painting). */
|
|
201
|
+
screenRamp?: ScreenRampReport;
|
|
202
|
+
/** Liveness v7 §4.5 item 2: how the capture was made (whenever the engine had a camera track). */
|
|
203
|
+
provenance?: CaptureProvenance;
|
|
137
204
|
}
|
|
138
205
|
interface CaptureSessionEvents {
|
|
139
206
|
statechange: {
|
|
@@ -224,7 +291,7 @@ interface V3GateTickInput {
|
|
|
224
291
|
frameWidth: number;
|
|
225
292
|
frameHeight: number;
|
|
226
293
|
}
|
|
227
|
-
type V3GateFactor = "presence" | "centering" | "size" | "pose" | "sharpness" | "exposure" | "motion";
|
|
294
|
+
type V3GateFactor = "presence" | "single" | "centering" | "size" | "pose" | "sharpness" | "exposure" | "motion";
|
|
228
295
|
/** Per-tick output — the telemetry + chrome contract. */
|
|
229
296
|
interface V3GateTick {
|
|
230
297
|
at: number;
|
|
@@ -255,7 +322,7 @@ declare class FaceGateV3 {
|
|
|
255
322
|
private geometryOf;
|
|
256
323
|
private motionOf;
|
|
257
324
|
/** Lowest failing factor speaks — fixed priority (diagnostic, incl. light):
|
|
258
|
-
* presence → size → centering → pose → exposure → sharpness → hold.
|
|
325
|
+
* presence → single → size → centering → pose → exposure → sharpness → hold.
|
|
259
326
|
*
|
|
260
327
|
* HONESTY FALLBACK (operator ruling 2026-07-12): when every factor clears
|
|
261
328
|
* its guide threshold but q (= min factor) is still below Q_GOOD — i.e.
|
|
@@ -312,9 +379,56 @@ declare class DeviceProfiler {
|
|
|
312
379
|
record(detectMs: number): DeviceClass;
|
|
313
380
|
}
|
|
314
381
|
|
|
382
|
+
/** Where a capture failed: the engine step that was running. */
|
|
383
|
+
type CaptureErrorPhase = "preflight" | "acquiring" | "models" | "recording" | "keyframes" | "upload";
|
|
384
|
+
/** Engine-side failure detail (the public handle adds the engine kind). */
|
|
385
|
+
interface EngineErrorDetail {
|
|
386
|
+
phase: CaptureErrorPhase;
|
|
387
|
+
/** The thrown error's `name` only, sanitised by {@link errorNameOf}. */
|
|
388
|
+
name?: string;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** Why a gate tick did not advance: no face, or the weakest gate check. */
|
|
392
|
+
type GateBlockReason = "no_face" | Exclude<V3GateFactor, "presence">;
|
|
393
|
+
interface GateBlockEntry {
|
|
394
|
+
/** Ticks blocked by this reason. */
|
|
395
|
+
count: number;
|
|
396
|
+
/** Wall time (whole ms) those ticks covered. */
|
|
397
|
+
ms: number;
|
|
398
|
+
}
|
|
399
|
+
interface GateBlockSummary {
|
|
400
|
+
/** Only the reasons that blocked at least once. */
|
|
401
|
+
blocked: Partial<Record<GateBlockReason, GateBlockEntry>>;
|
|
402
|
+
/** Wall time (whole ms) of ticks the gate accepted (progress rising). */
|
|
403
|
+
acceptedMs: number;
|
|
404
|
+
/** Total ticks seen. */
|
|
405
|
+
ticks: number;
|
|
406
|
+
}
|
|
407
|
+
/** The reason one tick was held back, or null when the gate accepted it. */
|
|
408
|
+
declare function blockReasonOf(tick: Pick<V3GateTick, "accepted" | "factors">): GateBlockReason | null;
|
|
409
|
+
declare class GateBlockStats {
|
|
410
|
+
private blocked;
|
|
411
|
+
private acceptedMs;
|
|
412
|
+
private ticks;
|
|
413
|
+
private lastAt;
|
|
414
|
+
/** Record one gate tick; the time since the previous tick is charged to THIS tick's state. */
|
|
415
|
+
record(tick: Pick<V3GateTick, "at" | "accepted" | "factors">): void;
|
|
416
|
+
summary(): GateBlockSummary;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** A non-final `gate` telemetry snapshot at most this often while positioning
|
|
420
|
+
* (so an abandoned attempt still reports where its time went). */
|
|
421
|
+
declare const GATE_SNAPSHOT_MS = 1000;
|
|
422
|
+
/** Guidance key while a phone shows a landscape camera frame (the upright guard). */
|
|
423
|
+
declare const HOLD_UPRIGHT_KEY = "fcv3.hold_upright";
|
|
424
|
+
/** How often the upright guard re-reads the frame size while the clip records (plus every `resize` event). */
|
|
425
|
+
declare const UPRIGHT_WATCH_MS = 200;
|
|
315
426
|
/** Best-of-N keyframe window: up to 4 candidates over the first 600ms. */
|
|
316
427
|
declare const KEYFRAME_CANDIDATES = 4;
|
|
317
428
|
declare const KEYFRAME_WINDOW_MS = 600;
|
|
429
|
+
/** Liveness v7 §4.5 item 2: the longest the capture waits on the track description (its WebCrypto hash) once the
|
|
430
|
+
* clip is done; past it the artifacts ship without `provenance`. */
|
|
431
|
+
declare const PROVENANCE_WAIT_MS = 1000;
|
|
318
432
|
interface V3ChecksPayload {
|
|
319
433
|
engine: "v3";
|
|
320
434
|
/** Gate integrator 0..1 — the ring drives off this directly. */
|
|
@@ -335,9 +449,11 @@ interface CaptureSessionV3Events {
|
|
|
335
449
|
key: string;
|
|
336
450
|
};
|
|
337
451
|
artifacts: CaptureArtifacts;
|
|
452
|
+
/** `detail`: where the attempt failed and the thrown error's name (never its message). */
|
|
338
453
|
error: {
|
|
339
454
|
kind: CaptureErrorKind;
|
|
340
455
|
retryable: boolean;
|
|
456
|
+
detail?: EngineErrorDetail;
|
|
341
457
|
};
|
|
342
458
|
/** v3-only, CHROME-only (no data flows here): fires the instant the clip
|
|
343
459
|
* recording window ends — BEFORE the blob finalizes (iOS onstop can lag up
|
|
@@ -348,6 +464,12 @@ interface CaptureSessionV3Events {
|
|
|
348
464
|
frozen: {
|
|
349
465
|
previewDataUrl: string;
|
|
350
466
|
};
|
|
467
|
+
/** Ramp v2: paint the full-screen screen-ramp layer this colour, black (`"dark"`, the dark-gap arm) or clear it
|
|
468
|
+
* (`null`). Clip mode, a challenge issued by `screenRamp()`. CHROME-only: the host paints, the engine stamps the
|
|
469
|
+
* clip timeline. */
|
|
470
|
+
ramp: {
|
|
471
|
+
colour: ScreenRampPaint;
|
|
472
|
+
};
|
|
351
473
|
}
|
|
352
474
|
type V3TelemetryEvent = {
|
|
353
475
|
type: "detector";
|
|
@@ -363,10 +485,44 @@ type V3TelemetryEvent = {
|
|
|
363
485
|
timeToGateMs: number;
|
|
364
486
|
degradeCount: number;
|
|
365
487
|
meanDetectMs: number;
|
|
366
|
-
}
|
|
488
|
+
}
|
|
489
|
+
/** The first take was short, unreadable or errored: the clip is recorded once more (clip-duration fix). */
|
|
490
|
+
| {
|
|
491
|
+
type: "clip_retake";
|
|
492
|
+
reason: "short" | "unreadable" | "error";
|
|
493
|
+
}
|
|
494
|
+
/** Where the attempt's gate time went (see gate-blocking.ts): per-reason
|
|
495
|
+
* blocked tick counts + ms, accepted ms, and the ACTIVE device class /
|
|
496
|
+
* cadence after any dynamic profile adjustment. `final` on the attempt's
|
|
497
|
+
* end (fired / error / retry / destroy); throttled snapshots before it. */
|
|
498
|
+
| ({
|
|
499
|
+
type: "gate";
|
|
500
|
+
final: boolean;
|
|
501
|
+
activeClass: DeviceClass;
|
|
502
|
+
cadenceHz: number;
|
|
503
|
+
} & GateBlockSummary) | {
|
|
367
504
|
type: "error";
|
|
368
505
|
kind: CaptureErrorKind;
|
|
369
506
|
fallbackReason?: string;
|
|
507
|
+
}
|
|
508
|
+
/** Keyframe ranking (SDK spec §4.8a; only when `rankKeyframes` is on): the
|
|
509
|
+
* rank numbers of every candidate (never an image), the chosen index, the
|
|
510
|
+
* index sharpness alone would have chosen, and the extra detector time. */
|
|
511
|
+
| {
|
|
512
|
+
type: "keyframe";
|
|
513
|
+
tier: Detector["tier"] | null;
|
|
514
|
+
chosen: number;
|
|
515
|
+
sharpest: number;
|
|
516
|
+
detectMs: number;
|
|
517
|
+
candidates: Array<{
|
|
518
|
+
face: boolean;
|
|
519
|
+
frontal: number;
|
|
520
|
+
yaw?: number;
|
|
521
|
+
roll?: number;
|
|
522
|
+
eyes?: number;
|
|
523
|
+
score: number;
|
|
524
|
+
sharpness: number;
|
|
525
|
+
}>;
|
|
370
526
|
};
|
|
371
527
|
interface KeyframeCandidate {
|
|
372
528
|
blob: Blob;
|
|
@@ -405,7 +561,13 @@ interface CaptureSessionV3Options {
|
|
|
405
561
|
createRecorder?: () => Pick<ClipRecorder, "record" | "stop">;
|
|
406
562
|
/** (navigator.mediaDevices.getUserMedia) */
|
|
407
563
|
getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
|
|
408
|
-
/** (
|
|
564
|
+
/** (navigator.mediaDevices.enumerateDevices, only when `getUserMedia` is not overridden) — the back lenses by id. */
|
|
565
|
+
enumerateDevices?: () => Promise<ReadonlyArray<{
|
|
566
|
+
deviceId: string;
|
|
567
|
+
label: string;
|
|
568
|
+
kind?: string;
|
|
569
|
+
}>>;
|
|
570
|
+
/** (canvas keyframe, mirrored on the front camera only, + downscaled Laplacian sharpness) */
|
|
409
571
|
captureKeyframe?: (video: HTMLVideoElement) => Promise<KeyframeCandidate>;
|
|
410
572
|
/** (downscaled face-crop sharpness/exposure via canvas) */
|
|
411
573
|
measureQuality?: (video: HTMLVideoElement, box: {
|
|
@@ -422,13 +584,33 @@ interface CaptureSessionV3Options {
|
|
|
422
584
|
* worker-side through WorkerDetectorProxy. Hosts own Worker construction
|
|
423
585
|
* (bundler-specific `new Worker(new URL(...))`). */
|
|
424
586
|
createWorker?: () => WorkerLike;
|
|
587
|
+
/** Keyframe ranking switch (SDK spec §4.8a; server tuning
|
|
588
|
+
* `capture.liveness.keyframe.rank`, default off): read when positioning
|
|
589
|
+
* starts (prefetches the lazy ranker) and again when the capture fires.
|
|
590
|
+
* Off → today's sharpest-of-N, byte for byte. */
|
|
591
|
+
rankKeyframes?: () => boolean;
|
|
592
|
+
/** Screen-ramp challenge (liveness v7 §4.4; server tuning `capture.liveness.screenRamp`): read once when the
|
|
593
|
+
* clip recording starts. A challenge → the engine emits `ramp` at each issued onset on the clip timeline and
|
|
594
|
+
* reports what it rendered in `artifacts.screenRamp`; `undefined` (older backends, assisted sessions, no host
|
|
595
|
+
* painting) → no ramp, no field. Photo mode never ramps. */
|
|
596
|
+
screenRamp?: () => ScreenRampChallenge | undefined;
|
|
425
597
|
/** INERT (Phase 3 escalation seam — see EscalationHook). Accepted and
|
|
426
598
|
* retained, never called in Phases 1–2. */
|
|
427
599
|
escalation?: EscalationHook;
|
|
600
|
+
/** Upright guard (spec 2026-10-28 §4.2): the device is a phone, so a landscape frame (videoWidth > videoHeight)
|
|
601
|
+
* holds the gate and drops a clip being recorded (or the keyframes of a photo-mode capture). Read at each attempt
|
|
602
|
+
* start. (detectFormFactor() === 'phone' — desktop webcams are landscape by nature, and a tablet may stand in
|
|
603
|
+
* landscape on a stand: neither is ever guarded) */
|
|
604
|
+
isPhone?: () => boolean;
|
|
428
605
|
/** (performance.now) */
|
|
429
606
|
now?: () => number;
|
|
430
607
|
}
|
|
431
608
|
type Handler<K extends keyof CaptureSessionV3Events> = (payload: CaptureSessionV3Events[K]) => void;
|
|
609
|
+
/** Per-start options (the public handle's `start({ facing })`). */
|
|
610
|
+
interface CaptureSessionV3StartOptions {
|
|
611
|
+
/** Camera for this attempt AND later retries; absent → keep the current one. */
|
|
612
|
+
facingMode?: "user" | "environment";
|
|
613
|
+
}
|
|
432
614
|
declare class CaptureSessionV3 {
|
|
433
615
|
private readonly options;
|
|
434
616
|
private readonly handlers;
|
|
@@ -449,14 +631,32 @@ declare class CaptureSessionV3 {
|
|
|
449
631
|
private fired;
|
|
450
632
|
private carriedDegrade;
|
|
451
633
|
private carriedMeans;
|
|
634
|
+
private blockStats;
|
|
635
|
+
private lastGateSnapshotAt;
|
|
636
|
+
/** The upright guard applies to this attempt (a phone). */
|
|
637
|
+
private uprightGuard;
|
|
638
|
+
/** Liveness v7 §4.5 item 2: the attempt's video track described right after getUserMedia (null: no track). */
|
|
639
|
+
private trackProvenance;
|
|
640
|
+
/** The capture environment read when the camera opened (record only); `{}` when the reading failed. */
|
|
641
|
+
private openEnvironment;
|
|
642
|
+
/** The ramp of the clip being recorded (stopped with the recording, the attempt or the session). */
|
|
643
|
+
private ramp;
|
|
452
644
|
constructor(options: CaptureSessionV3Options);
|
|
453
645
|
get state(): CaptureState;
|
|
454
646
|
on<K extends keyof CaptureSessionV3Events>(event: K, handler: Handler<K>): () => void;
|
|
455
647
|
private emit;
|
|
456
|
-
start(): Promise<void>;
|
|
648
|
+
start(options?: CaptureSessionV3StartOptions): Promise<void>;
|
|
649
|
+
/** The camera of the current attempt: the one its track reports once the stream is live, else the requested one
|
|
650
|
+
* (start option, switchCamera toggles). */
|
|
651
|
+
get facingMode(): "user" | "environment";
|
|
457
652
|
/** Full reset + camera restart — the documented recovery path (v1 parity). */
|
|
458
653
|
retry(): void;
|
|
459
654
|
switchCamera(): void;
|
|
655
|
+
/**
|
|
656
|
+
* Spec 2026-11-06 §3.3 (the capture mode switch): drop the running attempt (a recording is discarded, never
|
|
657
|
+
* finalized) and start again on `facingMode`.
|
|
658
|
+
*/
|
|
659
|
+
restart(facingMode: "user" | "environment"): void;
|
|
460
660
|
destroy(): void;
|
|
461
661
|
private run;
|
|
462
662
|
/** Chrome hint (Task 11): 'reduced' on LOW even without the media query. */
|
|
@@ -464,7 +664,24 @@ declare class CaptureSessionV3 {
|
|
|
464
664
|
private startScheduler;
|
|
465
665
|
private detectTick;
|
|
466
666
|
private fire;
|
|
467
|
-
/**
|
|
667
|
+
/**
|
|
668
|
+
* One recording of `windowMs` on the preview's frame clock, with the screen ramp (when issued) and the upright
|
|
669
|
+
* guard; rejects with the recorder's error. `onStopped` fires the moment the recording ends (before finalize).
|
|
670
|
+
*/
|
|
671
|
+
private recordTake;
|
|
672
|
+
/** `{ provenance }` from the live track's description, the recording's frame statistics and the painter flag; `{}` without a track. */
|
|
673
|
+
private provenance;
|
|
674
|
+
/** A phone showing a landscape frame: the guard holds the gate. */
|
|
675
|
+
private isLandscape;
|
|
676
|
+
/** Positioning on a sideways phone: no detection, the gate restarts from zero and the coaching says why. */
|
|
677
|
+
private holdUpright;
|
|
678
|
+
/** While the clip records (or, `recorder` null, the photo-mode keyframes are taken): a rotation to landscape aborts
|
|
679
|
+
* it. Returns the unwatch function. */
|
|
680
|
+
private watchRotation;
|
|
681
|
+
/** Drop the clip being recorded (or the photo-mode keyframes being taken; same stream, same detector) and go back to
|
|
682
|
+
* positioning with the upright coaching. */
|
|
683
|
+
private abortRecording;
|
|
684
|
+
/** Up to KEYFRAME_CANDIDATES frames (mirrored on the front camera) over KEYFRAME_WINDOW_MS —
|
|
468
685
|
* sharpest wins (reuses frame-quality.sharpness via the capture seam). */
|
|
469
686
|
private collectKeyframes;
|
|
470
687
|
private finishCapture;
|
|
@@ -478,10 +695,12 @@ declare class CaptureSessionV3 {
|
|
|
478
695
|
private defaultQuality;
|
|
479
696
|
private centerSharpness;
|
|
480
697
|
private teardownAttempt;
|
|
698
|
+
/** Emit the attempt's gate breakdown; a final report closes it (exactly once). */
|
|
699
|
+
private reportGate;
|
|
481
700
|
private stopTracks;
|
|
482
701
|
private fail;
|
|
483
702
|
private setState;
|
|
484
703
|
private now;
|
|
485
704
|
}
|
|
486
705
|
|
|
487
|
-
export {
|
|
706
|
+
export { V3_GATE_DEFAULTS as $, GateBlockStats as A, type GateBlockSummary as B, type CameraErrorKind as C, DEFAULT_CLIP_MIME as D, ENCODER_TAIL_MS as E, FRAME_POLL_MS as F, GATE_SNAPSHOT_MS as G, type GateChecks as H, HOLD_UPRIGHT_KEY as I, INSPECT_WAIT_MS as J, KEYFRAME_CANDIDATES as K, KEYFRAME_WINDOW_MS as L, MAX_CLIP_BYTES as M, MAX_OVERRUN_MS as N, MIME_CANDIDATES as O, PROVENANCE_WAIT_MS as P, STOP_GRACE_MS as Q, type V3GateFactor as R, SHORT_CLIP_TOLERANCE_MS as S, TIMESLICE_MS as T, UPRIGHT_WATCH_MS as U, type V3ChecksPayload as V, type V3GateQuality as W, type V3GateThresholds as X, type V3GateTick as Y, type V3GateTickInput as Z, type V3TelemetryEvent as _, CLIP_MS as a, VIDEO_BPS as a0, betterTake as a1, blockReasonOf as a2, buildLivenessV2FormData as a3, cameraPreflight as a4, classifyDevice as a5, extForMime as a6, isClipTooLarge as a7, isMediaRecorderSupported as a8, mapGetUserMediaError as a9, needsRetake as aa, pickMimeType as ab, probeDevice as ac, type EngineErrorDetail as ad, 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 ClipRecorderOptions as n, type ClipResult as o, DEVICE_PROFILES as p, type DeviceClass as q, type DeviceProbe as r, type DeviceProfile as s, DeviceProfiler as t, type EscalationClipArtifact as u, type EscalationHook as v, FaceGateV3 as w, type FrameClock as x, type GateBlockEntry as y, type GateBlockReason as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-ZVD6VHM2.js";export{c as CHALLENGE_EXECUTE_TIMEOUT_MS,b as CHALLENGE_READY_TIMEOUT_MS,a as ChallengeError,e as executeChallenge,d as resetChallengeFrameForTests};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g="0.1.0-rc.40";var T=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function p(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return T.test(e)}var h="sekyro.did",P=1e4,v=()=>globalThis.process?.versions?.node,y;function b(){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 I(){try{let t=localStorage.getItem(h);if(t)return t;let e=b();return e!==void 0&&localStorage.setItem(h,e),e}catch{return y??(y=b()),y}}async function w(){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]),i=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").slice(0,32)}function k(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function x(t){let e=new TextEncoder().encode(t),r="";for(let i of e)r+=String.fromCharCode(i);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function A(t){let e,r,i,o,a,l,u=()=>l?.readyState==="live",_=()=>{a!==void 0||!globalThis.crypto?.subtle||v()||u()||(a=Promise.race([import("./print-DCYX3CZD.js"),new Promise(n=>setTimeout(n,P))]).then(n=>n?.computePrint(u)).then(n=>{n==="busy"?a=void 0:o=n}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},noteCamera(n){r=n},noteCameraTrack(n){l=n},async deviceHeader(){try{i??(i=w().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let m=await i,f=I(),S={v:1,platform:"web",sdk:t.sdk.slice(0,64),caps:["session_proof"],rampAtArm:!0,ids:[...f?[{kind:"web_local",value:f.slice(0,128)}]:[],...m?[{kind:"web_fp",value:m}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...k(),...e?{cameraLabel:e}:{},...n.length?{signals:n}:{},...o?{print:{v:2,...o,...r?{camera:r}:{}}}:{},...p()?{inApp:!0}:{}},C=x(JSON.stringify(S));return _(),C}catch{return}},printReady(){return a??Promise.resolve()}}}var s=Symbol.for("sekyro.web.clientContext"),c=globalThis,d=c[s]??(c[s]=A({sdk:`@sekyro/web@${g}`}));function M(t){try{let e=t.getVideoTracks?.()[0];if(e){if(d.noteCameraLabel(e.label),d.noteCameraTrack(e),v())return;import("./camera-trait-DELAK3YN.js").then(r=>r.noteCameraTrait(e,d)).catch(()=>{})}}catch{}}export{g as a,p as b,d as c,M as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d,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,lowerEyeMin:.32},mouth:{jawOpenMax:.13,smileMax:.28,puckerMax:.48},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,lowerEyeMin:.32},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:d,...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 y=k("id_document"),I=/^[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):y,l=o(r.eyes),t=o(r.mouth),m=o(r.lighting),s=o(r.background),c=o(r.resolution),g=o(r.baseline),w=o(r.glare),b=o(r.camera),h=typeof s.required=="boolean"?s.required:e.background.required,M=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),lowerEyeMin:n(l.lowerEyeMin,e.eyes.lowerEyeMin,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(s.lumaMin,e.background.lumaMin,0,255),lumaSdMax:n(s.lumaSdMax,e.background.lumaSdMax,0,255)},resolution:{minIodPx:n(c.minIodPx,e.resolution.minIodPx,1,2e3),minWidth:n(c.minWidth,e.resolution.minWidth,1,8e3),minHeight:n(c.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?M:{...M,enabled:!1},tuningVersion:typeof i=="string"&&I.test(i)?i:null}}export{y as a,R as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as x}from"./chunk-BRLQIJYF.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
|
+
import{d as ae,h as _e,i as Ae,j as Be,l as Ie}from"./chunk-MQHTFHSN.js";import{a as oe,e as Te,g as Le}from"./chunk-BRLQIJYF.js";import{m as J}from"./chunk-BPAGOPYL.js";import{a as Re,g as Pe}from"./chunk-7QZWBDI5.js";import{k as re}from"./chunk-CPUECYAJ.js";import{d as Oe,g as Ee}from"./chunk-WNBEOK5Q.js";function Fe(e,t){let n=new Set(e.flatMap(o=>o.sides.filter(i=>i[t]!==null).map(i=>i.side)));return n.size===1?[...n][0]:null}function pt(e){let t=Te.find(o=>o.docType===e),n=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:Le(e),mrz:t.mrz==="none"?"none":"required",mrzSide:n,barcodeSide:null,portraitSide:t.portraitSide,scripts:null}}function ft(e){let t=[];for(let n of e)for(let o of n.sides){if(!Array.isArray(o.scripts))return null;for(let i of o.scripts)t.includes(i)||t.push(i)}return t}function We(e,t){if(t.length===0)return pt(e);let n=t.some(u=>u.sides.length>1),o=new Set(t.map(u=>u.format)),i=o.size===1?[...o][0]:"card",l=t.filter(u=>u.sides.some(m=>m.mrz!==null)).length,s=t.find(u=>u.sides.length>1===n)?.sides.find(u=>u.portrait)?.side;return{sides:n?["recto","verso"]:["single"],format:i,mrz:l===t.length?"required":l===0?"none":"optional",mrzSide:Fe(t,"mrz"),barcodeSide:Fe(t,"barcode"),portraitSide:s??(n?"recto":"single"),scripts:ft(t)}}function ze(e,t){if(e===void 0)return[];let n=e.toUpperCase();return Object.prototype.hasOwnProperty.call(oe,n)?oe[n]?.[t]??[]:[]}async function Ue(e,t,n){return await e(t)?n:n==="recto"?"verso":"recto"}function Ne(e,t,n){return e!==t&&t==="verso"&&n.recto!==void 0&&n.verso===void 0?"verso":e}var gt={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 ht(e){let{deviceMemory:t,effectiveType:n,saveData:o,downlinkMbps:i,sourceLongEdge:l}=e,s=o===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,u=t!=null&&t<=2,m=n==="4g"||i!=null&&i>=5,c=t!=null&&t>=6,b;s||u?b="low":m&&c?b="good":b="mid";let f=gt[b],L=l&&l>0?Math.min(f.maxLongEdge,l):f.maxLongEdge;return{tier:b,...f,maxLongEdge:L}}function Ge(e){let t={};try{let n=navigator;typeof n.deviceMemory=="number"&&(t.deviceMemory=n.deviceMemory);let o=n.connection;o&&(t.effectiveType=o.effectiveType,t.saveData=o.saveData,t.downlinkMbps=o.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),ht(t)}function bt(e,t,n){let o=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),i=(t+n)/2;return Math.max(t,n-o*(n-i))}function St(e,t,n){let o=Math.max(e,t),i=o>0?Math.min(1,n/o):1;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}async function yt(e,t){let n=t.startQ,o=await e(n);for(let i=0;i<4&&!(o.size<=t.budgetBytes||n<=t.qMin);i++)n=Math.max(t.qMin,n-.08),o=await e(n);return{blob:o,quality:n}}async function qe(e,t,n,o,i){if(t<=0||n<=0)return null;let{width:l,height:s}=St(t,n,o.maxLongEdge),u=document.createElement("canvas");u.width=l,u.height=s;let m=u.getContext("2d");if(!m)return null;m.drawImage(e,0,0,l,s);let c=k=>new Promise((S,v)=>{u.toBlob(p=>p?S(p):v(new Error("canvas toBlob returned null")),"image/jpeg",k)}),b=bt(i,o.qMin,o.qMax),{blob:f,quality:L}=await yt(c,{startQ:b,qMin:o.qMin,budgetBytes:o.payloadTargetBytes}).finally(()=>{u.width=0,u.height=0});if(f.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:f,quality:L,width:l,height:s}}async function ie(e){let t=Ge(Math.max(e.width,e.height)),n=await qe(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 Ht(e){let t=await createImageBitmap(e);try{return await ie(t)}finally{t.close()}}var Yt=250,Vt=.6,Qt=1800,Kt=6e3,jt=2e3,He=.16;function ue(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 Xe=e=>e==="recto"?"verso":"recto",Ye=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",le=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function se(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 Mt(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let o=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:l}=e;o&&(l=l??n),l!==void 0&&n-l>=250&&(i=!0),o||(l=void 0);let s=e.flipTimeoutSpent&&!(i&&!e.flipped),u=e.notice==="same_face"&&i&&!e.flipped?void 0:e.notice,m={...e,lastReportAt:n,flipped:i,awaySince:l,flipTimeoutSpent:s,notice:u,lastArea:t.areaFrac};if(!Ye(e))return m;if(e.needFlip&&!i){if(!t.ready)return{...m,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...m,goodSince:void 0,phase:e.restPhase};let b=e.goodSince??n;return n-b>=1800?{...m,goodSince:b,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...m,goodSince:b,phase:e.restPhase}}return t.ready?{...m,phase:"capturing",goodSince:e.goodSince??n}:{...m,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function Dt(e,t){if(!Ye(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,o=t-e.lastCaptureAt>=6e3;return n||o?{...e,manualShutter:!0}:e}function wt(e,t,n){let o=e.layout==="singlePage",i=o?{recto:t}:e.captured,l=o?[]:[...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 o||le({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 Ve(e,t,n){return e.pending.includes(t)?{...e,pending:e.pending.filter(o=>o!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Xe(n),needFlip:!0,flipTimeoutSpent:!1,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function kt(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return Ve(e,t,n);let o=e.pending.filter(m=>m!==t),i={...e,pending:o,captured:{...e.captured,[n]:t}};if(le(i)!==1||e.layout==="singlePage")return i;let l=Xe(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 Ct(e,t){let n=t.id??e.captured[t.side],o={...e.captured};(t.id===void 0||o[t.side]===t.id)&&delete o[t.side];let i=e.pending.filter(c=>c!==n),l=e.layout==="twoSided"&&le({captured:o,pending:i})>0,s=e.lastShotByTimeout||n===e.lastShot!==e.flipped,u=l&&!s,m=u?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:o,pending:i,readSides:e.readSides.filter(c=>c!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:m,restPhase:m,current:t.side,needFlip:u,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function Qe(e,t){switch(t.type){case"report":return Mt(se(e,t.at),t.report,t.at);case"tick":return Dt(se(e,t.at),t.at);case"captured":return wt(se(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 kt(e,t.id,t.side);case"duplicate":return Ve(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],o=["recto","verso"].filter(l=>e.captured[l]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&o.every(l=>n.includes(l));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return Ct(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{...ue(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function xt(e,t,n=!1){let o=e(t);return o===null?"recto":!n||o.y+o.height/2>=t.height/2?"verso":"recto"}async function vt(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return xt(n,e,t)}async function ce(e,t=480,n,o=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 vt(u.getImageData(0,0,t,l),o))}finally{s.width=0,s.height=0}}async function Jt(e,t=480){try{let n=await createImageBitmap(e),o=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=o;let l=i.getContext("2d");return l===null?(n.close(),null):(l.drawImage(n,0,0,t,o),n.close(),l.getImageData(0,0,t,o))}catch{return null}}var de=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),Z=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Ke(e,t,n,o){let i=o.decode??(m=>createImageBitmap(m)),l=async()=>e.stillRead(await i(t),o.region??[0,0,1,1],o.detectorLimit),s;try{s=await l()}catch{try{await new Promise(m=>setTimeout(m,o.retryMs??300)),s=await l()}catch{return null}}let u=s.mrzBox;return u===void 0?null:{engine:o.engine,source:"live_mrz",format:n.format,lineCount:de(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===n.digest,band:[Z(u[0]),Z(u[1]),Z(Math.min(u[2],1-u[0])),Z(Math.min(u[3],1-u[1]))],digest:n.digest,framesToValid:de(n.framesToValid,1,1e3),msToValid:de(n.msToValid,0,12e4)}}function en(e){let t=null;return e?.then(n=>{t=n}),()=>t}var Rt=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]),Pt=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 je(e=globalThis){let t=e.WebAssembly?.validate;if(typeof t!="function")return{ok:!1,reason:"simd"};try{if(!t.call(e.WebAssembly,Rt)||!t.call(e.WebAssembly,Pt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}return typeof e.Worker!="function"?{ok:!1,reason:"worker"}:typeof e.createImageBitmap!="function"?{ok:!1,reason:"bitmap"}:{ok:!0}}function $e(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var E=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function Je(){let e=t=>(t.close(),Promise.reject(new E("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Ze(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 Je()}catch{return Je()}let n=new Map,o=0,i=!1,l=!1,s=!1;t.addEventListener("message",p=>{let g=p.data,M=n.get(g.id);M&&(n.delete(g.id),M.resolve(g))});let u=()=>{for(let p of n.values())p.reject(new E("error"));n.clear(),c()};t.addEventListener("error",u),t.addEventListener("messageerror",u);function m(p,g=[]){if(i)return Promise.reject(new E("disposed"));let M=++o;return new Promise((I,z)=>{n.set(M,{resolve:I,reject:z});try{t.postMessage({...p,id:M},g)}catch{n.delete(M),z(new E("error"))}})}function c(){if(!i){i=!0;try{t.postMessage({id:++o,kind:"dispose"})}catch{}t.terminate();for(let p of n.values())p.reject(new E("disposed"));n.clear()}}let b=(async()=>{let p=await m({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(p.kind==="failed")return p.reason;if(p.kind!=="ready")return"error";let g=await m({kind:"warmup"});if(g.kind!=="ready")return"error";let M=g.benchMs??g.warmupMs,I=e.deviceMemoryGb===void 0?Ee():e.deviceMemoryGb;return{warmupMs:g.warmupMs,downloadMs:p.downloadMs,cached:p.cached,benchMs:M,tier:Oe(M,I)}})().catch(()=>"error"),f,L=new Promise(p=>{f=setTimeout(()=>p("timeout"),e.tuning.loadTimeoutMs)}),k=Promise.race([b,L]).then(p=>(clearTimeout(f),typeof p=="string"?c():s=!0,i&&typeof p!="string"?"error":p));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",c,{once:!0});async function v(p,g,M){if(i)throw g.close(),new E("disposed");if(!s)throw g.close(),new E("not_ready");if(l)throw g.close(),new E("busy");l=!0;let I;try{let z=new Promise((N,G)=>{I=setTimeout(()=>{G(new E("timeout")),c()},e.tuning.readTimeoutMs??1e4)}),B=await Promise.race([m(p,[g]),z]);if(B.kind===M){let{id:N,...G}=B;return G}throw new E(B.kind==="error"?B.code:B.kind==="failed"?B.reason:"error")}finally{clearTimeout(I),l=!1}}return{ready:k,get busy(){return l},bandRead:(p,g=e.tuning.detectorLimit)=>v({kind:"band",bitmap:p,detectorLimit:g},p,"band"),stillRead:(p,g,M=e.tuning.detectorLimit)=>v({kind:"still",bitmap:p,region:g,detectorLimit:M},p,"band"),layoutRead:(p,g)=>v({kind:"layout",bitmap:p,detectorLimit:g},p,"layout"),dispose:c}}var V="sekyro-ocr-1",me=e=>e!==null&&typeof e=="object"?e:{},O=(e,t,n,o)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:o,et=(e,t)=>typeof e=="boolean"?e:t,tt=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function nt(e,t={}){let n=me(e),o=me(n.liveMrz),i=me(n.frontLock),l=tt(t.engine??V),s=t.mode==="off",u=p=>p.enabled===!0?p.arm==="live"?"live":"control":null,m=u(o),c=u(i),b=(p,g)=>!s&&g==="live"&&tt(p.minEngine??V)<=l,f=Be,L=b(o,m)?{detectorLimit:O(o.detectorLimit,320,1600,f.detectorLimit),bandMaxWidthPx:O(o.bandMaxWidthPx,320,4096,f.bandMaxWidthPx),minBandWidthPx:O(o.minBandWidthPx,0,4096,f.minBandWidthPx),bandTop:O(o.bandTop,0,.95,f.bandTop),minIntervalMs:O(o.minIntervalMs,0,5e3,f.minIntervalMs),stableReads:Math.round(O(o.stableReads,1,10,f.stableReads)),profileReads:Math.round(O(o.profileReads,1,100,f.profileReads)),maxReadMs:O(o.maxReadMs,50,6e4,f.maxReadMs),searchTimeoutMs:O(o.searchTimeoutMs,1e3,12e4,f.searchTimeoutMs),hint:et(o.hint,!0),stillConfirm:et(o.stillConfirm,!0)}:null,k=Ae,S=(p,g,M)=>O(i[p],g,M,k[p]),v=b(i,c)?{minLines:Math.round(S("minLines",1,50)),fillMin:S("fillMin",0,1),fillMax:S("fillMax",0,2),offsetMax:S("offsetMax",0,1),steadyFillDelta:S("steadyFillDelta",0,1),steadyOffsetDelta:S("steadyOffsetDelta",0,1),layoutShiftMax:S("layoutShiftMax",0,1),lineCountDelta:Math.round(S("lineCountDelta",0,50)),lockMs:S("lockMs",0,3e4),steadyMs:S("steadyMs",0,3e4),minFrames:Math.round(S("minFrames",1,100)),minIntervalMs:S("minIntervalMs",0,5e3),maxWidthPx:S("maxWidthPx",160,2048),detectorLimit:S("detectorLimit",320,1600),searchTimeoutMs:S("searchTimeoutMs",1e3,12e4)}:null;return{enabled:L!==null||v!==null,liveMrz:L,textLock:v,liveMrzArm:m,frontLockArm:c,load:{detectorLimit:L?.detectorLimit??v?.detectorLimit??f.detectorLimit,loadTimeoutMs:O(o.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:O(o.maxDownloadMs,1e3,12e4,2e4)},reportSampleRate:O(o.reportSampleRate,0,1,1)}}function rt(e,t){return e.enabled?!(t.probe??je)().ok||(t.slow??$e)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Ze({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}:{},...t.deviceMemoryGb!==void 0?{deviceMemoryGb:t.deviceMemoryGb}:{}})}:{ok:!1,reason:"off"}}function Tt(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))),pe=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function ot(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,o=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:o==="unsupported"||o==="download"||o==="integrity"?o:o==="error"||o==="timeout"?"error":"off",l={kind:"live_mrz",platform:"web",engine:e.engine??V,arm:e.arm,capture:e.capture,outcome:i,reads:pe(t?.reads??0,0,1e4)??0,browser:e.browser??Tt()},s=(u,m)=>{m!==void 0&&(l[u]=m)};return s("format",t?.format),s("framesToValid",pe(t?.framesToValid,1,1e4)),s("msToValid",W(t?.msToValid)),s("framesToLock",pe(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("tier",n.tier),s("benchMs",W(n.benchMs))),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),l}function fe(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var Lt=2,_t=1500;async function Ot(e){let t=await import("./capture-session-doc-DFLSX6BB.js");return new t.CaptureSessionDoc(e)}function Et(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 At(e,t,n){let o=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let l=0;l<o.length;l+=1){let s=o[l],u=o[(l+1)%o.length];i+=s.x*u.y-u.x*s.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function kn(){import("./capture-session-doc-DFLSX6BB.js").then(e=>e.warmDocDetector()).catch(()=>{})}function Cn(e){return Bt(e,{}).handle}function Bt(e,t){let n=Re(),o=Pe({enabled:e.keepScreenAwake!==!1}),i=t.decode??(r=>createImageBitmap(r)),l=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),u=We(e.documentType,t.catalogCapture===!0?t.captureSeries??ze(e.issuer,e.documentType):[]),m=u.sides.length===1||e.side==="single",c=ue(m?"singlePage":"twoSided",s());if(!m&&(e.side==="recto"||e.side==="verso")){let r=e.side==="recto"?"verso":"recto";c={...c,captured:{[r]:"server"},readSides:[r],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let b="idle",f=null,L=null,k=!0,S=0,v=0,p=null,g=!1,M=!1,I="",z=null,B,N=null,G=[],ge=u.mrz==="none",at=u.barcodeSide==="recto"||u.barcodeSide==="verso"?u.barcodeSide:null,q=ge&&!m?t.barcode?.side??at:null,he=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,be=null,Se=()=>q===null||he===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(be??(be=import("./barcode-detect-C5IOXMKI.js").then(r=>r.loadBarcodeDetect(he)).catch(()=>null)),be),it=(r,a)=>{if(q===null)return Promise.resolve(null);let d,h=new Promise(D=>{d=setTimeout(()=>D(null),t.barcode?.budgetMs??_t)});return Promise.race([st(r,a,q),h]).finally(()=>clearTimeout(d))},st=async(r,a,d)=>{let h=d==="recto"?"verso":"recto";try{let D=t.barcode?.seen;if(D!==void 0)return await D(r)?d:h;let[_,x]=await Promise.all([Se(),a()]);if(_===null||x===null)return null;let y=Math.min(1600,x.width),w=document.createElement("canvas");w.width=y,w.height=Math.max(1,Math.round(x.height/x.width*y));try{let A=w.getContext("2d");return A===null?null:(A.drawImage(x,0,0,w.width,w.height),await Ue(_,A.getImageData(0,0,w.width,w.height),d))}finally{w.width=0,w.height=0}}catch{return null}},C=t.webOcr!==void 0&&!ge?nt(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,X=null,F=C===null||!C.enabled?"off":null,Q=null,K=null,ye=new WeakMap,ee="";if(C!==null&&C.enabled&&t.webOcr!==void 0){let r=t.webOcr,a=rt(C,{baseUrl:e.liveMrz?.assetBaseUrl??r.baseUrl,salt:r.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...r.createWorker!==void 0?{createWorker:r.createWorker}:{}});if(a.ok){X=a.engine;let d=new Ie({textLock:C.textLock,liveMrz:C.liveMrz});Q=d;let h=a.engine;h.ready.then(D=>{F=D,typeof D!="string"&&k&&d.setEngine(h,D.tier)})}else F=a.reason}let H=r=>{let a=JSON.stringify(r);a!==ee&&(ee=a,n.emit("mrz",r))},Me=(r,a)=>{let d=t.webOcr?.reports;if(d===void 0||C===null||r===void 0)return;let h=r.format==="ID-3"||r.side==="single"?"single":r.side==="verso"?"verso":"recto",D=h!=="recto"?C.liveMrzArm??C.frontLockArm:C.frontLockArm;if(D===null||Math.random()>=C.reportSampleRate)return;let _=r.via==="live_mrz"?K:null,x=()=>{let y=_?.value??null;d([ot({arm:D,capture:h,assist:r.ocr??null,load:D==="control"?"off":F,...r.msToCapture!==void 0?{msToCapture:r.msToCapture}:{},...y!==null&&y.stillConfirmed!==void 0?{stillConfirmed:y.stillConfirmed}:{},...a!==void 0?{typeMismatch:fe(a.format,u.format==="ID-3"?"passport":"card")}:{}})])};_!==null&&_.value===null?Promise.race([_.promise,new Promise(y=>setTimeout(y,3e3))]).then(x):x()},U=r=>{!k||r===b||(b=r,o.setActive(r==="starting"||r==="scanning"),n.emit("state",r))},ut=(r,a)=>a===void 0?null:m?"single":r.captured.recto===a?"recto":r.captured.verso===a?"verso":null,lt=r=>({phase:r.phase,captured:m?r.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>r.captured[a]!==void 0),expected:m?null:r.current??null,notice:r.notice??null,lastShot:ut(r,r.lastShot),manualShutter:r.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:M}),De=()=>{let r=f;r!==null&&r.captureNow().catch(()=>R({type:"captureFailed",at:s()}))};function R(r){if(!k)return;let a=c;c=Qe(c,r),c.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(De),c.phase==="result"&&a.phase!=="result"&&(U("done"),we());let d=lt(c),h=JSON.stringify(d);h!==I&&(I=h,n.emit("scan",d))}function we(){N!==null&&clearInterval(N),N=null;for(let r of G.splice(0))r();f?.destroy(),f=null,o.setActive(!1)}let ke=()=>f?.captureReport?.(),te=!1,Ce=(r,a)=>{if(!(r===void 0||t.onFaceReport===void 0))try{t.onFaceReport(r,a)}catch{}},j=r=>{ee="",!(f===null||c.phase==="reading"||c.phase==="result")&&(te=!1,p=m?"single":c.current??r,f.rearm(p))},ct=async(r,a,d,h)=>{K=null;let D=F!==null&&typeof F=="object"&&F.tier==="low";if(h!==void 0&&X!==null&&C?.liveMrz?.hint===!0&&!D){let A={promise:Ke(X,r,h,{engine:V,detectorLimit:C.liveMrz.detectorLimit}).catch(()=>null),value:null};A.promise.then(P=>{A.value=P}),K=A}h!==void 0&&fe(h.format,u.format==="ID-3"?"passport":"card")&&H({state:"mismatch",format:h.format});let _=ke();Ce(_,"captured"),te=!0,Me(_,h);let x=d===void 0?z:d===null?null:{quad:Et(d),frameWidth:0,frameHeight:0,inStill:!0},y={decoded:null},w=()=>(y.decoded??(y.decoded=Promise.resolve().then(()=>i(r)).catch(()=>null)),y.decoded);try{await dt(r,a,x,w,K,h)}finally{y.decoded!==null&&(await y.decoded)?.close()}},dt=async(r,a,d,h,D,_)=>{let x=`shot-${S+=1}`,y=c.current;if(R({type:"captured",id:x,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!g&&l>0){let P=await(t.measureSharpness!==void 0?t.measureSharpness(r,d):h().then(T=>T===null?-1:_e(T,ae(d?.quad??null,d?.inStill===!0?T:{width:d?.frameWidth??0,height:d?.frameHeight??0},T)))).catch(()=>-1);if(!k)return;if(Number.isFinite(P)&&P>=0&&P<l){g=!0;let T=m?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:T,id:x,issue:"blurry"}),j(T);return}}g=!1;let w;if(m)w="single";else{let P=_!==void 0&&_.format!=="TD3"&&(u.mrzSide==="recto"||u.mrzSide==="verso")?u.mrzSide:null,T=P===null&&t.classify===void 0?await it(r,h):null,xe=T===null||q===null?T:Ne(T,q,c.captured),Y=P??xe??(xe===null&&q!==null&&y!==void 0?y:null)??await(t.classify!==void 0?t.classify(r):h().then($=>$===null?y??"recto":d?.inStill===!0?ce($,480,null,!0):ce($,480,ae(d?.quad??null,{width:d?.frameWidth??0,height:d?.frameHeight??0},$)))).catch(()=>y??"recto");if(!k)return;if(c.captured[Y]!==void 0&&v<Lt){v+=1,R({type:"duplicate",id:x,side:Y}),j(Y==="recto"?"verso":"recto");return}let ve=c.captured.recto===void 0?"recto":c.captured.verso===void 0?"verso":void 0;w=c.captured[Y]!==void 0&&ve!==void 0?ve:Y,v=0,R({type:"classified",id:x,side:w})}let A=w==="verso"?"verso":"recto";try{let P=t.encode!==void 0?await t.encode(r):await h().then(T=>{if(T===null)throw new Error("the still could not be decoded");return ie(T)});if(!k)return;D!==null&&ye.set(P.blob,D),n.emit("captured",{image:P.blob,side:w,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:P.width,height:P.height,previewDataUrl:a}),t.deferRead!==!0&&R({type:"readOk",side:A})}catch(P){R({type:"readFailed",side:A,id:x,issue:"technical"}),n.emit("error",J("generic",!0,{phase:"keyframes",name:re(P)}))}j(A==="recto"?"verso":"recto")},mt=r=>{G.push(r.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?U("starting"):a==="positioning"?U("scanning"):a==="captured"?U("captured"):a==="error"&&U("error")}),r.on("feedback",({key:a,reticle:d})=>n.emit("feedback",{key:a,reticle:d})),r.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 d=a.ocr?.mrz;d!==void 0&&(d.state==="fallback"?H({state:"fallback",reason:d.reason}):d.state==="valid"?H({state:"valid",format:d.format}):d.state==="reading"?H({state:"reading",...d.format?{format:d.format}:{},...d.coach?{coach:d.coach}:{}}):H({state:"searching"}));let h=a.quad===null?0:At(a.quad,a.frameWidth,a.frameHeight);z=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:h},at:s()})}),r.on("error",({kind:a,retryable:d,detail:h})=>n.emit("error",J(a,d,h))),r.on("artifacts",a=>{ct(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},ne=()=>(L??(L=(async()=>{if(k){if(Se(),f===null){let r;try{r=await(t.createEngine??Ot)({...t.engineOptions??{},...B!==void 0?{guide:B}:{},video:e.video,format:u.format,side:m?"single":e.side??"recto",autoCapture:!1,...Q!==null?{ocr:Q}:{}})}catch(d){U("error"),n.emit("error",J("models",!0,{phase:"models",name:re(d)}));return}if(!k){r.destroy();return}f=r,p=m?"single":e.side??"recto",mt(r);let a=t.tickMs??500;a>0&&(N=setInterval(()=>R({type:"tick",at:s()}),a))}R({type:"clockRestart"}),C!==null&&C.liveMrzArm==="live"&&(F==="unsupported"||F==="off")&&H({state:"fallback",reason:F}),await f.start()}})().finally(()=>{L=null})),L);return{handle:{get state(){return b},on:(r,a)=>n.on(r,a),start:ne,retry:()=>{if(f===null&&c.phase==="result"){R({type:"retake"}),v=0,g=!1,ne();return}if(f!==null&&b!=="error"){R({type:"retake"}),v=0,g=!1,p=m?"single":null,f.rearm(m?"single":void 0);return}ne()},setSide:r=>{m||r==="single"||f!==null&&c.current===r&&p===r&&c.phase!=="reading"&&c.phase!=="result"||(c.current!==r&&(c={...c,current:r}),R({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&f!==null&&(p=r,f.rearm(r)))},shutter:De,focusAt:(r,a)=>{f?.focusAt?.(r,a)},setGuide:r=>{B=r,f?.setGuide?.(r)},setTorch:r=>{M=r,f?.setTorch(r),R({type:"tick",at:s()})},destroy:()=>{if(k&&f!==null&&b!=="done"){let r=ke();!te&&r!==void 0&&r.ticks>0&&Ce(r,"abandoned"),Me(r,void 0)}k=!1,we(),Q?.setEngine(null),X?.dispose(),X=null,n.clear()}},plan:u,setFlowState:r=>{(c.phase==="reading"||c.phase==="result")&&U(r==="done"&&c.phase!=="result"?"scanning":r)},settle:(r,a)=>{let d=r==="verso"?"verso":"recto";R(a.ok?{type:"readOk",side:d}:{type:"readFailed",side:d,issue:a.issue}),a.ok||j(d)},takeDeviceRead:r=>ye.get(r.image)?.value??null}}export{Ht as a,Yt as b,Vt as c,Qt as d,Kt as e,jt as f,He as g,ue as h,Qe as i,xt as j,vt as k,Jt as l,Ke as m,en as n,V as o,nt as p,rt as q,Tt as r,ot as s,fe as t,Lt as u,_t as v,kn as w,Cn as x,Bt as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var L=[468,473],$=[[33,133],[362,263]],ee=[[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]],ne=1;function j(e){let n=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(let l of e)l.x<n&&(n=l.x),l.y<o&&(o=l.y),l.x>a&&(a=l.x),l.y>r&&(r=l.y);return e.length===0?{x:0,y:0,width:0,height:0}:{x:n,y:o,width:a-n,height:r-o}}var A=(e,n)=>({x:(e.x+n.x)/2,y:(e.y+n.y)/2});function se(e,n,o){if(e.length<468)return null;let a=f=>{let y=e[f];return{x:y.x*n,y:y.y*o}},r=[0,1].map(f=>{let y=e.length>L[1]?a(L[f]):null,[i,s]=$[f];return y??A(a(i),a(s))}),l=ee.map(f=>j(f.map(a))),c=[];for(let f=0;f<Math.min(e.length,468);f+=1)c.push(a(f));let[b,h]=r,u=b.x>h.x,g=u?h:b,p=u?b:h;return{leftEye:g,rightEye:p,iod:Math.hypot(p.x-g.x,p.y-g.y),box:j(c),nose:a(ne),leftEyeBox:u?l[1]:l[0],rightEyeBox:u?l[0]:l[1]}}var P=180/Math.PI;function W(e,n="column"){if(e.length<16||e.some(f=>!Number.isFinite(f)))return null;let o=(f,y)=>n==="column"?e[y*4+f]:e[f*4+y],a=Math.hypot(o(0,0),o(1,0),o(2,0))||1,r=o(0,0)/a,l=o(1,0)/a,c=o(2,0)/a,b=o(2,1)/a,h=o(2,2)/a,u=Math.asin(Math.max(-1,Math.min(1,-c)))*P,g=Math.atan2(b,h)*P,p=Math.atan2(l,r)*P;return{yaw:u,pitch:g,roll:p}}function U(e){return Math.atan2(e.rightEye.y-e.leftEye.y,e.rightEye.x-e.leftEye.x)*P}var _={width:480,height:640,eyeX:240,eyeY:289,iodMin:120,iodMax:160};function F(e){let n=_,o=e.iod>=n.iodMin&&e.iod<=n.iodMax?1:n.iodMin/Math.max(e.iod,1e-6),a=n.width/o,r=n.height/o,l=A(e.leftEye,e.rightEye);return{x:l.x-n.eyeX/n.width*a,y:l.y-n.eyeY/n.height*r,width:a,height:r}}function Y(e,n,o){let a=Math.max(0,-e.x),r=Math.max(0,-e.y),l=Math.max(0,e.x+e.width-n),c=Math.max(0,e.y+e.height-o);return Math.max((a+l)/e.width,(r+c)/e.height)}function ue(e,n,o,a){let r=F(e),l=r.x+r.width/2,c=r.y+r.height/2,b=_.width/_.height,h=Math.max(r.height*a.margin,a.minHeight,a.minWidth/b);h=Math.min(h,o,n/b);let u=h*b,g=Math.min(Math.max(l-u/2,0),Math.max(0,n-u)),p=Math.min(Math.max(c-h/2,0),Math.max(0,o-h));return{x:Math.round(g),y:Math.round(p),width:Math.round(u),height:Math.round(h)}}var G=["face","framing","pose","eyes","mouth","glare","lighting","background","resolution","sharpness"],K=new Set(["glare","background"]),k=e=>({pass:!0,value:e,coach:null}),x=(e,n)=>({pass:!1,value:e,coach:n}),O=(e,n)=>({pass:e,value:null,coach:e?null:n,none:!0});function te(e,n){let o=e.pose,a;if(o!==null){let i=o.pitch-n.pitchOffsetDeg,s=Math.max(Math.abs(o.yaw),Math.abs(i),Math.abs(o.roll));a=Math.abs(o.yaw)<=n.yawDeg&&Math.abs(i)<=n.pitchDeg&&Math.abs(o.roll)<=n.rollDeg?k(s):x(s,"pose")}else a={...O(!1,"pose"),value:e.eyeLineRoll??null};let r=O(!1,"eyes");if(e.eyes!==null){let{left:i,right:s}=e.eyes,d=Math.min(i,s),m=e.baselines,R=1-n.eyes.blinkMax;if(m!=null&&m.left>0&&m.left<=1&&m.right>0&&m.right<=1){let M=Math.max(i,s)>=R-1e-9&&d>=n.eyes.lowerEyeMin-1e-9&&i>=n.eyes.relativeMin*m.left-1e-9&&s>=n.eyes.relativeMin*m.right-1e-9,E=Math.min(i/m.left,s/m.right);r=M?k(E):x(E,"eyes")}else{let M=e.baseline,E=Math.max(R,M!==null&&M>0&&M<=1?n.eyes.relativeMin*M:0),w=M!==null&&M>0?d/M:null;r=d>=E-1e-9?k(w):x(w,"eyes")}}let l=O(!1,"mouth");if(e.mouth!==null){let{jawOpen:i,smile:s,pucker:d}=e.mouth,m=Math.max(i/n.mouth.jawOpenMax,s/n.mouth.smileMax,d/n.mouth.puckerMax);l=i<=n.mouth.jawOpenMax&&s<=n.mouth.smileMax&&d<=n.mouth.puckerMax?k(m):x(m,"mouth")}let c=e.lighting,b=O(!0,"lighting");if(c!==null){let[i,s]=n.lighting.faceLuma,[d,m]=n.lighting.halfRatio;b=c.faceLuma<i||c.faceLuma>s||c.clipped>n.lighting.clippedMax?x(c.faceLuma,"lighting"):c.halfRatio<d||c.halfRatio>m?x(c.halfRatio,"lighting_side"):k(c.faceLuma)}let h=e.uniformity,u=e.background,g=n.background.required?h!=null&&n.backgroundCheck.enabled?h.uniform?k(h.colorStd):x(h.colorStd,"background"):u===null?O(!0,"background"):u.luma>=n.background.lumaMin&&u.sd<=n.background.lumaSdMax?k(u.luma):x(u.luma,"background"):O(!0,"background"),p=n.resolution,f=Math.min(e.frameWidth,e.frameHeight)>=p.minWidth&&Math.max(e.frameWidth,e.frameHeight)>=p.minHeight,y=e.iod>=p.minIodPx&&f?k(e.iod):x(e.iod,"resolution");return{pose:a,eyes:r,mouth:l,lighting:b,background:g,resolution:y}}function D(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 oe(e,n){if(e.length===0)return null;let o=[...e].sort((r,l)=>r-l),a=Math.min(o.length-1,Math.max(0,Math.ceil(n*o.length)-1));return o[a]}function V(e,n,o,a=null){let r={},l=e.geometry;if(e.faces!==1||l===null){let s=e.faces>1?x(e.faces,"multiple_faces"):x(e.faces,"no_face");for(let d of G)r[d]=d==="face"?s:O(!1,"no_face");return{results:r,pose:null}}r.face=k(1);let c=F(l),b=Y(c,e.frameWidth,e.frameHeight);r.framing=c.height>e.frameHeight*1.02||c.width>e.frameWidth*1.02?x(b,"too_close"):b>.02?x(b,"center"):k(b);let h=e.matrix!=null?W(e.matrix):null,u=D(e.blendshapes),g=e.blendshapes,p=e.stats??null,f=te({pose:h,eyeLineRoll:Math.abs(U(l)),eyes:u,baseline:o,baselines:a,mouth:g==null?null:{jawOpen:g.jawOpen??0,smile:Math.max(g.mouthSmileLeft??0,g.mouthSmileRight??0),pucker:g.mouthPucker??0},lighting:p?.lighting??null,background:p?.background??null,uniformity:e.backgroundCheck??null,iod:l.iod,frameWidth:e.frameWidth,frameHeight:e.frameHeight},n);Object.assign(r,f);let y=p?.eyeSpecular??null;r.glare=y===null?O(!0,"glare"):y<=n.glare.specularMax?k(y):x(y,"glare");let i=p?.sharpness??null;return r.sharpness=i===null||i>=n.sharpnessMin?k(i):x(i,"hold_still"),{results:r,pose:h}}var ae={pose:"pose",eyes:"eyes",mouth:"mouth",glare:"glare",lighting:"lighting",background:"background",framing:"resolution",resolution:"resolution"};function me(e,n={}){let o=n.policy==="alert",a=new Map,r=0,l=null,c=null,b={},h=[],u=null,g=null,p=null,f=0,y=i=>{let s=oe(h.map(i),e.baseline.percentile);return s===null||s<=0?null:Math.min(1,s)};return{push(i,s){let d=V(i,e,null),m=i.blendshapes;if(d.results.face.pass&&m!=null){let t=Z=>Math.round(Math.min(1,Math.max(0,Z??0))*1e3)/1e3,I={jawOpen:t(m.jawOpen),smile:t(Math.max(m.mouthSmileLeft??0,m.mouthSmileRight??0)),pucker:t(m.mouthPucker)};p===null&&(f=s);let S=p?.lowest??I;p={elapsedMs:Math.round(s-f),latest:I,lowest:{jawOpen:Math.min(S.jawOpen,I.jawOpen),smile:Math.min(S.smile,I.smile),pucker:Math.min(S.pucker,I.pucker)}}}let R=D(i.blendshapes);R!==null&&d.results.face.pass&&d.results.pose.pass&&h.push({at:s,left:R.left,right:R.right}),h=h.filter(t=>s-t.at<=e.baseline.windowMs);let M=h.length>=e.baseline.minSamples,E=M?y(t=>(t.left+t.right)/2):null,w=M?y(t=>t.left):null,B=M?y(t=>t.right):null,N=w!==null&&B!==null?{left:w,right:B}:null,{results:C,pose:q}=V(i,e,E,N);for(let t of G)C[t].pass&&(t!=="eyes"||E!==null)?a.has(t)||a.set(t,s):a.delete(t);let H=t=>{let I=a.get(t);return I!==void 0&&s-I>=e.holdMs};G.filter(t=>!K.has(t)).every(H)?l??(l=s):l=null;let X=t=>t==="background"&&i.backgroundCheck!=null?e.backgroundCheck.timeoutMs:e.softGraceMs,J=t=>K.has(t)&&!C[t].pass&&l!==null&&s-l>=X(t),v=G.map(t=>({criterion:t,pass:C[t].pass,held:H(t),waived:J(t),value:C[t].value,coach:C[t].pass?null:C[t].coach}));r=v.every(t=>t.pass||t.waived)?r+1:0;let T=v.find(t=>!t.pass&&!t.waived)??null,z=v.filter(t=>t.held||t.waived).length;C.face.pass&&C.framing.pass?c??(c=s):c=null;let Q=v.every(t=>t.held||t.waived)&&r>=e.holdFrames||o&&c!==null&&s-c>=e.alertGraceMs;b={};for(let t of G){let I=ae[t];I!==void 0&&C[t].none!==!0&&(b[I]=(b[I]??!0)&&C[t].pass)}return g=i.backgroundCheck??null,u={criteria:v,coach:T?.coach??"hold",failing:T?.criterion??null,progress:z/v.length,ready:Q,baseline:E,baselines:N,pose:q},u},last:()=>u,scores:()=>p,summary(){let i={criteria:{}};if(u===null)return i;i.verdict={...b},u.baseline!==null&&Math.round(u.baseline*1e3)>0&&(i.baselineEyeOpenness=Math.round(u.baseline*1e3)/1e3);let s=u.baselines;s!==null&&Math.round(s.left*1e3)>0&&Math.round(s.right*1e3)>0&&(i.baselineEyeOpennessLeft=Math.round(s.left*1e3)/1e3,i.baselineEyeOpennessRight=Math.round(s.right*1e3)/1e3);for(let d of u.criteria){let m=d.value===null||!Number.isFinite(d.value)?null:Math.round(d.value*1e3)/1e3;i.criteria[d.criterion]=d.waived?{pass:d.pass,value:m,waived:!0}:{pass:d.pass,value:m}}if(g!==null&&e.background.required){let{pixels:d,...m}=g;i.backgroundCheck=m}return i},reset(){a.clear(),r=0,l=null,c=null,b={},u=null,g=null,p=null}}}export{se as a,W as b,U as c,_ as d,F as e,Y as f,ue as g,G as h,te as i,D as j,oe as k,V as l,me as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function y(){let e=new Map;return{on(i,n){let t=e.get(i);t===void 0&&(t=new Set,e.set(i,t));let r=n;return t.add(r),()=>{t?.delete(r)}},emit(i,n){let t=e.get(i);if(t!==void 0)for(let r of[...t])r(n)},count(i){return e.get(i)?.size??0},clear(){e.clear()}}}async function f(){try{return typeof navigator>"u"||typeof navigator.permissions?.query!="function"?null:await navigator.permissions.query({name:"camera"})}catch{return null}}function c(e){return e==="granted"||e==="prompt"||e==="denied"?e:"unknown"}async function k(){let e=await f();return e===null?"unknown":c(e.state)}function w(e){let i=!1,n=null,t=()=>{!i&&n!==null&&e(c(n.state))};return f().then(r=>{i||(n=r,e(r===null?"unknown":c(r.state)),r?.addEventListener?.("change",t))}),()=>{i=!0,n?.removeEventListener?.("change",t)}}async function b(){if(typeof navigator>"u")return!1;let e=String(navigator.userAgent??"");if(/Android|iPhone|iPad|iPod/i.test(e)||/Macintosh/.test(e)&&(navigator.maxTouchPoints??0)>1)return!0;try{return(await navigator.mediaDevices?.enumerateDevices?.()??[]).filter(n=>n.kind==="videoinput").length>=2}catch{return!1}}var h=e=>e==="self"?"user":"environment";function S(){let e=!1,i=t=>{e||(e=!0,console.warn(`[@sekyro/web] ${t}`))},n=t=>t==="self"?"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.":"this capture is an assisted capture (another person films the face), which uses the back camera only. The front camera is for self capture, set in the flow.";return{facing:(t,r)=>{let o=h(t);return r!==void 0&&r!==o&&i(`facing "${r}" ignored: ${n(t)}`),o},refuseSwitch:t=>(i(`switchCamera() ignored: ${n(t)}`),!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 P(e={}){if(e.enabled===!1)return{setActive:()=>{}};let i=!1,n=null,t=!1,r=!1,o=()=>{if(!i||t||n!==null&&!n.released)return;let a=v();if(a===null||!m())return;let s;try{s=a.request("screen")}catch{return}t=!0,s.then(u=>{if(t=!1,!i){p(u);return}n=u,u.addEventListener?.("release",()=>{n===u&&(n=null)})},()=>{t=!1})},l=()=>{m()&&o()},d=a=>{typeof document>"u"||a===r||(r=a,a?document.addEventListener("visibilitychange",l):document.removeEventListener("visibilitychange",l))};return{setActive:a=>{if(i=a,a){if(v()===null)return;d(!0),o();return}if(d(!1),n!==null){let s=n;n=null,p(s)}}}}export{y as a,k as b,w as c,b as d,h as e,S as f,P as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"./chunk-JLVZ35QK.js";import{a as o}from"./chunk-QB62OPX5.js";var i=class extends Error{constructor(t){super(t),this.name="AssetFailure",this.reason=t}},S=Object.keys(o.files).filter(e=>o.files[e].tier==="live"),x=Object.keys(o.files).filter(e=>o.files[e].tier==="lazy");function w(e,t){return`${e.replace(/\/+$/,"")}/${o.fp12}/${t}`}async function A(e,t,u,h=fetch,a=()=>performance.now()){let f=o.files[t],y=a(),c=async r=>{try{let s=await h(w(e,t),{cache:r,signal:u,credentials:"omit"});if(!s.ok)throw new i("download");return await s.arrayBuffer()}catch(s){throw s instanceof i?s:new i("download")}},l=async r=>r.byteLength===f.bytes&&await m(r)===f.sha256,n=await c("force-cache");if(!await l(n)&&(n=await c("reload"),!await l(n)))throw new i("integrity");return{bytes:n,ms:a()-y}}async function k(e,t,u,h=fetch,a=()=>performance.now()){let f=new AbortController,y=new Map,c=t.reduce((s,d)=>s+o.files[d].bytes,0),l=a(),n=!0,r=0;for(let s of t){let d=await A(e,s,f.signal,h,a);y.set(s,d.bytes),d.ms>=50&&(n=!1),r+=d.bytes.byteLength;let p=a()-l;if(r<c&&p>0&&p*c/r>u)throw f.abort(),new i("download")}return{files:y,downloadMs:Math.round(a()-l),cached:n}}function E(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{i as a,S as b,k as c,E as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as re,d as ne,e as B,f as se,g as oe}from"./chunk-7QZWBDI5.js";import{A as te,a as X}from"./chunk-FYU7J2DC.js";import{f as j,l as J}from"./chunk-CPUECYAJ.js";import{c as Z}from"./chunk-TSA6GHUG.js";import{c as ee,h as L}from"./chunk-FSSMUAKC.js";var ve=12e4,ie=13e4,ge=3e3,he=1200,D=Symbol.for("@sekyro/web.preload.v1");function h(){let e=globalThis;return e[D]??(e[D]=new Map),e[D]}function b(e){let r=(e??ee).replace(/\/+$/,"");return r===""?"/":r}function ae(e){let r=h(),n=r.get(e);return n===void 0&&(n={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},r.set(e,n)),n}function k(e,r){if(e.status!==r){e.status=r;for(let n of[...e.listeners])n(r)}}var K=e=>L({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:ve}),H=K;function Te(e){H=e??K}function Oe(){for(let e of h().values())e.detector?.destroy();h().clear(),H=K}function Ce(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function Se(){return navigator.connection?.saveData===!0}function Ee(e){let r=window;if(typeof r.requestIdleCallback=="function"){let s=r.requestIdleCallback(e,{timeout:ge});return()=>r.cancelIdleCallback?.(s)}let n=setTimeout(e,he);return()=>clearTimeout(n)}function ye(e,r){let n,s=new Promise(d=>{n=d}),m=!1,u=()=>{},c={promise:s,settle:d=>{m||(m=!0,u(),e.scheduled===c&&(e.scheduled=null),n(d))}};return e.scheduled=c,u=Ee(()=>{m||c.settle(U(e,r))}),s}function U(e,r){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;k(e,"loading");let n=new Promise(d=>d(H(r)));e.detectorPromise=n;let s,m=new Promise((d,f)=>{s=setTimeout(()=>{n.then(C=>C.destroy(),()=>{}),f(new Error(`detector preload exceeded ${ie} ms`))},ie)}),c=Promise.race([n,m]).then(d=>e.detectorPromise!==n?(d.destroy(),e.status):(e.detector=d,k(e,"ready"),"ready"),d=>(e.detectorPromise===n&&(e.detectorPromise=null,e.detector=null,k(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",d)),e.status)).finally(()=>clearTimeout(s));return e.promise=c,e.scheduled?.settle(c),c}function xe(e={}){if(!Ce())return Promise.resolve("idle");let r=b(e.assetBaseUrl),n=ae(r);return e.respectSaveData===!0&&Se()?Promise.resolve(n.status):(n.status==="loading"||n.status==="ready")&&n.promise!==null?n.promise:e.idle===!0?n.scheduled?.promise??ye(n,r):U(n,r)}function Fe(e){return h().get(b(e))?.status??"idle"}function Ie(e,r){let n=ae(b(r));return n.listeners.add(e),()=>{n.listeners.delete(e)}}function Be(e){let r=h().get(b(e));r!==void 0&&(r.scheduled?.settle("idle"),r.detector?.destroy(),r.detector=null,r.detectorPromise=null,r.promise=null,k(r,"idle"))}function Le(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...r)=>e.detect(...r),destroy:()=>{}}}function de(e){let r=b(e),n=h().get(r);if(!(n===void 0||n.detector===null&&n.detectorPromise===null&&n.scheduled===null))return async()=>{n.scheduled!==null&&U(n,r);let s=n.promise;for(;n.detector===null&&s!==null&&(await s,n.promise!==s);)s=n.promise;return n.detector!==null?Le(n.detector):L({v3AssetBaseUrl:r})}}var be=new Set(["inuse","overconstrained","notfound"]),Me=[500,1500];function Ae(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";case"fcv3.one_face":return"one_face";default:return null}}function Pe(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function ue(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;case"backcamera":return"notfound";default:{let r=e;return"generic"}}}function we(e,r,n){if(n===void 0)return{kind:ue(e),retryable:r};let s=J(n.name);return{kind:ue(e),retryable:r,detail:{...s!==void 0?{name:s}:{},phase:n.phase,engineKind:e}}}var _e=new Set(["captured","uploading","checking"]);function De(e,r={},n,s=()=>"self",m=()=>{},u){let c=r.now??(()=>performance.now()),d=r.canChooseFacing??ne,f="user",C=se(),p=s(),l=re(),V=!j(),G=r.engineOptions,ce=G?.createDetector===void 0&&G?.createWorker===void 0?{createDetector:()=>{let t=de(e.assetBaseUrl);return t!==void 0?t():L({v3AssetBaseUrl:e.assetBaseUrl})}}:{},z={video:e.video,mode:V?"photo":"clip",rankKeyframes:n,facingMode:void 0,v3AssetBaseUrl:e.assetBaseUrl,screenRamp:()=>p==="self"&&l.count("ramp")>0?m():void 0,...r.engineOptions??{},...ce},a=r.createEngine?.(z)??new te(z),v="idle",M=null,A=0,R=!1,T="full",P=null,w=null,O=0,x=0,W=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(O=e.video.videoWidth,x=e.video.videoHeight)},q=oe({enabled:e.keepScreenAwake!==!1}),S=t=>{v=t,q.setActive(t==="starting"||t==="gating"||t==="recording"),l.emit("state",t)},F=()=>l.emit("gate",{progress:A,hint:M,faceDetected:R}),I=()=>{let t=a.animations??"full";t!==T&&(T=t,l.emit("profile",{animations:T}))},g=0,_=null,le=r.schedule??((t,o)=>{let i=setTimeout(t,o);return()=>clearTimeout(i)}),E=()=>{_?.(),_=null},fe=(t,o)=>{if(y||!be.has(t)||o?.phase!=="acquiring")return!1;let i=Me[g];return i===void 0?!1:(g+=1,E(),_=le(()=>{_=null,y||a.retry()},i),!0)},pe=[a.on("statechange",({state:t})=>{if(t==="error")return;let o=Pe(t);o==="gating"&&(g=0),o==="starting"&&v!=="starting"&&(M=null,A=0,R=!1,P=null,w=null,O=0,x=0),S(o),I(),o==="recording"&&(W(),P=c(),M="hold",A=1,F())}),a.on("checks",t=>{W(),A=t.progress,R=t.factors.presence>0,F(),I()}),a.on("guidance",({key:t})=>{M=Ae(t),F()}),a.on("frozen",({previewDataUrl:t})=>{w=c(),l.emit("frozen",{previewDataUrl:t})}),a.on("ramp",t=>l.emit("ramp",t)),a.on("artifacts",t=>{if(v!=="captured")return;let o=Z(),i=t.clipStats,Q=i!==void 0?Math.round(i.durationMs):P!==null&&w!==null?Math.max(0,Math.round(w-P)):void 0,Y=i!==void 0&&i.frames>1&&i.durationMs>0?Math.round(i.frames*1e4/i.durationMs)/10:void 0;l.emit("captured",{keyframe:t.keyframe,...t.clip!==void 0?{clip:t.clip}:{},...t.clipMimeType!==void 0?{clipMime:t.clipMimeType}:{},width:e.video.videoWidth||O,height:e.video.videoHeight||x,...Q!==void 0?{clipMs:Q}:{},...i!==void 0?{clipFrames:i.frames}:{},...Y!==void 0?{fps:Y}:{},...t.clipRetakes!==void 0?{clipRetakes:t.clipRetakes}:{},...t.clipMimeType!==void 0?{codec:X(t.clipMimeType)}:{},captureChannel:o==="desktop"?"desktop":"mobile",formFactor:o,...V?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:a.facingMode,mode:p,...t.timing,...t.screenRamp!==void 0?{screenRamp:t.screenRamp}:{},...t.provenance!==void 0?{provenance:t.provenance}:{}})}),a.on("error",({kind:t,retryable:o,detail:i})=>{t==="backcamera"&&me()||fe(t,i)||(S("error"),I(),l.emit("error",we(t,o,i)))})],N=!1;function me(){return y||N||p!=="assisted"||u===void 0||u.session()!=="choice"?!1:(N=!0,u.onModeChange("self"),p="self",f=B("self"),S("mode_switch"),a.restart(f),!0)}let $=async()=>u!==void 0&&u.session()==="choice"&&await d().catch(()=>!1),y=!1;return{handle:{get state(){return v},get captureMode(){return s()},get facingMode(){return a.facingMode??f},on:(t,o)=>l.on(t,o),start:t=>(p=s(),C.facing(p,e.facing),f=C.facing(p,t?.facing),E(),g=0,a.start({facingMode:f})),retry:()=>{E(),g=0,a.retry()},switchCamera:()=>C.refuseSwitch(s()),canSwitchCaptureMode:$,setCaptureMode:async t=>{if(t===s()||!await $()||y||_e.has(v)||u===void 0)return!1;u.onModeChange(t),p=t;let o=B(t);return f=o,v==="idle"||(S("mode_switch"),E(),g=0,a.restart(o)),!0},destroy:()=>{y=!0,E();for(let t of pe)t();q.setActive(!1),a.destroy(),l.clear()}},setFlowState:t=>{v!==t&&S(t)}}}function Ze(e){return De(e).handle}export{ve as a,ie as b,Te as c,Oe as d,xe as e,Fe as f,Ie as g,Be as h,de as i,Ae as j,Pe as k,ue as l,we as m,De as n,Ze as o};
|