idmission-web-sdk 2.1.6 → 2.1.7

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/sdk2.esm.js CHANGED
@@ -14,7 +14,7 @@ import LanguageDetector from 'i18next-browser-languagedetector';
14
14
  import i18n from 'i18next';
15
15
  import SignatureCanvas from 'react-signature-canvas';
16
16
 
17
- var webSdkVersion = '2.1.6';
17
+ var webSdkVersion = '2.1.7';
18
18
 
19
19
  function getPlatform() {
20
20
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2458,11 +2458,11 @@ function waitForVideoReady(videoRef, checkEveryMs) {
2458
2458
  checkEveryMs = 100;
2459
2459
  }
2460
2460
  return new Promise(function (resolve) {
2461
- var _a;
2462
- if (((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) === 4) return resolve();
2461
+ var _a, _b;
2462
+ if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) return resolve();
2463
2463
  var interval = setInterval(function () {
2464
- var _a;
2465
- if (((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) === 4) {
2464
+ var _a, _b;
2465
+ if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) {
2466
2466
  clearInterval(interval);
2467
2467
  resolve();
2468
2468
  }
@@ -7280,6 +7280,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
7280
7280
  dispatch = _8[1];
7281
7281
  var _9 = useContext(CameraStateContext),
7282
7282
  cameraAccessDenied = _9.cameraAccessDenied,
7283
+ requestCameraAccess = _9.requestCameraAccess,
7283
7284
  releaseCameraAccess = _9.releaseCameraAccess;
7284
7285
  var _10 = useState(false),
7285
7286
  overlayDismissed = _10[0],
@@ -7390,6 +7391,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
7390
7391
  attempt = _13[0],
7391
7392
  setAttempt = _13[1];
7392
7393
  var onExit = useCallback(function () {
7394
+ releaseCameraAccess();
7393
7395
  setOverlayDismissed(false);
7394
7396
  setAttempt(function (n) {
7395
7397
  return n + 1;
@@ -7398,7 +7400,8 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
7398
7400
  type: 'resetWizard'
7399
7401
  });
7400
7402
  onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
7401
- }, [dispatch, onExitCapture]);
7403
+ requestCameraAccess();
7404
+ }, [dispatch, onExitCapture, releaseCameraAccess]);
7402
7405
  useEffect(function () {
7403
7406
  if (submissionStatus !== SubmissionStatus.READY) {
7404
7407
  releaseCameraAccessOnExit && releaseCameraAccess();
@@ -9115,6 +9118,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
9115
9118
  logSelfieCaptureAttempt = _s.logSelfieCaptureAttempt;
9116
9119
  var _t = useContext(CameraStateContext),
9117
9120
  cameraAccessDenied = _t.cameraAccessDenied,
9121
+ requestCameraAccess = _t.requestCameraAccess,
9118
9122
  releaseCameraAccess = _t.releaseCameraAccess;
9119
9123
  var _u = useState(''),
9120
9124
  faceCropImageUrl = _u[0],
@@ -9186,8 +9190,22 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
9186
9190
  return n + 1;
9187
9191
  });
9188
9192
  setCaptureState('LOADING');
9193
+ releaseCameraAccess();
9189
9194
  onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
9190
- }, [onExitCapture]);
9195
+ requestCameraAccess();
9196
+ }, [onExitCapture, releaseCameraAccess, requestCameraAccess]);
9197
+ var onRetryCallback = useCallback(function () {
9198
+ logCaptureMetadata();
9199
+ setAttempt(function (n) {
9200
+ return n + 1;
9201
+ });
9202
+ setRetryCount(function (n) {
9203
+ return n + 1;
9204
+ });
9205
+ setCaptureState('LOADING');
9206
+ releaseCameraAccess();
9207
+ requestCameraAccess();
9208
+ }, [logCaptureMetadata, releaseCameraAccess, requestCameraAccess]);
9191
9209
  var onDoneCallback = useCallback(function () {
9192
9210
  logCaptureMetadata();
9193
9211
  releaseCameraAccessOnExit && releaseCameraAccess();
@@ -9233,10 +9251,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
9233
9251
  colors: colors.success,
9234
9252
  verbiage: verbiage.success,
9235
9253
  onDoneClick: onDoneCallback,
9236
- onRetryClick: function onRetryClick() {
9237
- logCaptureMetadata();
9238
- setCaptureState('CAPTURING');
9239
- }
9254
+ onRetryClick: onRetryCallback
9240
9255
  });
9241
9256
  case 'FAILED':
9242
9257
  return /*#__PURE__*/React__default.createElement(FaceLivenessFailure, {
@@ -9246,13 +9261,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
9246
9261
  colors: colors.failure,
9247
9262
  verbiage: verbiage.failure,
9248
9263
  canRetry: maxRetries > -1 && retryCount < maxRetries,
9249
- onRetryClick: function onRetryClick() {
9250
- logCaptureMetadata();
9251
- setRetryCount(function (c) {
9252
- return c + 1;
9253
- });
9254
- setCaptureState('CAPTURING');
9255
- },
9264
+ onRetryClick: onRetryCallback,
9256
9265
  onExitClick: function onExitClick() {
9257
9266
  releaseCameraAccessOnExit && releaseCameraAccess();
9258
9267
  setTimeout(function () {
@@ -10021,16 +10030,19 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
10021
10030
  setSignatureData = _k.setSignatureData,
10022
10031
  setSignatureVideoUrl = _k.setSignatureVideoUrl,
10023
10032
  logSelfieCaptureAttempt = _k.logSelfieCaptureAttempt;
10024
- var cameraAccessDenied = useContext(CameraStateContext).cameraAccessDenied;
10025
- var _l = useState('LOADING'),
10026
- captureState = _l[0],
10027
- setCaptureState = _l[1];
10033
+ var _l = useContext(CameraStateContext),
10034
+ cameraAccessDenied = _l.cameraAccessDenied,
10035
+ requestCameraAccess = _l.requestCameraAccess,
10036
+ releaseCameraAccess = _l.releaseCameraAccess;
10037
+ var _m = useState('LOADING'),
10038
+ captureState = _m[0],
10039
+ setCaptureState = _m[1];
10028
10040
  var operationStartedAt = useRef();
10029
10041
  var captureStartedAt = useRef();
10030
10042
  var captureEndedAt = useRef();
10031
- var _m = useContext(SelfieGuidanceModelsContext),
10032
- start = _m.start,
10033
- stop = _m.stop;
10043
+ var _o = useContext(SelfieGuidanceModelsContext),
10044
+ start = _o.start,
10045
+ stop = _o.stop;
10034
10046
  useEffect(function () {
10035
10047
  operationStartedAt.current = new Date();
10036
10048
  }, []);
@@ -10087,16 +10099,18 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
10087
10099
  var onSignatureCaptureFacesNotDetected = useCallback(function () {
10088
10100
  setCaptureState('CHECKING_LIVENESS');
10089
10101
  }, []);
10090
- var _o = useState(0),
10091
- attempt = _o[0],
10092
- setAttempt = _o[1];
10102
+ var _p = useState(0),
10103
+ attempt = _p[0],
10104
+ setAttempt = _p[1];
10093
10105
  var onExit = useCallback(function () {
10106
+ releaseCameraAccess();
10094
10107
  setAttempt(function (n) {
10095
10108
  return n + 1;
10096
10109
  });
10097
10110
  setCaptureState('LOADING');
10098
10111
  onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
10099
- }, [onExitCapture]);
10112
+ requestCameraAccess();
10113
+ }, [onExitCapture, releaseCameraAccess, requestCameraAccess]);
10100
10114
  var onRetry = useCallback(function () {
10101
10115
  onRetryClicked === null || onRetryClicked === void 0 ? void 0 : onRetryClicked();
10102
10116
  onExit();
@@ -10471,6 +10485,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
10471
10485
  onIdBackImageCaptured = _a.onIdBackImageCaptured,
10472
10486
  onFaceNotDetected = _a.onFaceNotDetected,
10473
10487
  onRecordingFailed = _a.onRecordingFailed,
10488
+ onExitCapture = _a.onExitCapture,
10474
10489
  _w = _a.idCaptureModelsEnabled,
10475
10490
  idCaptureModelsEnabled = _w === void 0 ? true : _w,
10476
10491
  _x = _a.idCardFrontDelay,
@@ -10851,7 +10866,10 @@ var IdVideoCapture = function IdVideoCapture(_a) {
10851
10866
  },
10852
10867
  disabled: !!countdownStartedAt || frameLock.current,
10853
10868
  className: classNames.captureBtn
10854
- }, captureBtnText))));
10869
+ }, captureBtnText))), /*#__PURE__*/React__default.createElement(ExitCaptureButton, {
10870
+ onClick: onExitCapture,
10871
+ className: classNames.exitCaptureBtn
10872
+ }));
10855
10873
  };
