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