@hexar/biometric-identity-sdk-core 1.3.0 → 1.5.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.
@@ -286,7 +286,7 @@ class BiometricIdentitySDK {
286
286
  const MIN_FRAMES = 10; // Minimum frames required for profile picture validation (backend warns if < 10)
287
287
  if (validFrames.length < MIN_FRAMES) {
288
288
  logger_1.logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
289
- throw this.createError(types_1.BiometricErrorCode.UNKNOWN_ERROR, `Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`);
289
+ throw this.createError(types_1.BiometricErrorCode.CAMERA_NOT_AVAILABLE, 'Camera capture failed. Please ensure good lighting and try again.');
290
290
  }
291
291
  /**
292
292
  * Perform backend validation
@@ -379,7 +379,11 @@ class BiometricIdentitySDK {
379
379
  minimumRequired: 10
380
380
  });
381
381
  }
382
- const MAX_FRAMES = 5; // Reduced to 5 to reduce payload size and processing time
382
+ // 15 frames gives the backend enough temporal spread to reliably detect
383
+ // blink (EAR variation) and head movement across the 8-second recording.
384
+ // The previous value of 5 was too low: at ~0.6 FPS a blink event
385
+ // (150–300 ms) was statistically unlikely to be captured in any frame.
386
+ const MAX_FRAMES = 15;
383
387
  if (videoFrames.length > MAX_FRAMES) {
384
388
  const step = Math.floor(videoFrames.length / MAX_FRAMES);
385
389
  videoFrames = videoFrames.filter((_, index) => index % step === 0).slice(0, MAX_FRAMES);
@@ -410,10 +414,10 @@ class BiometricIdentitySDK {
410
414
  const compressedFrame = this.fixBase64Padding(await this.compressImage(frame));
411
415
  validFrames.push(compressedFrame);
412
416
  }
413
- const MIN_FRAMES = 5; // Minimum frames required for validation
417
+ const MIN_FRAMES = 5;
414
418
  if (validFrames.length < MIN_FRAMES) {
415
419
  logger_1.logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
416
- throw new Error(`Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`);
420
+ throw new Error('Insufficient video frames captured. Please try again.');
417
421
  }
418
422
  logger_1.logger.info('Sending validation request to backend', {
419
423
  framesCount: validFrames.length,
@@ -87,6 +87,7 @@ exports.en = {
87
87
  almostDone: 'Almost done...',
88
88
  validatingDocumentAndFace: 'Validating document and face...',
89
89
  validatingFace: 'Validating face...',
90
+ doNotLockScreen: 'Do not lock your screen',
90
91
  },
91
92
  result: {
92
93
  success: {
@@ -87,6 +87,7 @@ exports.esAR = {
87
87
  almostDone: 'Ya casi terminamos...',
88
88
  validatingDocumentAndFace: 'Validando documento y rostro...',
89
89
  validatingFace: 'Validando rostro...',
90
+ doNotLockScreen: 'No bloquees la pantalla',
90
91
  },
91
92
  result: {
92
93
  success: {
@@ -87,6 +87,7 @@ exports.es = {
87
87
  almostDone: 'Casi terminamos...',
88
88
  validatingDocumentAndFace: 'Validando documento y rostro...',
89
89
  validatingFace: 'Validando rostro...',
90
+ doNotLockScreen: 'No bloquees la pantalla',
90
91
  },
91
92
  result: {
92
93
  success: {
@@ -87,6 +87,7 @@ exports.ptBR = {
87
87
  almostDone: 'Quase pronto...',
88
88
  validatingDocumentAndFace: 'Validando documento e rosto...',
89
89
  validatingFace: 'Validando rosto...',
90
+ doNotLockScreen: 'Nao bloqueie a tela',
90
91
  },
91
92
  result: {
92
93
  success: {
@@ -85,6 +85,7 @@ export interface LanguageStrings {
85
85
  almostDone: string;
86
86
  validatingDocumentAndFace: string;
87
87
  validatingFace: string;
88
+ doNotLockScreen: string;
88
89
  };
89
90
  result: {
90
91
  success: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexar/biometric-identity-sdk-core",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Core AI engine for biometric identity verification",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -376,8 +376,8 @@ export class BiometricIdentitySDK {
376
376
  if (validFrames.length < MIN_FRAMES) {
377
377
  logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
378
378
  throw this.createError(
379
- BiometricErrorCode.UNKNOWN_ERROR,
380
- `Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`
379
+ BiometricErrorCode.CAMERA_NOT_AVAILABLE,
380
+ 'Camera capture failed. Please ensure good lighting and try again.'
381
381
  );
382
382
  }
383
383
 
@@ -492,7 +492,11 @@ export class BiometricIdentitySDK {
492
492
  });
493
493
  }
494
494
 
495
- const MAX_FRAMES = 5; // Reduced to 5 to reduce payload size and processing time
495
+ // 15 frames gives the backend enough temporal spread to reliably detect
496
+ // blink (EAR variation) and head movement across the 8-second recording.
497
+ // The previous value of 5 was too low: at ~0.6 FPS a blink event
498
+ // (150–300 ms) was statistically unlikely to be captured in any frame.
499
+ const MAX_FRAMES = 15;
496
500
  if (videoFrames.length > MAX_FRAMES) {
497
501
  const step = Math.floor(videoFrames.length / MAX_FRAMES);
498
502
  videoFrames = videoFrames.filter((_, index) => index % step === 0).slice(0, MAX_FRAMES);
@@ -501,12 +505,12 @@ export class BiometricIdentitySDK {
501
505
  sampledCount: videoFrames.length
502
506
  });
503
507
  }
504
-
508
+
505
509
  const compressedFrontImage = this.fixBase64Padding(await this.compressImage(this.state.frontID.data));
506
- const compressedBackImage = this.state.backID?.data
510
+ const compressedBackImage = this.state.backID?.data
507
511
  ? this.fixBase64Padding(await this.compressImage(this.state.backID.data))
508
512
  : undefined;
509
-
513
+
510
514
  const validFrames: string[] = [];
511
515
  for (let i = 0; i < videoFrames.length; i++) {
512
516
  const frame = videoFrames[i];
@@ -514,25 +518,25 @@ export class BiometricIdentitySDK {
514
518
  logger.warn(`Skipping invalid frame ${i}: not a string`);
515
519
  continue;
516
520
  }
517
-
521
+
518
522
  if (frame.length < 100) {
519
523
  logger.warn(`Skipping invalid frame ${i}: too short (${frame.length} chars), likely a file path`);
520
524
  continue;
521
525
  }
522
-
526
+
523
527
  if (!this.isValidBase64(frame)) {
524
528
  logger.warn(`Skipping invalid frame ${i}: not valid base64`);
525
529
  continue;
526
530
  }
527
-
531
+
528
532
  const compressedFrame = this.fixBase64Padding(await this.compressImage(frame));
529
533
  validFrames.push(compressedFrame);
530
534
  }
531
535
 
532
- const MIN_FRAMES = 5; // Minimum frames required for validation
536
+ const MIN_FRAMES = 5;
533
537
  if (validFrames.length < MIN_FRAMES) {
534
538
  logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
535
- throw new Error(`Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`);
539
+ throw new Error('Insufficient video frames captured. Please try again.');
536
540
  }
537
541
 
538
542
  logger.info('Sending validation request to backend', {
@@ -91,6 +91,7 @@ export const en: LanguageStrings = {
91
91
  almostDone: 'Almost done...',
92
92
  validatingDocumentAndFace: 'Validating document and face...',
93
93
  validatingFace: 'Validating face...',
94
+ doNotLockScreen: 'Do not lock your screen',
94
95
  },
95
96
 
96
97
  result: {
@@ -91,6 +91,7 @@ export const esAR: LanguageStrings = {
91
91
  almostDone: 'Ya casi terminamos...',
92
92
  validatingDocumentAndFace: 'Validando documento y rostro...',
93
93
  validatingFace: 'Validando rostro...',
94
+ doNotLockScreen: 'No bloquees la pantalla',
94
95
  },
95
96
 
96
97
  result: {
@@ -91,6 +91,7 @@ export const es: LanguageStrings = {
91
91
  almostDone: 'Casi terminamos...',
92
92
  validatingDocumentAndFace: 'Validando documento y rostro...',
93
93
  validatingFace: 'Validando rostro...',
94
+ doNotLockScreen: 'No bloquees la pantalla',
94
95
  },
95
96
 
96
97
  result: {
@@ -91,6 +91,7 @@ export const ptBR: LanguageStrings = {
91
91
  almostDone: 'Quase pronto...',
92
92
  validatingDocumentAndFace: 'Validando documento e rosto...',
93
93
  validatingFace: 'Validando rosto...',
94
+ doNotLockScreen: 'Nao bloqueie a tela',
94
95
  },
95
96
 
96
97
  result: {
package/src/i18n/types.ts CHANGED
@@ -91,6 +91,7 @@ export interface LanguageStrings {
91
91
  almostDone: string;
92
92
  validatingDocumentAndFace: string;
93
93
  validatingFace: string;
94
+ doNotLockScreen: string;
94
95
  };
95
96
 
96
97
  result: {