@hexar/biometric-identity-sdk-react-native 1.10.0 → 1.11.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/dist/components/CameraCapture.d.ts.map +1 -1
- package/dist/components/CameraCapture.js +10 -27
- package/dist/components/VideoRecorder.d.ts.map +1 -1
- package/dist/components/VideoRecorder.js +11 -31
- package/package.json +1 -1
- package/src/components/CameraCapture.tsx +9 -27
- package/src/components/VideoRecorder.tsx +10 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraCapture.d.ts","sourceRoot":"","sources":["../../src/components/CameraCapture.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAY3D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAmC,MAAM,oCAAoC,CAAC;AAIrH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"CameraCapture.d.ts","sourceRoot":"","sources":["../../src/components/CameraCapture.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAY3D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAmC,MAAM,oCAAoC,CAAC;AAIrH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA8OtD,CAAC;AA0JF,eAAe,aAAa,CAAC"}
|
|
@@ -129,36 +129,19 @@ const CameraCapture = ({ mode, theme, language, onCapture, onCancel, }) => {
|
|
|
129
129
|
// Convert to base64
|
|
130
130
|
try {
|
|
131
131
|
const RNFS = require('react-native-fs');
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
biometric_identity_sdk_core_1.logger.info('Image converted to base64:', { sizeKB, path: processedPath });
|
|
135
|
-
onCapture(base64);
|
|
136
|
-
}
|
|
137
|
-
catch (fsError) {
|
|
138
|
-
// Fallback: try fetch method
|
|
132
|
+
// Try with original path first, then strip file:// prefix
|
|
133
|
+
let base64;
|
|
139
134
|
try {
|
|
140
|
-
|
|
141
|
-
const response = await fetch(fileUri);
|
|
142
|
-
const blob = await response.blob();
|
|
143
|
-
const reader = new FileReader();
|
|
144
|
-
reader.onloadend = () => {
|
|
145
|
-
const base64data = reader.result;
|
|
146
|
-
const base64 = base64data.includes(',')
|
|
147
|
-
? base64data.split(',')[1]
|
|
148
|
-
: base64data;
|
|
149
|
-
onCapture(base64);
|
|
150
|
-
setIsCapturing(false);
|
|
151
|
-
};
|
|
152
|
-
reader.onerror = () => {
|
|
153
|
-
throw new Error('Failed to read photo file');
|
|
154
|
-
};
|
|
155
|
-
reader.readAsDataURL(blob);
|
|
156
|
-
return;
|
|
135
|
+
base64 = await RNFS.readFile(processedPath, 'base64');
|
|
157
136
|
}
|
|
158
|
-
catch
|
|
159
|
-
|
|
160
|
-
onCapture(processedPath);
|
|
137
|
+
catch {
|
|
138
|
+
base64 = await RNFS.readFile(processedPath.replace('file://', ''), 'base64');
|
|
161
139
|
}
|
|
140
|
+
onCapture(base64);
|
|
141
|
+
}
|
|
142
|
+
catch (fsError) {
|
|
143
|
+
biometric_identity_sdk_core_1.logger.warn('Could not convert to base64, using file path:', processedPath);
|
|
144
|
+
onCapture(processedPath);
|
|
162
145
|
}
|
|
163
146
|
}
|
|
164
147
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoRecorder.d.ts","sourceRoot":"","sources":["../../src/components/VideoRecorder.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAaxE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,EAAmC,MAAM,oCAAoC,CAAC;AAE1I,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,0CAA0C;IAC1C,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wCAAwC;IACxC,UAAU,EAAE,CAAC,SAAS,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACtD,iCAAiC;IACjC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,C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,oBAAoB;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA2CD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAg5BtD,CAAC;AA6OF,eAAe,aAAa,CAAC"}
|
|
@@ -347,7 +347,7 @@ const VideoRecorder = ({ theme, language, duration, instructions, challenges: pr
|
|
|
347
347
|
framesRef.current = [];
|
|
348
348
|
let consecutiveErrors = 0;
|
|
349
349
|
const maxConsecutiveErrors = 10;
|
|
350
|
-
const MAX_FRAMES =
|
|
350
|
+
const MAX_FRAMES = 30;
|
|
351
351
|
// Serial capture: each frame is captured only after the previous one
|
|
352
352
|
// finishes, preventing overlapping takePhoto() calls that cause the
|
|
353
353
|
// camera to throw "busy" errors and kill the capture loop.
|
|
@@ -364,41 +364,21 @@ const VideoRecorder = ({ theme, language, duration, instructions, challenges: pr
|
|
|
364
364
|
let base64Data = null;
|
|
365
365
|
try {
|
|
366
366
|
const RNFS = require('react-native-fs');
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
catch (fsError) {
|
|
367
|
+
// Try with original path first, then strip file:// prefix
|
|
370
368
|
try {
|
|
371
|
-
|
|
372
|
-
const response = await fetch(fileUri);
|
|
373
|
-
const blob = await response.blob();
|
|
374
|
-
base64Data = await new Promise((resolve, reject) => {
|
|
375
|
-
const reader = new FileReader();
|
|
376
|
-
reader.onloadend = () => {
|
|
377
|
-
const result = reader.result;
|
|
378
|
-
const base64 = result.includes(',') ? result.split(',')[1] : result;
|
|
379
|
-
resolve(base64);
|
|
380
|
-
};
|
|
381
|
-
reader.onerror = reject;
|
|
382
|
-
reader.readAsDataURL(blob);
|
|
383
|
-
});
|
|
369
|
+
base64Data = await RNFS.readFile(photo.path, 'base64');
|
|
384
370
|
}
|
|
385
|
-
catch
|
|
386
|
-
|
|
387
|
-
base64Data = null;
|
|
371
|
+
catch {
|
|
372
|
+
base64Data = await RNFS.readFile(photo.path.replace('file://', ''), 'base64');
|
|
388
373
|
}
|
|
389
374
|
}
|
|
390
|
-
|
|
391
|
-
setFrames(prev => {
|
|
392
|
-
const newFrames = prev.length < MAX_FRAMES ? [...prev, base64Data] : prev;
|
|
393
|
-
framesRef.current = newFrames;
|
|
394
|
-
if (newFrames.length % 10 === 0) {
|
|
395
|
-
biometric_identity_sdk_core_1.logger.info('Captured frames:', newFrames.length);
|
|
396
|
-
}
|
|
397
|
-
return newFrames;
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
375
|
+
catch (fsError) {
|
|
401
376
|
biometric_identity_sdk_core_1.logger.warn('Could not convert photo to base64, skipping frame');
|
|
377
|
+
base64Data = null;
|
|
378
|
+
}
|
|
379
|
+
if (base64Data) {
|
|
380
|
+
framesRef.current = [...framesRef.current, base64Data];
|
|
381
|
+
setFrames(framesRef.current);
|
|
402
382
|
}
|
|
403
383
|
}
|
|
404
384
|
}
|
package/package.json
CHANGED
|
@@ -133,35 +133,17 @@ export const CameraCapture: React.FC<CameraCaptureProps> = ({
|
|
|
133
133
|
// Convert to base64
|
|
134
134
|
try {
|
|
135
135
|
const RNFS = require('react-native-fs');
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
logger.info('Image converted to base64:', { sizeKB, path: processedPath });
|
|
139
|
-
onCapture(base64);
|
|
140
|
-
} catch (fsError) {
|
|
141
|
-
// Fallback: try fetch method
|
|
136
|
+
// Try with original path first, then strip file:// prefix
|
|
137
|
+
let base64: string;
|
|
142
138
|
try {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const reader = new FileReader();
|
|
148
|
-
reader.onloadend = () => {
|
|
149
|
-
const base64data = reader.result as string;
|
|
150
|
-
const base64 = base64data.includes(',')
|
|
151
|
-
? base64data.split(',')[1]
|
|
152
|
-
: base64data;
|
|
153
|
-
onCapture(base64);
|
|
154
|
-
setIsCapturing(false);
|
|
155
|
-
};
|
|
156
|
-
reader.onerror = () => {
|
|
157
|
-
throw new Error('Failed to read photo file');
|
|
158
|
-
};
|
|
159
|
-
reader.readAsDataURL(blob);
|
|
160
|
-
return;
|
|
161
|
-
} catch (fetchError) {
|
|
162
|
-
logger.warn('Could not convert to base64, using file path:', processedPath);
|
|
163
|
-
onCapture(processedPath);
|
|
139
|
+
base64 = await RNFS.readFile(processedPath, 'base64');
|
|
140
|
+
} catch {
|
|
141
|
+
base64 = await RNFS.readFile(processedPath.replace('file://', ''), 'base64');
|
|
164
142
|
}
|
|
143
|
+
onCapture(base64);
|
|
144
|
+
} catch (fsError) {
|
|
145
|
+
logger.warn('Could not convert to base64, using file path:', processedPath);
|
|
146
|
+
onCapture(processedPath);
|
|
165
147
|
}
|
|
166
148
|
} catch (error) {
|
|
167
149
|
logger.error('Error processing image:', error);
|
|
@@ -415,7 +415,7 @@ export const VideoRecorder: React.FC<VideoRecorderProps> = ({
|
|
|
415
415
|
framesRef.current = [];
|
|
416
416
|
let consecutiveErrors = 0;
|
|
417
417
|
const maxConsecutiveErrors = 10;
|
|
418
|
-
const MAX_FRAMES =
|
|
418
|
+
const MAX_FRAMES = 30;
|
|
419
419
|
|
|
420
420
|
// Serial capture: each frame is captured only after the previous one
|
|
421
421
|
// finishes, preventing overlapping takePhoto() calls that cause the
|
|
@@ -436,39 +436,20 @@ export const VideoRecorder: React.FC<VideoRecorderProps> = ({
|
|
|
436
436
|
|
|
437
437
|
try {
|
|
438
438
|
const RNFS = require('react-native-fs');
|
|
439
|
-
|
|
440
|
-
} catch (fsError) {
|
|
439
|
+
// Try with original path first, then strip file:// prefix
|
|
441
440
|
try {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
base64Data = await new Promise<string>((resolve, reject) => {
|
|
446
|
-
const reader = new FileReader();
|
|
447
|
-
reader.onloadend = () => {
|
|
448
|
-
const result = reader.result as string;
|
|
449
|
-
const base64 = result.includes(',') ? result.split(',')[1] : result;
|
|
450
|
-
resolve(base64);
|
|
451
|
-
};
|
|
452
|
-
reader.onerror = reject;
|
|
453
|
-
reader.readAsDataURL(blob);
|
|
454
|
-
});
|
|
455
|
-
} catch (fetchError) {
|
|
456
|
-
logger.error('Failed to read photo file as base64:', fetchError);
|
|
457
|
-
base64Data = null;
|
|
441
|
+
base64Data = await RNFS.readFile(photo.path, 'base64');
|
|
442
|
+
} catch {
|
|
443
|
+
base64Data = await RNFS.readFile(photo.path.replace('file://', ''), 'base64');
|
|
458
444
|
}
|
|
445
|
+
} catch (fsError) {
|
|
446
|
+
logger.warn('Could not convert photo to base64, skipping frame');
|
|
447
|
+
base64Data = null;
|
|
459
448
|
}
|
|
460
449
|
|
|
461
450
|
if (base64Data) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
framesRef.current = newFrames;
|
|
465
|
-
if (newFrames.length % 10 === 0) {
|
|
466
|
-
logger.info('Captured frames:', newFrames.length);
|
|
467
|
-
}
|
|
468
|
-
return newFrames;
|
|
469
|
-
});
|
|
470
|
-
} else {
|
|
471
|
-
logger.warn('Could not convert photo to base64, skipping frame');
|
|
451
|
+
framesRef.current = [...framesRef.current, base64Data];
|
|
452
|
+
setFrames(framesRef.current);
|
|
472
453
|
}
|
|
473
454
|
}
|
|
474
455
|
} catch (error: any) {
|