idmission-web-sdk 1.0.329 → 1.0.331

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.
@@ -46,7 +46,7 @@ export type IdCaptureModelsState = {
46
46
  ready: boolean;
47
47
  modelDownloadProgress: number;
48
48
  working: MutableRefObject<boolean>;
49
- modelError: Error | null;
49
+ idModelError: Error | null;
50
50
  thresholds: IdCaptureThresholds;
51
51
  setThresholds: (value: IdCaptureThresholds) => void;
52
52
  makePrediction: (frame: Frame) => void;
@@ -50,7 +50,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
50
50
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
51
51
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
52
52
 
53
- var webSdkVersion = '1.0.329';
53
+ var webSdkVersion = '1.0.331';
54
54
 
55
55
  function getPlatform() {
56
56
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -8843,6 +8843,7 @@ var HighPerformanceSelfieGuidanceModelsContext = /*#__PURE__*/React.createContex
8843
8843
  error: null,
8844
8844
  modelDownloadProgress: 0
8845
8845
  });
8846
+ var persistentError = null;
8846
8847
  var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfieGuidanceModelsProvider(_a) {
8847
8848
  var _b = _a.autoStart,
8848
8849
  autoStart = _b === void 0 ? true : _b,
@@ -8866,7 +8867,7 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
8866
8867
  var detectorRef = React.useRef(null);
8867
8868
  var rafId = React.useRef(0);
8868
8869
  var loopId = React.useRef(0);
8869
- var _g = React.useState(null),
8870
+ var _g = React.useState(persistentError),
8870
8871
  modelError = _g[0],
8871
8872
  setModelError = _g[1];
8872
8873
  var _h = React.useState(0),
@@ -8888,6 +8889,7 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
8888
8889
  modelLoadTimeout = setTimeout(function () {
8889
8890
  console.log('button_fail', 'HighPerformanceSelfieGuidanceModelsProvider:modelLoadTimeout');
8890
8891
  setModelError(new Error('Model loading time limit exceeded.'));
8892
+ persistentError = new Error('Model loading time limit exceeded.');
8891
8893
  }, modelLoadTimeoutMs);
8892
8894
  _b.label = 1;
8893
8895
  case 1:
@@ -8900,6 +8902,7 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
8900
8902
  case 3:
8901
8903
  e_1 = _b.sent();
8902
8904
  setModelError(e_1);
8905
+ persistentError = e_1;
8903
8906
  return [3 /*break*/, 5];
8904
8907
  case 4:
8905
8908
  clearInterval(modelLoadTimeout);
@@ -8920,7 +8923,7 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
8920
8923
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
8921
8924
  }, [modelError, onModelError]);
