@hexar/biometric-identity-sdk-core 1.1.1 → 1.1.3

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,11 @@ 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)
254
+ // Reduce number of frames to prevent payload size issues
255
+ // For profile picture validation, we need more frames than full validation since we don't have ID images
256
+ // Frames will be compressed below, so we can safely use more frames
255
257
  let videoFrames = params.videoFrames;
256
- const MAX_FRAMES = 5; // Reduced to 5 to reduce payload size and processing time
258
+ const MAX_FRAMES = 15; // More frames needed for profile picture to detect movement sequences properly
257
259
  if (videoFrames.length > MAX_FRAMES) {
258
260
  const step = Math.floor(videoFrames.length / MAX_FRAMES);
259
261
  videoFrames = videoFrames.filter((_, index) => index % step === 0).slice(0, MAX_FRAMES);
@@ -262,10 +264,40 @@ class BiometricIdentitySDK {
262
264
  sampledCount: videoFrames.length
263
265
  });
264
266
  }
267
+ // Compress frames before sending (like regular validation does)
268
+ // This reduces payload size significantly
269
+ const validFrames = [];
270
+ for (let i = 0; i < videoFrames.length; i++) {
271
+ const frame = videoFrames[i];
272
+ if (!frame || typeof frame !== 'string') {
273
+ logger_1.logger.warn(`Skipping invalid frame ${i}: not a string`);
274
+ continue;
275
+ }
276
+ if (frame.length < 100) {
277
+ logger_1.logger.warn(`Skipping invalid frame ${i}: too short (${frame.length} chars), likely a file path`);
278
+ continue;
279
+ }
280
+ if (!this.isValidBase64(frame)) {
281
+ logger_1.logger.warn(`Skipping invalid frame ${i}: not valid base64`);
282
+ continue;
283
+ }
284
+ const compressedFrame = this.fixBase64Padding(await this.compressImage(frame));
285
+ validFrames.push(compressedFrame);
286
+ }
287
+ const MIN_FRAMES = 10; // Minimum frames required for profile picture validation (backend warns if < 10)
288
+ if (validFrames.length < MIN_FRAMES) {
289
+ logger_1.logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
290
+ throw this.createError(types_1.BiometricErrorCode.UNKNOWN_ERROR, `Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`);
291
+ }
292
+ logger_1.logger.info('Sending profile picture validation request to backend', {
293
+ framesCount: validFrames.length,
294
+ duration: params.videoDurationMs,
295
+ challengesCount: params.challengesCompleted?.length || 0,
296
+ });
265
297
  // Perform backend validation
266
298
  const response = await this.backendClient.validateProfilePicture({
267
299
  sessionId: params.sessionId,
268
- videoFrames: videoFrames,
300
+ videoFrames: validFrames,
269
301
  videoDurationMs: params.videoDurationMs,
270
302
  challengesCompleted: params.challengesCompleted,
271
303
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexar/biometric-identity-sdk-core",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Core AI engine for biometric identity verification",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -335,9 +335,11 @@ export class BiometricIdentitySDK {
335
335
  progress: 75
336
336
  });
337
337
 
338
- // Reduce number of frames to prevent payload size issues (same as validateIdentity)
338
+ // Reduce number of frames to prevent payload size issues
339
+ // For profile picture validation, we need more frames than full validation since we don't have ID images
340
+ // Frames will be compressed below, so we can safely use more frames
339
341
  let videoFrames = params.videoFrames;
340
- const MAX_FRAMES = 5; // Reduced to 5 to reduce payload size and processing time
342
+ const MAX_FRAMES = 15; // More frames needed for profile picture to detect movement sequences properly
341
343
  if (videoFrames.length > MAX_FRAMES) {
342
344
  const step = Math.floor(videoFrames.length / MAX_FRAMES);
343
345
  videoFrames = videoFrames.filter((_, index) => index % step === 0).slice(0, MAX_FRAMES);
@@ -347,10 +349,49 @@ export class BiometricIdentitySDK {
347
349
  });
348
350
  }
349
351
 
352
+ // Compress frames before sending (like regular validation does)
353
+ // This reduces payload size significantly
354
+ const validFrames: string[] = [];
355
+ for (let i = 0; i < videoFrames.length; i++) {
356
+ const frame = videoFrames[i];
357
+ if (!frame || typeof frame !== 'string') {
358
+ logger.warn(`Skipping invalid frame ${i}: not a string`);
359
+ continue;
360
+ }
361
+
362
+ if (frame.length < 100) {
363
+ logger.warn(`Skipping invalid frame ${i}: too short (${frame.length} chars), likely a file path`);
364
+ continue;
365
+ }
366
+
367
+ if (!this.isValidBase64(frame)) {
368
+ logger.warn(`Skipping invalid frame ${i}: not valid base64`);
369
+ continue;
370
+ }
371
+
372
+ const compressedFrame = this.fixBase64Padding(await this.compressImage(frame));
373
+ validFrames.push(compressedFrame);
374
+ }
375
+
376
+ const MIN_FRAMES = 10; // Minimum frames required for profile picture validation (backend warns if < 10)
377
+ if (validFrames.length < MIN_FRAMES) {
378
+ logger.error(`Insufficient valid frames: ${validFrames.length} < ${MIN_FRAMES}`);
379
+ throw this.createError(
380
+ BiometricErrorCode.UNKNOWN_ERROR,
381
+ `Insufficient valid video frames: ${validFrames.length} frames available, minimum ${MIN_FRAMES} required`
382
+ );
383
+ }
384
+
385
+ logger.info('Sending profile picture validation request to backend', {
386
+ framesCount: validFrames.length,
387
+ duration: params.videoDurationMs,
388
+ challengesCount: params.challengesCompleted?.length || 0,
389
+ });
390
+
350
391
  // Perform backend validation
351
392
  const response = await this.backendClient.validateProfilePicture({
352
393
  sessionId: params.sessionId,
353
- videoFrames: videoFrames,
394
+ videoFrames: validFrames,
354
395
  videoDurationMs: params.videoDurationMs,
355
396
  challengesCompleted: params.challengesCompleted,
356
397
  });