@sekyro/web 0.1.0-rc.21 → 0.1.0-rc.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +12 -11
  3. package/dist/camera-trait-V4UAOPIQ.js +1 -0
  4. package/dist/{capture-constraints-B5omafmk.d.cts → capture-constraints-CVqpMNGA.d.cts} +7 -3
  5. package/dist/{capture-constraints-B5omafmk.d.ts → capture-constraints-CVqpMNGA.d.ts} +7 -3
  6. package/dist/{capture-session-doc-XBZGXWOP.js → capture-session-doc-BBDKMEAP.js} +1 -1
  7. package/dist/{capture-session-v3-ZO0QOeQH.d.ts → capture-session-v3-CFXYS0Pg.d.cts} +90 -13
  8. package/dist/{capture-session-v3-26FgzBIl.d.cts → capture-session-v3-DID39wUZ.d.ts} +90 -13
  9. package/dist/chunk-2LDOXGY3.js +1 -0
  10. package/dist/chunk-5DTWBDCP.js +1 -0
  11. package/dist/chunk-72LG73YL.js +1 -0
  12. package/dist/chunk-7QZWBDI5.js +1 -0
  13. package/dist/chunk-CPUECYAJ.js +1 -0
  14. package/dist/chunk-FSSMUAKC.js +1 -0
  15. package/dist/chunk-JWEHH2MS.js +1 -0
  16. package/dist/chunk-JYU5YHXN.js +1 -0
  17. package/dist/chunk-LFMIFR6T.js +1 -0
  18. package/dist/chunk-LJYMZQY2.js +1 -0
  19. package/dist/chunk-PBLZ5W7P.js +1 -0
  20. package/dist/chunk-RPVI2OGR.js +1 -0
  21. package/dist/chunk-SX7TUC3V.js +1 -0
  22. package/dist/chunk-TSA6GHUG.js +1 -0
  23. package/dist/chunk-U3NYGTX7.js +1 -0
  24. package/dist/chunk-VWGKUQ3C.js +1 -0
  25. package/dist/chunk-X6UIO5E3.js +1 -0
  26. package/dist/{chunk-QYYJLXKA.js → chunk-YWGW63B3.js} +1 -1
  27. package/dist/client/index.cjs +1 -1
  28. package/dist/client/index.d.cts +3 -3
  29. package/dist/client/index.d.ts +3 -3
  30. package/dist/client/index.js +1 -1
  31. package/dist/clip-inspect-DLJXVKV6.js +1 -0
  32. package/dist/core/index.cjs +1 -1
  33. package/dist/core/index.d.cts +5 -5
  34. package/dist/core/index.d.ts +5 -5
  35. package/dist/core/index.js +1 -1
  36. package/dist/core/v3/detect-worker.cjs +1 -1
  37. package/dist/core/v3/detect-worker.d.cts +1 -1
  38. package/dist/core/v3/detect-worker.d.ts +1 -1
  39. package/dist/core/v3/detect-worker.js +1 -1
  40. package/dist/create-document-capture-K5PDVOGV.js +1 -0
  41. package/dist/create-portrait-capture-5VGYZUOK.js +1 -0
  42. package/dist/{create-verification-KlHIU4Fy.d.ts → create-verification-BP2L4rzV.d.cts} +201 -82
  43. package/dist/{create-verification-CXhXxknV.d.cts → create-verification-Dc1Rd-4T.d.ts} +201 -82
  44. package/dist/{detect-worker-DclNxkZT.d.cts → detect-worker-CHqsPJoM.d.cts} +19 -2
  45. package/dist/{detect-worker-DclNxkZT.d.ts → detect-worker-CHqsPJoM.d.ts} +19 -2
  46. package/dist/{icao-gate-DI8VePWd.d.ts → icao-gate-CIXjbPCL.d.cts} +8 -1
  47. package/dist/{icao-gate-DvzOzHq6.d.cts → icao-gate-COt4O4h_.d.ts} +8 -1
  48. package/dist/{icao-policy-MRB8NMAu.d.cts → icao-policy-Cizs5guu.d.cts} +2 -2
  49. package/dist/{icao-policy-DztbA50-.d.ts → icao-policy-DI4kU6Mv.d.ts} +2 -2
  50. package/dist/index.cjs +1 -1
  51. package/dist/index.d.cts +11 -15
  52. package/dist/index.d.ts +11 -15
  53. package/dist/index.js +1 -1
  54. package/dist/internal/index.cjs +1 -1
  55. package/dist/internal/index.d.cts +49 -34
  56. package/dist/internal/index.d.ts +49 -34
  57. package/dist/internal/index.js +1 -1
  58. package/dist/plan-runner-AD2JTMC7.js +1 -0
  59. package/dist/popup/index.cjs +1 -1
  60. package/dist/popup/index.d.cts +2 -2
  61. package/dist/popup/index.d.ts +2 -2
  62. package/dist/popup/index.js +1 -1
  63. package/dist/{print-AYSCRSZB.js → print-SEWS3VHQ.js} +1 -1
  64. package/dist/{turnstile-FATNZ4AG.js → turnstile-F4DS2L3F.js} +1 -1
  65. package/dist/{types-C_XP92JQ.d.cts → types-Cjnp1o8i.d.cts} +161 -84
  66. package/dist/{types-C_XP92JQ.d.ts → types-Cjnp1o8i.d.ts} +161 -84
  67. package/package.json +1 -1
  68. package/sbom.cdx.json +10 -10
  69. package/dist/camera-trait-45MJTW4K.js +0 -1
  70. package/dist/chunk-234OZEDB.js +0 -1
  71. package/dist/chunk-7Q4YPMAF.js +0 -1
  72. package/dist/chunk-B2X33ZW2.js +0 -1
  73. package/dist/chunk-CQ7SKLMC.js +0 -1
  74. package/dist/chunk-FUHDOEBP.js +0 -1
  75. package/dist/chunk-GT2ZLGF7.js +0 -1
  76. package/dist/chunk-H3HVCWLF.js +0 -1
  77. package/dist/chunk-O5WKNZ2C.js +0 -1
  78. package/dist/chunk-OKWG3PVH.js +0 -1
  79. package/dist/chunk-P3H3D33O.js +0 -1
  80. package/dist/chunk-P6UP4UQY.js +0 -1
  81. package/dist/chunk-SNACCYTL.js +0 -1
  82. package/dist/chunk-TQB3URP2.js +0 -1
  83. package/dist/chunk-VIAT4DEA.js +0 -1
  84. package/dist/chunk-ZADZTM3M.js +0 -1
  85. package/dist/chunk-ZNIZACXD.js +0 -1
  86. package/dist/create-document-capture-23R2F47A.js +0 -1
  87. package/dist/create-portrait-capture-AGFHECK7.js +0 -1
  88. package/dist/plan-runner-NUWONT7F.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @sekyro/web
