@hexar/biometric-identity-sdk-core 1.1.2 → 1.1.4
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.
|
@@ -251,9 +251,8 @@ class BiometricIdentitySDK {
|
|
|
251
251
|
currentStep: types_1.SDKStep.VALIDATING,
|
|
252
252
|
progress: 75
|
|
253
253
|
});
|
|
254
|
-
// Reduce number of frames to prevent payload size issues (same as validateIdentity)
|
|
255
254
|
let videoFrames = params.videoFrames;
|
|
256
|
-
const MAX_FRAMES =
|
|
255
|
+
const MAX_FRAMES = 25;
|
|
257
256
|
if (videoFrames.length > MAX_FRAMES) {
|
|
258
257
|
const step = Math.floor(videoFrames.length / MAX_FRAMES);
|
|
259
258
|
videoFrames = videoFrames.filter((_, index) => index % step === 0).slice(0, MAX_FRAMES);
|
|
@@ -262,8 +261,10 @@ class BiometricIdentitySDK {
|
|
|
262
261
|
sampledCount: videoFrames.length
|
|
263
262
|
});
|
|
264
263
|
}
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Compress frames before sending (like regular validation does)
|
|
266
|
+
* This reduces payload size significantly
|
|
267
|
+
*/
|
|
267
268
|
const validFrames = [];
|
|
268
269
|
for (let i = 0; i < videoFrames.length; i++) {
|
|
269
270
|
const frame = videoFrames[i];
|
|
@@ -282,17 +283,14 @@ class BiometricIdentitySDK {
|
|
|
282
283
|
const compressedFrame = this.fixBase64Padding(await this.compressImage(frame));
|
|
283
284
|
validFrames.push(compressedFrame);
|
|
284
285
|
}
|
|
285
|
-
const MIN_FRAMES =
|
|
286
|
+
const MIN_FRAMES = 10; // Minimum frames required for profile picture validation (backend warns if < 10)
|
|
286
287
|
if (validFrames.length < MIN_FRAMES) {
|
|
287
288
|
logger_1.logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
|
|
288
289
|
throw this.createError(types_1.BiometricErrorCode.UNKNOWN_ERROR, `Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`);
|
|
289
290
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
challengesCount: params.challengesCompleted?.length || 0,
|
|
294
|
-
});
|
|
295
|
-
// Perform backend validation
|
|
291
|
+
/**
|
|
292
|
+
* Perform backend validation
|
|
293
|
+
*/
|
|
296
294
|
const response = await this.backendClient.validateProfilePicture({
|
|
297
295
|
sessionId: params.sessionId,
|
|
298
296
|
videoFrames: validFrames,
|
|
@@ -542,7 +540,6 @@ class BiometricIdentitySDK {
|
|
|
542
540
|
catch (error) {
|
|
543
541
|
logger_1.logger.warn('Image compression not available, using original', error);
|
|
544
542
|
}
|
|
545
|
-
logger_1.logger.warn(`Image too large (${Math.round(base64Image.length / 1024)}KB) but compression not available`);
|
|
546
543
|
return base64Image;
|
|
547
544
|
}
|
|
548
545
|
/**
|
|
@@ -129,12 +129,6 @@ class BackendClient {
|
|
|
129
129
|
video_duration_ms: params.videoDurationMs,
|
|
130
130
|
challenges_completed: params.challengesCompleted || [],
|
|
131
131
|
};
|
|
132
|
-
logger_1.logger.info('Profile picture validation request', {
|
|
133
|
-
hasSessionId: !!this.currentSessionId,
|
|
134
|
-
sessionId: this.currentSessionId || params.sessionId,
|
|
135
|
-
videoFramesCount: params.videoFrames.length,
|
|
136
|
-
videoDurationMs: params.videoDurationMs,
|
|
137
|
-
});
|
|
138
132
|
return this.request('/api/v1/profile/validate-face', 'POST', requestBody);
|
|
139
133
|
}
|
|
140
134
|
/**
|
|
@@ -205,12 +199,6 @@ class BackendClient {
|
|
|
205
199
|
*/
|
|
206
200
|
async request(endpoint, method, body) {
|
|
207
201
|
const url = `${this.config.apiEndpoint}${endpoint}`;
|
|
208
|
-
logger_1.logger.info('Making backend request', {
|
|
209
|
-
url,
|
|
210
|
-
method,
|
|
211
|
-
hasBody: !!body,
|
|
212
|
-
bodySize: body ? JSON.stringify(body).length : 0
|
|
213
|
-
});
|
|
214
202
|
const controller = new AbortController();
|
|
215
203
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
216
204
|
const headers = {
|
|
@@ -227,12 +215,6 @@ class BackendClient {
|
|
|
227
215
|
body: body ? JSON.stringify(body) : undefined,
|
|
228
216
|
signal: controller.signal,
|
|
229
217
|
});
|
|
230
|
-
logger_1.logger.info('Backend response received', {
|
|
231
|
-
url,
|
|
232
|
-
status: response.status,
|
|
233
|
-
statusText: response.statusText,
|
|
234
|
-
ok: response.ok
|
|
235
|
-
});
|
|
236
218
|
clearTimeout(timeoutId);
|
|
237
219
|
if (!response.ok) {
|
|
238
220
|
let errorText = '';
|
package/package.json
CHANGED
|
@@ -335,9 +335,8 @@ export class BiometricIdentitySDK {
|
|
|
335
335
|
progress: 75
|
|
336
336
|
});
|
|
337
337
|
|
|
338
|
-
// Reduce number of frames to prevent payload size issues (same as validateIdentity)
|
|
339
338
|
let videoFrames = params.videoFrames;
|
|
340
|
-
const MAX_FRAMES =
|
|
339
|
+
const MAX_FRAMES = 25;
|
|
341
340
|
if (videoFrames.length > MAX_FRAMES) {
|
|
342
341
|
const step = Math.floor(videoFrames.length / MAX_FRAMES);
|
|
343
342
|
videoFrames = videoFrames.filter((_, index) => index % step === 0).slice(0, MAX_FRAMES);
|
|
@@ -347,8 +346,10 @@ export class BiometricIdentitySDK {
|
|
|
347
346
|
});
|
|
348
347
|
}
|
|
349
348
|
|
|
350
|
-
|
|
351
|
-
|
|
349
|
+
/**
|
|
350
|
+
* Compress frames before sending (like regular validation does)
|
|
351
|
+
* This reduces payload size significantly
|
|
352
|
+
*/
|
|
352
353
|
const validFrames: string[] = [];
|
|
353
354
|
for (let i = 0; i < videoFrames.length; i++) {
|
|
354
355
|
const frame = videoFrames[i];
|
|
@@ -371,7 +372,7 @@ export class BiometricIdentitySDK {
|
|
|
371
372
|
validFrames.push(compressedFrame);
|
|
372
373
|
}
|
|
373
374
|
|
|
374
|
-
const MIN_FRAMES =
|
|
375
|
+
const MIN_FRAMES = 10; // Minimum frames required for profile picture validation (backend warns if < 10)
|
|
375
376
|
if (validFrames.length < MIN_FRAMES) {
|
|
376
377
|
logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
|
|
377
378
|
throw this.createError(
|
|
@@ -380,13 +381,9 @@ export class BiometricIdentitySDK {
|
|
|
380
381
|
);
|
|
381
382
|
}
|
|
382
383
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
challengesCount: params.challengesCompleted?.length || 0,
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
// Perform backend validation
|
|
384
|
+
/**
|
|
385
|
+
* Perform backend validation
|
|
386
|
+
*/
|
|
390
387
|
const response = await this.backendClient.validateProfilePicture({
|
|
391
388
|
sessionId: params.sessionId,
|
|
392
389
|
videoFrames: validFrames,
|
|
@@ -683,8 +680,6 @@ export class BiometricIdentitySDK {
|
|
|
683
680
|
} catch (error) {
|
|
684
681
|
logger.warn('Image compression not available, using original', error);
|
|
685
682
|
}
|
|
686
|
-
|
|
687
|
-
logger.warn(`Image too large (${Math.round(base64Image.length / 1024)}KB) but compression not available`);
|
|
688
683
|
return base64Image;
|
|
689
684
|
}
|
|
690
685
|
|
package/src/api/BackendClient.ts
CHANGED
|
@@ -333,13 +333,6 @@ export class BackendClient {
|
|
|
333
333
|
challenges_completed: params.challengesCompleted || [],
|
|
334
334
|
};
|
|
335
335
|
|
|
336
|
-
logger.info('Profile picture validation request', {
|
|
337
|
-
hasSessionId: !!this.currentSessionId,
|
|
338
|
-
sessionId: this.currentSessionId || params.sessionId,
|
|
339
|
-
videoFramesCount: params.videoFrames.length,
|
|
340
|
-
videoDurationMs: params.videoDurationMs,
|
|
341
|
-
});
|
|
342
|
-
|
|
343
336
|
return this.request<ProfilePictureValidationResponse>(
|
|
344
337
|
'/api/v1/profile/validate-face',
|
|
345
338
|
'POST',
|
|
@@ -422,15 +415,7 @@ export class BackendClient {
|
|
|
422
415
|
method: 'GET' | 'POST' | 'PUT' | 'DELETE',
|
|
423
416
|
body?: any
|
|
424
417
|
): Promise<T> {
|
|
425
|
-
const url = `${this.config.apiEndpoint}${endpoint}`;
|
|
426
|
-
|
|
427
|
-
logger.info('Making backend request', {
|
|
428
|
-
url,
|
|
429
|
-
method,
|
|
430
|
-
hasBody: !!body,
|
|
431
|
-
bodySize: body ? JSON.stringify(body).length : 0
|
|
432
|
-
});
|
|
433
|
-
|
|
418
|
+
const url = `${this.config.apiEndpoint}${endpoint}`;
|
|
434
419
|
const controller = new AbortController();
|
|
435
420
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
436
421
|
|
|
@@ -450,13 +435,6 @@ export class BackendClient {
|
|
|
450
435
|
body: body ? JSON.stringify(body) : undefined,
|
|
451
436
|
signal: controller.signal as RequestInit['signal'],
|
|
452
437
|
});
|
|
453
|
-
|
|
454
|
-
logger.info('Backend response received', {
|
|
455
|
-
url,
|
|
456
|
-
status: response.status,
|
|
457
|
-
statusText: response.statusText,
|
|
458
|
-
ok: response.ok
|
|
459
|
-
});
|
|
460
438
|
|
|
461
439
|
clearTimeout(timeoutId);
|
|
462
440
|
|