8922
8925
  React.useEffect(function () {
8923
- if (!videoLoaded || !cameraReady || !running || !ready) return;
8926
+ if (!videoLoaded || !cameraReady || !running || !ready || modelError || persistentError) return;
8924
8927
  var timer;
8925
8928
  loopId.current += 1;
8926
8929
  var currentLoopId = loopId.current;
@@ -9226,7 +9229,7 @@ var IdCaptureModelsContext = /*#__PURE__*/React.createContext({
9226
9229
  working: {
9227
9230
  current: false
9228
9231
  },
9229
- modelError: null,
9232
+ idModelError: null,
9230
9233
  thresholds: {},
9231
9234
  setThresholds: function setThresholds() {
9232
9235
  return null;
@@ -9465,7 +9468,7 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
9465
9468
  resetBestFrame: resetBestFrame,
9466
9469
  bestFrameDetectionScore: bestFrameDetectionScore,
9467
9470
  bestFrameFocusScore: bestFrameFocusScore,
9468
- modelError: modelError,
9471
+ idModelError: modelError,
9469
9472
  modelDownloadProgress: modelDownloadProgress
9470
9473
  };
9471
9474
  }, [bestFrameDetectionScore, bestFrameFocusScore, detectionTime, focusPredictionTime, getBestFrame, modelError, makePrediction, onPredictionMade, ready, resetBestFrame, setThresholds, thresholds, modelDownloadProgress]);
@@ -13294,7 +13297,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
13294
13297
  setPassportImage = _16.setPassportImage,
13295
13298
  logIdFrontCaptureAttempt = _16.logIdFrontCaptureAttempt,
13296
13299
  logIdBackCaptureAttempt = _16.logIdBackCaptureAttempt;
13297
- var modelError = React.useContext(IdCaptureModelsContext).modelError;
13300
+ var idModelError = React.useContext(IdCaptureModelsContext).idModelError;
13298
13301
  var operationStartedAt = React.useRef();
13299
13302
  React.useEffect(function () {
13300
13303
  dispatch({
@@ -13420,7 +13423,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
13420
13423
  }, 6000);
13421
13424
  }
13422
13425
  }, [dispatch, state.captureState]);
13423
- if (modelError) {
13426
+ if (idModelError) {
13424
13427
  return /*#__PURE__*/React__default['default'].createElement(IdCaptureFallback, {
13425
13428
  idCaptureRequirement: captureRequirement,
13426
13429
  onFinished: onSubmitClick,
@@ -13945,7 +13948,9 @@ var SelfieCapture = function SelfieCapture(_a) {
13945
13948
  var satisfied = state.faceReady;
13946
13949
  if (typeof guidanceSatisfied === 'boolean') satisfied = guidanceSatisfied;
13947
13950
  guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceHoldStillText : state.faceLookingAway ? verbiage.guidanceLookStraightText : state.faceTooClose ? verbiage.guidanceMoveBackText : state.faceTooFar ? verbiage.guidanceMoveForwardText : state.faceNotCentered ? verbiage.guidanceMoveToCenterText : '');
13951
+ console.log('button guidanceError: ', guidanceError);
13948
13952
  if (guidanceError) {
13953
+ console.log('button falling back');
13949
13954
  return /*#__PURE__*/React__default['default'].createElement(SelfieCaptureFallback, {
13950
13955
  classNames: classNames.fallback
13951
13956
  });
@@ -14076,7 +14081,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
14076
14081
  var _j = React.useContext(SubmissionContext),
14077
14082
  checkLiveness = _j.checkLiveness,
14078
14083
  submissionError = _j.submissionError;
14079
- var modelsError = React.useContext(HighPerformanceSelfieGuidanceModelsContext).error;
14084
+ var modelError = React.useContext(HighPerformanceSelfieGuidanceModelsContext).error;
14080
14085
  var _k = React.useReducer(reducer$2, initialState$2),
14081
14086
  state = _k[0],
14082
14087
  dispatch = _k[1];
@@ -14191,12 +14196,13 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
14191
14196
  if (isPassed && state.imageUrl) onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(state.imageUrl);
14192
14197
  }, [onSuccess, state.imageUrl, isPassed]);
14193
14198
  React.useEffect(function () {
14194
- var allowedFailures = modelsError ? 1 : 2;
14199
+ if (modelError) return;
14200
+ var allowedFailures = 2;
14195
14201
  if (state.timesLivenessCheckFailed >= allowedFailures) {
14196
14202
  onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout();
14197
14203
  }
14198
- }, [modelsError, onTimeout, state.timesLivenessCheckFailed]);
14199
- useTimeout(timeoutDurationMs, onTimeout, state.requestState === 'PASSED' || !!modelsError, state.requestState === 'IN_PROGRESS');
14204
+ }, [modelError, onTimeout, state.timesLivenessCheckFailed]);
14205
+ useTimeout(timeoutDurationMs, onTimeout, state.requestState === 'PASSED' || !!modelError, state.requestState === 'IN_PROGRESS');
14200
14206
  var verbiage = useTranslations(rawVerbiage, {
14201
14207
  guidanceRemoveEyeCoveringsText: 'Please remove your eye coverings (sunglasses, eye patch, etc.)...',
14202
14208
  guidanceRemoveHeadCoveringsText: 'Please remove your head coverings (hat, scarf, etc.)...',
@@ -14204,7 +14210,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
14204
14210
  progressPreviewText: 'Processing...'
14205
14211
  });
14206
14212
  var guidanceMessage = state.eyeCoveringDetected ? verbiage.guidanceRemoveEyeCoveringsText : state.headCoveringDetected ? verbiage.guidanceRemoveHeadCoveringsText : state.maskDetected ? verbiage.guidanceRemoveMaskText : undefined;
14207
- if (modelsError) {
14213
+ if (modelError) {
14208
14214
  return /*#__PURE__*/React__default['default'].createElement(SelfieCaptureFallback, {
14209
14215
  onFinished: onFallbackImageCaptured
14210
14216
  });
@@ -16117,23 +16123,25 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16117
16123
  bestFrameDetectionScore = _18.bestFrameDetectionScore,
16118
16124
  bestFrameFocusScore = _18.bestFrameFocusScore,
16119
16125
  resetBestFrame = _18.resetBestFrame,
16120
- modelError = _18.modelError;
16126
+ idModelError = _18.idModelError;
16121
16127
  var _19 = React.useState(null),
16122
16128
  videoStartsAt = _19[0],
16123
16129
  setVideoStartsAt = _19[1];
16124
16130
  var _20 = React.useContext(SubmissionContext),
16125
16131
  setIdCaptureVideoAudioStartsAt = _20.setIdCaptureVideoAudioStartsAt,
16126
16132
  setExpectedAudioText = _20.setExpectedAudioText;
16127
- var onSelfiePredictionMade = React.useContext(HighPerformanceSelfieGuidanceModelsContext).onPredictionMade;
16133
+ var _21 = React.useContext(HighPerformanceSelfieGuidanceModelsContext),
16134
+ onSelfiePredictionMade = _21.onPredictionMade,
16135
+ selfieModelError = _21.error;
16128
16136
  var countdownTimeoutRef = React.useRef(undefined);
16129
- var _21 = React.useState(0),
16130
- countdownRemaining = _21[0],
16131
- setCountdownRemaining = _21[1];
16132
- var _22 = useVideoRecorder(cameraRef.current),
16133
- isRecording = _22.isRecording,
16134
- startRecording = _22.startRecording,
16135
- stopRecording = _22.stopRecording,
16136
- videoUrl = _22.videoUrl;
16137
+ var _22 = React.useState(0),
16138
+ countdownRemaining = _22[0],
16139
+ setCountdownRemaining = _22[1];
16140
+ var _23 = useVideoRecorder(cameraRef.current),
16141
+ isRecording = _23.isRecording,
16142
+ startRecording = _23.startRecording,
16143
+ stopRecording = _23.stopRecording,
16144
+ videoUrl = _23.videoUrl;
16137
16145
  React.useEffect(function () {
16138
16146
  if (!isRecording && !videoUrl) {
16139
16147
  startRecording();
@@ -16147,14 +16155,14 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16147
16155
  var animationFrame = React.useRef(0);
16148
16156
  var shouldCaptureFrames = React.useRef(false);
16149
16157
  React.useEffect(function () {
16150
- shouldCaptureFrames.current = videoLoaded && cameraReady && idModelsReady;
16151
- }, [cameraReady, idModelsReady, videoLoaded]);
16152
- var _23 = React.useState('SHOW_ID_FRONT'),
16153
- requestedAction = _23[0],
16154
- setRequestedAction = _23[1];
16158
+ shouldCaptureFrames.current = videoLoaded && cameraReady && idModelsReady && !idModelError;
16159
+ }, [cameraReady, idModelsReady, videoLoaded, idModelError]);
16160
+ var _24 = React.useState('SHOW_ID_FRONT'),
16161
+ requestedAction = _24[0],
16162
+ setRequestedAction = _24[1];
16155
16163
  React.useEffect(function () {
16156
16164
  if (requestedAction !== 'SHOW_ID_FRONT' && requestedAction !== 'SHOW_ID_BACK') return;
16157
- if (!idCaptureModelsEnabled || !idModelsReady || !cameraReady || !videoLoaded) return;
16165
+ if (!idCaptureModelsEnabled || !idModelsReady || !cameraReady || !videoLoaded || idModelError) return;
16158
16166
  animationFrame.current = requestAnimationFrame(function runFrame() {
16159
16167
  return tslib.__awaiter(this, void 0, void 0, function () {
16160
16168
  return tslib.__generator(this, function (_a) {
@@ -16179,19 +16187,19 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16179
16187
  }
16180
16188
  });
16181
16189
  }, [idCardBackDetectionThreshold, idCardBackFocusThreshold, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, requestedAction, setThresholds]);
16182
- var _24 = React.useState(0),
16183
- currentDetectionScore = _24[0],
16184
- setCurrentDetectionScore = _24[1];
16185
16190
  var _25 = React.useState(0),
16186
- currentFocusScore = _25[0],
16187
- setCurrentFocusScore = _25[1];
16191
+ currentDetectionScore = _25[0],
16192
+ setCurrentDetectionScore = _25[1];
16188
16193
  var _26 = React.useState(0),
16189
- goodFramesCount = _26[0],
16190
- setGoodFramesCount = _26[1];
16194
+ currentFocusScore = _26[0],
16195
+ setCurrentFocusScore = _26[1];
16196
+ var _27 = React.useState(0),
16197
+ goodFramesCount = _27[0],
16198
+ setGoodFramesCount = _27[1];
16191
16199
  var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? goodIdCardFrontFramesThreshold : goodIdCardBackFramesThreshold;
16192
16200
  var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
16193
16201
  React.useEffect(function () {
16194
- if (!idCaptureModelsEnabled) return;
16202
+ if (!idCaptureModelsEnabled || idModelError) return;
16195
16203
  onIdPredictionMade(function (prediction) {
16196
16204
  setDetectedObjects(prediction.detectedObjects);
16197
16205
  setCurrentDetectionScore(prediction.detectionScore);
@@ -16205,9 +16213,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16205
16213
  }
16206
16214
  });
16207
16215
  }, [idCaptureModelsEnabled, idCardFrontDetectionThreshold, onIdPredictionMade]);
16208
- var _27 = React.useState(null),
16209
- idFrontCaptureStartedAt = _27[0],
16210
- setFirstGoodFrameTime = _27[1];
16216
+ var _28 = React.useState(null),
16217
+ idFrontCaptureStartedAt = _28[0],
16218
+ setFirstGoodFrameTime = _28[1];
16211
16219
  React.useEffect(function () {
16212
16220
  if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
16213
16221
  }, [goodFramesCount]);
@@ -16227,9 +16235,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16227
16235
  var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
16228
16236
  var faceBox = (_f = faces === null || faces === void 0 ? void 0 : faces[0]) === null || _f === void 0 ? void 0 : _f.box;
16229
16237
  var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
16230
- var _28 = React.useState(),
16231
- countdownStartedAt = _28[0],
16232
- setCountdownStartedAt = _28[1];
16238
+ var _29 = React.useState(),
16239
+ countdownStartedAt = _29[0],
16240
+ setCountdownStartedAt = _29[1];
16233
16241
  var frameLock = React.useRef(false);
16234
16242
  var captureFrame = React.useCallback(function () {
16235
16243
  return tslib.__awaiter(void 0, void 0, void 0, function () {
@@ -16343,16 +16351,18 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16343
16351
  };
16344
16352
  }, [captureCountdownSeconds, captureFrame, countdownStartedAt]);
16345
16353
  var timeoutStartedAt = useTimeout(readTextTimeoutDurationMs, stopRecording, requestedAction !== 'READ_TEXT', false, requestedAction === 'READ_TEXT').timeoutStartedAt;
16346
- var _29 = React.useState(0),
16347
- numFramesWithoutFaces = _29[0],
16348
- setNumFramesWithoutFaces = _29[1];
16354
+ var _30 = React.useState(0),
16355
+ numFramesWithoutFaces = _30[0],
16356
+ setNumFramesWithoutFaces = _30[1];
16349
16357
  React.useEffect(function () {
16350
- onSelfiePredictionMade(function (faces) {
16351
- setFaces(faces);
16352
- setNumFramesWithoutFaces(function (n) {
16353
- return faces.length === 0 ? n + 1 : 0;
16358
+ if (!selfieModelError) {
16359
+ onSelfiePredictionMade(function (faces) {
16360
+ setFaces(faces);
16361
+ setNumFramesWithoutFaces(function (n) {
16362
+ return faces.length === 0 ? n + 1 : 0;
16363
+ });
16354
16364
  });
16355
- });
16365
+ }
16356
16366
  }, [onSelfiePredictionMade]);
16357
16367
  React.useEffect(function () {
16358
16368
  var ignoreMissingFaces = disableFaceDetectionWhileAudioCapture && (timeoutStartedAt === null || timeoutStartedAt === void 0 ? void 0 : timeoutStartedAt.getTime()) && new Date().getTime() - (timeoutStartedAt === null || timeoutStartedAt === void 0 ? void 0 : timeoutStartedAt.getTime()) > disableFaceDetectionWhileAudioCaptureMsDelay;
@@ -16361,14 +16371,14 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16361
16371
  }
16362
16372
  }, [numFramesWithoutFaces, onFaceNotDetected]);
16363
16373
  var theme = styled.useTheme();
16364
- var _30 = useTranslations(rawVerbiage, {
16374
+ var _31 = useTranslations(rawVerbiage, {
16365
16375
  faceNotCenteredText: 'Please move your face to the center...',
16366
16376
  searchingForIdCardText: 'Searching for ID card...',
16367
16377
  captureBtnText: 'Capture'
16368
16378
  }),
16369
- captureBtnText = _30.captureBtnText,
16370
- faceNotCenteredText = _30.faceNotCenteredText,
16371
- searchingForIdCardText = _30.searchingForIdCardText;
16379
+ captureBtnText = _31.captureBtnText,
16380
+ faceNotCenteredText = _31.faceNotCenteredText,
16381
+ searchingForIdCardText = _31.searchingForIdCardText;
16372
16382
  var debugScalingDetails = useDebugScalingDetails({
16373
16383
  enabled: debugMode,
16374
16384
  pageWidth: width,
@@ -16414,7 +16424,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16414
16424
  face: face,
16415
16425
  scaling: debugScalingDetails
16416
16426
  });
16417
- })))))), guidanceText && idCaptureModelsEnabled && !modelError && ( /*#__PURE__*/React__default['default'].createElement(GuidanceMessageContainer, {
16427
+ })))))), guidanceText && idCaptureModelsEnabled && !idModelError && ( /*#__PURE__*/React__default['default'].createElement(GuidanceMessageContainer, {
16418
16428
  className: classNames.guidanceMessageContainer
16419
16429
  }, /*#__PURE__*/React__default['default'].createElement(GuidanceMessage, {
16420
16430
  className: classNames.guidanceMessage,
@@ -16424,7 +16434,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16424
16434
  className: classNames.countdownContainer
16425
16435
  }, /*#__PURE__*/React__default['default'].createElement(Countdown, {
16426
16436
  className: classNames.countdown
16427
- }, countdownRemaining))), (!idCaptureModelsEnabled || modelError) && capturingId && ( /*#__PURE__*/React__default['default'].createElement(CaptureButtonContainer, {
16437
+ }, countdownRemaining))), (!idCaptureModelsEnabled || idModelError) && capturingId && ( /*#__PURE__*/React__default['default'].createElement(CaptureButtonContainer, {
16428
16438
  className: classNames.captureBtnContainer
16429
16439
  }, /*#__PURE__*/React__default['default'].createElement(CaptureButton, {
16430
16440
  finished: true,