idmission-web-sdk 1.0.182 → 1.0.184

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.
@@ -89,8 +89,12 @@ export interface VideoIdValidationProps extends PropsWithChildren {
89
89
  idCardFrontFocusThreshold?: number;
90
90
  /** Number of good frames of the ID card front that must be captured before moving on during video capture. */
91
91
  goodIdCardFrontFramesThreshold?: number;
92
- /** The duration of time in milliseconds that the user is instructed to show the back of their ID card during video capture. */
93
- showIdCardBackDurationMs?: number;
92
+ /** Number between 0 and 1 at which document detection guidance score condition is considered to be met for the ID card back during video capture. */
93
+ idCardBackDetectionThreshold?: number;
94
+ /** Number between 0 and 1 at which focus guidance score condition is considered to be met for the ID card back during video capture. */
95
+ idCardBackFocusThreshold?: number;
96
+ /** Number of good frames of the ID card back that must be captured before moving on during video capture. */
97
+ goodIdCardBackFramesThreshold?: number;
94
98
  /** An optional text prompt to display on screen for the user to read during video capture after the ID card has been shown. */
95
99
  readTextPrompt?: CustomerSuppliedVerbiage;
96
100
  /** The duration of time in milliseconds that the user is allowed to spend reading the `readTextPrompt`. */
@@ -20,6 +20,7 @@ export type IdVideoCaptureColors = {
20
20
  export type IdVideoCaptureVerbiage = {
21
21
  guides?: IdVideoCaptureGuidesVerbiage;
22
22
  readTextPrompt?: ReadTextPromptVerbiage;
23
+ faceNotCenteredText?: CustomerSuppliedVerbiage;
23
24
  };
24
25
  export type IdVideoCaptureProps = {
25
26
  onComplete?: (videoUrl: string) => void;
@@ -27,9 +28,11 @@ export type IdVideoCaptureProps = {
27
28
  onIdBackImageCaptured?: (imageUrl: string) => void;
28
29
  onFaceNotDetected?: () => void;
29
30
  idCardFrontDetectionThreshold?: number;
31
+ idCardBackDetectionThreshold?: number;
30
32
  idCardFrontFocusThreshold?: number;
33
+ idCardBackFocusThreshold?: number;
31
34
  goodIdCardFrontFramesThreshold?: number;
32
- showIdCardBackDurationMs?: number;
35
+ goodIdCardBackFramesThreshold?: number;
33
36
  skipShowIdCardBack?: boolean | (() => Promise<boolean>);
34
37
  readTextPrompt?: CustomerSuppliedVerbiage;
35
38
  readTextTimeoutDurationMs?: number;
@@ -39,4 +42,4 @@ export type IdVideoCaptureProps = {
39
42
  verbiage?: IdVideoCaptureVerbiage;
40
43
  debugMode?: boolean;
41
44
  };
42
- export declare const IdVideoCapture: ({ onComplete, onIdFrontImageCaptured, onIdBackImageCaptured, onFaceNotDetected, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, goodIdCardFrontFramesThreshold, showIdCardBackDurationMs, skipShowIdCardBack, readTextPrompt, readTextTimeoutDurationMs, assets, classNames, colors, verbiage: rawVerbiage, debugMode, }: IdVideoCaptureProps) => ReactElement;
45
+ export declare const IdVideoCapture: ({ onComplete, onIdFrontImageCaptured, onIdBackImageCaptured, onFaceNotDetected, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, goodIdCardFrontFramesThreshold, idCardBackDetectionThreshold, idCardBackFocusThreshold, goodIdCardBackFramesThreshold, skipShowIdCardBack, readTextPrompt, readTextTimeoutDurationMs, assets, classNames, colors, verbiage: rawVerbiage, debugMode, }: IdVideoCaptureProps) => ReactElement;
@@ -37,9 +37,11 @@ export type VideoIdWizardProps = {
37
37
  idCaptureProps?: IdCaptureWizardProps;
38
38
  faceLivenessProps?: FaceLivenessWizardProps;
39
39
  idCardFrontDetectionThreshold?: number;
40
+ idCardBackDetectionThreshold?: number;
40
41
  idCardFrontFocusThreshold?: number;
42
+ idCardBackFocusThreshold?: number;
41
43
  goodIdCardFrontFramesThreshold?: number;
42
- showIdCardBackDurationMs?: number;
44
+ goodIdCardBackFramesThreshold?: number;
43
45
  readTextPrompt?: CustomerSuppliedVerbiage;
44
46
  readTextTimeoutDurationMs?: number;
45
47
  skipSuccessScreen?: boolean | (() => Promise<boolean>);
@@ -53,4 +55,4 @@ export type VideoIdWizardProps = {
53
55
  verbiage?: VideoIdWizardVerbiage;
54
56
  debugMode?: boolean;
55
57
  };
56
- export declare const VideoIdWizard: ({ onComplete, onExitCapture, onExitAfterFailure, onUserCancel, idCaptureProps, faceLivenessProps, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, goodIdCardFrontFramesThreshold, showIdCardBackDurationMs, readTextPrompt, readTextTimeoutDurationMs, skipIdCapture, skipShowIdCardBack, skipSuccessScreen, idCaptureGuideType, idCapturePortraitGuidesOnMobile, assets, classNames, colors, verbiage, debugMode, }: VideoIdWizardProps) => ReactElement;
58
+ export declare const VideoIdWizard: ({ onComplete, onExitCapture, onExitAfterFailure, onUserCancel, idCaptureProps, faceLivenessProps, idCardFrontDetectionThreshold, idCardBackDetectionThreshold, idCardFrontFocusThreshold, idCardBackFocusThreshold, goodIdCardFrontFramesThreshold, goodIdCardBackFramesThreshold, readTextPrompt, readTextTimeoutDurationMs, skipIdCapture, skipShowIdCardBack, skipSuccessScreen, idCaptureGuideType, idCapturePortraitGuidesOnMobile, assets, classNames, colors, verbiage, debugMode, }: VideoIdWizardProps) => ReactElement;
@@ -65,6 +65,7 @@ declare const _default: {
65
65
  'Upload succeeded!': string;
66
66
  'Display the front of your ID card...': string;
67
67
  'Display the back of your ID card...': string;
68
+ 'Please move your face to the center...': string;
68
69
  'Please read the following text aloud': string;
69
70
  'Video ID has been successfully captured!': string;
70
71
  };
@@ -73,6 +73,7 @@ export declare const resources: {
73
73
  'Upload succeeded!': string;
74
74
  'Display the front of your ID card...': string;
75
75
  'Display the back of your ID card...': string;
76
+ 'Please move your face to the center...': string;
76
77
  'Please read the following text aloud': string;
77
78
  'Video ID has been successfully captured!': string;
78
79
  };
@@ -48,7 +48,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
48
48
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
49
49
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
50
50
 
51
- var webSdkVersion = '1.0.182';
51
+ var webSdkVersion = '1.0.184';
52
52
 
53
53
  function getPlatform() {
54
54
  if (typeof window === 'undefined') return;
@@ -8853,6 +8853,9 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
8853
8853
  var resetBestFrame = React.useCallback(function () {
8854
8854
  bestFocusScore.current = 0;
8855
8855
  clearCanvas(bestPredictionCanvas.current);
8856
+ setBestFrameBoundingBox([]);
8857
+ setBestFrameDetectionScore(0);
8858
+ setBestFrameFocusScore(0);
8856
8859
  }, []);
8857
8860
  var value = React.useMemo(function () {
8858
8861
  return {
@@ -9658,11 +9661,12 @@ var esTranslation = {
9658
9661
  'Document Capture': 'Captura de documento',
9659
9662
  Capture: 'Capturar',
9660
9663
  'Retry capture': 'Reintentar la captura',
9661
- Upload: 'Adjuntar',
9664
+ Upload: 'Enviar',
9662
9665
  'Uploading...': 'Procesando...',
9663
9666
  'Upload succeeded!': 'Proceso completo!',
9664
9667
  'Display the front of your ID card...': 'Hay que mostrar el frente de la identificación...',
9665
9668
  'Display the back of your ID card...': 'Hay que mostrar el reverso de la identificación...',
9669
+ 'Please move your face to the center...': 'Por favor, hay que mover la cabeza hacia el centro...',
9666
9670
  'Please read the following text aloud': 'Hay que leer el siguiente texto en voz alta',
9667
9671
  'Video ID has been successfully captured!': 'Video ID capturado exitosamente!'
9668
9672
  };
@@ -14010,66 +14014,75 @@ var ReadTextPromptTimeRemaining = styled__default['default'].div(templateObject_
14010
14014
  var DoneButton = styled__default['default'](LoaderButton)(templateObject_6$1 || (templateObject_6$1 = tslib.__makeTemplateObject(["\n margin: auto 0;\n"], ["\n margin: auto 0;\n"])));
14011
14015
  var templateObject_1$7, templateObject_2$6, templateObject_3$5, templateObject_4$1, templateObject_5$1, templateObject_6$1;
14012
14016
 
14017
+ var edgeBoundary = 0.05;
14013
14018
  var IdVideoCapture = function IdVideoCapture(_a) {
14014
- var _b, _c, _d, _e, _f, _g, _h;
14019
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
14015
14020
  var onComplete = _a.onComplete,
14016
14021
  onIdFrontImageCaptured = _a.onIdFrontImageCaptured,
14017
14022
  onIdBackImageCaptured = _a.onIdBackImageCaptured,
14018
14023
  onFaceNotDetected = _a.onFaceNotDetected,
14019
- _j = _a.idCardFrontDetectionThreshold,
14020
- idCardFrontDetectionThreshold = _j === void 0 ? 0.48 : _j,
14021
- _k = _a.idCardFrontFocusThreshold,
14022
- idCardFrontFocusThreshold = _k === void 0 ? 0 : _k,
14023
- _l = _a.goodIdCardFrontFramesThreshold,
14024
- goodIdCardFrontFramesThreshold = _l === void 0 ? 3 : _l,
14025
- _m = _a.showIdCardBackDurationMs,
14026
- showIdCardBackDurationMs = _m === void 0 ? 5000 : _m,
14027
- _o = _a.skipShowIdCardBack,
14028
- skipShowIdCardBack = _o === void 0 ? false : _o,
14024
+ _u = _a.idCardFrontDetectionThreshold,
14025
+ idCardFrontDetectionThreshold = _u === void 0 ? 0.6 : _u,
14026
+ _v = _a.idCardFrontFocusThreshold,
14027
+ idCardFrontFocusThreshold = _v === void 0 ? 0 : _v,
14028
+ _w = _a.goodIdCardFrontFramesThreshold,
14029
+ goodIdCardFrontFramesThreshold = _w === void 0 ? 3 : _w,
14030
+ _x = _a.idCardBackDetectionThreshold,
14031
+ idCardBackDetectionThreshold = _x === void 0 ? 0.6 : _x,
14032
+ _y = _a.idCardBackFocusThreshold,
14033
+ idCardBackFocusThreshold = _y === void 0 ? 0 : _y,
14034
+ _z = _a.goodIdCardBackFramesThreshold,
14035
+ goodIdCardBackFramesThreshold = _z === void 0 ? 3 : _z,
14036
+ _0 = _a.skipShowIdCardBack,
14037
+ skipShowIdCardBack = _0 === void 0 ? false : _0,
14029
14038
  readTextPrompt = _a.readTextPrompt,
14030
- _p = _a.readTextTimeoutDurationMs,
14031
- readTextTimeoutDurationMs = _p === void 0 ? 15000 : _p,
14032
- _q = _a.assets,
14033
- assets = _q === void 0 ? {} : _q,
14034
- _r = _a.classNames,
14035
- classNames = _r === void 0 ? {} : _r,
14036
- _s = _a.colors,
14037
- colors = _s === void 0 ? {} : _s,
14038
- _t = _a.verbiage,
14039
- rawVerbiage = _t === void 0 ? {} : _t,
14040
- _u = _a.debugMode,
14041
- debugMode = _u === void 0 ? false : _u;
14042
- var _v = useResizeObserver__default['default'](),
14043
- ref = _v.ref,
14044
- _w = _v.width,
14045
- width = _w === void 0 ? 1 : _w,
14046
- _x = _v.height,
14047
- height = _x === void 0 ? 1 : _x;
14048
- var _y = React.useContext(CameraStateContext),
14049
- cameraRef = _y.cameraRef,
14050
- videoRef = _y.videoRef,
14051
- videoLoaded = _y.videoLoaded,
14052
- cameraReady = _y.cameraReady;
14053
- var _z = React.useState([]),
14054
- detectedObjects = _z[0],
14055
- setDetectedObjects = _z[1];
14056
- var _0 = React.useState([]),
14057
- faces = _0[0],
14058
- setFaces = _0[1];
14059
- var _1 = React.useContext(IdCaptureModelsContext),
14060
- idModelsReady = _1.ready,
14061
- idModelsWorking = _1.working,
14062
- makeIdPrediction = _1.makePrediction,
14063
- onIdPredictionMade = _1.onPredictionMade,
14064
- setThresholds = _1.setThresholds,
14065
- bestFrameDetectionScore = _1.bestFrameDetectionScore,
14066
- bestFrameFocusScore = _1.bestFrameFocusScore;
14039
+ _1 = _a.readTextTimeoutDurationMs,
14040
+ readTextTimeoutDurationMs = _1 === void 0 ? 15000 : _1,
14041
+ _2 = _a.assets,
14042
+ assets = _2 === void 0 ? {} : _2,
14043
+ _3 = _a.classNames,
14044
+ classNames = _3 === void 0 ? {} : _3,
14045
+ _4 = _a.colors,
14046
+ colors = _4 === void 0 ? {} : _4,
14047
+ _5 = _a.verbiage,
14048
+ rawVerbiage = _5 === void 0 ? {} : _5,
14049
+ _6 = _a.debugMode,
14050
+ debugMode = _6 === void 0 ? false : _6;
14051
+ var _7 = useResizeObserver__default['default'](),
14052
+ ref = _7.ref,
14053
+ _8 = _7.width,
14054
+ width = _8 === void 0 ? 1 : _8,
14055
+ _9 = _7.height,
14056
+ height = _9 === void 0 ? 1 : _9;
14057
+ var _10 = React.useContext(CameraStateContext),
14058
+ cameraRef = _10.cameraRef,
14059
+ videoRef = _10.videoRef,
14060
+ videoLoaded = _10.videoLoaded,
14061
+ cameraReady = _10.cameraReady;
14062
+ var _11 = React.useState([]),
14063
+ detectedObjects = _11[0],
14064
+ setDetectedObjects = _11[1];
14065
+ var _12 = React.useState([]),
14066
+ faces = _12[0],
14067
+ setFaces = _12[1];
14068
+ var _13 = React.useState(true),
14069
+ faceCentered = _13[0],
14070
+ setFaceCentered = _13[1];
14071
+ var _14 = React.useContext(IdCaptureModelsContext),
14072
+ idModelsReady = _14.ready,
14073
+ idModelsWorking = _14.working,
14074
+ makeIdPrediction = _14.makePrediction,
14075
+ onIdPredictionMade = _14.onPredictionMade,
14076
+ setThresholds = _14.setThresholds,
14077
+ bestFrameDetectionScore = _14.bestFrameDetectionScore,
14078
+ bestFrameFocusScore = _14.bestFrameFocusScore,
14079
+ resetBestFrame = _14.resetBestFrame;
14067
14080
  var onSelfiePredictionMade = React.useContext(HighPerformanceSelfieGuidanceModelsContext).onPredictionMade;
14068
- var _2 = useVideoRecorder(cameraRef.current),
14069
- isRecording = _2.isRecording,
14070
- startRecording = _2.startRecording,
14071
- stopRecording = _2.stopRecording,
14072
- videoUrl = _2.videoUrl;
14081
+ var _15 = useVideoRecorder(cameraRef.current),
14082
+ isRecording = _15.isRecording,
14083
+ startRecording = _15.startRecording,
14084
+ stopRecording = _15.stopRecording,
14085
+ videoUrl = _15.videoUrl;
14073
14086
  React.useEffect(function () {
14074
14087
  if (!isRecording && !videoUrl) startRecording();
14075
14088
  if (videoUrl) onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl);
@@ -14079,11 +14092,11 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14079
14092
  React.useEffect(function () {
14080
14093
  shouldCaptureFrames.current = videoLoaded && cameraReady && idModelsReady;
14081
14094
  }, [cameraReady, idModelsReady, videoLoaded]);
14082
- var _3 = React.useState('SHOW_ID_FRONT'),
14083
- requestedAction = _3[0],
14084
- setRequestedAction = _3[1];
14095
+ var _16 = React.useState('SHOW_ID_FRONT'),
14096
+ requestedAction = _16[0],
14097
+ setRequestedAction = _16[1];
14085
14098
  React.useEffect(function () {
14086
- if (requestedAction !== 'SHOW_ID_FRONT') return;
14099
+ if (requestedAction !== 'SHOW_ID_FRONT' && requestedAction !== 'SHOW_ID_BACK') return;
14087
14100
  if (!idModelsReady || !cameraReady || !videoLoaded) return;
14088
14101
  animationFrame.current = requestAnimationFrame(function runFrame() {
14089
14102
  return tslib.__awaiter(this, void 0, void 0, function () {
@@ -14102,23 +14115,24 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14102
14115
  }, [cameraReady, idModelsReady, idModelsWorking, makeIdPrediction, requestedAction, videoLoaded, videoRef]);
14103
14116
  React.useEffect(function () {
14104
14117
  setThresholds({
14105
- document: idCardFrontDetectionThreshold,
14118
+ document: requestedAction === 'SHOW_ID_FRONT' ? idCardFrontDetectionThreshold : requestedAction === 'SHOW_ID_BACK' ? idCardBackDetectionThreshold : 1,
14106
14119
  passport: 1,
14107
14120
  focus: {
14108
- mobile: idCardFrontFocusThreshold
14121
+ mobile: requestedAction === 'SHOW_ID_FRONT' ? idCardFrontFocusThreshold : requestedAction === 'SHOW_ID_BACK' ? idCardBackFocusThreshold : 0
14109
14122
  }
14110
14123
  });
14111
- }, [idCardFrontDetectionThreshold, idCardFrontFocusThreshold, setThresholds]);
14112
- var _4 = React.useState(0),
14113
- currentDetectionScore = _4[0],
14114
- setCurrentDetectionScore = _4[1];
14115
- var _5 = React.useState(0),
14116
- currentFocusScore = _5[0],
14117
- setCurrentFocusScore = _5[1];
14118
- var _6 = React.useState(0),
14119
- goodIdCardFrontFramesCount = _6[0],
14120
- setGoodFramesCount = _6[1];
14121
- var goodFramesThresholdMet = goodIdCardFrontFramesCount >= goodIdCardFrontFramesThreshold;
14124
+ }, [idCardBackDetectionThreshold, idCardBackFocusThreshold, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, requestedAction, setThresholds]);
14125
+ var _17 = React.useState(0),
14126
+ currentDetectionScore = _17[0],
14127
+ setCurrentDetectionScore = _17[1];
14128
+ var _18 = React.useState(0),
14129
+ currentFocusScore = _18[0],
14130
+ setCurrentFocusScore = _18[1];
14131
+ var _19 = React.useState(0),
14132
+ goodFramesCount = _19[0],
14133
+ setGoodFramesCount = _19[1];
14134
+ var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? goodIdCardFrontFramesThreshold : goodIdCardBackFramesThreshold;
14135
+ var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
14122
14136
  React.useEffect(function () {
14123
14137
  onIdPredictionMade(function (prediction) {
14124
14138
  setDetectedObjects(prediction.detectedObjects);
@@ -14151,15 +14165,18 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14151
14165
  React.useEffect(function () {
14152
14166
  (function () {
14153
14167
  return tslib.__awaiter(void 0, void 0, void 0, function () {
14154
- var frame;
14168
+ var frame, frame;
14155
14169
  return tslib.__generator(this, function (_a) {
14156
14170
  switch (_a.label) {
14157
14171
  case 0:
14158
- if (!(goodFramesThresholdMet && requestedAction == 'SHOW_ID_FRONT')) return [3 /*break*/, 4];
14172
+ if (!goodFramesThresholdMet) return [3 /*break*/, 5];
14173
+ setCurrentDetectionScore(0);
14174
+ setCurrentFocusScore(0);
14175
+ setGoodFramesCount(0);
14176
+ resetBestFrame();
14177
+ if (!(requestedAction == 'SHOW_ID_FRONT')) return [3 /*break*/, 4];
14159
14178
  if (onIdFrontImageCaptured) {
14160
- console.log('capturing front frame!');
14161
14179
  frame = captureFrame();
14162
- console.log(frame);
14163
14180
  frame && onIdFrontImageCaptured(frame);
14164
14181
  }
14165
14182
  if (!skipShowIdCardBack) return [3 /*break*/, 3];
@@ -14176,39 +14193,47 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14176
14193
  setRequestedAction('FLIP_ID');
14177
14194
  setTimeout(function () {
14178
14195
  setRequestedAction('SHOW_ID_BACK');
14179
- setTimeout(function () {
14180
- if (onIdBackImageCaptured) {
14181
- console.log('capturing rear frame!');
14182
- var frame = captureFrame();
14183
- console.log(frame);
14184
- frame && onIdBackImageCaptured(frame);
14185
- }
14186
- }, showIdCardBackDurationMs - 1000);
14187
14196
  }, 3500);
14188
- _a.label = 4;
14197
+ return [3 /*break*/, 5];
14189
14198
  case 4:
14199
+ if (requestedAction == 'SHOW_ID_BACK') {
14200
+ if (onIdBackImageCaptured) {
14201
+ frame = captureFrame();
14202
+ frame && onIdBackImageCaptured(frame);
14203
+ }
14204
+ onIdBackCaptureComplete();
14205
+ }
14206
+ _a.label = 5;
14207
+ case 5:
14190
14208
  return [2 /*return*/];
14191
14209
  }
14192
14210
  });
14193
14211
  });
14194
14212
  })();
14195
- }, [captureFrame, goodFramesThresholdMet, onIdBackCaptureComplete, onIdBackImageCaptured, onIdFrontImageCaptured, requestedAction, showIdCardBackDurationMs, skipShowIdCardBack]);
14196
- useTimeout(showIdCardBackDurationMs, onIdBackCaptureComplete, requestedAction !== 'SHOW_ID_BACK', false, requestedAction === 'SHOW_ID_BACK');
14213
+ }, [captureFrame, goodFramesThresholdMet, onIdBackCaptureComplete, onIdBackImageCaptured, onIdFrontImageCaptured, requestedAction, resetBestFrame, skipShowIdCardBack]);
14197
14214
  var onReadTextTimeout = React.useCallback(function () {
14198
14215
  stopRecording();
14199
14216
  }, [stopRecording]);
14200
14217
  var timeoutStartedAt = useTimeout(readTextTimeoutDurationMs, onReadTextTimeout, requestedAction !== 'READ_TEXT', false, requestedAction === 'READ_TEXT').timeoutStartedAt;
14201
- var _7 = React.useState(0),
14202
- numFramesWithoutFaces = _7[0],
14203
- setNumFramesWithoutFaces = _7[1];
14218
+ var frameWidth = (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0;
14219
+ var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
14220
+ var _20 = React.useState(0),
14221
+ numFramesWithoutFaces = _20[0],
14222
+ setNumFramesWithoutFaces = _20[1];
14204
14223
  React.useEffect(function () {
14205
14224
  onSelfiePredictionMade(function (faces) {
14206
14225
  setFaces(faces);
14207
14226
  setNumFramesWithoutFaces(function (n) {
14208
14227
  return faces.length === 0 ? n + 1 : 0;
14209
14228
  });
14229
+ if (faces.length > 0) {
14230
+ var box = faces[0].box;
14231
+ setFaceCentered(box.xMin > frameWidth * edgeBoundary && box.yMin > frameHeight * edgeBoundary && box.xMax < frameWidth * (1 - edgeBoundary) && box.yMax < frameWidth * (1 - edgeBoundary));
14232
+ } else {
14233
+ setFaceCentered(false);
14234
+ }
14210
14235
  });
14211
- }, [onSelfiePredictionMade]);
14236
+ }, [frameHeight, frameWidth, onSelfiePredictionMade]);
14212
14237
  React.useEffect(function () {
14213
14238
  if (numFramesWithoutFaces >= 2) {
14214
14239
  onFaceNotDetected === null || onFaceNotDetected === void 0 ? void 0 : onFaceNotDetected();
@@ -14216,17 +14241,21 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14216
14241
  }, [numFramesWithoutFaces, onFaceNotDetected]);
14217
14242
  colors.guidesSatisfiedColor || (colors.guidesSatisfiedColor = 'green');
14218
14243
  colors.guidesUnsatisfiedColor || (colors.guidesUnsatisfiedColor = 'white');
14244
+ var theme = styled.useTheme();
14245
+ var faceNotCenteredText = useTranslations(rawVerbiage, {
14246
+ faceNotCenteredText: 'Please move your face to the center...'
14247
+ }).faceNotCenteredText;
14219
14248
  var debugScalingDetails = useDebugScalingDetails({
14220
14249
  enabled: debugMode,
14221
14250
  pageWidth: width,
14222
14251
  pageHeight: height,
14223
- videoWidth: (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0,
14224
- videoHeight: (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0
14252
+ videoWidth: (_g = (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.videoWidth) !== null && _g !== void 0 ? _g : 0,
14253
+ videoHeight: (_j = (_h = videoRef.current) === null || _h === void 0 ? void 0 : _h.videoHeight) !== null && _j !== void 0 ? _j : 0
14225
14254
  });
14226
- var satisfied = requestedAction === 'SHOW_ID_BACK' || goodIdCardFrontFramesCount > 0;
14255
+ var satisfied = goodFramesCount > 0 && faceCentered;
14227
14256
  return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
14228
14257
  ref: ref,
14229
- className: "flex ".concat((_f = classNames.container) !== null && _f !== void 0 ? _f : '')
14258
+ className: "flex ".concat((_k = classNames.container) !== null && _k !== void 0 ? _k : '')
14230
14259
  }, /*#__PURE__*/React__default['default'].createElement(CameraVideoTag, {
14231
14260
  className: classNames.cameraFeed
14232
14261
  }), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
@@ -14243,8 +14272,11 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14243
14272
  verbiage: rawVerbiage.guides,
14244
14273
  requestedAction: requestedAction,
14245
14274
  borderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor
14246
- }), debugMode && requestedAction === 'SHOW_ID_FRONT' && ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(ObjectDetectionDebugOverlayDiv, {
14247
- "$flipX": !((_g = cameraRef.current) === null || _g === void 0 ? void 0 : _g.isRearFacing)
14275
+ }), !faceCentered && ( /*#__PURE__*/React__default['default'].createElement(GuidanceMessageContainer, null, /*#__PURE__*/React__default['default'].createElement(GuidanceMessage, {
14276
+ "$background": (_o = (_m = (_l = theme.guidanceMessages) === null || _l === void 0 ? void 0 : _l.negative) === null || _m === void 0 ? void 0 : _m.backgroundColor) !== null && _o !== void 0 ? _o : 'red',
14277
+ "$textColor": (_r = (_q = (_p = theme.guidanceMessages) === null || _p === void 0 ? void 0 : _p.negative) === null || _q === void 0 ? void 0 : _q.textColor) !== null && _r !== void 0 ? _r : 'white'
14278
+ }, faceNotCenteredText))), debugMode && ['SHOW_ID_FRONT', 'SHOW_ID_BACK'].includes(requestedAction) && ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(ObjectDetectionDebugOverlayDiv, {
14279
+ "$flipX": !((_s = cameraRef.current) === null || _s === void 0 ? void 0 : _s.isRearFacing)
14248
14280
  }, detectedObjects.map(function (obj, i) {
14249
14281
  var _a;
14250
14282
  return /*#__PURE__*/React__default['default'].createElement(IdCaptureDetectedObjectDebugBox, {
@@ -14255,7 +14287,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14255
14287
  flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
14256
14288
  });
14257
14289
  })), /*#__PURE__*/React__default['default'].createElement(DebugBoundingBoxOverlay, {
14258
- "$flipX": !((_h = cameraRef.current) === null || _h === void 0 ? void 0 : _h.isRearFacing)
14290
+ "$flipX": !((_t = cameraRef.current) === null || _t === void 0 ? void 0 : _t.isRearFacing)
14259
14291
  }, faces.map(function (face, i) {
14260
14292
  var _a;
14261
14293
  return /*#__PURE__*/React__default['default'].createElement(SelfieCaptureFaceDebugBox, {
@@ -14264,7 +14296,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14264
14296
  scaling: debugScalingDetails,
14265
14297
  flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
14266
14298
  });
14267
- })))))), 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), isRecording ? '✅ Recording' : '❌ Not recording', /*#__PURE__*/React__default['default'].createElement("br", null), goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', goodIdCardFrontFramesCount, "/", goodIdCardFrontFramesThreshold, /*#__PURE__*/React__default['default'].createElement("br", null), "Detection Score: ", currentDetectionScore, /*#__PURE__*/React__default['default'].createElement("br", null), "Focus Score: ", currentFocusScore, /*#__PURE__*/React__default['default'].createElement("br", null), "Best Frame Detection Score: ", bestFrameDetectionScore, /*#__PURE__*/React__default['default'].createElement("br", null), "Best Frame Focus Score: ", bestFrameFocusScore)));
14299
+ })))))), 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), isRecording ? '✅ Recording' : '❌ Not recording', /*#__PURE__*/React__default['default'].createElement("br", null), goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', goodFramesCount, "/", goodFramesThreshold, /*#__PURE__*/React__default['default'].createElement("br", null), "Detection Score: ", currentDetectionScore, /*#__PURE__*/React__default['default'].createElement("br", null), "Focus Score: ", currentFocusScore, /*#__PURE__*/React__default['default'].createElement("br", null), "Best Frame Detection Score: ", bestFrameDetectionScore, /*#__PURE__*/React__default['default'].createElement("br", null), "Best Frame Focus Score: ", bestFrameFocusScore)));
14268
14300
  };
14269
14301
 
14270
14302
  var IdVideoCaptureSuccess = function IdVideoCaptureSuccess(_a) {
@@ -14327,9 +14359,11 @@ var VideoIdWizard = function VideoIdWizard(_a) {
14327
14359
  _g = _a.faceLivenessProps,
14328
14360
  faceLivenessProps = _g === void 0 ? {} : _g,
14329
14361
  idCardFrontDetectionThreshold = _a.idCardFrontDetectionThreshold,
14362
+ idCardBackDetectionThreshold = _a.idCardBackDetectionThreshold,
14330
14363
  idCardFrontFocusThreshold = _a.idCardFrontFocusThreshold,
14364
+ idCardBackFocusThreshold = _a.idCardBackFocusThreshold,
14331
14365
  goodIdCardFrontFramesThreshold = _a.goodIdCardFrontFramesThreshold,
14332
- showIdCardBackDurationMs = _a.showIdCardBackDurationMs,
14366
+ goodIdCardBackFramesThreshold = _a.goodIdCardBackFramesThreshold,
14333
14367
  readTextPrompt = _a.readTextPrompt,
14334
14368
  readTextTimeoutDurationMs = _a.readTextTimeoutDurationMs,
14335
14369
  _h = _a.skipIdCapture,
@@ -14468,9 +14502,11 @@ var VideoIdWizard = function VideoIdWizard(_a) {
14468
14502
  onIdBackImageCaptured: setIdCaptureVideoIdBackImage,
14469
14503
  onFaceNotDetected: onVideoCaptureFaceNotDetected,
14470
14504
  idCardFrontDetectionThreshold: idCardFrontDetectionThreshold,
14505
+ idCardBackDetectionThreshold: idCardBackDetectionThreshold,
14471
14506
  idCardFrontFocusThreshold: idCardFrontFocusThreshold,
14507
+ idCardBackFocusThreshold: idCardBackFocusThreshold,
14472
14508
  goodIdCardFrontFramesThreshold: goodIdCardFrontFramesThreshold,
14473
- showIdCardBackDurationMs: showIdCardBackDurationMs,
14509
+ goodIdCardBackFramesThreshold: goodIdCardBackFramesThreshold,
14474
14510
  skipShowIdCardBack: skipShowIdCardBack,
14475
14511
  readTextPrompt: readTextPrompt,
14476
14512
  readTextTimeoutDurationMs: readTextTimeoutDurationMs,
@@ -16591,48 +16627,52 @@ var VideoIdValidation = function VideoIdValidation(_a) {
16591
16627
  idCaptureProps = _a.idCaptureProps,
16592
16628
  faceLivenessProps = _a.faceLivenessProps,
16593
16629
  _c = _a.idCardFrontDetectionThreshold,
16594
- idCardFrontDetectionThreshold = _c === void 0 ? 0.48 : _c,
16630
+ idCardFrontDetectionThreshold = _c === void 0 ? 0.6 : _c,
16595
16631
  _d = _a.idCardFrontFocusThreshold,
16596
16632
  idCardFrontFocusThreshold = _d === void 0 ? 0 : _d,
16597
16633
  _e = _a.goodIdCardFrontFramesThreshold,
16598
16634
  goodIdCardFrontFramesThreshold = _e === void 0 ? 3 : _e,
16599
- _f = _a.showIdCardBackDurationMs,
16600
- showIdCardBackDurationMs = _f === void 0 ? 5000 : _f,
16635
+ _f = _a.idCardBackDetectionThreshold,
16636
+ idCardBackDetectionThreshold = _f === void 0 ? 0.6 : _f,
16637
+ _g = _a.idCardBackFocusThreshold,
16638
+ idCardBackFocusThreshold = _g === void 0 ? 0 : _g,
16639
+ _h = _a.goodIdCardBackFramesThreshold,
16640
+ goodIdCardBackFramesThreshold = _h === void 0 ? 3 : _h,
16601
16641
  readTextPrompt = _a.readTextPrompt,
16602
- _g = _a.readTextTimeoutDurationMs,
16603
- readTextTimeoutDurationMs = _g === void 0 ? 15000 : _g,
16604
- _h = _a.skipSuccessScreen,
16605
- skipSuccessScreen = _h === void 0 ? false : _h,
16606
- _j = _a.skipIdCapture,
16607
- skipIdCapture = _j === void 0 ? false : _j,
16608
- _k = _a.skipShowIdCardBack,
16609
- skipShowIdCardBack = _k === void 0 ? false : _k,
16610
- _l = _a.idCaptureGuideType,
16611
- idCaptureGuideType = _l === void 0 ? 'fit' : _l,
16612
- _m = _a.idCapturePortraitGuidesOnMobile,
16613
- idCapturePortraitGuidesOnMobile = _m === void 0 ? false : _m,
16614
- _o = _a.theme,
16615
- theme = _o === void 0 ? 'default' : _o,
16616
- _p = _a.assets,
16617
- assets = _p === void 0 ? {} : _p,
16618
- _q = _a.classNames,
16619
- classNames = _q === void 0 ? {} : _q,
16620
- _r = _a.colors,
16621
- colors = _r === void 0 ? {} : _r,
16622
- _s = _a.verbiage,
16623
- verbiage = _s === void 0 ? {} : _s,
16624
- _t = _a.captureSignature,
16625
- captureSignature = _t === void 0 ? false : _t,
16626
- _u = _a.captureSignatureVideo,
16627
- captureSignatureVideo = _u === void 0 ? false : _u,
16628
- _v = _a.captureAdditionalDocuments,
16629
- captureAdditionalDocuments = _v === void 0 ? [] : _v,
16630
- _w = _a.geolocationEnabled,
16631
- geolocationEnabled = _w === void 0 ? true : _w,
16632
- _x = _a.geolocationRequired,
16633
- geolocationRequired = _x === void 0 ? false : _x,
16634
- _y = _a.debugMode,
16635
- debugMode = _y === void 0 ? false : _y;
16642
+ _j = _a.readTextTimeoutDurationMs,
16643
+ readTextTimeoutDurationMs = _j === void 0 ? 15000 : _j,
16644
+ _k = _a.skipSuccessScreen,
16645
+ skipSuccessScreen = _k === void 0 ? false : _k,
16646
+ _l = _a.skipIdCapture,
16647
+ skipIdCapture = _l === void 0 ? false : _l,
16648
+ _m = _a.skipShowIdCardBack,
16649
+ skipShowIdCardBack = _m === void 0 ? false : _m,
16650
+ _o = _a.idCaptureGuideType,
16651
+ idCaptureGuideType = _o === void 0 ? 'fit' : _o,
16652
+ _p = _a.idCapturePortraitGuidesOnMobile,
16653
+ idCapturePortraitGuidesOnMobile = _p === void 0 ? false : _p,
16654
+ _q = _a.theme,
16655
+ theme = _q === void 0 ? 'default' : _q,
16656
+ _r = _a.assets,
16657
+ assets = _r === void 0 ? {} : _r,
16658
+ _s = _a.classNames,
16659
+ classNames = _s === void 0 ? {} : _s,
16660
+ _t = _a.colors,
16661
+ colors = _t === void 0 ? {} : _t,
16662
+ _u = _a.verbiage,
16663
+ verbiage = _u === void 0 ? {} : _u,
16664
+ _v = _a.captureSignature,
16665
+ captureSignature = _v === void 0 ? false : _v,
16666
+ _w = _a.captureSignatureVideo,
16667
+ captureSignatureVideo = _w === void 0 ? false : _w,
16668
+ _x = _a.captureAdditionalDocuments,
16669
+ captureAdditionalDocuments = _x === void 0 ? [] : _x,
16670
+ _y = _a.geolocationEnabled,
16671
+ geolocationEnabled = _y === void 0 ? true : _y,
16672
+ _z = _a.geolocationRequired,
16673
+ geolocationRequired = _z === void 0 ? false : _z,
16674
+ _0 = _a.debugMode,
16675
+ debugMode = _0 === void 0 ? false : _0;
16636
16676
  useLanguage(lang);
16637
16677
  var videoIdCaptureProps = React.useMemo(function () {
16638
16678
  return {
@@ -16641,7 +16681,9 @@ var VideoIdValidation = function VideoIdValidation(_a) {
16641
16681
  idCardFrontDetectionThreshold: idCardFrontDetectionThreshold,
16642
16682
  idCardFrontFocusThreshold: idCardFrontFocusThreshold,
16643
16683
  goodIdCardFrontFramesThreshold: goodIdCardFrontFramesThreshold,
16644
- showIdCardBackDurationMs: showIdCardBackDurationMs,
16684
+ idCardBackDetectionThreshold: idCardBackDetectionThreshold,
16685
+ idCardBackFocusThreshold: idCardBackFocusThreshold,
16686
+ goodIdCardBackFramesThreshold: goodIdCardBackFramesThreshold,
16645
16687
  readTextPrompt: readTextPrompt,
16646
16688
  readTextTimeoutDurationMs: readTextTimeoutDurationMs,
16647
16689
  onExitCapture: onExitCapture,
@@ -16658,7 +16700,7 @@ var VideoIdValidation = function VideoIdValidation(_a) {
16658
16700
  verbiage: verbiage,
16659
16701
  debugMode: debugMode
16660
16702
  };
16661
- }, [assets, classNames, colors, debugMode, faceLivenessProps, goodIdCardFrontFramesThreshold, idCaptureGuideType, idCapturePortraitGuidesOnMobile, idCaptureProps, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, onExitAfterFailure, onExitCapture, onUserCancel, readTextPrompt, readTextTimeoutDurationMs, showIdCardBackDurationMs, skipIdCapture, skipShowIdCardBack, skipSuccessScreen, verbiage]);
16703
+ }, [assets, classNames, colors, debugMode, faceLivenessProps, goodIdCardBackFramesThreshold, goodIdCardFrontFramesThreshold, idCaptureGuideType, idCapturePortraitGuidesOnMobile, idCaptureProps, idCardBackDetectionThreshold, idCardBackFocusThreshold, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, onExitAfterFailure, onExitCapture, onUserCancel, readTextPrompt, readTextTimeoutDurationMs, skipIdCapture, skipShowIdCardBack, skipSuccessScreen, verbiage]);
16662
16704
  var additionalDocumentCaptureProps = React.useMemo(function () {
16663
16705
  return {
16664
16706
  documents: captureAdditionalDocuments,