idmission-web-sdk 2.1.6 → 2.1.8

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.
@@ -19,6 +19,7 @@ export type IdVideoCaptureClassNames = {
19
19
  countdown?: string;
20
20
  captureBtnContainer?: string;
21
21
  captureBtn?: string;
22
+ exitCaptureBtn?: string;
22
23
  };
23
24
  export type IdVideoCaptureColors = {
24
25
  guidesSatisfiedColor?: string;
@@ -47,6 +48,7 @@ export type IdVideoCaptureProps = {
47
48
  onIdBackImageCaptured?: (imageUrl: string) => void;
48
49
  onFaceNotDetected?: () => void;
49
50
  onRecordingFailed?: () => void;
51
+ onExitCapture?: () => void;
50
52
  idCaptureModelsEnabled?: boolean;
51
53
  videoIdCaptureThresholds?: VideoIdCaptureThresholds;
52
54
  idCardFrontDelay?: number;
@@ -64,4 +66,4 @@ export type IdVideoCaptureProps = {
64
66
  verbiage?: IdVideoCaptureVerbiage;
65
67
  debugMode?: boolean;
66
68
  };
67
- export declare const IdVideoCapture: ({ onComplete, onIdFrontImageCaptured, onIdBackImageCaptured, onFaceNotDetected, onRecordingFailed, idCaptureModelsEnabled, idCardFrontDelay, videoIdCaptureThresholds, skipShowIdCardBack, captureCountdownSeconds, readTextPrompt, readTextTimeoutDurationMs, readTextMinReadingMs, disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, mergeAVStreams, assets, classNames, colors, verbiage: rawVerbiage, debugMode, }: IdVideoCaptureProps) => ReactElement;
69
+ export declare const IdVideoCapture: ({ onComplete, onIdFrontImageCaptured, onIdBackImageCaptured, onFaceNotDetected, onRecordingFailed, onExitCapture, idCaptureModelsEnabled, idCardFrontDelay, videoIdCaptureThresholds, skipShowIdCardBack, captureCountdownSeconds, readTextPrompt, readTextTimeoutDurationMs, readTextMinReadingMs, disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, mergeAVStreams, assets, classNames, colors, verbiage: rawVerbiage, debugMode, }: IdVideoCaptureProps) => ReactElement;
@@ -1,5 +1,5 @@
1
1
  import { Frame } from './getFrameDimensions';
2
2
  import { DetectedObjectBox } from '../models/DocumentDetection';
3
3
  import { Face } from '../models/FaceDetection';
4
- export declare function cropToShoulders(rawCanvas: HTMLCanvasElement | null, cropCanvas: HTMLCanvasElement | null, frame: ImageData, face: Face): string;
4
+ export declare function cropToShoulders(rawCanvas: HTMLCanvasElement | null, cropCanvas: HTMLCanvasElement | null, resizeCanvas: HTMLCanvasElement | null, frame: ImageData, face: Face, quality?: number, maxHeight?: number): string;
5
5
  export declare function cropToDetectedObjectBox(frame: Frame, box: DetectedObjectBox, canvas?: HTMLCanvasElement): HTMLCanvasElement;
@@ -49,7 +49,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
49
49
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
50
50
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
51
51
 
52
- var webSdkVersion = '2.1.6';
52
+ var webSdkVersion = '2.1.8';
53
53
 
54
54
  function getPlatform() {
55
55
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2278,39 +2278,15 @@ function preloadVisionRuntime() {
2278
2278
  });
2279
2279
  }
2280
2280
 
2281
- function _isNavigatorDefined() {
2282
- return typeof navigator !== 'undefined' && navigator != null;
2283
- }
2284
- function isMobile(nav) {
2285
- if (nav || _isNavigatorDefined()) {
2286
- if (!nav) {
2287
- nav = navigator;
2288
- }
2289
- if (nav.product === 'ReactNative') {
2290
- return true;
2291
- }
2292
- var a = nav.userAgent || nav.vendor || (
2293
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2294
- // @ts-ignore
2295
- typeof window !== 'undefined' ? window.opera : '');
2296
- if (!a) {
2297
- var navAny = nav;
2298
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2299
- // @ts-ignore
2300
- return navAny.userAgentData && navAny.userAgentData.mobile;
2301
- }
2302
- return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) ||
2303
- // tslint:disable-next-line:max-line-length
2304
- /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
2281
+ function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
2282
+ if (quality === void 0) {
2283
+ quality = 0.92;
2305
2284
  }
2306
- return false;
2307
- }
2308
-
2309
- function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
2310
- if (!rawCanvas || !cropCanvas) return '';
2285
+ if (!rawCanvas || !cropCanvas || !resizeCanvas) return '';
2311
2286
  var rawCtx = rawCanvas.getContext('2d');
2312
2287
  var cropCtx = cropCanvas.getContext('2d');
2313
- if (!rawCtx || !cropCtx) throw new Error('could not get 2d context');
2288
+ var resizeCtx = resizeCanvas.getContext('2d');
2289
+ if (!rawCtx || !cropCtx || !resizeCtx) throw new Error('could not get 2d context');
2314
2290
  rawCanvas.width = frame.width;
2315
2291
  rawCanvas.height = frame.height;
2316
2292
  rawCtx.putImageData(frame, 0, 0);
@@ -2320,7 +2296,7 @@ function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
2320
2296
  var frameHeight = frame.height;
2321
2297
  var xPadding = frameHeight * 0.6 - width;
2322
2298
  var xPos = Math.max(0, xMin - xPadding / 2);
2323
- if (isMobile()) {
2299
+ if (frame.height > frame.width) {
2324
2300
  cropCanvas.width = frame.width;
2325
2301
  cropCanvas.height = frame.height;
2326
2302
  cropCtx.drawImage(rawCanvas, 0, 0, cropCanvas.width, cropCanvas.height);
@@ -2329,9 +2305,14 @@ function cropToShoulders(rawCanvas, cropCanvas, frame, face) {
2329
2305
  cropCanvas.height = frame.height;
2330
2306
  cropCtx.drawImage(rawCanvas, xPos, 0, cropCanvas.width, cropCanvas.height, 0, 0, cropCanvas.width, cropCanvas.height);
2331
2307
  }
2332
- var dataURL = cropCanvas.toDataURL('image/jpeg', 0.92);
2308
+ resizeCanvas.height = maxHeight !== null && maxHeight !== void 0 ? maxHeight : cropCanvas.height;
2309
+ resizeCanvas.width = cropCanvas.width * (resizeCanvas.height / cropCanvas.height);
2310
+ resizeCtx === null || resizeCtx === void 0 ? void 0 : resizeCtx.drawImage(cropCanvas, 0, 0, resizeCanvas.width, resizeCanvas.height);
2311
+ var dataURL = resizeCanvas.toDataURL('image/jpeg', quality);
2312
+ log('cropToShoulders size', new TextEncoder().encode(dataURL).length);
2333
2313
  clearCanvas(rawCanvas);
2334
2314
  clearCanvas(cropCanvas);
2315
+ clearCanvas(resizeCanvas);
2335
2316
  return dataURL;
2336
2317
  }
2337
2318
  function cropToDetectedObjectBox(frame, box, canvas) {
@@ -2493,11 +2474,11 @@ function waitForVideoReady(videoRef, checkEveryMs) {
2493
2474
  checkEveryMs = 100;
2494
2475
  }
2495
2476
  return new Promise(function (resolve) {
2496
- var _a;
2497
- if (((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) === 4) return resolve();
2477
+ var _a, _b;
2478
+ if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) return resolve();
2498
2479
  var interval = setInterval(function () {
2499
- var _a;
2500
- if (((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) === 4) {
2480
+ var _a, _b;
2481
+ if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) {
2501
2482
  clearInterval(interval);
2502
2483
  resolve();
2503
2484
  }
@@ -3664,6 +3645,34 @@ function FocusModelProvider(_a) {
3664
3645
  }), children);
3665
3646
  }
3666
3647
 
3648
+ function _isNavigatorDefined() {
3649
+ return typeof navigator !== 'undefined' && navigator != null;
3650
+ }
3651
+ function isMobile(nav) {
3652
+ if (nav || _isNavigatorDefined()) {
3653
+ if (!nav) {
3654
+ nav = navigator;
3655
+ }
3656
+ if (nav.product === 'ReactNative') {
3657
+ return true;
3658
+ }
3659
+ var a = nav.userAgent || nav.vendor || (
3660
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3661
+ // @ts-ignore
3662
+ typeof window !== 'undefined' ? window.opera : '');
3663
+ if (!a) {
3664
+ var navAny = nav;
3665
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3666
+ // @ts-ignore
3667
+ return navAny.userAgentData && navAny.userAgentData.mobile;
3668
+ }
3669
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) ||
3670
+ // tslint:disable-next-line:max-line-length
3671
+ /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
3672
+ }
3673
+ return false;
3674
+ }
3675
+
3667
3676
  var onMobile = isMobile();
3668
3677
  var defaultIdCaptureThresholds = {
3669
3678
  detection: defaultDocumentDetectionThresholds,
@@ -7315,6 +7324,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
7315
7324
  dispatch = _8[1];
7316
7325
  var _9 = React.useContext(CameraStateContext),
7317
7326
  cameraAccessDenied = _9.cameraAccessDenied,
7327
+ requestCameraAccess = _9.requestCameraAccess,
7318
7328
  releaseCameraAccess = _9.releaseCameraAccess;
7319
7329
  var _10 = React.useState(false),
7320
7330
  overlayDismissed = _10[0],
@@ -7425,6 +7435,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
7425
7435
  attempt = _13[0],
7426
7436
  setAttempt = _13[1];
7427
7437
  var onExit = React.useCallback(function () {
7438
+ releaseCameraAccess();
7428
7439
  setOverlayDismissed(false);
7429
7440
  setAttempt(function (n) {
7430
7441
  return n + 1;
@@ -7433,7 +7444,8 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
7433
7444
  type: 'resetWizard'
7434
7445
  });
7435
7446
  onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
7436
- }, [dispatch, onExitCapture]);
7447
+ requestCameraAccess();
7448
+ }, [dispatch, onExitCapture, releaseCameraAccess]);
7437
7449
  React.useEffect(function () {
7438
7450
  if (submissionStatus !== SubmissionStatus.READY) {
7439
7451
  releaseCameraAccessOnExit && releaseCameraAccess();
@@ -7940,9 +7952,6 @@ var templateObject_1$j, templateObject_2$d, templateObject_3$c, templateObject_4
7940
7952
  var initialState$3 = {
7941
7953
  videoWidth: 0,
7942
7954
  videoHeight: 0,
7943
- capturing: false,
7944
- captured: false,
7945
- captureFailed: false,
7946
7955
  frame: null,
7947
7956
  faces: [],
7948
7957
  faceNotCentered: false,
@@ -7950,36 +7959,12 @@ var initialState$3 = {
7950
7959
  faceTooClose: false,
7951
7960
  faceTooFar: false,
7952
7961
  faceReady: false,
7953
- faceReadyAt: null,
7954
- goodFramesCount: 0,
7955
- goodFramesThreshold: 1,
7956
- goodFramesThresholdMet: false
7962
+ faceReadyAt: null
7957
7963
  };
7958
7964
  var reducer$3 = function reducer(state, action) {
7959
7965
  switch (action.type) {
7960
7966
  case 'configure':
7961
- return tslib.__assign(tslib.__assign({}, state), {
7962
- videoWidth: action.payload.videoWidth,
7963
- videoHeight: action.payload.videoHeight
7964
- });
7965
- case 'capturing':
7966
- return tslib.__assign(tslib.__assign({}, state), {
7967
- capturing: true,
7968
- captured: false,
7969
- captureFailed: false
7970
- });
7971
- case 'captured':
7972
- return tslib.__assign(tslib.__assign({}, state), {
7973
- capturing: false,
7974
- captured: true,
7975
- captureFailed: false
7976
- });
7977
- case 'captureFailed':
7978
- return tslib.__assign(tslib.__assign({}, state), {
7979
- capturing: false,
7980
- captured: false,
7981
- captureFailed: true
7982
- });
7967
+ return tslib.__assign(tslib.__assign({}, state), action.payload);
7983
7968
  case 'facesDetected':
7984
7969
  {
7985
7970
  var faces = action.payload.faces;
@@ -7988,8 +7973,7 @@ var reducer$3 = function reducer(state, action) {
7988
7973
  faceLookingAway = false,
7989
7974
  faceTooClose = false,
7990
7975
  faceTooFar = false,
7991
- faceReadyAt = state.faceReadyAt,
7992
- goodFramesCount = state.goodFramesCount;
7976
+ faceReadyAt = state.faceReadyAt;
7993
7977
  if (face) {
7994
7978
  // calculate centroids
7995
7979
  var vCX = state.videoWidth / 2;
@@ -8015,7 +7999,6 @@ var reducer$3 = function reducer(state, action) {
8015
7999
  var faceReady = !faceNotCentered && !faceLookingAway && !faceTooClose && !faceTooFar;
8016
8000
  if (!faceReady) {
8017
8001
  faceReadyAt = null;
8018
- goodFramesCount = 0;
8019
8002
  } else if (!state.faceReady) {
8020
8003
  faceReadyAt = new Date();
8021
8004
  }
@@ -8026,8 +8009,7 @@ var reducer$3 = function reducer(state, action) {
8026
8009
  faceTooClose: faceTooClose,
8027
8010
  faceTooFar: faceTooFar,
8028
8011
  faceReady: faceReady,
8029
- faceReadyAt: faceReadyAt,
8030
- goodFramesCount: goodFramesCount
8012
+ faceReadyAt: faceReadyAt
8031
8013
  });
8032
8014
  }
8033
8015
  }
@@ -8079,16 +8061,14 @@ var SelfieCapture = function SelfieCapture(_a) {
8079
8061
  });
8080
8062
  }
8081
8063
  }, [cameraReady, videoRef]);
8082
- React.useEffect(function () {
8083
- onPredictionMade(function (prediction) {
8084
- dispatch({
8085
- type: 'facesDetected',
8086
- payload: {
8087
- faces: prediction
8088
- }
8089
- });
8064
+ onPredictionMade(useDebounce.useThrottledCallback(function (prediction) {
8065
+ dispatch({
8066
+ type: 'facesDetected',
8067
+ payload: {
8068
+ faces: prediction
8069
+ }
8090
8070
  });
8091
- }, [onPredictionMade]);
8071
+ }, 16));
8092
8072
  var _p = React.useState(false),
8093
8073
  captureReady = _p[0],
8094
8074
  setCaptureReady = _p[1];
@@ -8107,22 +8087,14 @@ var SelfieCapture = function SelfieCapture(_a) {
8107
8087
  };
8108
8088
  }, [onGuidanceNotSatisfied, onGuidanceSatisfied, state.faceReady]);
8109
8089
  React.useEffect(function () {
8110
- (function () {
8111
- return tslib.__awaiter(void 0, void 0, void 0, function () {
8112
- var ctx, imageData;
8113
- return tslib.__generator(this, function (_a) {
8114
- if (captureReady && videoRef.current && lastPredictionCanvas.current && state.faces.length > 0) {
8115
- drawToCanvas(lastPredictionCanvas.current, videoRef.current);
8116
- ctx = lastPredictionCanvas.current.getContext('2d');
8117
- if (!ctx) return [2 /*return*/];
8118
- imageData = ctx.getImageData(0, 0, videoRef.current.videoWidth, videoRef.current.videoHeight);
8119
- onSelfieCaptured === null || onSelfieCaptured === void 0 ? void 0 : onSelfieCaptured(imageData, state.faces[0]);
8120
- clearCanvas(lastPredictionCanvas.current);
8121
- }
8122
- return [2 /*return*/];
8123
- });
8124
- });
8125
- })();
8090
+ if (captureReady && videoRef.current && lastPredictionCanvas.current && state.faces.length > 0) {
8091
+ drawToCanvas(lastPredictionCanvas.current, videoRef.current);
8092
+ var ctx = lastPredictionCanvas.current.getContext('2d');
8093
+ if (!ctx) return;
8094
+ var imageData = ctx.getImageData(0, 0, videoRef.current.videoWidth, videoRef.current.videoHeight);
8095
+ onSelfieCaptured === null || onSelfieCaptured === void 0 ? void 0 : onSelfieCaptured(imageData, state.faces[0]);
8096
+ clearCanvas(lastPredictionCanvas.current);
8097
+ }
8126
8098
  }, [captureReady, onSelfieCaptured, state.faces, videoRef]);
8127
8099
  var _q = useTimeout(timeoutDurationMs, onTimeout),
8128
8100
  timedOut = _q.timedOut,
@@ -8171,7 +8143,7 @@ var SelfieCapture = function SelfieCapture(_a) {
8171
8143
  scaling: debugScalingDetails,
8172
8144
  color: satisfied ? 'green' : 'red'
8173
8145
  });
8174
- }))), debugMode && ( /*#__PURE__*/React__default['default'].createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default['default'].createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " ", state.goodFramesCount, ' ', "Good Frames", /*#__PURE__*/React__default['default'].createElement("br", null), !timedOut ? '✅' : '❌', " Time Remaining:", ' ', Math.max(0, timeoutDurationMs - (new Date().getTime() - (timeoutStartedAt !== null && timeoutStartedAt !== void 0 ? timeoutStartedAt : new Date()).getTime())), "ms")), /*#__PURE__*/React__default['default'].createElement(ExitCaptureButton, {
8146
+ }))), debugMode && ( /*#__PURE__*/React__default['default'].createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default['default'].createElement("br", null), !timedOut ? '✅' : '❌', " Time Remaining:", ' ', Math.max(0, timeoutDurationMs - (new Date().getTime() - (timeoutStartedAt !== null && timeoutStartedAt !== void 0 ? timeoutStartedAt : new Date()).getTime())), "ms")), /*#__PURE__*/React__default['default'].createElement(ExitCaptureButton, {
8175
8147
  onClick: onExit,
8176
8148
  className: classNames.exitCaptureBtn
8177
8149
  }));
