biometry-react-components 1.2.13 → 1.2.15

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
@@ -91,17 +91,17 @@ Records video with facial guidance overlay and displays 10 random numbers (0-9)
91
91
  import { FaceRecorder } from 'biometry-react-components';
92
92
 
93
93
  function FaceRecorder() {
94
- const handleCapture = (video: File, audio: File, phrase: string) => {
95
- console.log('Captured video:', video);
96
- console.log('Captured audio:', audio);
94
+ const handleConfirm = (video: File, audio: File, phrase: string) => {
95
+ console.log('Confirmed video:', video);
96
+ console.log('Confirmed audio:', audio);
97
97
  console.log('Phrase:', phrase);
98
98
  // Send files to your endpoint that will process the biometric data
99
- // or
100
99
  // const response = await sdk.processVideo(video, phrase, userFullName);
100
+ // or
101
101
  // const voiceResponse = await sdk.enrollVoice(audio, userFullName);
102
102
  };
103
103
 
104
- return <FaceRecorder onCapture={handleCapture} />;
104
+ return <FaceRecorder onConfirmRecording={handleConfirm} />;
105
105
  }
106
106
  ```
107
107
 
@@ -109,7 +109,8 @@ function FaceRecorder() {
109
109
 
110
110
  | Prop | Type | Default | Description |
111
111
  |------|------|---------|-------------|
112
- | `onCapture` | `(video: File, audio: File, phrase: string) => void` | **required** | Callback with captured video file, audio file, and phrase |
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
114
  | `rectWidth` | `number` | `360` | Width of camera area |
114
115
  | `rectHeight` | `number` | `576` | Height of camera area |
115
116
  | `className` | `string` | - | Custom CSS class |
package/dist/index.d.ts CHANGED
@@ -23,7 +23,8 @@ declare const FaceCapture: React.FC<FaceCaptureProps>;
23
23
  interface FaceRecorderProps {
24
24
  rectWidth?: number;
25
25
  rectHeight?: number;
26
- onCapture: (file: File, audio: File, phrase: string) => void;
26
+ onConfirmRecording: (file: File, audio: File, phrase: string) => void;
27
+ onRecordingComplete?: (video: File, audio: File, phrase: string) => void;
27
28
  className?: string;
28
29
  style?: React.CSSProperties;
29
30
  noShadow?: boolean;
package/dist/index.esm.js CHANGED
@@ -7279,7 +7279,7 @@ function generateRandomDigits$1(count) {
7279
7279
  }
7280
7280
  return digits.slice(0, count);
7281
7281
  }
7282
- const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className, style, noShadow = false, }) => {
7282
+ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecordingComplete, className, style, noShadow = false, }) => {
7283
7283
  const [state, setState] = useState('preparation');
7284
7284
  const [prepTimer, setPrepTimer] = useState(PREP_SECONDS$1);
7285
7285
  const [recordTimer, setRecordTimer] = useState(RECORD_SECONDS$1);
@@ -7311,12 +7311,16 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7311
7311
  });
7312
7312
  // Audio recorder
7313
7313
  const { startRecording: startAudioRecording, cancelRecording: cancelAudioRecording } = useRecorder(stream, "audio", (blob) => {
7314
- if (blob && blob.size > 0) {
7315
- setAudioBlob(blob);
7316
- }
7317
- else {
7318
- const dummyBlob = new Blob(['dummy audio data'], { type: 'audio/webm' });
7319
- setAudioBlob(dummyBlob);
7314
+ let finalAudioBlob = blob && blob.size > 0
7315
+ ? blob
7316
+ : new Blob(['dummy audio data'], { type: 'audio/webm' });
7317
+ setAudioBlob(finalAudioBlob);
7318
+ // Ensure we have both blobs before triggering new callback
7319
+ if (videoBlob && finalAudioBlob && onRecordingComplete) {
7320
+ const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
7321
+ const audioFile = new File([finalAudioBlob], 'face-audio.webm', { type: finalAudioBlob.type });
7322
+ const phrase = numbersToPhrase(digits);
7323
+ onRecordingComplete(videoFile, audioFile, phrase);
7320
7324
  }
7321
7325
  // Only show result when both recordings are done
7322
7326
  // Video callback will be called first, then audio
@@ -7410,8 +7414,8 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7410
7414
  // Create file objects
7411
7415
  const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
7412
7416
  const audioFile = new File([audioBlob], 'face-audio.webm', { type: audioBlob.type });
7413
- // Call onCapture immediately with both files
7414
- onCapture(videoFile, audioFile, numbersToPhrase(digits));
7417
+ // required callback in parent app
7418
+ onConfirmRecording(videoFile, audioFile, numbersToPhrase(digits));
7415
7419
  // Clean up and reset state
7416
7420
  if (videoUrl)
7417
7421
  URL.revokeObjectURL(videoUrl);
package/dist/index.js CHANGED
@@ -7279,7 +7279,7 @@ function generateRandomDigits$1(count) {
7279
7279
  }
7280
7280
  return digits.slice(0, count);
7281
7281
  }
7282
- const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className, style, noShadow = false, }) => {
7282
+ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecordingComplete, className, style, noShadow = false, }) => {
7283
7283
  const [state, setState] = React.useState('preparation');
7284
7284
  const [prepTimer, setPrepTimer] = React.useState(PREP_SECONDS$1);
7285
7285
  const [recordTimer, setRecordTimer] = React.useState(RECORD_SECONDS$1);
@@ -7311,12 +7311,16 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7311
7311
  });
7312
7312
  // Audio recorder
7313
7313
  const { startRecording: startAudioRecording, cancelRecording: cancelAudioRecording } = useRecorder(stream, "audio", (blob) => {
7314
- if (blob && blob.size > 0) {
7315
- setAudioBlob(blob);
7316
- }
7317
- else {
7318
- const dummyBlob = new Blob(['dummy audio data'], { type: 'audio/webm' });
7319
- setAudioBlob(dummyBlob);
7314
+ let finalAudioBlob = blob && blob.size > 0
7315
+ ? blob
7316
+ : new Blob(['dummy audio data'], { type: 'audio/webm' });
7317
+ setAudioBlob(finalAudioBlob);
7318
+ // Ensure we have both blobs before triggering new callback
7319
+ if (videoBlob && finalAudioBlob && onRecordingComplete) {
7320
+ const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
7321
+ const audioFile = new File([finalAudioBlob], 'face-audio.webm', { type: finalAudioBlob.type });
7322
+ const phrase = numbersToPhrase(digits);
7323
+ onRecordingComplete(videoFile, audioFile, phrase);
7320
7324
  }
7321
7325
  // Only show result when both recordings are done
7322
7326
  // Video callback will be called first, then audio
@@ -7410,8 +7414,8 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7410
7414
  // Create file objects
7411
7415
  const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
7412
7416
  const audioFile = new File([audioBlob], 'face-audio.webm', { type: audioBlob.type });
7413
- // Call onCapture immediately with both files
7414
- onCapture(videoFile, audioFile, numbersToPhrase(digits));
7417
+ // required callback in parent app
7418
+ onConfirmRecording(videoFile, audioFile, numbersToPhrase(digits));
7415
7419
  // Clean up and reset state
7416
7420
  if (videoUrl)
7417
7421
  URL.revokeObjectURL(videoUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biometry-react-components",
3
- "version": "1.2.13",
3
+ "version": "1.2.15",
4
4
  "type": "module",
5
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",