biometry-react-components 1.2.16 → 1.3.0

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/README.md CHANGED
@@ -31,14 +31,14 @@ Captures ID documents, driver license and etc. Suitable component for Biometry's
31
31
  import { DocScan } from 'biometry-react-components';
32
32
 
33
33
  function DocumentCapture() {
34
- const handleCapture = (file: File) => {
35
- console.log('Captured document:', file);
34
+ const handleConfirmCapture = (file: File) => {
35
+ console.log('Confirmed captured document:', file);
36
36
  // Send file to your endpoint that will process DocAuth (we recommend this way, because you will not expose the API key on client side)
37
37
  // or
38
38
  // const response = await sdk.checkDocAuth(file, userFullName, { sessionId });
39
39
  };
40
40
 
41
- return <DocScan onCapture={handleCapture} />;
41
+ return <DocScan onConfirmCapture={handleConfirmCapture} />;
42
42
  }
43
43
  ```
44
44
 
@@ -46,7 +46,8 @@ function DocumentCapture() {
46
46
 
47
47
  | Prop | Type | Default | Description |
48
48
  |------|------|---------|-------------|
49
- | `onCapture` | `(file: File) => void` | **required** | Callback with captured image file |
49
+ | `onConfirmCapture` | `(file: File) => void` | **required** | Callback with captured image file. Triggered when the user confirms the captured image/document |
50
+ | `onCapture` | `(file: File) => void` | *optional* | Callback with captured image file. Triggered automatically when image/document capture finishes. |
50
51
  | `rectWidth` | `number` | `640` | Width of camera area |
51
52
  | `rectHeight` | `number` | `400` | Height of camera area |
52
53
  | `className` | `string` | - | Custom CSS class |
@@ -61,14 +62,12 @@ Captures facial images with an oval guidance overlay. Ideal for [Face Match](htt
61
62
  import { FaceCapture } from 'biometry-react-components';
62
63
 
63
64
  function FaceCapture() {
64
- const handleCapture = (file: File) => {
65
- console.log('Captured face:', file);
66
- // Send file to your endpoint that will process DocAuth (we recommend this way, because you will not expose the API key on client side)
67
- // or
65
+ const handleConfirmCapture = (file: File) => {
66
+ console.log('Confirmed captured face:', file);
68
67
  // const response = await sdk.enrollFace(file, 'John Doe');
69
68
  };
70
69
 
71
- return <FaceCapture onCapture={handleCapture} />;
70
+ return <FaceCapture onConfirmCapture={handleConfirmCapture} />;
72
71
  }
73
72
  ```
74
73
 
@@ -76,7 +75,8 @@ function FaceCapture() {
76
75
 
77
76
  | Prop | Type | Default | Description |
78
77
  |------|------|---------|-------------|
79
- | `onCapture` | `(file: File) => void` | **required** | Callback with captured image file |
78
+ | `onConfirmCapture` | `(file: File) => void` | **required** | Callback with captured image file. Triggered when the user confirms the captured image |
79
+ | `onCapture` | `(file: File) => void` | *optional* | Callback with captured image file. Triggered automatically when user captures the image. |
80
80
  | `rectWidth` | `number` | `360` | Width of camera area |
81
81
  | `rectHeight` | `number` | `576` | Height of camera area |
82
82
  | `className` | `string` | - | Custom CSS class |
@@ -110,7 +110,7 @@ function FaceRecorder() {
110
110
  | Prop | Type | Default | Description |
111
111
  |------|------|---------|-------------|
112
112
  | `onConfirmRecording` | `(video: File, audio: File, phrase: string) => void` | **required** | Triggered when the user confirms they want to use the recorded video. Provides both media files and the spoken phrase. |
113
- | `onRecordingComplete` | `(video: File, audio: File, phrase: string) => void` | - | Triggered automatically right after recording finishes. Useful for pre-uploading or background processing. *Optional* |
113
+ | `onRecorded` | `(video: File, audio: File, phrase: string) => void` | *optional* | Triggered automatically right after recording finishes. Useful for pre-uploading or background processing. |
114
114
  | `rectWidth` | `number` | `360` | Width of camera area |
115
115
  | `rectHeight` | `number` | `576` | Height of camera area |
116
116
  | `className` | `string` | - | Custom CSS class |
@@ -125,15 +125,13 @@ Records audio with real-time waveform visualization and adaptive quality setting
125
125
  import { VoiceRecorder } from 'biometry-react-components';
126
126
 
127
127
  function VoiceRecorder() {
128
- const handleCapture = (file: File, phrase: string) => {
129
- console.log('Captured audio:', file);
128
+ const handleConfirm = (file: File, phrase: string) => {
129
+ console.log('Confirmed audio:', file);
130
130
  console.log('Phrase:', phrase);
131
- // Send file to your endpoint that will process DocAuth (we recommend this way, because you will not expose the API key on client side)
132
- // or
133
131
  // const response = await sdk.enrollVoice(file, 'John Doe');
134
132
  };
135
133
 
136
- return <VoiceRecorder onCapture={handleCapture} />;
134
+ return <VoiceRecorder onConfirmRecording={handleConfirm} />;
137
135
  }
138
136
  ```
139
137
 
@@ -141,7 +139,8 @@ function VoiceRecorder() {
141
139
 
142
140
  | Prop | Type | Default | Description |
143
141
  |------|------|---------|-------------|
144
- | `onCapture` | `(file: File, phrase: string) => void` | **required** | Callback with captured audio file and phrase |
142
+ | `onConfirmRecording` | `(file: File, phrase: string) => void` | **required** | Callback with captured audio file and phrase. Triggered when the user confirms the recorded media |
143
+ | `onRecorded` | `(file: File, phrase: string) => void` | *optional* | Callback with captured audio file and phrase. Triggered automatically when recording finishes |
145
144
  | `rectWidth` | `number` | `360` | Width of component area |
146
145
  | `rectHeight` | `number` | `undefined` | Height of component area (optional) |
147
146
  | `className` | `string` | - | Custom CSS class |
package/dist/index.d.ts CHANGED
@@ -3,7 +3,8 @@ import React from 'react';
3
3
  interface DocScanProps {
4
4
  rectWidth?: number;
5
5
  rectHeight?: number;
6
- onCapture: (file: File) => void;
6
+ onConfirmCapture: (file: File) => void;
7
+ onCapture?: (file: File) => void;
7
8
  className?: string;
8
9
  style?: React.CSSProperties;
9
10
  noShadow?: boolean;
@@ -13,7 +14,8 @@ declare const DocScan: React.FC<DocScanProps>;
13
14
  interface FaceCaptureProps {
14
15
  rectWidth?: number;
15
16
  rectHeight?: number;
16
- onCapture: (file: File) => void;
17
+ onConfirmCapture: (file: File) => void;
18
+ onCapture?: (file: File) => void;
17
19
  className?: string;
18
20
  style?: React.CSSProperties;
19
21
  noShadow?: boolean;
@@ -24,7 +26,7 @@ interface FaceRecorderProps {
24
26
  rectWidth?: number;
25
27
  rectHeight?: number;
26
28
  onConfirmRecording: (file: File, audio: File, phrase: string) => void;
27
- onRecordingComplete?: (video: File, audio: File, phrase: string) => void;
29
+ onRecorded?: (video: File, audio: File, phrase: string) => void;
28
30
  className?: string;
29
31
  style?: React.CSSProperties;
30
32
  noShadow?: boolean;
@@ -34,7 +36,8 @@ declare const FaceRecorder: React.FC<FaceRecorderProps>;
34
36
  interface VoiceRecorderProps {
35
37
  rectWidth?: number;
36
38
  rectHeight?: number | undefined;
37
- onCapture: (file: File, phrase: string) => void;
39
+ onConfirmRecording: (file: File, phrase: string) => void;
40
+ onRecorded?: (file: File, phrase: string) => void;
38
41
  className?: string;
39
42
  style?: React.CSSProperties;
40
43
  noShadow?: boolean;
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,useEffect}from'react';const DocScan = ({ rectWidth = 640, rectHeight = 400, onCapture, className, style, noShadow = false, }) => {
1
+ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,useEffect}from'react';const DocScan = ({ rectWidth = 640, rectHeight = 400, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
2
2
  const [isConfirming, setIsConfirming] = useState(false);
3
3
  const [capturedUrl, setCapturedUrl] = useState(null);
4
4
  const [capturedFile, setCapturedFile] = useState(null);
@@ -65,13 +65,21 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
65
65
  setCapturedFile(file);
66
66
  setCapturedUrl(URL.createObjectURL(blob));
67
67
  setIsConfirming(true);
68
+ if (onCapture) {
69
+ try {
70
+ onCapture(file);
71
+ }
72
+ catch (err) {
73
+ console.error('onCapture callback threw:', err);
74
+ }
75
+ }
68
76
  }
69
77
  }, "image/jpeg", 0.98);
70
78
  }
71
79
  };
72
80
  const handleConfirm = () => {
73
81
  if (capturedFile) {
74
- onCapture(capturedFile);
82
+ onConfirmCapture(capturedFile);
75
83
  }
76
84
  };
77
85
  const handleDecline = () => {
@@ -176,6 +184,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
176
184
  objectFit: 'cover',
177
185
  borderRadius: noShadow ? 0 : 8,
178
186
  zIndex: 0,
187
+ transform: 'scaleX(-1)'
179
188
  }, playsInline: true, muted: true, autoPlay: true }), jsx("div", { className: "docscan-dark-overlay", style: {
180
189
  position: 'absolute',
181
190
  top: 0,
@@ -186,7 +195,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
186
195
  zIndex: 1,
187
196
  borderRadius: noShadow ? 0 : 8,
188
197
  } }), jsx("div", { className: "docscan-dashed-area", style: defaultDashedArea, children: jsx("span", { className: "docscan-guidance-text", style: defaultGuidanceText, children: "Place your document here" }) })] }), jsx("button", { type: "button", className: "docscan-capture-btn", style: defaultCaptureButton, onClick: handleCapture, children: "Capture" })] })) : (jsxs(Fragment, { children: [jsx("div", { className: "docscan-preview", style: defaultPreview, children: capturedUrl && (jsx("img", { src: capturedUrl, alt: "Captured document", className: "docscan-preview-img", style: { maxWidth: '100%', maxHeight: '100%', borderRadius: 8 } })) }), jsx("div", { className: "docscan-confirm-text", style: defaultConfirmText, children: "Do you want to use this photo?" }), jsxs("div", { className: "docscan-confirm-btns", style: { display: 'flex', justifyContent: 'center', gap: 32, marginTop: 16, width: '100%' }, children: [jsx("button", { type: "button", "aria-label": "Retake", className: "docscan-icon-btn", style: defaultIconButton, onClick: handleDecline, onMouseOver: e => (e.currentTarget.style.background = 'rgba(211,47,47,0.12)'), onMouseOut: e => (e.currentTarget.style.background = 'none'), children: jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#fff", fillOpacity: "0.15" }), jsx("path", { d: "M12 12L24 24", stroke: "#d32f2f", strokeWidth: "3", strokeLinecap: "round" }), jsx("path", { d: "M24 12L12 24", stroke: "#d32f2f", strokeWidth: "3", strokeLinecap: "round" })] }) }), jsx("button", { type: "button", "aria-label": "Confirm", className: "docscan-icon-btn", style: defaultIconButton, onClick: handleConfirm, onMouseOver: e => (e.currentTarget.style.background = 'rgba(56,142,60,0.12)'), onMouseOut: e => (e.currentTarget.style.background = 'none'), children: jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#fff", fillOpacity: "0.15" }), jsx("path", { d: "M10 19L16 25L26 13", stroke: "#388e3c", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" })] }) })] })] })) }));
189
- };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onCapture, className, style, noShadow = false, }) => {
198
+ };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
190
199
  const [isConfirming, setIsConfirming] = useState(false);
191
200
  const [capturedUrl, setCapturedUrl] = useState(null);
192
201
  const [capturedFile, setCapturedFile] = useState(null);
@@ -237,13 +246,21 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
237
246
  setCapturedFile(file);
238
247
  setCapturedUrl(URL.createObjectURL(blob));
239
248
  setIsConfirming(true);
249
+ if (onCapture) {
250
+ try {
251
+ onCapture(file);
252
+ }
253
+ catch (err) {
254
+ console.error('onCapture callback threw:', err);
255
+ }
256
+ }
240
257
  }
241
258
  }, "image/jpeg", 0.98);
242
259
  }
243
260
  };
244
261
  const handleConfirm = () => {
245
262
  if (capturedFile) {
246
- onCapture(capturedFile);
263
+ onConfirmCapture(capturedFile);
247
264
  }
248
265
  };
249
266
  const handleDecline = () => {
@@ -325,8 +342,8 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
325
342
  display: 'block',
326
343
  };
327
344
  const preview = {
328
- width: rectWidth - 25,
329
- height: rectHeight - 25,
345
+ width: '100%',
346
+ height: '100%',
330
347
  display: 'flex',
331
348
  alignItems: 'center',
332
349
  justifyContent: 'center',
@@ -357,6 +374,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
357
374
  objectFit: 'cover',
358
375
  borderRadius: noShadow ? 0 : 8,
359
376
  zIndex: 0,
377
+ transform: 'scaleX(-1)'
360
378
  }, playsInline: true, muted: true, autoPlay: true }), jsx("div", { className: "facecapture-dark-overlay", style: {
361
379
  position: 'absolute',
362
380
  top: 0,
@@ -7279,7 +7297,7 @@ function generateRandomDigits$1(count) {
7279
7297
  }
7280
7298
  return digits.slice(0, count);
7281
7299
  }
7282
- const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecordingComplete, className, style, noShadow = false, }) => {
7300
+ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecorded, className, style, noShadow = false, }) => {
7283
7301
  const [state, setState] = useState('preparation');
7284
7302
  const [prepTimer, setPrepTimer] = useState(PREP_SECONDS$1);
7285
7303
  const [recordTimer, setRecordTimer] = useState(RECORD_SECONDS$1);
@@ -7330,20 +7348,20 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7330
7348
  // If we already notified for this recording, skip
7331
7349
  if (hasNotifiedRef.current)
7332
7350
  return;
7333
- if (videoBlob && audioBlob && onRecordingComplete) {
7351
+ if (videoBlob && audioBlob && onRecorded) {
7334
7352
  hasNotifiedRef.current = true; // prevent double-calls
7335
7353
  const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
7336
7354
  const audioFile = new File([audioBlob], 'face-audio.webm', { type: audioBlob.type });
7337
7355
  const phrase = numbersToPhrase(digits);
7338
7356
  try {
7339
- onRecordingComplete(videoFile, audioFile, phrase);
7357
+ onRecorded(videoFile, audioFile, phrase);
7340
7358
  }
7341
7359
  catch (err) {
7342
7360
  // swallow errors from consumer callback to avoid breaking SDK logic
7343
- console.error('onRecordingComplete callback threw:', err);
7361
+ console.error('onRecorded callback threw:', err);
7344
7362
  }
7345
7363
  }
7346
- }, [videoBlob, audioBlob, digits, onRecordingComplete]);
7364
+ }, [videoBlob, audioBlob, digits, onRecorded]);
7347
7365
  // Attach the video stream to the <video> element
7348
7366
  useEffect(() => {
7349
7367
  let isMounted = true;
@@ -7684,6 +7702,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7684
7702
  objectFit: 'cover',
7685
7703
  borderRadius: noShadow ? 0 : 8,
7686
7704
  zIndex: 0,
7705
+ transform: 'scaleX(-1)'
7687
7706
  }, playsInline: true, muted: true, autoPlay: true }), jsx("div", { className: "facerecorder-dark-overlay", style: {
7688
7707
  position: 'absolute',
7689
7708
  top: 0,
@@ -7809,7 +7828,7 @@ function generateRandomDigits(count) {
7809
7828
  }
7810
7829
  return digits.slice(0, count);
7811
7830
  }
7812
- const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, style, noShadow = false, }) => {
7831
+ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onConfirmRecording, onRecorded, className, style, noShadow = false, }) => {
7813
7832
  const [state, setState] = useState('preparation');
7814
7833
  const [prepTimer, setPrepTimer] = useState(PREP_SECONDS);
7815
7834
  const [recordTimer, setRecordTimer] = useState(RECORD_SECONDS);
@@ -7831,6 +7850,15 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7831
7850
  setAudioUrl(url);
7832
7851
  setState('result');
7833
7852
  setIsConfirming(true);
7853
+ if (onRecorded) {
7854
+ try {
7855
+ const file = new File([blob], 'voice-recording.webm', { type: blob.type });
7856
+ onRecorded(file, numbersToPhrase(digits));
7857
+ }
7858
+ catch (err) {
7859
+ console.error('onRecorded callback threw:', err);
7860
+ }
7861
+ }
7834
7862
  }
7835
7863
  else {
7836
7864
  const dummyBlob = new Blob(['dummy audio data'], { type: 'audio/webm' });
@@ -7921,7 +7949,9 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7921
7949
  const handleConfirm = () => {
7922
7950
  if (audioBlob) {
7923
7951
  const file = new File([audioBlob], 'voice-recording.webm', { type: audioBlob.type });
7924
- onCapture(file, numbersToPhrase(digits));
7952
+ // required callback in parent app
7953
+ onConfirmRecording(file, numbersToPhrase(digits));
7954
+ // Clean up and reset state
7925
7955
  if (audioUrl)
7926
7956
  URL.revokeObjectURL(audioUrl);
7927
7957
  setAudioUrl(null);
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var jsxRuntime=require('react/jsx-runtime'),React=require('react');const DocScan = ({ rectWidth = 640, rectHeight = 400, onCapture, className, style, noShadow = false, }) => {
1
+ 'use strict';var jsxRuntime=require('react/jsx-runtime'),React=require('react');const DocScan = ({ rectWidth = 640, rectHeight = 400, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
2
2
  const [isConfirming, setIsConfirming] = React.useState(false);
3
3
  const [capturedUrl, setCapturedUrl] = React.useState(null);
4
4
  const [capturedFile, setCapturedFile] = React.useState(null);
@@ -65,13 +65,21 @@
65
65
  setCapturedFile(file);
66
66
  setCapturedUrl(URL.createObjectURL(blob));
67
67
  setIsConfirming(true);
68
+ if (onCapture) {
69
+ try {
70
+ onCapture(file);
71
+ }
72
+ catch (err) {
73
+ console.error('onCapture callback threw:', err);
74
+ }
75
+ }
68
76
  }
69
77
  }, "image/jpeg", 0.98);
70
78
  }
71
79
  };
72
80
  const handleConfirm = () => {
73
81
  if (capturedFile) {
74
- onCapture(capturedFile);
82
+ onConfirmCapture(capturedFile);
75
83
  }
76
84
  };
77
85
  const handleDecline = () => {
@@ -176,6 +184,7 @@
176
184
  objectFit: 'cover',
177
185
  borderRadius: noShadow ? 0 : 8,
178
186
  zIndex: 0,
187
+ transform: 'scaleX(-1)'
179
188
  }, playsInline: true, muted: true, autoPlay: true }), jsxRuntime.jsx("div", { className: "docscan-dark-overlay", style: {
180
189
  position: 'absolute',
181
190
  top: 0,
@@ -186,7 +195,7 @@
186
195
  zIndex: 1,
187
196
  borderRadius: noShadow ? 0 : 8,
188
197
  } }), jsxRuntime.jsx("div", { className: "docscan-dashed-area", style: defaultDashedArea, children: jsxRuntime.jsx("span", { className: "docscan-guidance-text", style: defaultGuidanceText, children: "Place your document here" }) })] }), jsxRuntime.jsx("button", { type: "button", className: "docscan-capture-btn", style: defaultCaptureButton, onClick: handleCapture, children: "Capture" })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "docscan-preview", style: defaultPreview, children: capturedUrl && (jsxRuntime.jsx("img", { src: capturedUrl, alt: "Captured document", className: "docscan-preview-img", style: { maxWidth: '100%', maxHeight: '100%', borderRadius: 8 } })) }), jsxRuntime.jsx("div", { className: "docscan-confirm-text", style: defaultConfirmText, children: "Do you want to use this photo?" }), jsxRuntime.jsxs("div", { className: "docscan-confirm-btns", style: { display: 'flex', justifyContent: 'center', gap: 32, marginTop: 16, width: '100%' }, children: [jsxRuntime.jsx("button", { type: "button", "aria-label": "Retake", className: "docscan-icon-btn", style: defaultIconButton, onClick: handleDecline, onMouseOver: e => (e.currentTarget.style.background = 'rgba(211,47,47,0.12)'), onMouseOut: e => (e.currentTarget.style.background = 'none'), children: jsxRuntime.jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#fff", fillOpacity: "0.15" }), jsxRuntime.jsx("path", { d: "M12 12L24 24", stroke: "#d32f2f", strokeWidth: "3", strokeLinecap: "round" }), jsxRuntime.jsx("path", { d: "M24 12L12 24", stroke: "#d32f2f", strokeWidth: "3", strokeLinecap: "round" })] }) }), jsxRuntime.jsx("button", { type: "button", "aria-label": "Confirm", className: "docscan-icon-btn", style: defaultIconButton, onClick: handleConfirm, onMouseOver: e => (e.currentTarget.style.background = 'rgba(56,142,60,0.12)'), onMouseOut: e => (e.currentTarget.style.background = 'none'), children: jsxRuntime.jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#fff", fillOpacity: "0.15" }), jsxRuntime.jsx("path", { d: "M10 19L16 25L26 13", stroke: "#388e3c", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" })] }) })] })] })) }));
189
- };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onCapture, className, style, noShadow = false, }) => {
198
+ };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
190
199
  const [isConfirming, setIsConfirming] = React.useState(false);
191
200
  const [capturedUrl, setCapturedUrl] = React.useState(null);
192
201
  const [capturedFile, setCapturedFile] = React.useState(null);
@@ -237,13 +246,21 @@
237
246
  setCapturedFile(file);
238
247
  setCapturedUrl(URL.createObjectURL(blob));
239
248
  setIsConfirming(true);
249
+ if (onCapture) {
250
+ try {
251
+ onCapture(file);
252
+ }
253
+ catch (err) {
254
+ console.error('onCapture callback threw:', err);
255
+ }
256
+ }
240
257
  }
241
258
  }, "image/jpeg", 0.98);
242
259
  }
243
260
  };
244
261
  const handleConfirm = () => {
245
262
  if (capturedFile) {
246
- onCapture(capturedFile);
263
+ onConfirmCapture(capturedFile);
247
264
  }
248
265
  };
249
266
  const handleDecline = () => {
@@ -325,8 +342,8 @@
325
342
  display: 'block',
326
343
  };
327
344
  const preview = {
328
- width: rectWidth - 25,
329
- height: rectHeight - 25,
345
+ width: '100%',
346
+ height: '100%',
330
347
  display: 'flex',
331
348
  alignItems: 'center',
332
349
  justifyContent: 'center',
@@ -357,6 +374,7 @@
357
374
  objectFit: 'cover',
358
375
  borderRadius: noShadow ? 0 : 8,
359
376
  zIndex: 0,
377
+ transform: 'scaleX(-1)'
360
378
  }, playsInline: true, muted: true, autoPlay: true }), jsxRuntime.jsx("div", { className: "facecapture-dark-overlay", style: {
361
379
  position: 'absolute',
362
380
  top: 0,
@@ -7279,7 +7297,7 @@ function generateRandomDigits$1(count) {
7279
7297
  }
7280
7298
  return digits.slice(0, count);
7281
7299
  }
7282
- const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecordingComplete, className, style, noShadow = false, }) => {
7300
+ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecorded, className, style, noShadow = false, }) => {
7283
7301
  const [state, setState] = React.useState('preparation');
7284
7302
  const [prepTimer, setPrepTimer] = React.useState(PREP_SECONDS$1);
7285
7303
  const [recordTimer, setRecordTimer] = React.useState(RECORD_SECONDS$1);
@@ -7330,20 +7348,20 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7330
7348
  // If we already notified for this recording, skip
7331
7349
  if (hasNotifiedRef.current)
7332
7350
  return;
7333
- if (videoBlob && audioBlob && onRecordingComplete) {
7351
+ if (videoBlob && audioBlob && onRecorded) {
7334
7352
  hasNotifiedRef.current = true; // prevent double-calls
7335
7353
  const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
7336
7354
  const audioFile = new File([audioBlob], 'face-audio.webm', { type: audioBlob.type });
7337
7355
  const phrase = numbersToPhrase(digits);
7338
7356
  try {
7339
- onRecordingComplete(videoFile, audioFile, phrase);
7357
+ onRecorded(videoFile, audioFile, phrase);
7340
7358
  }
7341
7359
  catch (err) {
7342
7360
  // swallow errors from consumer callback to avoid breaking SDK logic
7343
- console.error('onRecordingComplete callback threw:', err);
7361
+ console.error('onRecorded callback threw:', err);
7344
7362
  }
7345
7363
  }
7346
- }, [videoBlob, audioBlob, digits, onRecordingComplete]);
7364
+ }, [videoBlob, audioBlob, digits, onRecorded]);
7347
7365
  // Attach the video stream to the <video> element
7348
7366
  React.useEffect(() => {
7349
7367
  let isMounted = true;
@@ -7684,6 +7702,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7684
7702
  objectFit: 'cover',
7685
7703
  borderRadius: noShadow ? 0 : 8,
7686
7704
  zIndex: 0,
7705
+ transform: 'scaleX(-1)'
7687
7706
  }, playsInline: true, muted: true, autoPlay: true }), jsxRuntime.jsx("div", { className: "facerecorder-dark-overlay", style: {
7688
7707
  position: 'absolute',
7689
7708
  top: 0,
@@ -7809,7 +7828,7 @@ function generateRandomDigits(count) {
7809
7828
  }
7810
7829
  return digits.slice(0, count);
7811
7830
  }
7812
- const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, style, noShadow = false, }) => {
7831
+ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onConfirmRecording, onRecorded, className, style, noShadow = false, }) => {
7813
7832
  const [state, setState] = React.useState('preparation');
7814
7833
  const [prepTimer, setPrepTimer] = React.useState(PREP_SECONDS);
7815
7834
  const [recordTimer, setRecordTimer] = React.useState(RECORD_SECONDS);
@@ -7831,6 +7850,15 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7831
7850
  setAudioUrl(url);
7832
7851
  setState('result');
7833
7852
  setIsConfirming(true);
7853
+ if (onRecorded) {
7854
+ try {
7855
+ const file = new File([blob], 'voice-recording.webm', { type: blob.type });
7856
+ onRecorded(file, numbersToPhrase(digits));
7857
+ }
7858
+ catch (err) {
7859
+ console.error('onRecorded callback threw:', err);
7860
+ }
7861
+ }
7834
7862
  }
7835
7863
  else {
7836
7864
  const dummyBlob = new Blob(['dummy audio data'], { type: 'audio/webm' });
@@ -7921,7 +7949,9 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7921
7949
  const handleConfirm = () => {
7922
7950
  if (audioBlob) {
7923
7951
  const file = new File([audioBlob], 'voice-recording.webm', { type: audioBlob.type });
7924
- onCapture(file, numbersToPhrase(digits));
7952
+ // required callback in parent app
7953
+ onConfirmRecording(file, numbersToPhrase(digits));
7954
+ // Clean up and reset state
7925
7955
  if (audioUrl)
7926
7956
  URL.revokeObjectURL(audioUrl);
7927
7957
  setAudioUrl(null);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "biometry-react-components",
3
- "version": "1.2.16",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
- "description": "React UI component library for capturing high-quality biometric data (voice, face, documents, video) to facilitate integration with Biometry services",
5
+ "description": "React UI component library for capturing high-quality biometric data (voice, face, documents, video) to facilitate integration with 'Biometry' services",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.esm.js",
8
8
  "types": "dist/index.d.ts",