10856
10874
  var CountdownContainer = styled.div(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100dvw;\n height: 100dvh;\n z-index: 99999;\n display: flex;\n"], ["\n position: fixed;\n top: 0;\n left: 0;\n width: 100dvw;\n height: 100dvh;\n z-index: 99999;\n display: flex;\n"])));
10857
10875
  var Countdown = styled.div(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"], ["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"])));
@@ -11104,13 +11122,19 @@ var VideoIdWizard = function VideoIdWizard(_a) {
11104
11122
  });
11105
11123
  setCaptureState('CHECKING_LIVENESS');
11106
11124
  }, []);
11125
+ var handleExitCapture = useCallback(function () {
11126
+ setAttempt(function (n) {
11127
+ return n + 1;
11128
+ });
11129
+ onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
11130
+ }, [onExitCapture]);
11107
11131
  if (submissionStatus === SubmissionStatus.SUBMITTING) {
11108
11132
  return /*#__PURE__*/React__default.createElement(PageContainer, {
11109
11133
  className: "flex"
11110
11134
  }, /*#__PURE__*/React__default.createElement(Spinner, null));
11111
11135
  }
11112
11136
  return /*#__PURE__*/React__default.createElement(CameraProvider, {
11113
- key: isCapturingId ? 'id-camera' : 'selfie-camera',
11137
+ key: "".concat(isCapturingId ? 'id' : 'selfie', "-camera-").concat(attempt),
11114
11138
  preferContinuityCamera: isCapturingId,
11115
11139
  preferFrontFacingCamera: !isCapturingId,
11116
11140
  requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
@@ -11146,7 +11170,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
11146
11170
  colors: colors.idCapture,
11147
11171
  verbiage: verbiage.idCapture,
11148
11172
  onSuccess: onIdCaptureSuccess,
11149
- onExitCapture: onExitCapture,
11173
+ onExitCapture: handleExitCapture,
11150
11174
  onUserCancel: onUserCancel,
11151
11175
  skipSuccessScreen: true,
11152
11176
  releaseCameraAccessOnExit: false,
@@ -11162,7 +11186,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
11162
11186
  silentFallback: silentFallback
11163
11187
  }, faceLivenessProps, {
11164
11188
  onComplete: onFaceCaptureSuccess,
11165
- onExitCapture: onExitCapture,
11189
+ onExitCapture: handleExitCapture,
11166
11190
  onExitAfterFailure: onFaceCaptureExitAfterFailure,
11167
11191
  onUserCancel: onUserCancel,
11168
11192
  skipSuccessScreen: true,
@@ -11182,6 +11206,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
11182
11206
  onIdBackImageCaptured: setIdCaptureVideoIdBackImage,
11183
11207
  onFaceNotDetected: onVideoCaptureFaceNotDetected,
11184
11208
  onRecordingFailed: onRecordingFailed,
11209
+ onExitCapture: handleExitCapture,
11185
11210
  idCaptureModelsEnabled: idCaptureModelsEnabled,
11186
11211
  videoIdCaptureThresholds: videoIdCaptureThresholds,
11187
11212
  skipShowIdCardBack: skipShowIdCardBack,