idmission-web-sdk 2.3.113 → 2.3.115

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.
Files changed (27) hide show
  1. package/dist/components/common/debug.d.ts +1 -1
  2. package/dist/components/common/debug.d.ts.map +1 -1
  3. package/dist/components/selfie_capture/SelfieGuidanceModelsProvider.d.ts.map +1 -1
  4. package/dist/components/video_id/IdVideoCaptureWizard.d.ts.map +1 -1
  5. package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
  6. package/dist/components/video_signature_capture/VideoSignatureContext.d.ts +2 -0
  7. package/dist/components/video_signature_capture/VideoSignatureContext.d.ts.map +1 -1
  8. package/dist/components/video_signature_capture/VideoSignatureGuides.d.ts.map +1 -1
  9. package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
  10. package/dist/lib/camera/useVideoRecorder.d.ts.map +1 -1
  11. package/dist/lib/models/DocumentDetection.d.ts +2 -1
  12. package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
  13. package/dist/lib/models/FaceDetection.d.ts +5 -4
  14. package/dist/lib/models/FaceDetection.d.ts.map +1 -1
  15. package/dist/lib/models/defaults/DocumentDetector.d.ts +2 -2
  16. package/dist/sdk2.cjs.development.js +142 -212
  17. package/dist/sdk2.cjs.development.js.map +1 -1
  18. package/dist/sdk2.cjs.production.js +1 -1
  19. package/dist/sdk2.cjs.production.js.map +1 -1
  20. package/dist/sdk2.esm.js +143 -213
  21. package/dist/sdk2.esm.js.map +1 -1
  22. package/dist/sdk2.umd.development.js +142 -212
  23. package/dist/sdk2.umd.development.js.map +1 -1
  24. package/dist/sdk2.umd.production.js +1 -1
  25. package/dist/sdk2.umd.production.js.map +1 -1
  26. package/dist/version.d.ts +1 -1
  27. package/package.json +3 -3
@@ -211,7 +211,7 @@
211
211
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
212
212
  };
213
213
 
214
- var webSdkVersion = '2.3.113';
214
+ var webSdkVersion = '2.3.115';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -8252,8 +8252,8 @@
8252
8252
 
8253
8253
  var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
8254
8254
 
8255
- var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20250815_115859.tflite");
8256
- var defaultDocumentDetectorModelHash = '64LSaO2ctQsTkGJoZ6Et4v2KH28Fz1ettgkxD+qFg6frxY7ufL9l/lkjw2ljX2cR';
8255
+ var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20251018_121234.tflite");
8256
+ var defaultDocumentDetectorModelHash = 'cTLjb4g6H+a+RHnLaYrvVF8050qv/Ox04rMtxFXBDR6Xv8Pv+X//hsaO3K3jNPog';
8257
8257
 
8258
8258
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
8259
8259
  var defaultFocusModelHash = 'HTJNLB7QybtPXIIyUI9oNqW40vE5bgSV5V24R1wXLQHknNEVOSyDQDo/QzRgJ8jb';
@@ -8570,8 +8570,8 @@
8570
8570
  singlePage: 'Single page',
8571
8571
  none: 'None'
8572
8572
  };
8573
- var detector$1 = null;
8574
- var detectorSettings$1 = null;
8573
+ var detector = null;
8574
+ var detectorSettings = null;
8575
8575
  function loadDocumentDetector() {
8576
8576
  return __awaiter(this, arguments, void 0, function (modelAssetPath, scoreThreshold) {
8577
8577
  var _a, _b;
@@ -8584,7 +8584,7 @@
8584
8584
  return __generator(this, function (_c) {
8585
8585
  switch (_c.label) {
8586
8586
  case 0:
8587
- if (detector$1 && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.modelAssetPath) === modelAssetPath && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.scoreThreshold) === scoreThreshold) return [2 /*return*/, detector$1];
8587
+ if (detector && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.modelAssetPath) === modelAssetPath && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.scoreThreshold) === scoreThreshold) return [2 /*return*/, detector];
8588
8588
  closeDocumentDetector();
8589
8589
  return [4 /*yield*/, preloadDocumentDetectorDependencies()];
8590
8590
  case 1:
@@ -8605,20 +8605,20 @@
8605
8605
  runningMode: 'VIDEO'
8606
8606
  }])];
8607
8607
  case 3:
8608
- detector$1 = _c.sent();
8609
- detectorSettings$1 = {
8608
+ detector = _c.sent();
8609
+ detectorSettings = {
8610
8610
  modelAssetPath: modelAssetPath,
8611
8611
  scoreThreshold: scoreThreshold
8612
8612
  };
8613
- return [2 /*return*/, detector$1];
8613
+ return [2 /*return*/, detector];
8614
8614
  }
