@hexar/biometric-identity-sdk-core 1.1.0 → 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.
@@ -251,10 +251,51 @@ 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
+ let videoFrames = params.videoFrames;
256
+ const MAX_FRAMES = 5; // Reduced to 5 to reduce payload size and processing time
257
+ if (videoFrames.length > MAX_FRAMES) {
258
+ const step = Math.floor(videoFrames.length / MAX_FRAMES);
259
+ videoFrames = videoFrames.filter((_, index) => index % step === 0).slice(0, MAX_FRAMES);
260
+ logger_1.logger.info('Sampled frames for profile picture validation', {
261
+ originalCount: params.videoFrames.length,
262
+ sampledCount: videoFrames.length
263
+ });
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
+ });
254
295
  // Perform backend validation
255
296
  const response = await this.backendClient.validateProfilePicture({
256
297
  sessionId: params.sessionId,
257
- videoFrames: params.videoFrames,
298
+ videoFrames: validFrames,
258
299
  videoDurationMs: params.videoDurationMs,
259
300
  challengesCompleted: params.challengesCompleted,
260
301
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexar/biometric-identity-sdk-core",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Core AI engine for biometric identity verification",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -335,10 +335,61 @@ 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
+ let videoFrames = params.videoFrames;
340
+ const MAX_FRAMES = 5; // Reduced to 5 to reduce payload size and processing time
341
+ if (videoFrames.length > MAX_FRAMES) {
342
+ const step = Math.floor(videoFrames.length / MAX_FRAMES);
343
+ videoFrames = videoFrames.filter((_, index) => index % step === 0).slice(0, MAX_FRAMES);
344
+ logger.info('Sampled frames for profile picture validation', {
345
+ originalCount: params.videoFrames.length,
346
+ sampledCount: videoFrames.length
347
+ });
348
+ }
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
+
338
389
  // Perform backend validation
339
390
  const response = await this.backendClient.validateProfilePicture({
340
391
  sessionId: params.sessionId,
341
- videoFrames: params.videoFrames,
392
+ videoFrames: validFrames,
342
393
  videoDurationMs: params.videoDurationMs,
343
394
  challengesCompleted: params.challengesCompleted,
344
395
  });