@sekyro/react 0.1.0-rc.1 → 0.1.0-rc.3
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 +35 -0
- package/README.md +76 -2
- package/assets/audio/v1/README.md +60 -0
- package/assets/audio/v1/manifest.json +7 -0
- package/dist/index.cjs +2 -900
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +162 -15
- package/dist/index.d.ts +162 -15
- package/dist/index.js +2 -879
- package/dist/index.js.map +1 -1
- package/dist/styles.css +275 -1
- package/package.json +7 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, RefObject } from 'react';
|
|
3
|
-
import { CaptureErrorKind, GateHint, ReasonCode, Verification, CaptureError, CapturedArtifacts, VerificationResult, CaptureState } from '@sekyro/web';
|
|
3
|
+
import { CaptureErrorKind, GateHint, ReasonCode, CameraPermissionState, CameraFacing, Verification, CaptureError, CapturedArtifacts, VerificationResult, CaptureState } from '@sekyro/web';
|
|
4
|
+
|
|
5
|
+
/** A built-in tip (copy `capture.tips.<id>`, built-in icon). */
|
|
6
|
+
type BuiltInTipId = "light" | "uncover" | "eyeLevel" | "straight";
|
|
7
|
+
/** A host-provided tip. `id` is the React key; `icon` is decorative (rendered aria-hidden). */
|
|
8
|
+
interface IntroTip {
|
|
9
|
+
id: string;
|
|
10
|
+
text: ReactNode;
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** The tips shown when the host passes none. */
|
|
14
|
+
declare const DEFAULT_TIPS: readonly BuiltInTipId[];
|
|
4
15
|
|
|
5
16
|
/**
|
|
6
17
|
* Every string the component renders, keyed like the hosted message catalog
|
|
@@ -76,6 +87,22 @@ interface Strings {
|
|
|
76
87
|
"errors.network_error": string;
|
|
77
88
|
"errors.session_expired": string;
|
|
78
89
|
"errors.nni_unbound": string;
|
|
90
|
+
"capture.tips.title": string;
|
|
91
|
+
"capture.tips.light": string;
|
|
92
|
+
"capture.tips.uncover": string;
|
|
93
|
+
"capture.tips.eyeLevel": string;
|
|
94
|
+
"capture.tips.straight": string;
|
|
95
|
+
"capture.permission.granted": string;
|
|
96
|
+
"capture.permission.prompt": string;
|
|
97
|
+
"capture.permission.denied": string;
|
|
98
|
+
"capture.permission.unknown": string;
|
|
99
|
+
"capture.cameraLabel": string;
|
|
100
|
+
"capture.facing.user": string;
|
|
101
|
+
"capture.facing.environment": string;
|
|
102
|
+
"capture.voiceGuidance": string;
|
|
103
|
+
"capture.preparing.hint": string;
|
|
104
|
+
"capture.ready": string;
|
|
105
|
+
"fcv2.err.models": string;
|
|
79
106
|
}
|
|
80
107
|
/** Every string key the component renders. */
|
|
81
108
|
type StringKey = keyof Strings;
|
|
@@ -106,6 +133,72 @@ declare function reasonStringKey(reason: ReasonCode): StringKey | null;
|
|
|
106
133
|
*/
|
|
107
134
|
declare function attemptsRemainingText(dictionary: Strings, locale: SekyroLocale, count: number): string;
|
|
108
135
|
|
|
136
|
+
/** Guidance keys that can be spoken (the engine's fcv3.* gate hints). */
|
|
137
|
+
type VoiceKey = "fcv3.no_face" | "fcv3.come_closer" | "fcv3.move_back" | "fcv3.center_face" | "fcv3.straighten" | "fcv3.more_light" | "fcv3.too_bright" | "fcv3.hold_still" | "fcv3.steady_camera";
|
|
138
|
+
/** Every {@link VoiceKey}, in a stable order (e.g. to build a clip map). */
|
|
139
|
+
declare const VOICE_KEYS: readonly VoiceKey[];
|
|
140
|
+
|
|
141
|
+
/** Resolve a voice clip URL; `null`/`undefined` = no clip (speech fallback applies). */
|
|
142
|
+
type VoiceClipResolver = (key: VoiceKey, locale: SekyroLocale) => string | null | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Clip URLs per locale and key — e.g. the map a backend hands the SDK in the
|
|
145
|
+
* session view. A new object identity is the change signal.
|
|
146
|
+
*/
|
|
147
|
+
type VoiceClipMap = {
|
|
148
|
+
readonly [L in SekyroLocale]?: {
|
|
149
|
+
readonly [K in VoiceKey]?: string | null | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
};
|
|
152
|
+
/** `voice.clips`: a resolver function or a `{ [locale]: { [voiceKey]: url } }` map. */
|
|
153
|
+
type VoiceClipSource = VoiceClipResolver | VoiceClipMap;
|
|
154
|
+
/**
|
|
155
|
+
* A clip-set manifest (the `assets/audio/<set>/manifest.json` shape): per
|
|
156
|
+
* locale, one entry per shipped clip, keyed by clip name (`center_face` for
|
|
157
|
+
* `fcv3.center_face`). Entry contents (sha256, text, bytes) are not needed to resolve.
|
|
158
|
+
*/
|
|
159
|
+
interface VoiceClipManifest {
|
|
160
|
+
readonly set: string;
|
|
161
|
+
readonly clips: {
|
|
162
|
+
readonly [L in SekyroLocale]?: Readonly<Record<string, unknown>> | undefined;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Resolver over a manifest: a listed key resolves to `<baseUrl>/<locale>/<name>.mp3`
|
|
167
|
+
* (`baseUrl` = the set's directory, where its manifest.json lives); anything
|
|
168
|
+
* else resolves to `null`, so a missing clip costs no 404 round-trip.
|
|
169
|
+
*/
|
|
170
|
+
declare function createManifestResolver(manifest: VoiceClipManifest, baseUrl: string): VoiceClipResolver;
|
|
171
|
+
|
|
172
|
+
/** Voice-guidance options of `<LivenessCapture voice>`. */
|
|
173
|
+
interface VoiceOptions {
|
|
174
|
+
/** Initial state when the viewer has no stored preference. Default `true`. */
|
|
175
|
+
defaultEnabled?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Clip source; replaces the bundled set. Either a resolver `(key, locale) → url | null`
|
|
178
|
+
* or a map `{ [locale]: { [voiceKey]: url } }` (e.g. delivered by the backend;
|
|
179
|
+
* pass a new object to change it). A key without a URL — or a resolver that
|
|
180
|
+
* throws — means "no clip" (speech fallback applies).
|
|
181
|
+
*/
|
|
182
|
+
clips?: VoiceClipSource;
|
|
183
|
+
/** Base of the bundled clip set; default `${assetBaseUrl ?? "/models-v3"}/audio/v1`. */
|
|
184
|
+
clipBaseUrl?: string;
|
|
185
|
+
/** Locales where the device voice (speechSynthesis) may speak when no clip plays. Default `true` (all). */
|
|
186
|
+
speechFallback?: boolean | readonly SekyroLocale[];
|
|
187
|
+
/** localStorage key of the viewer's preference; `null` = do not persist. Default `"sekyro.voiceGuidance"`. */
|
|
188
|
+
storageKey?: string | null;
|
|
189
|
+
}
|
|
190
|
+
/** The shared voice state the intro switch, the stage chip and the slots read. */
|
|
191
|
+
interface VoiceControl {
|
|
192
|
+
/** Something can speak for this locale (a resolvable clip, or a usable device voice). `false` on the server and with `voice={false}`. */
|
|
193
|
+
readonly supported: boolean;
|
|
194
|
+
/** The viewer's choice (persisted under `storageKey`). */
|
|
195
|
+
readonly enabled: boolean;
|
|
196
|
+
/** Turn voice on / off; call it from a click (turning on unlocks audio on iOS). */
|
|
197
|
+
setEnabled(next: boolean): void;
|
|
198
|
+
/** Flip `enabled` (same gesture rule as `setEnabled`). */
|
|
199
|
+
toggle(): void;
|
|
200
|
+
}
|
|
201
|
+
|
|
109
202
|
/**
|
|
110
203
|
* Display debounce before the no-face copy replaces another hint: detector
|
|
111
204
|
* blips flash "we can't see your face" while the face is clearly visible, so
|
|
@@ -113,6 +206,28 @@ declare function attemptsRemainingText(dictionary: Strings, locale: SekyroLocale
|
|
|
113
206
|
* immediately and cancels a pending no-face. Chrome only — never gate input.
|
|
114
207
|
*/
|
|
115
208
|
declare const NO_FACE_DEBOUNCE_MS = 800;
|
|
209
|
+
/** A host message shown above the pre-capture screen (`notice` prop). */
|
|
210
|
+
interface LivenessNotice {
|
|
211
|
+
/** `info` is a polite status; `warning` / `danger` are announced as alerts. */
|
|
212
|
+
tone: "info" | "warning" | "danger";
|
|
213
|
+
text: ReactNode;
|
|
214
|
+
}
|
|
215
|
+
/** What `slots.intro` gets besides `start`: the state the built-in screen renders from. */
|
|
216
|
+
interface IntroContext {
|
|
217
|
+
/**
|
|
218
|
+
* Detector preload gate: Start should wait for `ready`; `failed` offers `retryAssets`.
|
|
219
|
+
* Also `loading` while `autoStart="when-permitted"` waits for the first camera-permission answer.
|
|
220
|
+
*/
|
|
221
|
+
assets: "loading" | "ready" | "failed";
|
|
222
|
+
retryAssets: () => void;
|
|
223
|
+
permission: CameraPermissionState;
|
|
224
|
+
/** The camera `start` opens (and the in-stage switch flips). */
|
|
225
|
+
facing: CameraFacing;
|
|
226
|
+
setFacing: (facing: CameraFacing) => void;
|
|
227
|
+
/** A front/back choice makes sense on this device. */
|
|
228
|
+
canChooseFacing: boolean;
|
|
229
|
+
voice: VoiceControl;
|
|
230
|
+
}
|
|
116
231
|
/** Render slots — partners inject their own chrome around and inside the stage. */
|
|
117
232
|
interface LivenessCaptureSlots {
|
|
118
233
|
/** Above the stage (title, step indicator). */
|
|
@@ -120,22 +235,26 @@ interface LivenessCaptureSlots {
|
|
|
120
235
|
/** Below everything (security note, help link). */
|
|
121
236
|
footer?: ReactNode;
|
|
122
237
|
/**
|
|
123
|
-
* Replaces the built-in
|
|
124
|
-
*
|
|
125
|
-
*
|
|
238
|
+
* Replaces the built-in pre-capture screen while the capture is idle.
|
|
239
|
+
* `start` begins the attempt with `context.facing` and unlocks audio — call
|
|
240
|
+
* it from the click handler (iOS needs the user gesture). `context` carries
|
|
241
|
+
* the preload gate, permission, facing and voice state the built-in screen
|
|
242
|
+
* renders from.
|
|
126
243
|
*/
|
|
127
|
-
intro?: (start: () => void) => ReactNode;
|
|
244
|
+
intro?: (start: () => void, context: IntroContext) => ReactNode;
|
|
128
245
|
/**
|
|
129
246
|
* Rendered inside the stage box above the ring (measurement overlays,
|
|
130
247
|
* watermarks); receives the ref of the component-owned `<video>`.
|
|
131
248
|
*/
|
|
132
249
|
stageOverlay?: (videoRef: RefObject<HTMLVideoElement | null>) => ReactNode;
|
|
133
250
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
251
|
+
* Replaces the built-in voice chip in the stage's start corner; receives the
|
|
252
|
+
* current hint code, the on-screen text, the string key behind it and the
|
|
253
|
+
* shared voice state. The component keeps speaking the guidance itself —
|
|
254
|
+
* pass `voice={false}` if this slot plays its own audio (a development build
|
|
255
|
+
* warns when this slot is set and `voice` is left undefined).
|
|
137
256
|
*/
|
|
138
|
-
voicePrompt?: (hint: GateHint | null, text: string, key: StringKey | null) => ReactNode;
|
|
257
|
+
voicePrompt?: (hint: GateHint | null, text: string, key: StringKey | null, voice: VoiceControl) => ReactNode;
|
|
139
258
|
/** Replaces the default camera-error notice. `retry` starts a fresh attempt. */
|
|
140
259
|
errorPanel?: (error: CaptureError, retry: () => void) => ReactNode;
|
|
141
260
|
}
|
|
@@ -152,11 +271,39 @@ interface LivenessCaptureProps {
|
|
|
152
271
|
/** Render slots around / inside the stage. */
|
|
153
272
|
slots?: LivenessCaptureSlots;
|
|
154
273
|
/**
|
|
155
|
-
* Start the camera instead of showing the
|
|
156
|
-
* the
|
|
157
|
-
* once its own preconditions
|
|
274
|
+
* Start the camera instead of showing the pre-capture screen — at most once
|
|
275
|
+
* per mount, once the detector preload is ready. `true` arms it (a host may
|
|
276
|
+
* flip it later, once its own preconditions are met); `"when-permitted"`
|
|
277
|
+
* arms it only while the camera permission is already `granted`. While armed
|
|
278
|
+
* but not ready the screen shows its loader (or the retry on failure).
|
|
279
|
+
*
|
|
280
|
+
* An auto-start has no user gesture, so iOS keeps audio locked until the
|
|
281
|
+
* person's first activating touch (`touchend`), click or key press (not
|
|
282
|
+
* Escape) anywhere inside the component; the voice unlocks then (clips that
|
|
283
|
+
* were due before stay silent).
|
|
284
|
+
*/
|
|
285
|
+
autoStart?: boolean | "when-permitted";
|
|
286
|
+
/** Host message above the pre-capture screen (or `slots.intro`); hidden once capture starts. */
|
|
287
|
+
notice?: ReactNode | LivenessNotice;
|
|
288
|
+
/**
|
|
289
|
+
* Disable the built-in Start (e.g. a busy cooldown); pair with `startLabel`.
|
|
290
|
+
* Gates only the pre-capture Start — not the error Retry, "record again" or
|
|
291
|
+
* the retake button (gate those flows yourself, e.g. via `slots.errorPanel`).
|
|
292
|
+
*/
|
|
293
|
+
startDisabled?: boolean;
|
|
294
|
+
/** Built-in Start label; default `capture.start`. */
|
|
295
|
+
startLabel?: ReactNode;
|
|
296
|
+
/** Tips on the pre-capture screen; default {@link DEFAULT_TIPS}; `false` hides the card. */
|
|
297
|
+
tips?: false | ReadonlyArray<BuiltInTipId | IntroTip>;
|
|
298
|
+
/** Camera the attempt opens with; default `"user"` (front). */
|
|
299
|
+
defaultFacing?: CameraFacing;
|
|
300
|
+
/**
|
|
301
|
+
* Voice guidance (on by default: bundled clips, device-voice fallback).
|
|
302
|
+
* `false` = no speech, no voice switch, no stage chip.
|
|
158
303
|
*/
|
|
159
|
-
|
|
304
|
+
voice?: false | VoiceOptions;
|
|
305
|
+
/** Telemetry: once per change of the displayed, spoken-able (`fcv3.*`) guidance key. */
|
|
306
|
+
onGuidance?: (key: StringKey) => void;
|
|
160
307
|
/** Fires BEFORE any upload, with the engine's artifacts. */
|
|
161
308
|
onCaptured?: (artifacts: CapturedArtifacts) => void;
|
|
162
309
|
/** Verification mode only: the verdict for this session / capture. */
|
|
@@ -177,7 +324,7 @@ interface LivenessCaptureProps {
|
|
|
177
324
|
* {@link SekyroThemeProvider} (or set the `--sekyro-*` variables yourself) and
|
|
178
325
|
* import `@sekyro/react/styles.css` once.
|
|
179
326
|
*/
|
|
180
|
-
declare function LivenessCapture({ verification, locale, dir, strings, slots, autoStart, onCaptured, onResult, onError, onStateChange, assetBaseUrl, className, }: LivenessCaptureProps): react.JSX.Element;
|
|
327
|
+
declare function LivenessCapture({ verification, locale, dir, strings, slots, autoStart, notice, startDisabled, startLabel, tips, defaultFacing, voice: voiceOption, onGuidance, onCaptured, onResult, onError, onStateChange, assetBaseUrl, className, }: LivenessCaptureProps): react.JSX.Element;
|
|
181
328
|
|
|
182
329
|
/** Color tokens. Every value is any valid CSS `<color>`. */
|
|
183
330
|
interface SekyroThemeColors {
|
|
@@ -239,4 +386,4 @@ declare function SekyroThemeProvider({ theme, children, className }: SekyroTheme
|
|
|
239
386
|
/** The complete dictionary for `locale` with `overrides` merged on top. */
|
|
240
387
|
declare function resolveStrings(locale: SekyroLocale, overrides?: Partial<Strings>): Strings;
|
|
241
388
|
|
|
242
|
-
export { DEFAULT_THEME, LivenessCapture, type LivenessCaptureProps, type LivenessCaptureSlots, NO_FACE_DEBOUNCE_MS, type SekyroLocale, type SekyroTheme, type SekyroThemeColors, SekyroThemeProvider, type SekyroThemeProviderProps, type StringKey, type Strings, ar, attemptsRemainingText, captureErrorStringKey, en, fr, hintStringKey, reasonStringKey, resolveStrings, themeToCssVars };
|
|
389
|
+
export { type BuiltInTipId, DEFAULT_THEME, DEFAULT_TIPS, type IntroContext, type IntroTip, LivenessCapture, type LivenessCaptureProps, type LivenessCaptureSlots, type LivenessNotice, NO_FACE_DEBOUNCE_MS, type SekyroLocale, type SekyroTheme, type SekyroThemeColors, SekyroThemeProvider, type SekyroThemeProviderProps, type StringKey, type Strings, VOICE_KEYS, type VoiceClipManifest, type VoiceClipMap, type VoiceClipResolver, type VoiceClipSource, type VoiceControl, type VoiceKey, type VoiceOptions, ar, attemptsRemainingText, captureErrorStringKey, createManifestResolver, en, fr, hintStringKey, reasonStringKey, resolveStrings, themeToCssVars };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, RefObject } from 'react';
|
|
3
|
-
import { CaptureErrorKind, GateHint, ReasonCode, Verification, CaptureError, CapturedArtifacts, VerificationResult, CaptureState } from '@sekyro/web';
|
|
3
|
+
import { CaptureErrorKind, GateHint, ReasonCode, CameraPermissionState, CameraFacing, Verification, CaptureError, CapturedArtifacts, VerificationResult, CaptureState } from '@sekyro/web';
|
|
4
|
+
|
|
5
|
+
/** A built-in tip (copy `capture.tips.<id>`, built-in icon). */
|
|
6
|
+
type BuiltInTipId = "light" | "uncover" | "eyeLevel" | "straight";
|
|
7
|
+
/** A host-provided tip. `id` is the React key; `icon` is decorative (rendered aria-hidden). */
|
|
8
|
+
interface IntroTip {
|
|
9
|
+
id: string;
|
|
10
|
+
text: ReactNode;
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** The tips shown when the host passes none. */
|
|
14
|
+
declare const DEFAULT_TIPS: readonly BuiltInTipId[];
|
|
4
15
|
|
|
5
16
|
/**
|
|
6
17
|
* Every string the component renders, keyed like the hosted message catalog
|
|
@@ -76,6 +87,22 @@ interface Strings {
|
|
|
76
87
|
"errors.network_error": string;
|
|
77
88
|
"errors.session_expired": string;
|
|
78
89
|
"errors.nni_unbound": string;
|
|
90
|
+
"capture.tips.title": string;
|
|
91
|
+
"capture.tips.light": string;
|
|
92
|
+
"capture.tips.uncover": string;
|
|
93
|
+
"capture.tips.eyeLevel": string;
|
|
94
|
+
"capture.tips.straight": string;
|
|
95
|
+
"capture.permission.granted": string;
|
|
96
|
+
"capture.permission.prompt": string;
|
|
97
|
+
"capture.permission.denied": string;
|
|
98
|
+
"capture.permission.unknown": string;
|
|
99
|
+
"capture.cameraLabel": string;
|
|
100
|
+
"capture.facing.user": string;
|
|
101
|
+
"capture.facing.environment": string;
|
|
102
|
+
"capture.voiceGuidance": string;
|
|
103
|
+
"capture.preparing.hint": string;
|
|
104
|
+
"capture.ready": string;
|
|
105
|
+
"fcv2.err.models": string;
|
|
79
106
|
}
|
|
80
107
|
/** Every string key the component renders. */
|
|
81
108
|
type StringKey = keyof Strings;
|
|
@@ -106,6 +133,72 @@ declare function reasonStringKey(reason: ReasonCode): StringKey | null;
|
|
|
106
133
|
*/
|
|
107
134
|
declare function attemptsRemainingText(dictionary: Strings, locale: SekyroLocale, count: number): string;
|
|
108
135
|
|
|
136
|
+
/** Guidance keys that can be spoken (the engine's fcv3.* gate hints). */
|
|
137
|
+
type VoiceKey = "fcv3.no_face" | "fcv3.come_closer" | "fcv3.move_back" | "fcv3.center_face" | "fcv3.straighten" | "fcv3.more_light" | "fcv3.too_bright" | "fcv3.hold_still" | "fcv3.steady_camera";
|
|
138
|
+
/** Every {@link VoiceKey}, in a stable order (e.g. to build a clip map). */
|
|
139
|
+
declare const VOICE_KEYS: readonly VoiceKey[];
|
|
140
|
+
|
|
141
|
+
/** Resolve a voice clip URL; `null`/`undefined` = no clip (speech fallback applies). */
|
|
142
|
+
type VoiceClipResolver = (key: VoiceKey, locale: SekyroLocale) => string | null | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Clip URLs per locale and key — e.g. the map a backend hands the SDK in the
|
|
145
|
+
* session view. A new object identity is the change signal.
|
|
146
|
+
*/
|
|
147
|
+
type VoiceClipMap = {
|
|
148
|
+
readonly [L in SekyroLocale]?: {
|
|
149
|
+
readonly [K in VoiceKey]?: string | null | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
};
|
|
152
|
+
/** `voice.clips`: a resolver function or a `{ [locale]: { [voiceKey]: url } }` map. */
|
|
153
|
+
type VoiceClipSource = VoiceClipResolver | VoiceClipMap;
|
|
154
|
+
/**
|
|
155
|
+
* A clip-set manifest (the `assets/audio/<set>/manifest.json` shape): per
|
|
156
|
+
* locale, one entry per shipped clip, keyed by clip name (`center_face` for
|
|
157
|
+
* `fcv3.center_face`). Entry contents (sha256, text, bytes) are not needed to resolve.
|
|
158
|
+
*/
|
|
159
|
+
interface VoiceClipManifest {
|
|
160
|
+
readonly set: string;
|
|
161
|
+
readonly clips: {
|
|
162
|
+
readonly [L in SekyroLocale]?: Readonly<Record<string, unknown>> | undefined;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Resolver over a manifest: a listed key resolves to `<baseUrl>/<locale>/<name>.mp3`
|
|
167
|
+
* (`baseUrl` = the set's directory, where its manifest.json lives); anything
|
|
168
|
+
* else resolves to `null`, so a missing clip costs no 404 round-trip.
|
|
169
|
+
*/
|
|
170
|
+
declare function createManifestResolver(manifest: VoiceClipManifest, baseUrl: string): VoiceClipResolver;
|
|
171
|
+
|
|
172
|
+
/** Voice-guidance options of `<LivenessCapture voice>`. */
|
|
173
|
+
interface VoiceOptions {
|
|
174
|
+
/** Initial state when the viewer has no stored preference. Default `true`. */
|
|
175
|
+
defaultEnabled?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Clip source; replaces the bundled set. Either a resolver `(key, locale) → url | null`
|
|
178
|
+
* or a map `{ [locale]: { [voiceKey]: url } }` (e.g. delivered by the backend;
|
|
179
|
+
* pass a new object to change it). A key without a URL — or a resolver that
|
|
180
|
+
* throws — means "no clip" (speech fallback applies).
|
|
181
|
+
*/
|
|
182
|
+
clips?: VoiceClipSource;
|
|
183
|
+
/** Base of the bundled clip set; default `${assetBaseUrl ?? "/models-v3"}/audio/v1`. */
|
|
184
|
+
clipBaseUrl?: string;
|
|
185
|
+
/** Locales where the device voice (speechSynthesis) may speak when no clip plays. Default `true` (all). */
|
|
186
|
+
speechFallback?: boolean | readonly SekyroLocale[];
|
|
187
|
+
/** localStorage key of the viewer's preference; `null` = do not persist. Default `"sekyro.voiceGuidance"`. */
|
|
188
|
+
storageKey?: string | null;
|
|
189
|
+
}
|
|
190
|
+
/** The shared voice state the intro switch, the stage chip and the slots read. */
|
|
191
|
+
interface VoiceControl {
|
|
192
|
+
/** Something can speak for this locale (a resolvable clip, or a usable device voice). `false` on the server and with `voice={false}`. */
|
|
193
|
+
readonly supported: boolean;
|
|
194
|
+
/** The viewer's choice (persisted under `storageKey`). */
|
|
195
|
+
readonly enabled: boolean;
|
|
196
|
+
/** Turn voice on / off; call it from a click (turning on unlocks audio on iOS). */
|
|
197
|
+
setEnabled(next: boolean): void;
|
|
198
|
+
/** Flip `enabled` (same gesture rule as `setEnabled`). */
|
|
199
|
+
toggle(): void;
|
|
200
|
+
}
|
|
201
|
+
|
|
109
202
|
/**
|
|
110
203
|
* Display debounce before the no-face copy replaces another hint: detector
|
|
111
204
|
* blips flash "we can't see your face" while the face is clearly visible, so
|
|
@@ -113,6 +206,28 @@ declare function attemptsRemainingText(dictionary: Strings, locale: SekyroLocale
|
|
|
113
206
|
* immediately and cancels a pending no-face. Chrome only — never gate input.
|
|
114
207
|
*/
|
|
115
208
|
declare const NO_FACE_DEBOUNCE_MS = 800;
|
|
209
|
+
/** A host message shown above the pre-capture screen (`notice` prop). */
|
|
210
|
+
interface LivenessNotice {
|
|
211
|
+
/** `info` is a polite status; `warning` / `danger` are announced as alerts. */
|
|
212
|
+
tone: "info" | "warning" | "danger";
|
|
213
|
+
text: ReactNode;
|
|
214
|
+
}
|
|
215
|
+
/** What `slots.intro` gets besides `start`: the state the built-in screen renders from. */
|
|
216
|
+
interface IntroContext {
|
|
217
|
+
/**
|
|
218
|
+
* Detector preload gate: Start should wait for `ready`; `failed` offers `retryAssets`.
|
|
219
|
+
* Also `loading` while `autoStart="when-permitted"` waits for the first camera-permission answer.
|
|
220
|
+
*/
|
|
221
|
+
assets: "loading" | "ready" | "failed";
|
|
222
|
+
retryAssets: () => void;
|
|
223
|
+
permission: CameraPermissionState;
|
|
224
|
+
/** The camera `start` opens (and the in-stage switch flips). */
|
|
225
|
+
facing: CameraFacing;
|
|
226
|
+
setFacing: (facing: CameraFacing) => void;
|
|
227
|
+
/** A front/back choice makes sense on this device. */
|
|
228
|
+
canChooseFacing: boolean;
|
|
229
|
+
voice: VoiceControl;
|
|
230
|
+
}
|
|
116
231
|
/** Render slots — partners inject their own chrome around and inside the stage. */
|
|
117
232
|
interface LivenessCaptureSlots {
|
|
118
233
|
/** Above the stage (title, step indicator). */
|
|
@@ -120,22 +235,26 @@ interface LivenessCaptureSlots {
|
|
|
120
235
|
/** Below everything (security note, help link). */
|
|
121
236
|
footer?: ReactNode;
|
|
122
237
|
/**
|
|
123
|
-
* Replaces the built-in
|
|
124
|
-
*
|
|
125
|
-
*
|
|
238
|
+
* Replaces the built-in pre-capture screen while the capture is idle.
|
|
239
|
+
* `start` begins the attempt with `context.facing` and unlocks audio — call
|
|
240
|
+
* it from the click handler (iOS needs the user gesture). `context` carries
|
|
241
|
+
* the preload gate, permission, facing and voice state the built-in screen
|
|
242
|
+
* renders from.
|
|
126
243
|
*/
|
|
127
|
-
intro?: (start: () => void) => ReactNode;
|
|
244
|
+
intro?: (start: () => void, context: IntroContext) => ReactNode;
|
|
128
245
|
/**
|
|
129
246
|
* Rendered inside the stage box above the ring (measurement overlays,
|
|
130
247
|
* watermarks); receives the ref of the component-owned `<video>`.
|
|
131
248
|
*/
|
|
132
249
|
stageOverlay?: (videoRef: RefObject<HTMLVideoElement | null>) => ReactNode;
|
|
133
250
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
251
|
+
* Replaces the built-in voice chip in the stage's start corner; receives the
|
|
252
|
+
* current hint code, the on-screen text, the string key behind it and the
|
|
253
|
+
* shared voice state. The component keeps speaking the guidance itself —
|
|
254
|
+
* pass `voice={false}` if this slot plays its own audio (a development build
|
|
255
|
+
* warns when this slot is set and `voice` is left undefined).
|
|
137
256
|
*/
|
|
138
|
-
voicePrompt?: (hint: GateHint | null, text: string, key: StringKey | null) => ReactNode;
|
|
257
|
+
voicePrompt?: (hint: GateHint | null, text: string, key: StringKey | null, voice: VoiceControl) => ReactNode;
|
|
139
258
|
/** Replaces the default camera-error notice. `retry` starts a fresh attempt. */
|
|
140
259
|
errorPanel?: (error: CaptureError, retry: () => void) => ReactNode;
|
|
141
260
|
}
|
|
@@ -152,11 +271,39 @@ interface LivenessCaptureProps {
|
|
|
152
271
|
/** Render slots around / inside the stage. */
|
|
153
272
|
slots?: LivenessCaptureSlots;
|
|
154
273
|
/**
|
|
155
|
-
* Start the camera instead of showing the
|
|
156
|
-
* the
|
|
157
|
-
* once its own preconditions
|
|
274
|
+
* Start the camera instead of showing the pre-capture screen — at most once
|
|
275
|
+
* per mount, once the detector preload is ready. `true` arms it (a host may
|
|
276
|
+
* flip it later, once its own preconditions are met); `"when-permitted"`
|
|
277
|
+
* arms it only while the camera permission is already `granted`. While armed
|
|
278
|
+
* but not ready the screen shows its loader (or the retry on failure).
|
|
279
|
+
*
|
|
280
|
+
* An auto-start has no user gesture, so iOS keeps audio locked until the
|
|
281
|
+
* person's first activating touch (`touchend`), click or key press (not
|
|
282
|
+
* Escape) anywhere inside the component; the voice unlocks then (clips that
|
|
283
|
+
* were due before stay silent).
|
|
284
|
+
*/
|
|
285
|
+
autoStart?: boolean | "when-permitted";
|
|
286
|
+
/** Host message above the pre-capture screen (or `slots.intro`); hidden once capture starts. */
|
|
287
|
+
notice?: ReactNode | LivenessNotice;
|
|
288
|
+
/**
|
|
289
|
+
* Disable the built-in Start (e.g. a busy cooldown); pair with `startLabel`.
|
|
290
|
+
* Gates only the pre-capture Start — not the error Retry, "record again" or
|
|
291
|
+
* the retake button (gate those flows yourself, e.g. via `slots.errorPanel`).
|
|
292
|
+
*/
|
|
293
|
+
startDisabled?: boolean;
|
|
294
|
+
/** Built-in Start label; default `capture.start`. */
|
|
295
|
+
startLabel?: ReactNode;
|
|
296
|
+
/** Tips on the pre-capture screen; default {@link DEFAULT_TIPS}; `false` hides the card. */
|
|
297
|
+
tips?: false | ReadonlyArray<BuiltInTipId | IntroTip>;
|
|
298
|
+
/** Camera the attempt opens with; default `"user"` (front). */
|
|
299
|
+
defaultFacing?: CameraFacing;
|
|
300
|
+
/**
|
|
301
|
+
* Voice guidance (on by default: bundled clips, device-voice fallback).
|
|
302
|
+
* `false` = no speech, no voice switch, no stage chip.
|
|
158
303
|
*/
|
|
159
|
-
|
|
304
|
+
voice?: false | VoiceOptions;
|
|
305
|
+
/** Telemetry: once per change of the displayed, spoken-able (`fcv3.*`) guidance key. */
|
|
306
|
+
onGuidance?: (key: StringKey) => void;
|
|
160
307
|
/** Fires BEFORE any upload, with the engine's artifacts. */
|
|
161
308
|
onCaptured?: (artifacts: CapturedArtifacts) => void;
|
|
162
309
|
/** Verification mode only: the verdict for this session / capture. */
|
|
@@ -177,7 +324,7 @@ interface LivenessCaptureProps {
|
|
|
177
324
|
* {@link SekyroThemeProvider} (or set the `--sekyro-*` variables yourself) and
|
|
178
325
|
* import `@sekyro/react/styles.css` once.
|
|
179
326
|
*/
|
|
180
|
-
declare function LivenessCapture({ verification, locale, dir, strings, slots, autoStart, onCaptured, onResult, onError, onStateChange, assetBaseUrl, className, }: LivenessCaptureProps): react.JSX.Element;
|
|
327
|
+
declare function LivenessCapture({ verification, locale, dir, strings, slots, autoStart, notice, startDisabled, startLabel, tips, defaultFacing, voice: voiceOption, onGuidance, onCaptured, onResult, onError, onStateChange, assetBaseUrl, className, }: LivenessCaptureProps): react.JSX.Element;
|
|
181
328
|
|
|
182
329
|
/** Color tokens. Every value is any valid CSS `<color>`. */
|
|
183
330
|
interface SekyroThemeColors {
|
|
@@ -239,4 +386,4 @@ declare function SekyroThemeProvider({ theme, children, className }: SekyroTheme
|
|
|
239
386
|
/** The complete dictionary for `locale` with `overrides` merged on top. */
|
|
240
387
|
declare function resolveStrings(locale: SekyroLocale, overrides?: Partial<Strings>): Strings;
|
|
241
388
|
|
|
242
|
-
export { DEFAULT_THEME, LivenessCapture, type LivenessCaptureProps, type LivenessCaptureSlots, NO_FACE_DEBOUNCE_MS, type SekyroLocale, type SekyroTheme, type SekyroThemeColors, SekyroThemeProvider, type SekyroThemeProviderProps, type StringKey, type Strings, ar, attemptsRemainingText, captureErrorStringKey, en, fr, hintStringKey, reasonStringKey, resolveStrings, themeToCssVars };
|
|
389
|
+
export { type BuiltInTipId, DEFAULT_THEME, DEFAULT_TIPS, type IntroContext, type IntroTip, LivenessCapture, type LivenessCaptureProps, type LivenessCaptureSlots, type LivenessNotice, NO_FACE_DEBOUNCE_MS, type SekyroLocale, type SekyroTheme, type SekyroThemeColors, SekyroThemeProvider, type SekyroThemeProviderProps, type StringKey, type Strings, VOICE_KEYS, type VoiceClipManifest, type VoiceClipMap, type VoiceClipResolver, type VoiceClipSource, type VoiceControl, type VoiceKey, type VoiceOptions, ar, attemptsRemainingText, captureErrorStringKey, createManifestResolver, en, fr, hintStringKey, reasonStringKey, resolveStrings, themeToCssVars };
|