8615
8615
  });
8616
8616
  });
8617
8617
  }
8618
8618
  function closeDocumentDetector() {
8619
- detector$1 === null || detector$1 === void 0 ? void 0 : detector$1.close();
8620
- detector$1 = null;
8621
- detectorSettings$1 = null;
8619
+ detector === null || detector === void 0 ? void 0 : detector.close();
8620
+ detector = null;
8621
+ detectorSettings = null;
8622
8622
  }
8623
8623
  function useLoadDocumentDetector(_a) {
8624
8624
  var _b = _a.shouldLoadModels,
@@ -8719,12 +8719,12 @@
8719
8719
  return __awaiter(this, void 0, void 0, function () {
8720
8720
  var startedAt, prediction, time, frameWidth, frameHeight;
8721
8721
  return __generator(this, function (_a) {
8722
- if (!detector$1) return [2 /*return*/, null];
8722
+ if (!detector) return [2 /*return*/, null];
8723
8723
  startedAt = performance.now();
8724
8724
  // Detectors can throw errors, for example when using custom URLs that
8725
8725
  // contain a model that doesn't provide the expected output.
8726
8726
  try {
8727
- prediction = detector$1.detectForVideo(frame, performance.now());
8727
+ prediction = detector.detectForVideo(frame, performance.now());
8728
8728
  time = performance.now() - startedAt;
8729
8729
  frameWidth = frame.width;
8730
8730
  frameHeight = frame.height;
@@ -15922,6 +15922,7 @@
15922
15922
  scaledHeight = _c.scaledHeight,
15923
15923
  xOffset = _c.xOffset,
15924
15924
  yOffset = _c.yOffset;
15925
+ if (!point) return /*#__PURE__*/React.createElement(React.Fragment, null);
15925
15926
  var left, top;
15926
15927
  if (horizontal) {
15927
15928
  left = point.x / videoWidth * scaledWidth - xOffset;
@@ -21011,136 +21012,6 @@
21011
21012
  var templateObject_1$n, templateObject_2$l;
21012
21013
 
21013
21014
  var defaultSelfieCaptureModelLoadTimeoutMs = 45000;
21014
- var detector = null;
21015
- var detectorSettings = null;
21016
- function loadFaceDetector() {
21017
- return __awaiter(this, arguments, void 0, function (modelAssetPath) {
21018
- var _a, _b;
21019
- if (modelAssetPath === void 0) {
21020
- modelAssetPath = defaultFaceDetectorModelPath;
21021
- }
21022
- return __generator(this, function (_c) {
21023
- switch (_c.label) {
21024
- case 0:
21025
- if (detector && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.modelAssetPath) === modelAssetPath) return [2 /*return*/, detector];
21026
- closeFaceDetector();
21027
- return [4 /*yield*/, preloadFaceDetectorDependencies()];
21028
- case 1:
21029
- _c.sent();
21030
- if (modelCapabilities.delegate === 'NONE') {
21031
- throw new Error('No available delegate for face detector.');
21032
- }
21033
- _b = (_a = ya).createFromOptions;
21034
- return [4 /*yield*/, ao.forVisionTasks(visionTasksBasePath)];
21035
- case 2:
21036
- return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
21037
- // canvas: document.createElement('canvas'),
21038
- baseOptions: {
21039
- modelAssetPath: modelAssetPath,
21040
- delegate: modelCapabilities.delegate
21041
- },
21042
- runningMode: 'VIDEO'
21043
- }])];
21044
- case 3:
21045
- detector = _c.sent();
21046
- detectorSettings = {
21047
- modelAssetPath: modelAssetPath
21048
- };
21049
- return [2 /*return*/, detector];
21050
- }
21051
- });
21052
- });
21053
- }
21054
- function closeFaceDetector() {
21055
- detector === null || detector === void 0 ? void 0 : detector.close();
21056
- detector = null;
21057
- detectorSettings = null;
21058
- }
21059
- function useLoadFaceDetector(_a) {
21060
- var onModelError = _a.onModelError,
21061
- _b = _a.modelLoadTimeoutMs,
21062
- modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b,
21063
- videoRef = _a.videoRef;
21064
- var _c = React.useState('not-started'),
21065
- modelLoadState = _c[0],
21066
- setModelLoadState = _c[1];
21067
- var _d = React.useState(0),
21068
- modelDownloadProgress = _d[0],
21069
- setModelDownloadProgress = _d[1];
21070
- var _e = React.useState(null),
21071
- modelWarmingStartedAt = _e[0],
21072
- setModelWarmingStartedAt = _e[1];
21073
- var _f = React.useState(null),
21074
- modelError = _f[0],
21075
- setModelError = _f[1];
21076
- React.useEffect(function loadModel() {
21077
- var _this = this;
21078
- setModelLoadState('downloading');
21079
- setModelWarmingStartedAt(null);
21080
- var modelLoadTimeout = setTimeout(function () {
21081
- setModelError(new Error('Model loading time limit exceeded.'));
21082
- }, modelLoadTimeoutMs);
21083
- function handleDownloadProgress(event) {
21084
- setModelDownloadProgress(progressToPercentage(event.detail));
21085
- }
21086
- document.addEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
21087
- var cancelVideoReady = function cancelVideoReady() {};
21088
- loadFaceDetector().then(function (model) {
21089
- return __awaiter(_this, void 0, void 0, function () {
21090
- var _a, videoReady, cancel, cancelled;
21091
- return __generator(this, function (_b) {
21092
- switch (_b.label) {
21093
- case 0:
21094
- setModelDownloadProgress(100);
21095
- clearTimeout(modelLoadTimeout);
21096
- setModelLoadState('warming');
21097
- setModelWarmingStartedAt(performance.now());
21098
- return [4 /*yield*/, testFaceDetectionAgainstKnownImage(model)];
21099
- case 1:
21100
- _b.sent();
21101
- _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
21102
- cancelled = false;
21103
- cancelVideoReady = function cancelVideoReady() {
21104
- cancelled = true;
21105
- cancel();
21106
- };
21107
- return [4 /*yield*/, videoReady];
21108
- case 2:
21109
- _b.sent();
21110
- if (cancelled) return [2 /*return*/];
21111
- model.detectForVideo(videoRef.current, performance.now());
21112
- setModelLoadState('ready');
21113
- return [2 /*return*/];
21114
- }
21115
- });
21116
- });
21117
- })["catch"](function (e) {
21118
- setModelError(e);
21119
- setModelLoadState('error');
21120
- })["finally"](function () {
21121
- clearTimeout(modelLoadTimeout);
21122
- });
21123
- return function () {
21124
- log('unloading face detection model');
21125
- cancelVideoReady();
21126
- closeFaceDetector();
21127
- clearTimeout(modelLoadTimeout);
21128
- document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
21129
- };
21130
- }, [modelLoadTimeoutMs, videoRef]);
21131
- React.useEffect(function handleModelError() {
21132
- if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
21133
- }, [modelError, onModelError]);
21134
- return React.useMemo(function () {
21135
- return {
21136
- ready: modelLoadState === 'ready',
21137
- modelLoadState: modelLoadState,
21138
- modelDownloadProgress: modelDownloadProgress,
21139
- modelWarmingStartedAt: modelWarmingStartedAt,
21140
- modelError: modelError
21141
- };
21142
- }, [modelLoadState, modelDownloadProgress, modelWarmingStartedAt, modelError]);
21143
- }
21144
21015
  var lastFaceDetectionAt = 0;
21145
21016
  var lastFaceDetectionTime = 0;
21146
21017
  function setLastFaceDetectionAt(time) {
@@ -21190,24 +21061,68 @@
21190
21061
  if (lastNNosePairs.length > framesNeeded - 1) lastNNosePairs.length = framesNeeded - 1;
21191
21062
  }
21192
21063
  }
21193
- function makeFaceDetectorPrediction(imageData) {
21194
- if (!detector) return null;
21195
- var prediction = detector.detectForVideo(imageData, performance.now());
21196
- var faces = prediction.detections.map(function (d) {
21197
- return {
21198
- box: convertBoundingBox(d.boundingBox),
21199
- keypoints: d.keypoints.map(function (k) {
21200
- var _a;
21201
- return _assign(_assign({}, k), {
21202
- x: k.x * imageData.width,
21203
- y: k.y * imageData.height,
21204
- name: (_a = k.label) !== null && _a !== void 0 ? _a : ''
21205
- });
21206
- })
21207
- };
21064
+ function isFaceDetection(detection) {
21065
+ return detection.boundingBox && detection.categories.some(function (c) {
21066
+ return c.categoryName === 'Primary face' || c.categoryName === 'Secondary face';
21208
21067
  });
21209
- return _assign(_assign({}, prediction), {
21210
- faces: faces
21068
+ }
21069
+ function isNoseDetection(detection) {
21070
+ return detection.categories.some(function (c) {
21071
+ return c.categoryName === 'Nose';
21072
+ });
21073
+ }
21074
+ function makeFacePredictionWithDocumentDetector(frame) {
21075
+ return __awaiter(this, void 0, void 0, function () {
21076
+ var prediction, faceDetections, noseDetections, _i, _a, detection, faces, _b, faceDetections_1, d, faceBox, nose, _c, noseDetections_1, n, noseBox, cX, cY;
21077
+ return __generator(this, function (_d) {
21078
+ switch (_d.label) {
21079
+ case 0:
21080
+ return [4 /*yield*/, makeDocumentDetectorPrediction(frame)];
21081
+ case 1:
21082
+ prediction = _d.sent();
21083
+ if (!prediction) return [2 /*return*/, null];
21084
+ faceDetections = [];
21085
+ noseDetections = [];
21086
+ for (_i = 0, _a = prediction.detections; _i < _a.length; _i++) {
21087
+ detection = _a[_i];
21088
+ if (isNoseDetection(detection)) {
21089
+ noseDetections.push(detection);
21090
+ } else if (isFaceDetection(detection)) {
21091
+ faceDetections.push(detection);
21092
+ }
21093
+ }
21094
+ faces = [];
21095
+ for (_b = 0, faceDetections_1 = faceDetections; _b < faceDetections_1.length; _b++) {
21096
+ d = faceDetections_1[_b];
21097
+ faceBox = d.boundingBox;
21098
+ if (!faceBox) continue;
21099
+ nose = null;
21100
+ for (_c = 0, noseDetections_1 = noseDetections; _c < noseDetections_1.length; _c++) {
21101
+ n = noseDetections_1[_c];
21102
+ noseBox = n.boundingBox;
21103
+ if (!noseBox) continue;
21104
+ cX = noseBox.originX + noseBox.width / 2;
21105
+ cY = noseBox.originY + noseBox.height / 2;
21106
+ if (cX >= faceBox.originX && cX <= faceBox.originX + faceBox.width && cY >= faceBox.originY && cY <= faceBox.originY + faceBox.height) {
21107
+ nose = {
21108
+ x: cX,
21109
+ y: cY,
21110
+ name: 'nose'
21111
+ };
21112
+ break;
21113
+ }
21114
+ }
21115
+ faces.push({
21116
+ box: convertBoundingBox(d.boundingBox),
21117
+ keypoints: [null, null, nose, null, null]
21118
+ });
21119
+ }
21120
+ debug('faces', faces);
21121
+ return [2 /*return*/, _assign(_assign({}, prediction), {
21122
+ faces: faces
21123
+ })];
21124
+ }
21125
+ });
21211
21126
  });
21212
21127
  }
21213
21128
  function processFaceDetectorPrediction(_a) {
@@ -21235,13 +21150,9 @@
21235
21150
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video width
21236
21151
  yCentroidBoundary = _h === void 0 ? 0.125 : _h,
21237
21152
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video height
21238
- _j = _a.foreheadRatio,
21153
+ _j = _a.noseTrackingThreshold,
21239
21154
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video height
21240
- foreheadRatio = _j === void 0 ? 0.275 : _j,
21241
- // we found that the bounding box ends at the brow and misses the forehead. this ratio represents how much we should extend the box to include the forehead.
21242
- _k = _a.noseTrackingThreshold,
21243
- // we found that the bounding box ends at the brow and misses the forehead. this ratio represents how much we should extend the box to include the forehead.
21244
- noseTrackingThreshold = _k === void 0 ? 0.2 : _k,
21155
+ noseTrackingThreshold = _j === void 0 ? 0.2 : _j,
21245
21156
  // this represents the maximum distance that the nose can be from the center of the face box -- 20% of the face box width or height
21246
21157
  minCaptureBrightnessThreshold = _a.minCaptureBrightnessThreshold,
21247
21158
  minCaptureRangeThreshold = _a.minCaptureRangeThreshold,
@@ -21268,10 +21179,10 @@
21268
21179
  var frameCX = videoWidth / 2;
21269
21180
  var frameCY = videoHeight / 2;
21270
21181
  // calculate head bounding box, with forehead extension
21271
- var foreheadSize = face.box.height * foreheadRatio;
21182
+ // const foreheadSize = face.box.height * foreheadRatio
21272
21183
  var headXMin = face.box.xMin;
21273
21184
  var headXMax = face.box.xMax;
21274
- var headYMin = face.box.yMin - foreheadSize;
21185
+ var headYMin = face.box.yMin; // - foreheadSize
21275
21186
  var headYMax = face.box.yMax;
21276
21187
  // calculate head centroids
21277
21188
  var headCX = (headXMin + headXMax) / 2;
@@ -21327,26 +21238,6 @@
21327
21238
  faceVisibilityTooLow: faceVisibilityTooLow
21328
21239
  };
21329
21240
  }
21330
- function testFaceDetectionAgainstKnownImage(detector) {
21331
- return new Promise(function (resolve, reject) {
21332
- var img = new Image();
21333
- img.crossOrigin = 'anonymous';
21334
- img.onload = function () {
21335
- var prediction = detector.detectForVideo(img, performance.now());
21336
- if (prediction.detections.length > 0) {
21337
- debug('face detection test result', prediction.detections);
21338
- resolve(void 0);
21339
- } else {
21340
- warn('face detection test failed');
21341
- reject(new Error('testFaceDetectionAgainstKnownImage failed to predict'));
21342
- }
21343
- };
21344
- img.onerror = function () {
21345
- return reject(new Error('testFaceDetectionAgainstKnownImage failed to load image'));
21346
- };
21347
- img.src = "".concat(DEFAULT_CDN_URL, "/head-test.jpg");
21348
- });
21349
- }
21350
21241
 
21351
21242
  function detectBrightnessAndContrast(frame, brightnessAverager) {
21352
21243
  var ctx = frame.getContext('2d');
@@ -21498,16 +21389,27 @@
21498
21389
  var canvasRef = React.useRef(null);
21499
21390
  var onPredictionHandler = React.useRef();
21500
21391
  var addToAverage = useRunningAvg(5).addToAverage;
21501
- var _f = useLoadFaceDetector({
21392
+ var _f = useLoadDocumentDetector({
21393
+ videoRef: videoRef,
21502
21394
  onModelError: onModelError,
21503
- modelLoadTimeoutMs: modelLoadTimeoutMs,
21504
- videoRef: videoRef
21395
+ modelLoadTimeoutMs: modelLoadTimeoutMs
21505
21396
  }),
21506
21397
  ready = _f.ready,
21507
21398
  modelLoadState = _f.modelLoadState,
21508
21399
  modelDownloadProgress = _f.modelDownloadProgress,
21509
21400
  modelWarmingStartedAt = _f.modelWarmingStartedAt,
21510
21401
  modelError = _f.modelError;
21402
+ // const {
21403
+ // ready,
21404
+ // modelLoadState,
21405
+ // modelDownloadProgress,
21406
+ // modelWarmingStartedAt,
21407
+ // modelError,
21408
+ // } = useLoadFaceDetector({
21409
+ // onModelError,
21410
+ // modelLoadTimeoutMs,
21411
+ // videoRef,
21412
+ // })
21511
21413
  var _g = useFrameLoop(React.useCallback(function () {
21512
21414
  return __awaiter(_this, void 0, void 0, function () {
21513
21415
  var vw, vh, ctx, thresholdsProvided, brightnessResults, brightness, range, variance, prediction, processed, e_1;
@@ -21521,19 +21423,21 @@
21521
21423
  ctx = canvasRef.current.getContext('2d');
21522
21424
  canvasRef.current.width = vw;
21523
21425
  canvasRef.current.height = vh;
21524
- if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 4];
21426
+ if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 5];
21525
21427
  ctx.translate(vw, 0);
21526
21428
  ctx.scale(-1, 1);
21527
21429
  ctx.drawImage(videoRef.current, 0, 0, vw, vh);
21528
21430
  _c.label = 1;
21529
21431
  case 1:
21530
- _c.trys.push([1, 3,, 4]);
21432
+ _c.trys.push([1, 4,, 5]);
21531
21433
  thresholdsProvided = minCaptureBrightnessThreshold !== undefined || minCaptureRangeThreshold !== undefined || minCaptureVarianceThreshold !== undefined;
21532
21434
  brightnessResults = thresholdsProvided ? detectBrightnessAndContrast(canvasRef.current, addToAverage) : undefined;
21533
21435
  brightness = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.brightness;
21534
21436
  range = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.range;
21535
21437
  variance = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.variance;
21536
- prediction = makeFaceDetectorPrediction(canvasRef.current);
21438
+ return [4 /*yield*/, makeFacePredictionWithDocumentDetector(canvasRef.current)];
21439
+ case 2:
21440
+ prediction = _c.sent();
21537
21441
  processed = processFaceDetectorPrediction({
21538
21442
  faces: (_a = prediction === null || prediction === void 0 ? void 0 : prediction.faces) !== null && _a !== void 0 ? _a : [],
21539
21443
  videoWidth: vw,
@@ -21549,15 +21453,15 @@
21549
21453
  setLastFaceDetectionAt(new Date().getTime());
21550
21454
  // setLastPrediction(processed)
21551
21455
  return [4 /*yield*/, (_b = onPredictionHandler.current) === null || _b === void 0 ? void 0 : _b.call(onPredictionHandler, processed)];
21552
- case 2:
21456
+ case 3:
21553
21457
  // setLastPrediction(processed)
21554
21458
  _c.sent();
21555
- return [3 /*break*/, 4];
21556
- case 3:
21459
+ return [3 /*break*/, 5];
21460
+ case 4:
21557
21461
  e_1 = _c.sent();
21558
21462
  error('caught face detection error', e_1);
21559
- return [3 /*break*/, 4];
21560
- case 4:
21463
+ return [3 /*break*/, 5];
21464
+ case 5:
21561
21465
  return [2 /*return*/];
21562
21466
  }
21563
21467
  });
@@ -24363,7 +24267,7 @@
24363
24267
  _a.sent();
24364
24268
  signatureRecorder.onstop = function () {
24365
24269
  return __awaiter(_this, void 0, void 0, function () {
24366
- var recordingStoppedAt, mimeType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, recordingStopRequestedAt, lastChunkReceivedAt, supportsRequestVideoFrameCallback, supportsRoundRect;
24270
+ var recordingStoppedAt, mimeType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, acceptClickedAt, recordingStopRequestedAt, lastChunkReceivedAt, supportsRequestVideoFrameCallback, supportsRoundRect;
24367
24271
  return __generator(this, function (_b) {
24368
24272
  recordingStoppedAt = performance.now();
24369
24273
  set({
@@ -24375,7 +24279,7 @@
24375
24279
  });
24376
24280
  signatureChunks = [];
24377
24281
  signatureRecorder = null;
24378
- _a = get(), onSignatureVideoCaptured = _a.onSignatureVideoCaptured, recordingStartRequestedAt = _a.recordingStartRequestedAt, recordingStartedAt = _a.recordingStartedAt, firstChunkReceivedAt = _a.firstChunkReceivedAt, signatureStartedAt = _a.signatureStartedAt, signatureEndedAt = _a.signatureEndedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt, lastChunkReceivedAt = _a.lastChunkReceivedAt, supportsRequestVideoFrameCallback = _a.supportsRequestVideoFrameCallback, supportsRoundRect = _a.supportsRoundRect;
24282
+ _a = get(), onSignatureVideoCaptured = _a.onSignatureVideoCaptured, recordingStartRequestedAt = _a.recordingStartRequestedAt, recordingStartedAt = _a.recordingStartedAt, firstChunkReceivedAt = _a.firstChunkReceivedAt, signatureStartedAt = _a.signatureStartedAt, signatureEndedAt = _a.signatureEndedAt, acceptClickedAt = _a.acceptClickedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt, lastChunkReceivedAt = _a.lastChunkReceivedAt, supportsRequestVideoFrameCallback = _a.supportsRequestVideoFrameCallback, supportsRoundRect = _a.supportsRoundRect;
24379
24283
  onSignatureVideoCaptured(blob, signatureData !== null && signatureData !== void 0 ? signatureData : null, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, {
24380
24284
  mimeType: mimeType,
24381
24285
  browserFeatures: {
@@ -24388,6 +24292,7 @@
24388
24292
  firstChunkReceivedAt: firstChunkReceivedAt ? Math.ceil(firstChunkReceivedAt) : 0,
24389
24293
  signatureStartedAt: signatureStartedAt ? Math.ceil(signatureStartedAt) : 0,
24390
24294
  signatureEndedAt: signatureEndedAt ? Math.ceil(signatureEndedAt) : 0,
24295
+ acceptClickedAt: acceptClickedAt ? Math.ceil(acceptClickedAt) : 0,
24391
24296
  recordingStopRequestedAt: recordingStopRequestedAt ? Math.ceil(recordingStopRequestedAt) : 0,
24392
24297
  recordingStoppedAt: Math.ceil(recordingStoppedAt),
24393
24298
  lastChunkReceivedAt: lastChunkReceivedAt ? Math.ceil(lastChunkReceivedAt) : 0
@@ -24418,6 +24323,7 @@
24418
24323
  signatureValid: false,
24419
24324
  signatureStartedAt: undefined,
24420
24325
  signatureEndedAt: undefined,
24326
+ acceptClickedAt: undefined,
24421
24327
  supportsRequestVideoFrameCallback: undefined,
24422
24328
  supportsRoundRect: undefined
24423
24329
  });
@@ -24725,12 +24631,15 @@
24725
24631
  React.useEffect(function () {
24726
24632
  if (guideToDisplay) setMode(guideToDisplay);
24727
24633
  }, [guideToDisplay]);
24728
- var firstChunkReceivedAt = useVideoSignatureStore(useShallow(function (state) {
24729
- return {
24730
- firstChunkReceivedAt: state.firstChunkReceivedAt
24731
- };
24732
- })).firstChunkReceivedAt;
24733
- var signaturePadDisabled = requestedAction !== 'CAPTURE_SIGNATURE' || !firstChunkReceivedAt;
24634
+ var _h = useVideoSignatureStore(useShallow(function (state) {
24635
+ return {
24636
+ firstChunkReceivedAt: state.firstChunkReceivedAt,
24637
+ acceptClickedAt: state.acceptClickedAt
24638
+ };
24639
+ })),
24640
+ firstChunkReceivedAt = _h.firstChunkReceivedAt,
24641
+ acceptClickedAt = _h.acceptClickedAt;
24642
+ var signaturePadDisabled = requestedAction !== 'CAPTURE_SIGNATURE' || !firstChunkReceivedAt || !!acceptClickedAt;
24734
24643
  return /*#__PURE__*/React.createElement(Container$3, {
24735
24644
  className: classNames.container
24736
24645
  }, /*#__PURE__*/React.createElement(Inner$1, {
@@ -24857,7 +24766,8 @@
24857
24766
  var rightEdge = videoWidth * (1 - headTrackingBoundaryPercentage);
24858
24767
  var topEdge = videoHeight * headTrackingBoundaryPercentage;
24859
24768
  var bottomEdge = videoHeight * (1 - headTrackingBoundaryPercentage);
24860
- var nearBoundary = !!face && (headTrackingBoundaryType === 'nose' ? face.keypoints[2].x < leftEdge || face.keypoints[2].x > rightEdge || face.keypoints[2].y < topEdge || face.keypoints[2].y > bottomEdge : (face === null || face === void 0 ? void 0 : face.box.xMin) < leftEdge || (face === null || face === void 0 ? void 0 : face.box.xMax) > rightEdge || (face === null || face === void 0 ? void 0 : face.box.yMin) < topEdge || (face === null || face === void 0 ? void 0 : face.box.yMax) > bottomEdge);
24769
+ var nose = face === null || face === void 0 ? void 0 : face.keypoints[2];
24770
+ var nearBoundary = !!face && !!nose && (headTrackingBoundaryType === 'nose' ? nose.x < leftEdge || nose.x > rightEdge || nose.y < topEdge || nose.y > bottomEdge : (face === null || face === void 0 ? void 0 : face.box.xMin) < leftEdge || (face === null || face === void 0 ? void 0 : face.box.xMax) > rightEdge || (face === null || face === void 0 ? void 0 : face.box.yMin) < topEdge || (face === null || face === void 0 ? void 0 : face.box.yMax) > bottomEdge);
24861
24771
  setLastFace(face);
24862
24772
  setHeadTrackingSatisfied(!!face && !nearBoundary);
24863
24773
  setNumFramesWithoutFaces(face ? 0 : function (n) {
@@ -25338,6 +25248,7 @@
25338
25248
  return n + 1;
25339
25249
  });
25340
25250
  setCaptureState(skipLivenessValidation ? 'CAPTURING_SELFIE' : 'CHECKING_LIVENESS');
25251
+ useVideoSignatureStore.getState().clearRecordedData();
25341
25252
  }, [onRetryClicked, skipLivenessValidation]);
25342
25253
  var onExitSignatureCapture = React.useCallback(function () {
25343
25254
  setAttempt(function (n) {
@@ -25480,6 +25391,9 @@
25480
25391
  props = __rest(_a, ["status", "restartVideoOnSignaturePadCleared", "captureAudio", "component", "showFaceGuideThenSignaturePad"]);
25481
25392
  var Component = component !== null && component !== void 0 ? component : VideoSignatureGuides;
25482
25393
  var onAcceptBtnClicked = React.useCallback(function () {
25394
+ useVideoSignatureStore.setState({
25395
+ acceptClickedAt: performance.now()
25396
+ });
25483
25397
  var signaturePad = useVideoSignatureStore.getState().signaturePad;
25484
25398
  if (!signaturePad.current) throw new Error('Signature pad not found');
25485
25399
  var signatureData = buildSignatureData(signaturePad.current);
@@ -25802,6 +25716,16 @@
25802
25716
  clearRecordedData: function clearRecordedData() {
25803
25717
  clearVideoChunks();
25804
25718
  clearAudioChunks();
25719
+ set({
25720
+ videoUrl: null,
25721
+ audioUrl: null,
25722
+ isRecordingVideo: false,
25723
+ isRecordingAudio: false,
25724
+ videoRecordingStopped: false,
25725
+ audioRecordingStopped: false,
25726
+ videoRecordingIntentionallyStopped: false,
25727
+ audioRecordingIntentionallyStopped: false
25728
+ });
25805
25729
  }
25806
25730
  });
25807
25731
  }));
@@ -26084,10 +26008,10 @@
26084
26008
  var _14 = React.useState(null),
26085
26009
  videoStartsAt = _14[0],
26086
26010
  setVideoStartsAt = _14[1];
26087
- var _15 = React.useContext(SubmissionContext),
26011
+ var _15 = useSubmissionContext(),
26088
26012
  setIdCaptureVideoAudioStartsAt = _15.setIdCaptureVideoAudioStartsAt,
26089
26013
  setExpectedAudioText = _15.setExpectedAudioText;
26090
- var _16 = React.useContext(SelfieGuidanceModelsContext),
26014
+ var _16 = useSelfieGuidanceModelsContext(),
26091
26015
  startSelfieGuidance = _16.start,
26092
26016
  stopSelfieGuidance = _16.stop,
26093
26017
  onSelfiePredictionMade = _16.onPredictionMade,
@@ -26684,6 +26608,7 @@
26684
26608
  return n + 1;
26685
26609
  });
26686
26610
  setCaptureState('CAPTURING_ID');
26611
+ useVideoRecorderStore.getState().clearRecordedData();
26687
26612
  }, []);
26688
26613
  var isCapturingId = !skipIdCapture && ['LOADING', 'CAPTURING_ID'].includes(captureState);
26689
26614
  React.useEffect(function () {
@@ -26718,6 +26643,7 @@
26718
26643
  });
26719
26644
  }, [capturedIdDocumentType, (_b = classNames.idVideoCapture) === null || _b === void 0 ? void 0 : _b.guides, (_c = colors.idVideoCapture) === null || _c === void 0 ? void 0 : _c.guidesSatisfiedColor, (_d = colors.idVideoCapture) === null || _d === void 0 ? void 0 : _d.guidesUnsatisfiedColor, idCaptureGuideImages, (_e = verbiage.idVideoCapture) === null || _e === void 0 ? void 0 : _e.guides]);
26720
26645
  return /*#__PURE__*/React.createElement(CameraStoreProvider, {
26646
+ key: "camera-store-".concat(attempt),
26721
26647
  preferIphoneContinuityCamera: isCapturingId,
26722
26648
  preferFrontFacingCamera: !isCapturingId,
26723
26649
  requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
@@ -26729,6 +26655,7 @@
26729
26655
  classNames: classNames === null || classNames === void 0 ? void 0 : classNames.cameraStoreProvider,
26730
26656
  verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.cameraStoreProvider
26731
26657
  }, /*#__PURE__*/React.createElement(IdCaptureModelsProvider, {
26658
+ key: "id-capture-models-".concat(attempt),
26732
26659
  autoStart: false,
26733
26660
  documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
26734
26661
  focusModelUrl: (_j = (_h = idCaptureProps.assets) === null || _h === void 0 ? void 0 : _h.focusModelUrl) !== null && _j !== void 0 ? _j : '',
@@ -26736,6 +26663,7 @@
26736
26663
  modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs,
26737
26664
  allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
26738
26665
  }, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
26666
+ key: "selfie-guidance-models-".concat(attempt),
26739
26667
  autoStart: false,
26740
26668
  onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
26741
26669
  modelLoadTimeoutMs: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.modelLoadTimeoutMs,
@@ -26745,7 +26673,9 @@
26745
26673
  })), function () {
26746
26674
  switch (captureState) {
26747
26675
  case 'CAPTURING_ID':
26748
- return /*#__PURE__*/React.createElement(IdCaptureStateProvider, null, /*#__PURE__*/React.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React.createElement(IdCaptureWizard, _assign({
26676
+ return /*#__PURE__*/React.createElement(IdCaptureStateProvider, {
26677
+ key: "id-capture-state-".concat(attempt)
26678
+ }, /*#__PURE__*/React.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React.createElement(IdCaptureWizard, _assign({
26749
26679
  key: "id-capture-".concat(attempt),
26750
26680
  loadingOverlayMode: idCaptureLoadingOverlayMode,
26751
26681
  customOverlayContent: customOverlayContent,