@@ -8291,6 +8263,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
8291
8263
  setImageUrl = _m[1];
8292
8264
  var rawCanvas = React.useRef(null);
8293
8265
  var cropCanvas = React.useRef(null);
8266
+ var resizeCanvas = React.useRef(null);
8294
8267
  var theme = styled.useTheme();
8295
8268
  var onSelfieCaptured = React.useCallback(function (frame, face) {
8296
8269
  onCapture === null || onCapture === void 0 ? void 0 : onCapture();
@@ -8319,7 +8292,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
8319
8292
  switch (_b.label) {
8320
8293
  case 0:
8321
8294
  _b.trys.push([0, 3,, 4]);
8322
- imageUrl_1 = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
8295
+ imageUrl_1 = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face, 0.92, 500);
8323
8296
  setImageUrl(imageUrl_1);
8324
8297
  _a = checkLiveness;
8325
8298
  return [4 /*yield*/, dataUrlToBase64(imageUrl_1)];
@@ -8432,6 +8405,8 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
8432
8405
  ref: rawCanvas
8433
8406
  }), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
8434
8407
  ref: cropCanvas
8408
+ }), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
8409
+ ref: resizeCanvas
8435
8410
  }), /*#__PURE__*/React__default['default'].createElement(SelfieCapture, {
8436
8411
  onSelfieCaptured: onSelfieCaptured,
8437
8412
  onExit: onExit,
@@ -9150,6 +9125,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
9150
9125
  logSelfieCaptureAttempt = _s.logSelfieCaptureAttempt;
9151
9126
  var _t = React.useContext(CameraStateContext),
9152
9127
  cameraAccessDenied = _t.cameraAccessDenied,
9128
+ requestCameraAccess = _t.requestCameraAccess,
9153
9129
  releaseCameraAccess = _t.releaseCameraAccess;
9154
9130
  var _u = React.useState(''),
9155
9131
  faceCropImageUrl = _u[0],
@@ -9221,8 +9197,22 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
9221
9197
  return n + 1;
9222
9198
  });
