idmission-web-sdk 1.0.183 → 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.
@@ -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;
@@ -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.183';
51
+ var webSdkVersion = '1.0.184';
52
52
 
53
53
  function getPlatform() {
54
54
  if (typeof window === 'undefined') return;
@@ -9666,6 +9666,7 @@ var esTranslation = {
9666
9666
  'Upload succeeded!': 'Proceso completo!',
9667
9667
  'Display the front of your ID card...': 'Hay que mostrar el frente de la identificación...',
9668
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...',
9669
9670
  'Please read the following text aloud': 'Hay que leer el siguiente texto en voz alta',
9670
9671
  'Video ID has been successfully captured!': 'Video ID capturado exitosamente!'
9671
9672
  };
@@ -14013,71 +14014,75 @@ var ReadTextPromptTimeRemaining = styled__default['default'].div(templateObject_
14013
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"])));
14014
14015
  var templateObject_1$7, templateObject_2$6, templateObject_3$5, templateObject_4$1, templateObject_5$1, templateObject_6$1;
14015
14016
 
14017
+ var edgeBoundary = 0.05;
14016
14018
  var IdVideoCapture = function IdVideoCapture(_a) {
14017
- 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;
14018
14020
  var onComplete = _a.onComplete,
14019
14021
  onIdFrontImageCaptured = _a.onIdFrontImageCaptured,
14020
14022
  onIdBackImageCaptured = _a.onIdBackImageCaptured,
14021
14023
  onFaceNotDetected = _a.onFaceNotDetected,
14022
- _j = _a.idCardFrontDetectionThreshold,
14023
- idCardFrontDetectionThreshold = _j === void 0 ? 0.6 : _j,
14024
- _k = _a.idCardFrontFocusThreshold,
14025
- idCardFrontFocusThreshold = _k === void 0 ? 0 : _k,
14026
- _l = _a.goodIdCardFrontFramesThreshold,
14027
- goodIdCardFrontFramesThreshold = _l === void 0 ? 3 : _l,
14028
- _m = _a.idCardBackDetectionThreshold,
14029
- idCardBackDetectionThreshold = _m === void 0 ? 0.6 : _m,
14030
- _o = _a.idCardBackFocusThreshold,
14031
- idCardBackFocusThreshold = _o === void 0 ? 0 : _o,
14032
- _p = _a.goodIdCardBackFramesThreshold,
14033
- goodIdCardBackFramesThreshold = _p === void 0 ? 3 : _p,
14034
- _q = _a.skipShowIdCardBack,
14035
- skipShowIdCardBack = _q === void 0 ? false : _q,
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,
14036
14038
  readTextPrompt = _a.readTextPrompt,
14037
- _r = _a.readTextTimeoutDurationMs,
14038
- readTextTimeoutDurationMs = _r === void 0 ? 15000 : _r,
14039
- _s = _a.assets,
14040
- assets = _s === void 0 ? {} : _s,
14041
- _t = _a.classNames,
14042
- classNames = _t === void 0 ? {} : _t,
14043
- _u = _a.colors,
14044
- colors = _u === void 0 ? {} : _u,
14045
- _v = _a.verbiage,
14046
- rawVerbiage = _v === void 0 ? {} : _v,
14047
- _w = _a.debugMode,
14048
- debugMode = _w === void 0 ? false : _w;
14049
- var _x = useResizeObserver__default['default'](),
14050
- ref = _x.ref,
14051
- _y = _x.width,
14052
- width = _y === void 0 ? 1 : _y,
14053
- _z = _x.height,
14054
- height = _z === void 0 ? 1 : _z;
14055
- var _0 = React.useContext(CameraStateContext),
14056
- cameraRef = _0.cameraRef,
14057
- videoRef = _0.videoRef,
14058
- videoLoaded = _0.videoLoaded,
14059
- cameraReady = _0.cameraReady;
14060
- var _1 = React.useState([]),
14061
- detectedObjects = _1[0],
14062
- setDetectedObjects = _1[1];
14063
- var _2 = React.useState([]),
14064
- faces = _2[0],
14065
- setFaces = _2[1];
14066
- var _3 = React.useContext(IdCaptureModelsContext),
14067
- idModelsReady = _3.ready,
14068
- idModelsWorking = _3.working,
14069
- makeIdPrediction = _3.makePrediction,
14070
- onIdPredictionMade = _3.onPredictionMade,
14071
- setThresholds = _3.setThresholds,
14072
- bestFrameDetectionScore = _3.bestFrameDetectionScore,
14073
- bestFrameFocusScore = _3.bestFrameFocusScore,
14074
- resetBestFrame = _3.resetBestFrame;
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;
14075
14080
  var onSelfiePredictionMade = React.useContext(HighPerformanceSelfieGuidanceModelsContext).onPredictionMade;
14076
- var _4 = useVideoRecorder(cameraRef.current),
14077
- isRecording = _4.isRecording,
14078
- startRecording = _4.startRecording,
14079
- stopRecording = _4.stopRecording,
14080
- videoUrl = _4.videoUrl;
14081
+ var _15 = useVideoRecorder(cameraRef.current),
14082
+ isRecording = _15.isRecording,
14083
+ startRecording = _15.startRecording,
14084
+ stopRecording = _15.stopRecording,
14085
+ videoUrl = _15.videoUrl;
14081
14086
  React.useEffect(function () {
14082
14087
  if (!isRecording && !videoUrl) startRecording();
14083
14088
  if (videoUrl) onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl);
@@ -14087,9 +14092,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14087
14092
  React.useEffect(function () {
14088
14093
  shouldCaptureFrames.current = videoLoaded && cameraReady && idModelsReady;
14089
14094
  }, [cameraReady, idModelsReady, videoLoaded]);
14090
- var _5 = React.useState('SHOW_ID_FRONT'),
14091
- requestedAction = _5[0],
14092
- setRequestedAction = _5[1];
14095
+ var _16 = React.useState('SHOW_ID_FRONT'),
14096
+ requestedAction = _16[0],
14097
+ setRequestedAction = _16[1];
14093
14098
  React.useEffect(function () {
14094
14099
  if (requestedAction !== 'SHOW_ID_FRONT' && requestedAction !== 'SHOW_ID_BACK') return;
14095
14100
  if (!idModelsReady || !cameraReady || !videoLoaded) return;
@@ -14117,15 +14122,15 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14117
14122
  }
14118
14123
  });
14119
14124
  }, [idCardBackDetectionThreshold, idCardBackFocusThreshold, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, requestedAction, setThresholds]);
14120
- var _6 = React.useState(0),
14121
- currentDetectionScore = _6[0],
14122
- setCurrentDetectionScore = _6[1];
14123
- var _7 = React.useState(0),
14124
- currentFocusScore = _7[0],
14125
- setCurrentFocusScore = _7[1];
14126
- var _8 = React.useState(0),
14127
- goodFramesCount = _8[0],
14128
- setGoodFramesCount = _8[1];
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];
14129
14134
  var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? goodIdCardFrontFramesThreshold : goodIdCardBackFramesThreshold;
