@hexar/biometric-identity-sdk-core 1.6.0 → 1.8.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/BiometricIdentitySDK.js +35 -9
- package/dist/i18n/languages/en.js +2 -0
- package/dist/i18n/languages/es-AR.js +2 -0
- package/dist/i18n/languages/es.js +2 -0
- package/dist/i18n/languages/pt-BR.js +2 -0
- package/dist/i18n/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/BiometricIdentitySDK.ts +36 -12
- package/src/i18n/languages/en.ts +2 -0
- package/src/i18n/languages/es-AR.ts +2 -0
- package/src/i18n/languages/es.ts +2 -0
- package/src/i18n/languages/pt-BR.ts +2 -0
- package/src/i18n/types.ts +2 -0
|
@@ -287,10 +287,10 @@ class BiometricIdentitySDK {
|
|
|
287
287
|
const compressedFrame = this.fixBase64Padding(await this.compressImage(frame));
|
|
288
288
|
validFrames.push(compressedFrame);
|
|
289
289
|
}
|
|
290
|
-
const MIN_FRAMES =
|
|
290
|
+
const MIN_FRAMES = 5;
|
|
291
291
|
if (validFrames.length < MIN_FRAMES) {
|
|
292
292
|
logger_1.logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
|
|
293
|
-
throw this.createError(types_1.BiometricErrorCode.
|
|
293
|
+
throw this.createError(types_1.BiometricErrorCode.LIVENESS_CHECK_FAILED, 'Not enough valid video frames captured. Please try again.');
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Perform backend validation
|
|
@@ -456,14 +456,40 @@ class BiometricIdentitySDK {
|
|
|
456
456
|
errorData: error?.errorData,
|
|
457
457
|
errorStack: error?.stack?.substring(0, 500)
|
|
458
458
|
});
|
|
459
|
-
//
|
|
459
|
+
// Categorise the error properly instead of lumping everything as NETWORK_ERROR
|
|
460
460
|
const isTimeout = error?.message?.includes('timeout') || error?.message?.includes('Request timeout') || error?.message?.includes('AbortError');
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
461
|
+
const isNetwork = error?.message?.includes('Network request failed') || error?.message?.includes('Failed to fetch') || error?.message?.includes('NETWORK_ERROR');
|
|
462
|
+
let errorCode;
|
|
463
|
+
let errorMessage;
|
|
464
|
+
let status;
|
|
465
|
+
let statusText;
|
|
466
|
+
if (isTimeout) {
|
|
467
|
+
errorCode = types_1.BiometricErrorCode.VALIDATION_TIMEOUT;
|
|
468
|
+
errorMessage = 'La validación está tomando demasiado tiempo. Por favor, intenta nuevamente.';
|
|
469
|
+
status = 504;
|
|
470
|
+
statusText = 'Gateway Timeout';
|
|
471
|
+
}
|
|
472
|
+
else if (isNetwork) {
|
|
473
|
+
errorCode = types_1.BiometricErrorCode.NETWORK_ERROR;
|
|
474
|
+
errorMessage = error?.message || 'Network error';
|
|
475
|
+
status = error?.status;
|
|
476
|
+
statusText = error?.statusText;
|
|
477
|
+
}
|
|
478
|
+
else if (error?.message?.includes('liveness') || error?.message?.includes('Liveness')) {
|
|
479
|
+
errorCode = types_1.BiometricErrorCode.LIVENESS_CHECK_FAILED;
|
|
480
|
+
errorMessage = error?.message || 'Liveness check failed';
|
|
481
|
+
status = error?.status;
|
|
482
|
+
statusText = error?.statusText;
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
errorCode = types_1.BiometricErrorCode.UNKNOWN_ERROR;
|
|
486
|
+
errorMessage = error?.message || (error?.status ? `Backend request failed with status ${error.status}` : 'Backend validation failed');
|
|
487
|
+
status = error?.status;
|
|
488
|
+
statusText = error?.statusText;
|
|
489
|
+
}
|
|
490
|
+
const errorToThrow = this.createError(errorCode, errorMessage, {
|
|
491
|
+
status,
|
|
492
|
+
statusText,
|
|
467
493
|
errorData: error?.errorData,
|
|
468
494
|
originalError: error?.message
|
|
469
495
|
});
|
|
@@ -117,6 +117,8 @@ exports.en = {
|
|
|
117
117
|
networkError: 'Network error. Please check your connection.',
|
|
118
118
|
timeout: 'Request timeout. Please try again.',
|
|
119
119
|
unknownError: 'An unexpected error occurred.',
|
|
120
|
+
systemBusy: 'Service temporarily unavailable',
|
|
121
|
+
systemBusyMessage: 'Our system is currently processing other requests. Please try again in a few moments.',
|
|
120
122
|
videoTooShort: {
|
|
121
123
|
title: 'Recording Too Short',
|
|
122
124
|
message: 'Video must be at least 8 seconds. Please try again.',
|
|
@@ -117,6 +117,8 @@ exports.esAR = {
|
|
|
117
117
|
networkError: 'Error de red. Verificá tu conexión.',
|
|
118
118
|
timeout: 'Tiempo de espera agotado. Intentá nuevamente.',
|
|
119
119
|
unknownError: 'Ocurrió un error inesperado.',
|
|
120
|
+
systemBusy: 'Servicio temporalmente no disponible',
|
|
121
|
+
systemBusyMessage: 'Nuestro sistema está procesando otras solicitudes en este momento. Por favor, intentá nuevamente en unos instantes.',
|
|
120
122
|
videoTooShort: {
|
|
121
123
|
title: 'Grabación Muy Corta',
|
|
122
124
|
message: 'El video debe durar al menos 8 segundos. Por favor intentá nuevamente.',
|
|
@@ -117,6 +117,8 @@ exports.es = {
|
|
|
117
117
|
networkError: 'Error de red. Verifica tu conexión.',
|
|
118
118
|
timeout: 'Tiempo de espera agotado. Intenta nuevamente.',
|
|
119
119
|
unknownError: 'Ocurrió un error inesperado.',
|
|
120
|
+
systemBusy: 'Servicio temporalmente no disponible',
|
|
121
|
+
systemBusyMessage: 'Nuestro sistema está procesando otras solicitudes en este momento. Por favor, intenta nuevamente en unos instantes.',
|
|
120
122
|
videoTooShort: {
|
|
121
123
|
title: 'Grabación Muy Corta',
|
|
122
124
|
message: 'El video debe durar al menos 8 segundos. Por favor intenta nuevamente.',
|
|
@@ -117,6 +117,8 @@ exports.ptBR = {
|
|
|
117
117
|
networkError: 'Erro de rede. Verifique sua conexão.',
|
|
118
118
|
timeout: 'Tempo esgotado. Tente novamente.',
|
|
119
119
|
unknownError: 'Ocorreu um erro inesperado.',
|
|
120
|
+
systemBusy: 'Serviço temporariamente indisponível',
|
|
121
|
+
systemBusyMessage: 'Nosso sistema está processando outras solicitações no momento. Por favor, tente novamente em alguns instantes.',
|
|
120
122
|
videoTooShort: {
|
|
121
123
|
title: 'Gravação Muito Curta',
|
|
122
124
|
message: 'O vídeo deve durar pelo menos 8 segundos. Por favor, tente novamente.',
|
package/dist/i18n/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -376,12 +376,12 @@ export class BiometricIdentitySDK {
|
|
|
376
376
|
validFrames.push(compressedFrame);
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
const MIN_FRAMES =
|
|
379
|
+
const MIN_FRAMES = 5;
|
|
380
380
|
if (validFrames.length < MIN_FRAMES) {
|
|
381
381
|
logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
|
|
382
382
|
throw this.createError(
|
|
383
|
-
BiometricErrorCode.
|
|
384
|
-
'
|
|
383
|
+
BiometricErrorCode.LIVENESS_CHECK_FAILED,
|
|
384
|
+
'Not enough valid video frames captured. Please try again.'
|
|
385
385
|
);
|
|
386
386
|
}
|
|
387
387
|
|
|
@@ -579,19 +579,43 @@ export class BiometricIdentitySDK {
|
|
|
579
579
|
errorStack: error?.stack?.substring(0, 500)
|
|
580
580
|
});
|
|
581
581
|
|
|
582
|
-
//
|
|
582
|
+
// Categorise the error properly instead of lumping everything as NETWORK_ERROR
|
|
583
583
|
const isTimeout = error?.message?.includes('timeout') || error?.message?.includes('Request timeout') || error?.message?.includes('AbortError');
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
584
|
+
const isNetwork = error?.message?.includes('Network request failed') || error?.message?.includes('Failed to fetch') || error?.message?.includes('NETWORK_ERROR');
|
|
585
|
+
|
|
586
|
+
let errorCode: BiometricErrorCode;
|
|
587
|
+
let errorMessage: string;
|
|
588
|
+
let status: number | undefined;
|
|
589
|
+
let statusText: string | undefined;
|
|
590
|
+
|
|
591
|
+
if (isTimeout) {
|
|
592
|
+
errorCode = BiometricErrorCode.VALIDATION_TIMEOUT;
|
|
593
|
+
errorMessage = 'La validación está tomando demasiado tiempo. Por favor, intenta nuevamente.';
|
|
594
|
+
status = 504;
|
|
595
|
+
statusText = 'Gateway Timeout';
|
|
596
|
+
} else if (isNetwork) {
|
|
597
|
+
errorCode = BiometricErrorCode.NETWORK_ERROR;
|
|
598
|
+
errorMessage = error?.message || 'Network error';
|
|
599
|
+
status = error?.status;
|
|
600
|
+
statusText = error?.statusText;
|
|
601
|
+
} else if (error?.message?.includes('liveness') || error?.message?.includes('Liveness')) {
|
|
602
|
+
errorCode = BiometricErrorCode.LIVENESS_CHECK_FAILED;
|
|
603
|
+
errorMessage = error?.message || 'Liveness check failed';
|
|
604
|
+
status = error?.status;
|
|
605
|
+
statusText = error?.statusText;
|
|
606
|
+
} else {
|
|
607
|
+
errorCode = BiometricErrorCode.UNKNOWN_ERROR;
|
|
608
|
+
errorMessage = error?.message || (error?.status ? `Backend request failed with status ${error.status}` : 'Backend validation failed');
|
|
609
|
+
status = error?.status;
|
|
610
|
+
statusText = error?.statusText;
|
|
611
|
+
}
|
|
612
|
+
|
|
589
613
|
const errorToThrow = this.createError(
|
|
590
|
-
|
|
614
|
+
errorCode,
|
|
591
615
|
errorMessage,
|
|
592
616
|
{
|
|
593
|
-
status
|
|
594
|
-
statusText
|
|
617
|
+
status,
|
|
618
|
+
statusText,
|
|
595
619
|
errorData: error?.errorData,
|
|
596
620
|
originalError: error?.message
|
|
597
621
|
}
|
package/src/i18n/languages/en.ts
CHANGED
|
@@ -124,6 +124,8 @@ export const en: LanguageStrings = {
|
|
|
124
124
|
networkError: 'Network error. Please check your connection.',
|
|
125
125
|
timeout: 'Request timeout. Please try again.',
|
|
126
126
|
unknownError: 'An unexpected error occurred.',
|
|
127
|
+
systemBusy: 'Service temporarily unavailable',
|
|
128
|
+
systemBusyMessage: 'Our system is currently processing other requests. Please try again in a few moments.',
|
|
127
129
|
videoTooShort: {
|
|
128
130
|
title: 'Recording Too Short',
|
|
129
131
|
message: 'Video must be at least 8 seconds. Please try again.',
|
|
@@ -124,6 +124,8 @@ export const esAR: LanguageStrings = {
|
|
|
124
124
|
networkError: 'Error de red. Verificá tu conexión.',
|
|
125
125
|
timeout: 'Tiempo de espera agotado. Intentá nuevamente.',
|
|
126
126
|
unknownError: 'Ocurrió un error inesperado.',
|
|
127
|
+
systemBusy: 'Servicio temporalmente no disponible',
|
|
128
|
+
systemBusyMessage: 'Nuestro sistema está procesando otras solicitudes en este momento. Por favor, intentá nuevamente en unos instantes.',
|
|
127
129
|
videoTooShort: {
|
|
128
130
|
title: 'Grabación Muy Corta',
|
|
129
131
|
message: 'El video debe durar al menos 8 segundos. Por favor intentá nuevamente.',
|
package/src/i18n/languages/es.ts
CHANGED
|
@@ -124,6 +124,8 @@ export const es: LanguageStrings = {
|
|
|
124
124
|
networkError: 'Error de red. Verifica tu conexión.',
|
|
125
125
|
timeout: 'Tiempo de espera agotado. Intenta nuevamente.',
|
|
126
126
|
unknownError: 'Ocurrió un error inesperado.',
|
|
127
|
+
systemBusy: 'Servicio temporalmente no disponible',
|
|
128
|
+
systemBusyMessage: 'Nuestro sistema está procesando otras solicitudes en este momento. Por favor, intenta nuevamente en unos instantes.',
|
|
127
129
|
videoTooShort: {
|
|
128
130
|
title: 'Grabación Muy Corta',
|
|
129
131
|
message: 'El video debe durar al menos 8 segundos. Por favor intenta nuevamente.',
|
|
@@ -124,6 +124,8 @@ export const ptBR: LanguageStrings = {
|
|
|
124
124
|
networkError: 'Erro de rede. Verifique sua conexão.',
|
|
125
125
|
timeout: 'Tempo esgotado. Tente novamente.',
|
|
126
126
|
unknownError: 'Ocorreu um erro inesperado.',
|
|
127
|
+
systemBusy: 'Serviço temporariamente indisponível',
|
|
128
|
+
systemBusyMessage: 'Nosso sistema está processando outras solicitações no momento. Por favor, tente novamente em alguns instantes.',
|
|
127
129
|
videoTooShort: {
|
|
128
130
|
title: 'Gravação Muito Curta',
|
|
129
131
|
message: 'O vídeo deve durar pelo menos 8 segundos. Por favor, tente novamente.',
|
package/src/i18n/types.ts
CHANGED