9223
9199
  setCaptureState('LOADING');
9200
+ releaseCameraAccess();
9224
9201
  onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
9225
- }, [onExitCapture]);
9202
+ requestCameraAccess();
9203
+ }, [onExitCapture, releaseCameraAccess, requestCameraAccess]);
9204
+ var onRetryCallback = React.useCallback(function () {
9205
+ logCaptureMetadata();
9206
+ setAttempt(function (n) {
9207
+ return n + 1;
9208
+ });
9209
+ setRetryCount(function (n) {
9210
+ return n + 1;
9211
+ });
9212
+ setCaptureState('LOADING');
9213
+ releaseCameraAccess();
9214
+ requestCameraAccess();
9215
+ }, [logCaptureMetadata, releaseCameraAccess, requestCameraAccess]);
9226
9216
  var onDoneCallback = React.useCallback(function () {
9227
9217
  logCaptureMetadata();
9228
9218
  releaseCameraAccessOnExit && releaseCameraAccess();
@@ -9268,10 +9258,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
9268
9258
  colors: colors.success,
9269
9259
  verbiage: verbiage.success,
9270
9260
  onDoneClick: onDoneCallback,
9271
- onRetryClick: function onRetryClick() {
9272
- logCaptureMetadata();
9273
- setCaptureState('CAPTURING');
9274
- }
9261
+ onRetryClick: onRetryCallback
9275
9262
  });
