@hexar/biometric-identity-sdk-core 1.1.1 → 1.1.2
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.
|
@@ -262,10 +262,40 @@ class BiometricIdentitySDK {
|
|
|
262
262
|
sampledCount: videoFrames.length
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
|
+
// Compress frames before sending (like regular validation does)
|
|
266
|
+
// This reduces payload size significantly
|
|
267
|
+
const validFrames = [];
|
|
268
|
+
for (let i = 0; i < videoFrames.length; i++) {
|
|
269
|
+
const frame = videoFrames[i];
|
|
270
|
+
if (!frame || typeof frame !== 'string') {
|
|
271
|
+
logger_1.logger.warn(`Skipping invalid frame ${i}: not a string`);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (frame.length < 100) {
|
|
275
|
+
logger_1.logger.warn(`Skipping invalid frame ${i}: too short (${frame.length} chars), likely a file path`);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (!this.isValidBase64(frame)) {
|
|
279
|
+
logger_1.logger.warn(`Skipping invalid frame ${i}: not valid base64`);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const compressedFrame = this.fixBase64Padding(await this.compressImage(frame));
|
|
283
|
+
validFrames.push(compressedFrame);
|
|
284
|
+
}
|
|
285
|
+
const MIN_FRAMES = 5; // Minimum frames required for validation
|
|
286
|
+
if (validFrames.length < MIN_FRAMES) {
|
|
287
|
+
logger_1.logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
|
|
288
|
+
throw this.createError(types_1.BiometricErrorCode.UNKNOWN_ERROR, `Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`);
|
|
289
|
+
}
|
|
290
|
+
logger_1.logger.info('Sending profile picture validation request to backend', {
|
|
291
|
+
framesCount: validFrames.length,
|
|
292
|
+
duration: params.videoDurationMs,
|
|
293
|
+
challengesCount: params.challengesCompleted?.length || 0,
|
|
294
|
+
});
|
|
265
295
|
// Perform backend validation
|
|
266
296
|
const response = await this.backendClient.validateProfilePicture({
|
|
267
297
|
sessionId: params.sessionId,
|
|
268
|
-
videoFrames:
|
|
298
|
+
videoFrames: validFrames,
|
|
269
299
|
videoDurationMs: params.videoDurationMs,
|
|
270
300
|
challengesCompleted: params.challengesCompleted,
|
|
271
301
|
});
|
package/package.json
CHANGED
|
@@ -347,10 +347,49 @@ export class BiometricIdentitySDK {
|
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
// Compress frames before sending (like regular validation does)
|
|
351
|
+
// This reduces payload size significantly
|
|
352
|
+
const validFrames: string[] = [];
|
|
353
|
+
for (let i = 0; i < videoFrames.length; i++) {
|
|
354
|
+
const frame = videoFrames[i];
|
|
355
|
+
if (!frame || typeof frame !== 'string') {
|
|
356
|
+
logger.warn(`Skipping invalid frame ${i}: not a string`);
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (frame.length < 100) {
|
|
361
|
+
logger.warn(`Skipping invalid frame ${i}: too short (${frame.length} chars), likely a file path`);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (!this.isValidBase64(frame)) {
|
|
366
|
+
logger.warn(`Skipping invalid frame ${i}: not valid base64`);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const compressedFrame = this.fixBase64Padding(await this.compressImage(frame));
|
|
371
|
+
validFrames.push(compressedFrame);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const MIN_FRAMES = 5; // Minimum frames required for validation
|
|
375
|
+
if (validFrames.length < MIN_FRAMES) {
|
|
376
|
+
logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
|
|
377
|
+
throw this.createError(
|
|
378
|
+
BiometricErrorCode.UNKNOWN_ERROR,
|
|
379
|
+
`Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
logger.info('Sending profile picture validation request to backend', {
|
|
384
|
+
framesCount: validFrames.length,
|
|
385
|
+
duration: params.videoDurationMs,
|
|
386
|
+
challengesCount: params.challengesCompleted?.length || 0,
|
|
387
|
+
});
|
|
388
|
+
|
|
350
389
|
// Perform backend validation
|
|
351
390
|
const response = await this.backendClient.validateProfilePicture({
|
|
352
391
|
sessionId: params.sessionId,
|
|
353
|
-
videoFrames:
|
|
392
|
+
videoFrames: validFrames,
|
|
354
393
|
videoDurationMs: params.videoDurationMs,
|
|
355
394
|
challengesCompleted: params.challengesCompleted,
|
|
356
395
|
});
|