@sssxyd/face-liveness-detector 0.4.0-alpha.28 → 0.4.0-alpha.29

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/index.js CHANGED
@@ -5099,30 +5099,8 @@
5099
5099
  }, 'info');
5100
5100
  }
5101
5101
  // Step 3: Prepare finish data (before clearing images)
5102
- // Validate collected images if success is true
5103
- let finalSuccess = success;
5104
- if (success) {
5105
- const hasFrameImage = !!this.detectionState.bestFrameImage;
5106
- const hasFaceImage = !!this.detectionState.bestFaceImage;
5107
- if (!hasFrameImage || !hasFaceImage) {
5108
- finalSuccess = false;
5109
- this.emitDebug('detection', 'Detection marked as success but images are missing', {
5110
- hasFrameImage,
5111
- hasFaceImage,
5112
- collectCount: this.detectionState.collectCount,
5113
- bestQualityScore: this.detectionState.bestQualityScore,
5114
- period: this.detectionState.period
5115
- }, 'warn');
5116
- // Emit error event for missing images
5117
- this.emit('detector-error', {
5118
- code: exports.ErrorCode.INTERNAL_ERROR,
5119
- message: `Detection completed but images are missing: frameImage=${hasFrameImage}, faceImage=${hasFaceImage}`
5120
- });
5121
- }
5122
- }
5123
- // Create a finishData object for emission (with image data)
5124
5102
  const finishData = {
5125
- success: finalSuccess,
5103
+ success: success,
5126
5104
  silentPassedCount: this.detectionState.collectCount,
5127
5105
  actionPassedCount: this.detectionState.completedActions.size,
5128
5106
  totalTime: performance.now() - this.detectionState.startTime,
@@ -5137,10 +5115,6 @@
5137
5115
  catch (error) {
5138
5116
  this.emitDebug('detection', 'Error emitting detector-finish event', { error: error.message }, 'error');
5139
5117
  }
5140
- // Clear image references from the original finishData object immediately after emit
5141
- // to prevent external listeners from accessing stale data if they store the reference
5142
- finishData.bestFrameImage = undefined;
5143
- finishData.bestFaceImage = undefined;
5144
5118
  // Step 5: Stop video playback
5145
5119
  if (this.videoElement) {
5146
5120
  try {
@@ -5642,19 +5616,19 @@
5642
5616
  return true;
5643
5617
  }
5644
5618
  if (screenResult) {
5645
- this.emitDebug('screen-detection', 'Screen capture not detected', {
5646
- screenConfidence: screenResult.confidenceScore,
5647
- riskLevel: screenResult.riskLevel,
5648
- processingTimeMs: screenResult.processingTimeMs,
5649
- executedMethodsCount: screenResult.executedMethods?.length || 0,
5650
- methodsSummary: screenResult.executedMethods?.map((m) => `${m.method}:${m.confidence?.toFixed(2)}`).join(', ') || 'none',
5651
- stageCount: screenResult.debug?.stages?.length || 0
5652
- // 移除了 executedMethods stageDetails 的完整数据,避免超大输出
5653
- }, 'info');
5654
- }
5655
- // 只有ready状态的检测器的success结果才可信
5656
- if (this.detectionState.screenDetector?.isReady()) {
5657
- this.detectionState.realness = !screenResult?.isScreenCapture;
5619
+ // 只有ready状态的检测器的success结果才可信
5620
+ if (this.detectionState.screenDetector?.isReady() && !screenResult.isScreenCapture) {
5621
+ this.detectionState.realness = true;
5622
+ this.emitDebug('screen-detection', 'Screen capture not detected', {
5623
+ screenConfidence: screenResult.confidenceScore,
5624
+ riskLevel: screenResult.riskLevel,
5625
+ processingTimeMs: screenResult.processingTimeMs,
5626
+ executedMethodsCount: screenResult.executedMethods?.length || 0,
5627
+ methodsSummary: screenResult.executedMethods?.map((m) => `${m.method}:${m.confidence?.toFixed(2)}`).join(', ') || 'none',
5628
+ stageCount: screenResult.debug?.stages?.length || 0
5629
+ // 移除了 executedMethods 和 stageDetails 的完整数据,避免超大输出
5630
+ }, 'warn');
5631
+ }
5658
5632
  }
5659
5633
  return false;
5660
5634
  }
@@ -5703,6 +5677,14 @@
5703
5677
  this.partialResetDetectionState();
5704
5678
  return;
5705
5679
  }
5680
+ this.emitDebug('motion-detection', 'Motion liveness check passed', {
5681
+ motionScore: motionResult.motionScore,
5682
+ keypointVariance: motionResult.keypointVariance,
5683
+ opticalFlowMagnitude: motionResult.opticalFlowMagnitude,
5684
+ eyeMotionScore: motionResult.eyeMotionScore,
5685
+ mouthMotionScore: motionResult.mouthMotionScore,
5686
+ motionType: motionResult.motionType
5687
+ }, 'warn');
5706
5688
  this.detectionState.liveness = true;
5707
5689
  }
5708
5690
  // 计算面部大小比例,不达标则跳过当前帧