14130
14135
  var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
14131
14136
  React.useEffect(function () {
@@ -14210,17 +14215,25 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14210
14215
  stopRecording();
14211
14216
  }, [stopRecording]);
14212
14217
  var timeoutStartedAt = useTimeout(readTextTimeoutDurationMs, onReadTextTimeout, requestedAction !== 'READ_TEXT', false, requestedAction === 'READ_TEXT').timeoutStartedAt;
14213
- var _9 = React.useState(0),
14214
- numFramesWithoutFaces = _9[0],
14215
- setNumFramesWithoutFaces = _9[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];
14216
14223
  React.useEffect(function () {
14217
14224
  onSelfiePredictionMade(function (faces) {
14218
14225
  setFaces(faces);
14219
14226
  setNumFramesWithoutFaces(function (n) {
14220
14227
  return faces.length === 0 ? n + 1 : 0;
14221
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
+ }
14222
14235
  });
14223
- }, [onSelfiePredictionMade]);
14236
+ }, [frameHeight, frameWidth, onSelfiePredictionMade]);
14224
14237
  React.useEffect(function () {
14225
14238
  if (numFramesWithoutFaces >= 2) {
14226
14239
  onFaceNotDetected === null || onFaceNotDetected === void 0 ? void 0 : onFaceNotDetected();
@@ -14228,17 +14241,21 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14228
14241
  }, [numFramesWithoutFaces, onFaceNotDetected]);
14229
14242
  colors.guidesSatisfiedColor || (colors.guidesSatisfiedColor = 'green');
14230
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;
14231
14248
  var debugScalingDetails = useDebugScalingDetails({
14232
14249
  enabled: debugMode,
14233
14250
  pageWidth: width,
14234
14251
  pageHeight: height,
14235
- videoWidth: (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0,
14236
- 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
14237
14254
  });
14238
- var satisfied = goodFramesCount > 0;
14255
+ var satisfied = goodFramesCount > 0 && faceCentered;
14239
14256
  return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
14240
14257
  ref: ref,
14241
- className: "flex ".concat((_f = classNames.container) !== null && _f !== void 0 ? _f : '')
14258
+ className: "flex ".concat((_k = classNames.container) !== null && _k !== void 0 ? _k : '')
14242
14259
  }, /*#__PURE__*/React__default['default'].createElement(CameraVideoTag, {
14243
14260
  className: classNames.cameraFeed
14244
14261
  }), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
@@ -14255,8 +14272,11 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14255
14272
  verbiage: rawVerbiage.guides,
14256
14273
  requestedAction: requestedAction,
14257
14274
  borderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor
14258
- }), 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, {
14259
- "$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)
14260
14280
  }, detectedObjects.map(function (obj, i) {
14261
14281
  var _a;
14262
14282
  return /*#__PURE__*/React__default['default'].createElement(IdCaptureDetectedObjectDebugBox, {
@@ -14267,7 +14287,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14267
14287
  flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
14268
14288
  });
14269
14289
  })), /*#__PURE__*/React__default['default'].createElement(DebugBoundingBoxOverlay, {
14270
- "$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)
14271
14291
  }, faces.map(function (face, i) {
14272
14292
  var _a;
14273
14293
  return /*#__PURE__*/React__default['default'].createElement(SelfieCaptureFaceDebugBox, {