2
2
 
3
+ ## 0.1.0-rc.23
4
+
5
+ ### Minor Changes
6
+
7
+ - f7b755c: `StepContext.sandbox`: `true` on a Sandbox session (`view.sandbox`), `false` in Live. The flow is the same in both environments; a UI shows the "Test session" badge from it.
8
+ - 3eafb6e: The tester gate (Sandbox): `HostedSessionView.testerGate` and `StepContext.testerGate` offer "Run real checks as a tester" on a simulated Sandbox session before its first capture, and `verification.testerGate(artifacts)` sends one liveness capture to `POST /hosted/tester-gate`. `bound: true` means the session now runs real checks; `bound: false` keeps it simulated. `HostedClient.testerGate` and the types `HostedTesterGateView`, `TesterGateInput`, `TesterGateResponse`.
9
+ - d25960c: Turnstile runs in both environments: a Sandbox session's view carries Cloudflare's test site key, so the liveness submission sends the same `{ channel: "hosted_web", siteKey, turnstileToken }` as in Live. The `{ sandbox: true }` attestation is gone (the API refuses it in both environments).
10
+
11
+ ## 0.1.0-rc.22
12
+
13
+ ### Minor Changes
14
+
15
+ - ad0d148: Assisted capture uses the back camera only, on the liveness and the portrait cameras, as self capture uses the front camera only. `switchCamera()` on `LivenessCaptureHandle` and `PortraitCaptureHandle` does nothing and returns `false`, and a `facing` option or `start({ facing })` asking for the other camera is ignored; both log one console warning per handle. Under capture mode `choice` the person still switches the mode (`setCaptureMode`), and the camera follows it. `CapturedPortrait.facingMode` reports the camera the photo was taken with, and the portrait submission sends it as `input.capture.facingMode`. New reason `capture_front_camera` on `LivenessReason` and `PortraitIcaoReason`: an assisted capture reported on the front camera is refused before scoring, retryable, not billed and not counted as an attempt (in `RETRYABLE_REASONS`).
16
+
17
+ `@sekyro/react`: the front/back camera choice before an assisted capture and the flip button on the liveness and portrait cameras are gone. `IntroContext` no longer has `setFacing` or `canChooseFacing`; `IntroContext.facing` is the capture mode's camera. The new `reasons.capture_front_camera` string comes in every language.
18
+ - ad0d148: Under capture mode `choice` the person switches between filming themselves and being filmed on the camera view. `LivenessCaptureHandle.canSwitchCaptureMode()` says whether the switch is offered (a device with a front and a back camera), and `LivenessCaptureHandle.setCaptureMode(mode)` switches: the pick is recorded for the session (`Verification.chooseCaptureMode`), a running take restarts in the new mode (the recording is dropped, never submitted, and `CaptureState` passes through `mode_switch`), and the camera reopens on the front camera for `self` and the back one for `assisted`. The mode sets the camera.
19
+
20
+ `@sekyro/react`: `<LivenessCapture>` no longer asks who films before the liveness camera opens. Under `choice` the stage shows a chip in its end corner ("Someone is helping me", then "I film myself") that switches the mode and restarts the take with a "Camera switched" status line; a one-camera device does not show it. The new `capture.modeSwitch.*` strings come in every language. The portrait step keeps its who-takes-the-photo question.
21
+ - ad0d148: Every camera step hands off to a phone on a desktop browser, in every decision mode. `deriveStep` turns a `doc_ocr` or `portrait_icao` step that `requiresMobile` with the camera as its source into the `mobile_required` step (`MobileRequiredSnapshot.checkType` gains `doc_ocr` and `portrait_icao`); a `choice` photo step stays on the desktop with `photo.cameraOnPhone: true`, its upload offered and `refresh()` on the document and portrait handles. `Verification.mobileRequired()` covers every camera step. Under capture mode `choice`, `HostedCaptureTuning.pick` is the session's latest mode and the cameras open in it (`Verification.captureChoice` reports it). `detectFormFactor()` reads Windows and ChromeOS touch devices as desktops; iPadOS stays a tablet; a browser whose client hints (`navigator.userAgentData`) say `mobile` or an Android, iOS or iPadOS platform is never a desktop, so an Android phone in "desktop site" mode (a Windows user agent) is not handed off. The reason `uncalibrated_capture_channel` is gone from `LivenessReason`; `@sekyro/react` keeps its `reasons.uncalibrated_capture_channel` wording and `Strings` entry, frozen in the 0.1 dictionaries, though no reason resolves to it.
22
+
23
+ `@sekyro/react`: `<SekyroVerification>` shows the QR of `handoffUrl` at a camera document or portrait step, with a line that says what the phone is for; a `choice` photo step offers "Continue on my phone" and "Upload a photo", and never opens the webcam. Each of these hand-overs, and the liveness hand-over, uses the styled QR code with the Sekyro AI mark in the centre at error correction level H, like the QR codes in the dashboard. The code no longer shows your branding logo, with or without one in your session branding; the rest of the page keeps your branding. The code stays navy on a white tile, in dark mode and under your branding colours.
24
+ - 0804d05: Only one person may be in the liveness video. The capture gate reads the faces its detector already finds (no new model): while another face has at least a quarter of the person's face area, the gate waits (progress drains, the clip never starts) with the new hint `one_face` on `GateHint` and resumes once one face remains. Smaller faces further back never block. The native `FaceDetector` tier now asks for up to four faces and takes the largest as the person. New reason `multiple_faces` on `LivenessReason`: the server saw a second person in the clip and asks for a new one; retryable, not billed and not counted as an attempt for up to 5 retakes per step (in `RETRYABLE_REASONS`).
25
+
26
+ `@sekyro/react`: new strings `fcv3.one_face` (the guidance line, also spoken by the device voice) and `reasons.multiple_faces` (the retake line) in every language; `hintStringKey("one_face")` and `VOICE_KEYS` include it.
27
+ - ad0d148: The portrait step switches the capture mode on its camera too, under capture mode `choice`. `PortraitCaptureHandle.canSwitchCaptureMode()` and `PortraitCaptureHandle.setCaptureMode(mode)` work as on the liveness handle: the pick is recorded for the session, the camera reopens in the new mode (front for `self`, back for `assisted`) with the gate from zero, and `PortraitCaptureState` passes through `mode_switch`. Before the photo is taken only.
28
+
29
+ `@sekyro/react`: the portrait camera opens on the person's pick (`self` before one) with the switch chip in its end corner ("Someone is helping me", then "I take the photo myself") and a "Camera switched" line; a one-camera device does not show it. The who-takes-the-photo question is gone, and with it `CaptureModePicker` and the `capture.modePicker.*` strings; the new `capture.modeSwitch.*Photo` strings come in every language.
30
+ - f4840d7: `FaceMatchReason` no longer has `prior_review_rejected`: an earlier review is reused only when it approved the match, so a face match step never ends with that reason.
31
+ - 2beba0c: `PopulationReason` no longer has `result_from_cache`: a passed registry step carries no reason. `@sekyro/react` drops its wording (`reasons.result_from_cache`) in every language.
32
+
33
+ An object literal that overrides `reasons.result_from_cache` (for example the strings passed to `resolveStrings` or a custom dictionary typed with the package's strings type) must drop that key, or TypeScript reports an unknown property.
34
+ - 5329680: Screen ramp v2 (the liveness colour flash). The palette is four saturated colours, `magenta`, `yellow`, `green` and `blue` (`ScreenRampColour`); the six pastel names are gone. `ScreenRampChallenge` now carries `holdMs`, `endMs` and `clipMs`, and up to eight colours: the engine paints each colour at its onset, black after `holdMs` when the hold is shorter than the slot, and clears the layer at `endMs`. A capture that applies the ramp records the challenge's `clipMs` (3.0 s as issued, a 2.5 s clip otherwise) instead of 2.5 s. The `ramp` event's `colour` is a `ScreenRampPaint`: a colour, `"dark"` or `null`; `screenRampColourValue("dark")` is black. `SCREEN_RAMP_END_MS` and `SCREEN_RAMP_SEGMENT_MS` are removed (the challenge carries the timing). A challenge in the old shape is ignored: no ramp, the default clip.
35
+ - c5b46c4: A finished session is `verified` or `not_verified`. `SessionStatus` is `created | in_progress | review_pending | verified | not_verified`. A `not_verified` session says why in `reason` (`rejected`, `inconclusive`, `unavailable`, `abandoned`, `not_opened`, `policy`, `cancelled`, `superseded`), with the detailed code in `reasonCode`, who or what closed it in `closedBy` and the deciding step in `step`. Plan steps carry `result` (`passed`, `rejected`, `inconclusive`, `unreadable`, `unavailable`, `review`) next to `attempts { used, max }`.
36
+
37
+ `VerificationResult.status` is `verified | not_verified | review | retry | unavailable`. `reason` is the session reason and the check or SDK code is `reasonCode`. A capture refused while the session stays open (`autoRetry` off, or no try left) is `not_verified` with the reason its step result gives. A parked step with tries left is a `retry`, and a step the service could not run is `unavailable`.
38
+
39
+ The result step's `display` is `verified`, `review`, `rejected`, `inconclusive`, `unavailable`, `expired`, `policy`, `cooldown` or `platform_unsupported`. `ResultSnapshot` carries `reason`, `reasonCode` and `step`. The popup events are `session.verified`, `session.not_verified`, `session.review_pending` and `session.cancelled`.
40
+
41
+ Removed: `HostedSessionView.outcome` and `failureReason`, `SessionOutcome`, `PolicyFailureReason`, `HostedStepView.attemptsExhausted` (`attempts.used >= attempts.max` says it) and `ResultSnapshot.failureReason`. `CheckReason` gains `review_timeout` and `inference_unavailable`.
42
+
43
+ ### Patch Changes
44
+
45
+ - 37a6305: Assisted capture asks for the back camera exactly (`facingMode: { exact: "environment" }`), then a back lens by `deviceId`, then the browser's own pick, on the liveness and the portrait cameras. When only the front camera opens, nothing is recorded or uploaded: under capture mode `choice` the take continues as a self capture on the front camera (the pick is recorded and the stage shows the mode switch), otherwise the capture fails with `kind: "notfound"` and `detail.engineKind: "backcamera"`. Before this, a browser could answer the back-camera request with the front camera, and the server refused the uploaded clip with `capture_front_camera`.
46
+
47
+ `@sekyro/react`: the camera error notice shows the new `fcv2.err.backcamera` string for that failure, in every language.
48
+ - 960f295: Capture provenance reads the iPhone's camera names in the device language. `labelClass` was `unknown` for every iPhone set to Arabic, French, Spanish, Portuguese or German (`الكاميرا الأمامية`, `Caméra avant`, `Cámara frontal`, `Câmera frontal`, `Frontkamera` and their back-camera names). These now read as `platform`, like `Front Camera`. The label is still classified on the device and never sent. The field stays a recorded signal and decides nothing.
49
+ - ab329bc: The portrait and document steps no longer hand out a camera handle that was destroyed. A camera view that unmounts and mounts again on the same `<video>` (React StrictMode in development, or a remount) used to get the cached, destroyed handle back. Its `start()` did nothing, so the camera never appeared. It now gets a new handle.
50
+ - f8eae5a: The document step returns to the camera when the server asks for a retake of a passport page (`doc_ocr` `input_required` with `unreadable` or any other retryable reason). Before, the one-face read was settled as accepted and the camera stayed on the read screen with no way forward; a card whose two faces were both in but still asked for again did the same. Both now re-read the face that was sent. `@sekyro/react`: the retake line over the camera shows the server's reason, as the native SDKs do; a re-read the device asks for by itself keeps the re-read line.
51
+ - 704e58a: Liveness clips now cover their full window on Android browsers. The recording stops once the camera has presented `clipMs` of frames after the recorder started, plus 100 ms for the encoder to hand over the last frame (hard cap `clipMs` + 700 ms), instead of on a timer from `start()`. Browsers without an MP4 recorder (Chromium before 126) record H.264 in WebM on the hardware encoder before VP8 and VP9, and Chromium 126 skips its MP4 recorder. Every finished clip is measured from its container, a Chromium WebM gets the Duration its muxer leaves out, and a clip more than 100 ms short, unreadable or failed by the recorder is recorded once more, silently, then the better take is sent. `CapturedArtifacts` gains `clipFrames`, `fps`, `clipRetakes` and `codec`; `clipMs` is the measured clip length when the container was read. The liveness submission sends them in `input.capture`.
52
+ - 59b610b: A liveness capture made in a desktop browser is never uploaded or submitted, in every decision mode: the verification continues on a phone through the QR code. The device header now also reports the screen's touch points, so the server can tell a tablet that sends a desktop user agent (iPadOS Safari, Android "desktop site") from a desktop.
53
+ - 745caf9: Every hosted API call sends the browser's form factor in the `sekyro-client-form-factor` header (`desktop`, `phone` or `tablet`, from `detectFormFactor()`). The server reads it only to record where a session started and continued when its own request headers cannot tell (Safari or Firefox on a Mac, an iPad); it never decides whether a camera capture is accepted.
54
+ - 1d7ee00: The liveness submission waits less for its Turnstile token, and the consent is recorded when the person taps Continue. When the camera starts and the face capture is the next step, `createVerification` records the consent (the person's first action, spec §3.7) instead of just before the uploads; nothing else is submitted then, and a failed call is made again before the first submission. `createVerification` requests the token when the camera starts (and when consent is recorded), so the challenge runs while the person films, and submits it if it is less than 240 s old (Cloudflare accepts a token for 300 s); a token that is older, or a prefetch that failed, is replaced by a fresh one. One invisible widget per site key is rendered and kept: a later token is `reset()` and `execute()` on the same widget instead of a new widget each time. A challenge now times out after 10 s instead of 30 s; the submission still retries once. `input.capture.attestationMs` reports how long the token took once the uploads had settled.
55
+
3
56
  ## 0.1.0-rc.21
4
57
 
5
58
  ### Minor Changes
package/README.md CHANGED
@@ -17,9 +17,11 @@ Use of the SDK is governed by the [Sekyro AI SDK License](https://sekyro.ai/lega
17
17
  import { createVerification } from "@sekyro/web";
18
18
 
19
19
  const v = createVerification({ clientToken, locale: "ar" }); // token from your server (@sekyro/node)
20
- v.on("result", ({ status, reason }) => {
21
- // approved | rejected | review | retry | unavailable: for display;
22
- // the verdict that counts is read server-side (sessions.get + webhooks).
20
+ v.on("result", ({ status, reason, reasonCode }) => {
21
+ // verified | not_verified | review | retry | unavailable: for display.
22
+ // not_verified says why in `reason` (rejected, inconclusive, unavailable, abandoned,
23
+ // not_opened, policy, cancelled, superseded) and the detail in `reasonCode`.
24
+ // The verdict that counts is read server-side (sessions.get + webhooks).
23
25
  });
24
26
  const cap = v.liveness({ video }); // your <video playsinline muted>
25
27
  cap.on("gate", ({ progress, hint }) => {/* ring 0..1, hint code */});
@@ -79,13 +81,12 @@ await cap.start({ facing: "user" }); // reuses the warm detector automatically
79
81
  emits the current state first, then every change; `queryCameraPermission` is the
80
82
  one-shot read. Both report `'unknown'` where the Permissions API cannot tell.
81
83
  - The session decides who films the face (`HostedSessionView.capture.mode`, a flow
82
- setting), read from `handle.captureMode`. A **self** capture (the default, and
83
- every `createLivenessCapture()` not bound to a session) uses the front camera:
84
- `facing: "environment"` is ignored with a console warning and `switchCamera()`
85
- returns `false`. An **assisted** capture (an agent films the person) opens the back
86
- camera by default (the front one on a device without a front/back choice);
87
- `handle.facingMode` reports the camera the stream actually uses; `start({ facing })` picks the camera for the attempt and its
88
- retries and `switchCamera()` flips it (returns `true`).
84
+ setting), read from `handle.captureMode`, and the mode sets the camera. A **self**
85
+ capture (the default, and every `createLivenessCapture()` not bound to a session)
86
+ uses the front camera only; an **assisted** capture (an agent films the person) the
87
+ back camera only. A `facing` asking for the other camera is ignored and
88
+ `switchCamera()` returns `false`, with a console warning; `handle.facingMode`
89
+ reports the camera the stream actually uses.
89
90
  - On a phone the camera must be held upright: a landscape frame holds the gate
90
91
  (hint `upright`), and turning the phone sideways while the clip records drops that
91
92
  clip and goes back to positioning. Tablets and desktop webcams are not affected.
@@ -109,7 +110,7 @@ import { openHosted } from "@sekyro/web";
109
110
  const popup = openHosted(hostedUrl, {
110
111
  mode: "popup",
111
112
  onEvent: ({ event, sessionId }) => {
112
- // session.completed | session.failed | session.review_pending | session.expired | session.cancelled
113
+ // session.verified | session.not_verified | session.review_pending | session.cancelled
113
114
  // A hint only: read the session on your server (sessions.get) before deciding.
114
115
  },
115
116
  });
@@ -0,0 +1 @@
1
+ import{a,b,c,d}from"./chunk-2LDOXGY3.js";export{a as bounded,c as cameraHash,b as hex16,d as noteCameraTrait};
@@ -18,9 +18,13 @@ declare const PHONE_MAX_SHORT_SIDE = 600;
18
18
  * - phone: an iPhone / iPod user agent, an Android user agent with `Mobile`, a legacy mobile user agent, or a touch
19
19
  * device with a coarse primary pointer whose shorter screen side is under {@link PHONE_MAX_SHORT_SIDE} CSS px;
20
20
  * - tablet: iPadOS (an iPad user agent, or the desktop `Macintosh` one with touch points), Android without `Mobile`,
21
- * and other touch devices with a coarse primary pointer (Windows / ChromeOS tablets);
22
- * - desktop: everything else. The window width plays no part: a narrow desktop window is still a desktop, and a touch
23
- * laptop keeps a fine primary pointer.
21
+ * and other touch devices with a coarse primary pointer (a Linux user agent: an Android phone in "desktop site"
22
+ * mode sends one);
23
+ * - not a desktop whenever UA-CH (`navigator.userAgentData`) says `mobile` or an Android / iOS / iPadOS platform (an
24
+ * Android phone in "desktop site" mode sends a Windows user agent): a phone or tablet by its screen side;
25
+ * - desktop: everything else, Windows and ChromeOS touch devices included (spec 2026-11-06 §9 Q1: the liveness band
26
+ * is calibrated on phones, and the server classifies their requests as desktops). The window width plays no part:
27
+ * a narrow desktop window is still a desktop.
24
28
  * SSR-safe (`desktop` without window / navigator).
25
29
  */
26
30
  declare function detectFormFactor(): FormFactor;
@@ -18,9 +18,13 @@ declare const PHONE_MAX_SHORT_SIDE = 600;
18
18
  * - phone: an iPhone / iPod user agent, an Android user agent with `Mobile`, a legacy mobile user agent, or a touch
19
19
  * device with a coarse primary pointer whose shorter screen side is under {@link PHONE_MAX_SHORT_SIDE} CSS px;
20
20
  * - tablet: iPadOS (an iPad user agent, or the desktop `Macintosh` one with touch points), Android without `Mobile`,
21
- * and other touch devices with a coarse primary pointer (Windows / ChromeOS tablets);
22
- * - desktop: everything else. The window width plays no part: a narrow desktop window is still a desktop, and a touch
23
- * laptop keeps a fine primary pointer.
21
+ * and other touch devices with a coarse primary pointer (a Linux user agent: an Android phone in "desktop site"
22
+ * mode sends one);
23
+ * - not a desktop whenever UA-CH (`navigator.userAgentData`) says `mobile` or an Android / iOS / iPadOS platform (an
24
+ * Android phone in "desktop site" mode sends a Windows user agent): a phone or tablet by its screen side;
25
+ * - desktop: everything else, Windows and ChromeOS touch devices included (spec 2026-11-06 §9 Q1: the liveness band
26
+ * is calibrated on phones, and the server classifies their requests as desktops). The window width plays no part:
27
+ * a narrow desktop window is still a desktop.
24
28
  * SSR-safe (`desktop` without window / navigator).
25
29
  */
26
30
  declare function detectFormFactor(): FormFactor;
@@ -1 +1 @@
1
- import{C as a,D as b,E as c,F as d,G as e,H as f,I as g,J as h,K as i,L as j,M as k}from"./chunk-P6UP4UQY.js";import"./chunk-SMKCBUJL.js";import"./chunk-MXWLCDFX.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-POIQGEZM.js";import"./chunk-CQ7SKLMC.js";import"./chunk-FPXL63KZ.js";import"./chunk-VIAT4DEA.js";import"./chunk-DK5YPBDQ.js";export{k as CAPTURE_CANDIDATE_SPACING_MS,j as CAPTURE_EXTRA_CANDIDATES,h as CaptureSessionDoc,c as DOC_BLACK_FRAME_LUMA,d as DOC_BLACK_FRAME_TICKS,e as DOC_CADENCE_HZ,b as DOC_FIRST_FRAME_MS,f as DOC_SHUTTER_DEFAULTS,i as passportBandOf,g as resolveDocShutterTuning,a as warmDocDetector};
1
+ import{A as b,B as c,C as d,D as e,E as f,F as g,G as h,H as i,I as j,J as k,z as a}from"./chunk-LFMIFR6T.js";import"./chunk-G6LKLN4U.js";import"./chunk-SMKCBUJL.js";import"./chunk-MXWLCDFX.js";import"./chunk-TDLIXFDT.js";import"./chunk-POIQGEZM.js";import"./chunk-CPUECYAJ.js";import"./chunk-FPXL63KZ.js";import"./chunk-JYU5YHXN.js";import"./chunk-DK5YPBDQ.js";export{k as CAPTURE_CANDIDATE_SPACING_MS,j as CAPTURE_EXTRA_CANDIDATES,h as CaptureSessionDoc,c as DOC_BLACK_FRAME_LUMA,d as DOC_BLACK_FRAME_TICKS,e as DOC_CADENCE_HZ,b as DOC_FIRST_FRAME_MS,f as DOC_SHUTTER_DEFAULTS,i as passportBandOf,g as resolveDocShutterTuning,a as warmDocDetector};
@@ -1,5 +1,5 @@
1
- import { aU as ScreenRampReport, aM as CaptureProvenance, aS as ScreenRampChallenge, aI as ScreenRampColour } from './types-C_XP92JQ.js';
2
- import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-DclNxkZT.js';
1
+ import { a_ as ScreenRampReport, aR as CaptureProvenance, aX as ScreenRampChallenge, aY as ScreenRampPaint } from './types-Cjnp1o8i.cjs';
2
+ import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-CHqsPJoM.cjs';
3
3
 
4
4
  /** MP4-first ladder: one container (H.264 MP4) covers iOS/macOS Safari + Chrome 130+.
5
5
  * WebM/VP9→VP8 only as the Firefox/older-Chromium fallback. */
@@ -29,19 +29,60 @@ declare function buildLivenessV2FormData(args: {
29
29
  ts?: number;
30
30
  }): FormData;
31
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
+
32
40
  declare const CLIP_MS = 2500;
33
41
  declare const TIMESLICE_MS = 1000;
34
42
  declare const STOP_GRACE_MS = 1500;
35
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
+ }
36
58
  type ClipErrorKind = CameraErrorKind | "cliptoolarge";
37
59
  declare class ClipError extends Error {
38
60
  kind: ClipErrorKind;
61
+ /** The type the recorder was asked for when it failed (set by record()). */
62
+ requestedMimeType?: string;
39
63
  constructor(kind: ClipErrorKind, msg?: string);
40
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;
41
73
  interface ClipResult {
42
74
  blob: Blob;
43
75
  /** Container mime the clip was finalized with (recorder.mimeType || picked || DEFAULT_CLIP_MIME). */
44
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;
45
86
  }
46
87
  declare class ClipRecorder {
47
88
  private recorder;
@@ -50,7 +91,10 @@ declare class ClipRecorder {
50
91
  private bytes;
51
92
  private hardStopTimer;
52
93
  private graceTimer;
94
+ private pollTimer;
53
95
  private settled;
96
+ private readonly now;
97
+ constructor(options?: ClipRecorderOptions);
54
98
  private clearTimers;
55
99
  /** Records CLIP_MS of the stream. Resolves with the clip blob + its container mime;
56
100
  * rejects with ClipError. Behavior contract is the v1 hook's `start`, verbatim
@@ -74,8 +118,14 @@ declare class ClipRecorder {
74
118
  * `start` event: the zero of the clip's own timeline, which the screen ramp
75
119
  * stamps its colour changes against. PURE NOTIFICATION as well (the
76
120
  * `onstart` handler was unset before; nothing else changes), so it is
77
- * calibration-neutral. Never fires when construction or `start()` failed. */
78
- record(stream: MediaStream, onStopped?: () => void, onStarted?: () => void): Promise<ClipResult>;
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;
79
129
  /** Idempotent teardown: stop recorder + ALL tracks (v1 `stopAndCleanup` + the unmount
80
130
  * effect). Optional `stream` override mirrors v1's `stopAndCleanup(stream?)`.
81
131
  *
@@ -102,8 +152,10 @@ type CaptureState = "idle" | "preflight" | "acquiring" | "positioning" | "record
102
152
  * - 'cliptoolarge' the 8 MB clip cap (shared with the liveness API contract)
103
153
  * - 'recorder' MediaRecorder failed mid-clip. ClipRecorder's v1-verbatim kind for
104
154
  * this is 'generic'; CaptureSession REMAPS it to 'recorder' so hosts
105
- * can distinguish recorder failure from camera 'generic'. */
106
- type CaptureErrorKind = CameraErrorKind | "models" | "cliptoolarge" | "recorder";
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";
107
159
  /** The five v1 gate checks (hysteresis-smoothed statuses). */
108
160
  interface GateChecks {
109
161
  faceDetected: boolean;
@@ -135,6 +187,10 @@ interface CaptureArtifacts {
135
187
  clip?: Blob;
136
188
  /** Container mime the clip finalized with. Absent in photo mode. */
137
189
  clipMimeType?: string;
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;
138
194
  /** JPEG keyframe (captureMirroredKeyframe): mirrored on the front camera, as the sensor sees it on the back one. */
139
195
  keyframe: Blob;
140
196
  /** JPEG data URL of the keyframe canvas (v1 preview, quality 0.92). */
@@ -235,7 +291,7 @@ interface V3GateTickInput {
235
291
  frameWidth: number;
236
292
  frameHeight: number;
237
293
  }
238
- type V3GateFactor = "presence" | "centering" | "size" | "pose" | "sharpness" | "exposure" | "motion";
294
+ type V3GateFactor = "presence" | "single" | "centering" | "size" | "pose" | "sharpness" | "exposure" | "motion";
239
295
  /** Per-tick output — the telemetry + chrome contract. */
240
296
  interface V3GateTick {
241
297
  at: number;
@@ -266,7 +322,7 @@ declare class FaceGateV3 {
266
322
  private geometryOf;
267
323
  private motionOf;
268
324
  /** Lowest failing factor speaks — fixed priority (diagnostic, incl. light):
269
- * presence → size → centering → pose → exposure → sharpness → hold.
325
+ * presence → single → size → centering → pose → exposure → sharpness → hold.
270
326
  *
271
327
  * HONESTY FALLBACK (operator ruling 2026-07-12): when every factor clears
272
328
  * its guide threshold but q (= min factor) is still below Q_GOOD — i.e.
@@ -408,11 +464,11 @@ interface CaptureSessionV3Events {
408
464
  frozen: {
409
465
  previewDataUrl: string;
410
466
  };
411
- /** Liveness v7 §4.4: paint the full-viewport screen-ramp layer this colour (`null` clears it). Clip mode, a
412
- * challenge issued by `screenRamp()`; at most four events per recording. CHROME-only: the host paints, the
413
- * engine stamps the clip timeline. */
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. */
414
470
  ramp: {
415
- colour: ScreenRampColour | null;
471
+ colour: ScreenRampPaint;
416
472
  };
417
473
  }
418
474
  type V3TelemetryEvent = {
@@ -430,6 +486,11 @@ type V3TelemetryEvent = {
430
486
  degradeCount: number;
431
487
  meanDetectMs: number;
432
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
+ }
433
494
  /** Where the attempt's gate time went (see gate-blocking.ts): per-reason
434
495
  * blocked tick counts + ms, accepted ms, and the ACTIVE device class /
435
496
  * cadence after any dynamic profile adjustment. `final` on the attempt's
@@ -500,6 +561,12 @@ interface CaptureSessionV3Options {
500
561
  createRecorder?: () => Pick<ClipRecorder, "record" | "stop">;
501
562
  /** (navigator.mediaDevices.getUserMedia) */
502
563
  getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
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
+ }>>;
503
570
  /** (canvas keyframe, mirrored on the front camera only, + downscaled Laplacian sharpness) */
504
571
  captureKeyframe?: (video: HTMLVideoElement) => Promise<KeyframeCandidate>;
505
572
  /** (downscaled face-crop sharpness/exposure via canvas) */
@@ -583,6 +650,11 @@ declare class CaptureSessionV3 {
583
650
  /** Full reset + camera restart — the documented recovery path (v1 parity). */
584
651
  retry(): void;
585
652
  switchCamera(): void;
653
+ /**
654
+ * Spec 2026-11-06 §3.3 (the capture mode switch): drop the running attempt (a recording is discarded, never
655
+ * finalized) and start again on `facingMode`.
656
+ */
657
+ restart(facingMode: "user" | "environment"): void;
586
658
  destroy(): void;
587
659
  private run;
588
660
  /** Chrome hint (Task 11): 'reduced' on LOW even without the media query. */
@@ -590,6 +662,11 @@ declare class CaptureSessionV3 {
590
662
  private startScheduler;
591
663
  private detectTick;
592
664
  private fire;
665
+ /**
666
+ * One recording of `windowMs` on the preview's frame clock, with the screen ramp (when issued) and the upright
667
+ * guard; rejects with the recorder's error. `onStopped` fires the moment the recording ends (before finalize).
668
+ */
669
+ private recordTake;
593
670
  /** `{ provenance }` from the live track's description, the recording's frame statistics and the painter flag; `{}` without a track. */
594
671
  private provenance;
595
672
  /** A phone showing a landscape frame: the guard holds the gate. */
@@ -624,4 +701,4 @@ declare class CaptureSessionV3 {
624
701
  private now;
625
702
  }
626
703
 
627
- export { isClipTooLarge as $, MIME_CANDIDATES as A, type V3GateFactor as B, type CameraErrorKind as C, DEFAULT_CLIP_MIME as D, type EscalationClipArtifact as E, FaceGateV3 as F, GATE_SNAPSHOT_MS as G, HOLD_UPRIGHT_KEY as H, type V3GateQuality as I, type V3GateThresholds as J, KEYFRAME_CANDIDATES as K, type V3GateTick as L, MAX_CLIP_BYTES as M, type V3GateTickInput as N, type V3TelemetryEvent as O, PROVENANCE_WAIT_MS as P, V3_GATE_DEFAULTS as Q, VIDEO_BPS as R, STOP_GRACE_MS as S, TIMESLICE_MS as T, UPRIGHT_WATCH_MS as U, type V3ChecksPayload as V, blockReasonOf as W, buildLivenessV2FormData as X, cameraPreflight as Y, classifyDevice as Z, extForMime as _, CLIP_MS as a, isMediaRecorderSupported as a0, mapGetUserMediaError as a1, pickMimeType as a2, probeDevice as a3, type EngineErrorDetail as a4, 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 };
704
+ 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 };
@@ -1,5 +1,5 @@
1
- import { aU as ScreenRampReport, aM as CaptureProvenance, aS as ScreenRampChallenge, aI as ScreenRampColour } from './types-C_XP92JQ.cjs';
2
- import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-DclNxkZT.cjs';
1
+ import { a_ as ScreenRampReport, aR as CaptureProvenance, aX as ScreenRampChallenge, aY as ScreenRampPaint } from './types-Cjnp1o8i.js';
2
+ import { F as FaceObservation, b as Detector, W as WorkerLike } from './detect-worker-CHqsPJoM.js';
3
3
 
4
4
  /** MP4-first ladder: one container (H.264 MP4) covers iOS/macOS Safari + Chrome 130+.
5
5
  * WebM/VP9→VP8 only as the Firefox/older-Chromium fallback. */
@@ -29,19 +29,60 @@ declare function buildLivenessV2FormData(args: {
29
29
  ts?: number;
30
30
  }): FormData;
31
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
+
32
40
  declare const CLIP_MS = 2500;
33
41
  declare const TIMESLICE_MS = 1000;
34
42
  declare const STOP_GRACE_MS = 1500;
35
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
+ }
36
58
  type ClipErrorKind = CameraErrorKind | "cliptoolarge";
37
59
  declare class ClipError extends Error {
38
60
  kind: ClipErrorKind;
61
+ /** The type the recorder was asked for when it failed (set by record()). */
62
+ requestedMimeType?: string;
39
63
  constructor(kind: ClipErrorKind, msg?: string);
40
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;
41
73
  interface ClipResult {
42
74
  blob: Blob;
43
75
  /** Container mime the clip was finalized with (recorder.mimeType || picked || DEFAULT_CLIP_MIME). */
44
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;
45
86
  }
46
87
  declare class ClipRecorder {
47
88
  private recorder;
@@ -50,7 +91,10 @@ declare class ClipRecorder {
50
91
  private bytes;
51
92
  private hardStopTimer;
52
93
  private graceTimer;
94
+ private pollTimer;
53
95
  private settled;
96
+ private readonly now;
97
+ constructor(options?: ClipRecorderOptions);
54
98
  private clearTimers;
55
99
  /** Records CLIP_MS of the stream. Resolves with the clip blob + its container mime;
56
100
  * rejects with ClipError. Behavior contract is the v1 hook's `start`, verbatim
@@ -74,8 +118,14 @@ declare class ClipRecorder {
74
118
  * `start` event: the zero of the clip's own timeline, which the screen ramp
75
119
  * stamps its colour changes against. PURE NOTIFICATION as well (the
76
120
  * `onstart` handler was unset before; nothing else changes), so it is
77
- * calibration-neutral. Never fires when construction or `start()` failed. */
78
- record(stream: MediaStream, onStopped?: () => void, onStarted?: () => void): Promise<ClipResult>;
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;
79
129
  /** Idempotent teardown: stop recorder + ALL tracks (v1 `stopAndCleanup` + the unmount
80
130
  * effect). Optional `stream` override mirrors v1's `stopAndCleanup(stream?)`.
81
131
  *
@@ -102,8 +152,10 @@ type CaptureState = "idle" | "preflight" | "acquiring" | "positioning" | "record
102
152
  * - 'cliptoolarge' the 8 MB clip cap (shared with the liveness API contract)
103
153
  * - 'recorder' MediaRecorder failed mid-clip. ClipRecorder's v1-verbatim kind for
104
154
  * this is 'generic'; CaptureSession REMAPS it to 'recorder' so hosts
105
- * can distinguish recorder failure from camera 'generic'. */
106
- type CaptureErrorKind = CameraErrorKind | "models" | "cliptoolarge" | "recorder";
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";
107
159
  /** The five v1 gate checks (hysteresis-smoothed statuses). */
108
160
  interface GateChecks {
109
161
  faceDetected: boolean;
@@ -135,6 +187,10 @@ interface CaptureArtifacts {
135
187
  clip?: Blob;
136
188
  /** Container mime the clip finalized with. Absent in photo mode. */
137
189
  clipMimeType?: string;
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;
138
194
  /** JPEG keyframe (captureMirroredKeyframe): mirrored on the front camera, as the sensor sees it on the back one. */
139
195
  keyframe: Blob;
140
196
  /** JPEG data URL of the keyframe canvas (v1 preview, quality 0.92). */
@@ -235,7 +291,7 @@ interface V3GateTickInput {
235
291
  frameWidth: number;
236
292
  frameHeight: number;
237
293
  }
238
- type V3GateFactor = "presence" | "centering" | "size" | "pose" | "sharpness" | "exposure" | "motion";
294
+ type V3GateFactor = "presence" | "single" | "centering" | "size" | "pose" | "sharpness" | "exposure" | "motion";
239
295
  /** Per-tick output — the telemetry + chrome contract. */
240
296
  interface V3GateTick {
241
297
  at: number;
@@ -266,7 +322,7 @@ declare class FaceGateV3 {
266
322
  private geometryOf;
267
323
  private motionOf;
268
324
  /** Lowest failing factor speaks — fixed priority (diagnostic, incl. light):
269
- * presence → size → centering → pose → exposure → sharpness → hold.
325
+ * presence → single → size → centering → pose → exposure → sharpness → hold.
270
326
  *
271
327
  * HONESTY FALLBACK (operator ruling 2026-07-12): when every factor clears
272
328
  * its guide threshold but q (= min factor) is still below Q_GOOD — i.e.
@@ -408,11 +464,11 @@ interface CaptureSessionV3Events {
408
464
  frozen: {
409
465
  previewDataUrl: string;
410
466
  };
411
- /** Liveness v7 §4.4: paint the full-viewport screen-ramp layer this colour (`null` clears it). Clip mode, a
412
- * challenge issued by `screenRamp()`; at most four events per recording. CHROME-only: the host paints, the
413
- * engine stamps the clip timeline. */
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. */
414
470
  ramp: {
415
- colour: ScreenRampColour | null;
471
+ colour: ScreenRampPaint;
416
472
  };
417
473
  }
418
474
  type V3TelemetryEvent = {
@@ -430,6 +486,11 @@ type V3TelemetryEvent = {
430
486
  degradeCount: number;
431
487
  meanDetectMs: number;
432
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
+ }
433
494
  /** Where the attempt's gate time went (see gate-blocking.ts): per-reason
434
495
  * blocked tick counts + ms, accepted ms, and the ACTIVE device class /
435
496
  * cadence after any dynamic profile adjustment. `final` on the attempt's
@@ -500,6 +561,12 @@ interface CaptureSessionV3Options {
500
561
  createRecorder?: () => Pick<ClipRecorder, "record" | "stop">;
501
562
  /** (navigator.mediaDevices.getUserMedia) */
502
563
  getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
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
+ }>>;
503
570
  /** (canvas keyframe, mirrored on the front camera only, + downscaled Laplacian sharpness) */
504
571
  captureKeyframe?: (video: HTMLVideoElement) => Promise<KeyframeCandidate>;
505
572
  /** (downscaled face-crop sharpness/exposure via canvas) */
@@ -583,6 +650,11 @@ declare class CaptureSessionV3 {
583
650
  /** Full reset + camera restart — the documented recovery path (v1 parity). */
584
651
  retry(): void;
585
652
  switchCamera(): void;
653
+ /**
654
+ * Spec 2026-11-06 §3.3 (the capture mode switch): drop the running attempt (a recording is discarded, never
655
+ * finalized) and start again on `facingMode`.
656
+ */
657
+ restart(facingMode: "user" | "environment"): void;
586
658
  destroy(): void;
587
659
  private run;
588
660
  /** Chrome hint (Task 11): 'reduced' on LOW even without the media query. */
@@ -590,6 +662,11 @@ declare class CaptureSessionV3 {
590
662
  private startScheduler;
591
663
  private detectTick;
592
664
  private fire;
665
+ /**
666
+ * One recording of `windowMs` on the preview's frame clock, with the screen ramp (when issued) and the upright
667
+ * guard; rejects with the recorder's error. `onStopped` fires the moment the recording ends (before finalize).
668
+ */
669
+ private recordTake;
593
670
  /** `{ provenance }` from the live track's description, the recording's frame statistics and the painter flag; `{}` without a track. */
594
671
  private provenance;
595
672
  /** A phone showing a landscape frame: the guard holds the gate. */
@@ -624,4 +701,4 @@ declare class CaptureSessionV3 {
624
701
  private now;
625
702
  }
626
703
 
627
- export { isClipTooLarge as $, MIME_CANDIDATES as A, type V3GateFactor as B, type CameraErrorKind as C, DEFAULT_CLIP_MIME as D, type EscalationClipArtifact as E, FaceGateV3 as F, GATE_SNAPSHOT_MS as G, HOLD_UPRIGHT_KEY as H, type V3GateQuality as I, type V3GateThresholds as J, KEYFRAME_CANDIDATES as K, type V3GateTick as L, MAX_CLIP_BYTES as M, type V3GateTickInput as N, type V3TelemetryEvent as O, PROVENANCE_WAIT_MS as P, V3_GATE_DEFAULTS as Q, VIDEO_BPS as R, STOP_GRACE_MS as S, TIMESLICE_MS as T, UPRIGHT_WATCH_MS as U, type V3ChecksPayload as V, blockReasonOf as W, buildLivenessV2FormData as X, cameraPreflight as Y, classifyDevice as Z, extForMime as _, CLIP_MS as a, isMediaRecorderSupported as a0, mapGetUserMediaError as a1, pickMimeType as a2, probeDevice as a3, type EngineErrorDetail as a4, 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 };
704
+ 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
+ var u=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],l=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^caméra (avant|arrière)\b/i,/^cámara (frontal|trasera|delantera)\b/i,/^câmera (frontal|traseira)\b/i,/^(front|rück)kamera\b/i,/^الكاميرا (الأمامية|الخلفية)/,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function c(n){let e=(n??"").trim().toLowerCase();return e.length===0?"unknown":u.some(t=>e.includes(t))?"known_virtual":l.some(t=>t.test(e))?"platform":"unknown"}var d=1e3;function m(n,e){return new Promise(t=>{let a=setTimeout(()=>t(void 0),e),r=s=>{clearTimeout(a),t(s)};try{n().then(r,()=>r(void 0))}catch{r(void 0)}})}async function f(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(n)));return Array.from(new Uint8Array(e).subarray(0,8),t=>t.toString(16).padStart(2,"0")).join("")}var i=n=>Array.isArray(n)?[...n].sort():null,o=n=>{let e=n;return e==null?null:[e.min??null,e.max??null]};function p(n){try{return n.getSettings?.().facingMode==="environment"}catch{return!1}}async function b(n){try{if(n.readyState==="ended"||p(n))return;let e={};try{e=n.getCapabilities?.()??{}}catch{}let t=await m(()=>navigator.mediaDevices.enumerateDevices(),d);return await f([o(e.width),o(e.height),o(e.frameRate),i(e.facingMode),i(e.focusMode),i(e.exposureMode),c(n.label),t?.filter(a=>a.kind==="videoinput").length??null])}catch{return}}async function v(n,e){let t=await b(n);t&&e.noteCamera(t)}export{m as a,f as b,b as c,v as d};