9276
9263
  case 'FAILED':
9277
9264
  return /*#__PURE__*/React__default['default'].createElement(FaceLivenessFailure, {
@@ -9281,13 +9268,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
9281
9268
  colors: colors.failure,
9282
9269
  verbiage: verbiage.failure,
9283
9270
  canRetry: maxRetries > -1 && retryCount < maxRetries,
9284
- onRetryClick: function onRetryClick() {
9285
- logCaptureMetadata();
9286
- setRetryCount(function (c) {
9287
- return c + 1;
9288
- });
9289
- setCaptureState('CAPTURING');
9290
- },
9271
+ onRetryClick: onRetryCallback,
9291
9272
  onExitClick: function onExitClick() {
9292
9273
  releaseCameraAccessOnExit && releaseCameraAccess();
9293
9274
  setTimeout(function () {
@@ -10056,16 +10037,19 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
10056
10037
  setSignatureData = _k.setSignatureData,
10057
10038
  setSignatureVideoUrl = _k.setSignatureVideoUrl,
10058
10039
  logSelfieCaptureAttempt = _k.logSelfieCaptureAttempt;
10059
- var cameraAccessDenied = React.useContext(CameraStateContext).cameraAccessDenied;
10060
- var _l = React.useState('LOADING'),
10061
- captureState = _l[0],
10062
- setCaptureState = _l[1];
10040
+ var _l = React.useContext(CameraStateContext),
10041
+ cameraAccessDenied = _l.cameraAccessDenied,
10042
+ requestCameraAccess = _l.requestCameraAccess,
10043
+ releaseCameraAccess = _l.releaseCameraAccess;
10044
+ var _m = React.useState('LOADING'),
10045
+ captureState = _m[0],
10046
+ setCaptureState = _m[1];
10063
10047
  var operationStartedAt = React.useRef();
10064
10048
  var captureStartedAt = React.useRef();
10065
10049
  var captureEndedAt = React.useRef();
10066
- var _m = React.useContext(SelfieGuidanceModelsContext),
10067
- start = _m.start,
10068
- stop = _m.stop;
10050
+ var _o = React.useContext(SelfieGuidanceModelsContext),
10051
+ start = _o.start,
10052
+ stop = _o.stop;
10069
10053
  React.useEffect(function () {
10070
10054
  operationStartedAt.current = new Date();
10071
10055
  }, []);
@@ -10122,16 +10106,18 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
10122
10106
  var onSignatureCaptureFacesNotDetected = React.useCallback(function () {
10123
10107
  setCaptureState('CHECKING_LIVENESS');
10124
10108
  }, []);
10125
- var _o = React.useState(0),
10126
- attempt = _o[0],
10127
- setAttempt = _o[1];
10109
+ var _p = React.useState(0),
10110
+ attempt = _p[0],
10111
+ setAttempt = _p[1];
10128
10112
  var onExit = React.useCallback(function () {
10113
+ releaseCameraAccess();
10129
10114
  setAttempt(function (n) {
10130
10115
  return n + 1;
10131
10116
  });
10132
10117
  setCaptureState('LOADING');
10133
10118
  onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
10134
- }, [onExitCapture]);
10119
+ requestCameraAccess();
10120
+ }, [onExitCapture, releaseCameraAccess, requestCameraAccess]);
10135
10121
  var onRetry = React.useCallback(function () {
10136
10122
  onRetryClicked === null || onRetryClicked === void 0 ? void 0 : onRetryClicked();
10137
10123
  onExit();
@@ -10506,6 +10492,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
10506
10492
  onIdBackImageCaptured = _a.onIdBackImageCaptured,
10507
10493
  onFaceNotDetected = _a.onFaceNotDetected,
10508
10494
  onRecordingFailed = _a.onRecordingFailed,
10495
+ onExitCapture = _a.onExitCapture,
10509
10496
  _w = _a.idCaptureModelsEnabled,
10510
10497
  idCaptureModelsEnabled = _w === void 0 ? true : _w,
10511
10498
  _x = _a.idCardFrontDelay,
@@ -10886,7 +10873,10 @@ var IdVideoCapture = function IdVideoCapture(_a) {
10886
10873
  },
10887
10874
  disabled: !!countdownStartedAt || frameLock.current,
10888
10875
  className: classNames.captureBtn
10889
- }, captureBtnText))));
10876
+ }, captureBtnText))), /*#__PURE__*/React__default['default'].createElement(ExitCaptureButton, {
10877
+ onClick: onExitCapture,
10878
+ className: classNames.exitCaptureBtn
10879
+ }));
10890
10880
  };
10891
10881
  var CountdownContainer = styled__default['default'].div(templateObject_1$5 || (templateObject_1$5 = tslib.__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"])));
10892
10882
  var Countdown = styled__default['default'].div(templateObject_2$5 || (templateObject_2$5 = tslib.__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"])));
@@ -11139,13 +11129,19 @@ var VideoIdWizard = function VideoIdWizard(_a) {
11139
11129
  });
11140
11130
  setCaptureState('CHECKING_LIVENESS');
11141
11131
  }, []);
11132
+ var handleExitCapture = React.useCallback(function () {
11133
+ setAttempt(function (n) {
11134
+ return n + 1;
11135
+ });
11136
+ onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
11137
+ }, [onExitCapture]);
11142
11138
  if (submissionStatus === SubmissionStatus.SUBMITTING) {
11143
11139
  return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
11144
11140
  className: "flex"
11145
11141
  }, /*#__PURE__*/React__default['default'].createElement(Spinner, null));
11146
11142
  }
11147
11143
  return /*#__PURE__*/React__default['default'].createElement(CameraProvider, {
11148
- key: isCapturingId ? 'id-camera' : 'selfie-camera',
11144
+ key: "".concat(isCapturingId ? 'id' : 'selfie', "-camera-").concat(attempt),
11149
11145
  preferContinuityCamera: isCapturingId,
11150
11146
  preferFrontFacingCamera: !isCapturingId,
11151
11147
  requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
@@ -11181,7 +11177,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
11181
11177
  colors: colors.idCapture,
11182
11178
  verbiage: verbiage.idCapture,
11183
11179
  onSuccess: onIdCaptureSuccess,
11184
- onExitCapture: onExitCapture,
11180
+ onExitCapture: handleExitCapture,
11185
11181
  onUserCancel: onUserCancel,
11186
11182
  skipSuccessScreen: true,
11187
11183
  releaseCameraAccessOnExit: false,
@@ -11197,7 +11193,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
11197
11193
  silentFallback: silentFallback
11198
11194
  }, faceLivenessProps, {
11199
11195
  onComplete: onFaceCaptureSuccess,
11200
- onExitCapture: onExitCapture,
11196
+ onExitCapture: handleExitCapture,
11201
11197
  onExitAfterFailure: onFaceCaptureExitAfterFailure,
11202
11198
  onUserCancel: onUserCancel,
11203
11199
  skipSuccessScreen: true,
@@ -11217,6 +11213,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
11217
11213
  onIdBackImageCaptured: setIdCaptureVideoIdBackImage,
11218
11214
  onFaceNotDetected: onVideoCaptureFaceNotDetected,
11219
11215
  onRecordingFailed: onRecordingFailed,
11216
+ onExitCapture: handleExitCapture,
11220
11217
  idCaptureModelsEnabled: idCaptureModelsEnabled,
11221
11218
  videoIdCaptureThresholds: videoIdCaptureThresholds,
11222
11219
  skipShowIdCardBack: skipShowIdCardBack,
@@ -12504,6 +12501,7 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
12504
12501
  setImageUrl = _k[1];
12505
12502
  var rawCanvas = React.useRef(null);
12506
12503
  var cropCanvas = React.useRef(null);
12504
+ var resizeCanvas = React.useRef(null);
12507
12505
  var onSelfieCaptured = React.useCallback(function (frame, face) {
12508
12506
  dispatch({
12509
12507
  type: 'verificationReady',
@@ -12516,7 +12514,7 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
12516
12514
  var isReady = state.requestState === 'CAPTURED';
12517
12515
  React.useEffect(function () {
12518
12516
  if (!frame || !face || submissionError) return;
12519
- var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
12517
+ var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face);
12520
12518
  setImageUrl(imageUrl);
12521
12519
  dataUrlToBase64(imageUrl).then(function (img) {
12522
12520
  setSelfieImage(img);
@@ -12579,6 +12577,8 @@ var CustomerVerificationCapture = function CustomerVerificationCapture(_a) {
12579
12577
  ref: rawCanvas
12580
12578
  }), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
12581
12579
  ref: cropCanvas
12580
+ }), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
12581
+ ref: resizeCanvas
12582
12582
  }), /*#__PURE__*/React__default['default'].createElement(SelfieCapture, {
12583
12583
  onSelfieCaptured: onSelfieCaptured,
12584
12584
  onExit: onExit,
@@ -13057,6 +13057,7 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
13057
13057
  setImageUrl = _k[1];
13058
13058
  var rawCanvas = React.useRef(null);
13059
13059
  var cropCanvas = React.useRef(null);
13060
+ var resizeCanvas = React.useRef(null);
13060
13061
  var onSelfieCaptured = React.useCallback(function (frame, face) {
13061
13062
  dispatch({
13062
13063
  type: 'identificationReady',
@@ -13071,7 +13072,7 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
13071
13072
  var isReady = state.requestState === 'CAPTURED';
13072
13073
  React.useEffect(function () {
13073
13074
  if (!frame || !face || submissionError) return;
13074
- var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, frame, face);
13075
+ var imageUrl = cropToShoulders(rawCanvas.current, cropCanvas.current, resizeCanvas.current, frame, face);
13075
13076
  setImageUrl(imageUrl);
13076
13077
  dataUrlToBase64(imageUrl).then(function (img) {
13077
13078
  setSelfieImage(img);
@@ -13134,6 +13135,8 @@ var CustomerIdentificationCapture = function CustomerIdentificationCapture(_a) {
13134
13135
  ref: rawCanvas
13135
13136
  }), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
13136
13137
  ref: cropCanvas
13138
+ }), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
13139
+ ref: resizeCanvas
13137
13140
  }), /*#__PURE__*/React__default['default'].createElement(SelfieCapture, {
13138
13141
  onSelfieCaptured: onSelfieCaptured,
13139
13142
  onExit: onExit,