idmission-web-sdk 1.0.343 → 1.0.345

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.
@@ -2,7 +2,7 @@ import { ReactElement } from 'react';
2
2
  import { SelfieCaptureClassNames, SelfieCaptureColors, SelfieCaptureVerbiage } from '../selfie_capture/SelfieCapture';
3
3
  import { SelfieProgressPreviewClassNames } from '../common/SelfieProgressPreview';
4
4
  import { CustomerSuppliedVerbiage } from '../../lib/locales';
5
- import { SelfieCaptureLoadingOverlayProps } from "../selfie_capture/SelfieCaptureLoadingOverlay";
5
+ import { SelfieCaptureLoadingOverlayProps } from '../selfie_capture/SelfieCaptureLoadingOverlay';
6
6
  export type FaceLivenessCaptureClassNames = SelfieCaptureClassNames & {
7
7
  imagePreview?: SelfieProgressPreviewClassNames;
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { CustomerSuppliedVerbiage } from '../../lib/locales';
3
3
  import { LoaderButtonColors } from '../common/LoaderButton';
4
- import { SelfieCaptureLoadingOverlayProps } from "../selfie_capture/SelfieCaptureLoadingOverlay";
4
+ import { SelfieCaptureLoadingOverlayProps } from '../selfie_capture/SelfieCaptureLoadingOverlay';
5
5
  export type SelfieCaptureFallbackClassNames = {
6
6
  container?: string;
7
7
  inner?: string;
@@ -33,4 +33,4 @@ export type SelfieCaptureFallbackProps = {
33
33
  silentFallback?: boolean;
34
34
  selfieCaptureLoadingOverlayProps?: SelfieCaptureLoadingOverlayProps;
35
35
  };
36
- export declare const SelfieCaptureFallback: ({ onFinished, onCapture, classNames, colors, verbiage: rawVerbiage, silentFallback, selfieCaptureLoadingOverlayProps: overlayProps }: SelfieCaptureFallbackProps) => ReactElement;
36
+ export declare const SelfieCaptureFallback: ({ onFinished, onCapture, classNames, colors, verbiage: rawVerbiage, silentFallback, selfieCaptureLoadingOverlayProps: overlayProps, }: SelfieCaptureFallbackProps) => ReactElement;
@@ -50,7 +50,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
50
50
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
51
51
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
52
52
 
53
- var webSdkVersion = '1.0.343';
53
+ var webSdkVersion = '1.0.345';
54
54
 
55
55
  function getPlatform() {
56
56
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -14159,12 +14159,9 @@ var SelfieCaptureFallback = function SelfieCaptureFallback(_a) {
14159
14159
  var _j = React.useState(false),
14160
14160
  usingDocumentCapture = _j[0],
14161
14161
  setUsingDocumentCapture = _j[1];
14162
- var _k = React.useState(silentFallback),
14163
- useFallback = _k[0],
14164
- setUseFallback = _k[1];
14165
- var _l = React.useState(1),
14166
- selfieKey = _l[0],
14167
- setSelfieKey = _l[1];
14162
+ var _k = React.useState(1),
14163
+ selfieKey = _k[0],
14164
+ setSelfieKey = _k[1];
14168
14165
  var verbiage = useTranslations(rawVerbiage, {
14169
14166
  headingText: "We're having some trouble.",
14170
14167
  descriptionText: silentFallback ? 'Use your device camera to capture your face' : 'On-device capture guidance failed, please capture a selfie manually.',
@@ -14174,7 +14171,7 @@ var SelfieCaptureFallback = function SelfieCaptureFallback(_a) {
14174
14171
  });
14175
14172
  React.useEffect(function () {
14176
14173
  var fallbackTimeout;
14177
- if (useFallback) {
14174
+ if (silentFallback) {
14178
14175
  fallbackTimeout = setTimeout(function () {
14179
14176
  var _a;
14180
14177
  // using the input element, we want to click on it "immediately" which is 250ms to allow for even old browsers to finish connecting the input
@@ -14188,7 +14185,7 @@ var SelfieCaptureFallback = function SelfieCaptureFallback(_a) {
14188
14185
  return function () {
14189
14186
  clearTimeout(fallbackTimeout);
14190
14187
  };
14191
- }, [useFallback]);
14188
+ }, [silentFallback]);
14192
14189
  var onFileSelected = function onFileSelected(e) {
14193
14190
  var _a;
14194
14191
  var file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
@@ -14212,12 +14209,12 @@ var SelfieCaptureFallback = function SelfieCaptureFallback(_a) {
14212
14209
  onDocumentCaptured: function onDocumentCaptured(document) {
14213
14210
  var imageData = document.contentUrl;
14214
14211
  setImage(imageData);
14215
- setUseFallback(false);
14216
14212
  setUsingDocumentCapture(false);
14217
14213
  onCapture === null || onCapture === void 0 ? void 0 : onCapture(imageData);
14218
14214
  }
14219
14215
  });
14220
14216
  }
14217
+ // todo: we might be able to use the media stream instead if we clone it - as it stands today, we hae to use the camera to support iOS 16 devices
14221
14218
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("input", {
14222
14219
  ref: fileInput,
14223
14220
  type: "file",
@@ -14225,7 +14222,7 @@ var SelfieCaptureFallback = function SelfieCaptureFallback(_a) {
14225
14222
  capture: "user",
14226
14223
  onChange: onFileSelected,
14227
14224
  hidden: true
14228
- }), useFallback && !image ? ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(SelfieCaptureLoadingOverlay, {
14225
+ }), silentFallback && !image ? ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(SelfieCaptureLoadingOverlay, {
14229
14226
  key: selfieKey,
14230
14227
  assets: overlayProps.assets,
14231
14228
  classNames: overlayProps.classNames,
@@ -14241,29 +14238,38 @@ var SelfieCaptureFallback = function SelfieCaptureFallback(_a) {
14241
14238
  className: classNames.container
14242
14239
  }, /*#__PURE__*/React__default['default'].createElement(StyledOverlayInner, {
14243
14240
  className: classNames.inner
14244
- }, !useFallback && ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Heading$6, {
14241
+ }, !silentFallback && ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Heading$6, {
14245
14242
  className: classNames.heading
14246
14243
  }, verbiage.headingText), /*#__PURE__*/React__default['default'].createElement(Description$1, {
14247
14244
  className: classNames.description
14248
- }, verbiage.descriptionText))), image && ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(ImageContainer$5, {
14245
+ }, verbiage.descriptionText))), image && ( /*#__PURE__*/React__default['default'].createElement(ImageContainer$5, {
14249
14246
  className: classNames.imageContainer
14250
14247
  }, /*#__PURE__*/React__default['default'].createElement("img", {
14251
14248
  src: image,
14252
14249
  alt: "",
14253
14250
  className: classNames.image
14254
- })), /*#__PURE__*/React__default['default'].createElement(StyledButtonsRow$5, {
14251
+ }))), /*#__PURE__*/React__default['default'].createElement(StyledButtonsRow$5, {
14255
14252
  className: classNames.buttonsRow
14256
14253
  }, /*#__PURE__*/React__default['default'].createElement(LoaderButton, {
14257
14254
  variant: "positive",
14258
14255
  key: loading ? 'loading-btn' : 'ready-btn',
14259
- className: classNames.doneBtn,
14260
- colors: colors.doneBtn,
14261
- finished: !loading,
14256
+ className: !image ? classNames.captureBtn : classNames === null || classNames === void 0 ? void 0 : classNames.doneBtn,
14257
+ colors: !image ? colors.captureBtn : colors === null || colors === void 0 ? void 0 : colors.doneBtn,
14258
+ finished: !image ? true : !loading,
14262
14259
  onClick: function onClick() {
14263
- setLoading(true);
14264
- onFinished === null || onFinished === void 0 ? void 0 : onFinished(image);
14260
+ var _a;
14261
+ if (isMobile()) {
14262
+ (_a = fileInput.current) === null || _a === void 0 ? void 0 : _a.click();
14263
+ } else {
14264
+ if (!image) {
14265
+ setUsingDocumentCapture(true);
14266
+ } else {
14267
+ setLoading(true);
14268
+ onFinished === null || onFinished === void 0 ? void 0 : onFinished(image);
14269
+ }
14270
+ }
14265
14271
  }
14266
- }, loading ? verbiage.doneBtnLoadingText : verbiage.doneBtnText))))))));
14272
+ }, !image ? verbiage.captureBtnText : loading ? verbiage.doneBtnLoadingText : verbiage.doneBtnText))))));
14267
14273
  };
14268
14274
  var StyledOverlayInner = styled__default['default'](OverlayInner$2)(templateObject_1$g || (templateObject_1$g = tslib.__makeTemplateObject(["\n justify-content: center;\n"], ["\n justify-content: center;\n"])));
14269
14275
  var Heading$6 = styled__default['default'].h3(templateObject_2$a || (templateObject_2$a = tslib.__makeTemplateObject(["\n margin-bottom: 8px;\n"], ["\n margin-bottom: 8px;\n"])));
@@ -14525,6 +14531,9 @@ var initialState$2 = {
14525
14531
  phoneDetected: false,
14526
14532
  timesLivenessCheckFailed: 0
14527
14533
  };
14534
+ /** todo: this feels like it should be hoisted up to the wizard because these states of failed and error dovetail into those in the wizard.
14535
+ * There may also be some crossing of wires in how error/failed are used.
14536
+ */
14528
14537
  var reducer$2 = function reducer(state, action) {
14529
14538
  var _a, _b;
14530
14539
  switch (action.type) {
@@ -14688,21 +14697,28 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
14688
14697
  var onFallbackImageCaptured = React.useCallback(function (imageUrl) {
14689
14698
  return tslib.__awaiter(void 0, void 0, void 0, function () {
14690
14699
  var imageData, response, e_2;
14691
- return tslib.__generator(this, function (_a) {
14692
- switch (_a.label) {
14700
+ var _a;
14701
+ return tslib.__generator(this, function (_b) {
14702
+ switch (_b.label) {
14693
14703
  case 0:
14694
14704
  dispatch({
14695
14705
  type: 'livenessChecking'
14696
14706
  });
14697
- _a.label = 1;
14707
+ _b.label = 1;
14698
14708
  case 1:
14699
- _a.trys.push([1, 4,, 5]);
14709
+ _b.trys.push([1, 4,, 5]);
14700
14710
  return [4 /*yield*/, dataUrlToBase64(imageUrl)];
14701
14711
  case 2:
14702
- imageData = _a.sent();
14703
- return [4 /*yield*/, checkLiveness(imageData)];
14712
+ imageData = _b.sent();
14713
+ return [4 /*yield*/, checkLiveness(imageData)
14714
+ // todo: this feels dirty and is the reason for the todo around line 83 - but is necessary to handle fallback liveness validation
14715
+ ];
14704
14716
  case 3:
14705
- response = _a.sent();
14717
+ response = _b.sent();
14718
+ // todo: this feels dirty and is the reason for the todo around line 83 - but is necessary to handle fallback liveness validation
14719
+ if (((_a = response === null || response === void 0 ? void 0 : response.resultData) === null || _a === void 0 ? void 0 : _a.verificationResult) !== 'Live Face Detected') {
14720
+ onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout();
14721
+ }
14706
14722
  dispatch({
14707
14723
  type: 'livenessChecked',
14708
14724
  payload: {
@@ -14712,7 +14728,7 @@ var FaceLivenessCapture = function FaceLivenessCapture(_a) {
14712
14728
  });
14713
14729
  return [3 /*break*/, 5];
14714
14730
  case 4:
14715
- e_2 = _a.sent();
14731
+ e_2 = _b.sent();
14716
14732
  dispatch({
14717
14733
  type: 'livenessCheckFailed',
14718
14734
  payload: {
@@ -14961,7 +14977,8 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
14961
14977
  });
14962
14978
  });
14963
14979
  }, [onSuccess, setSelfieImage, livenessCheckRequest, submissionResponse]);
14964
- var onTimeoutCallback = React.useCallback(function () {
14980
+ // todo: how this is being used, it would make sense to rename the prop as well, but that would be a breaking change - discuss
14981
+ var onFailureOrTimeout = React.useCallback(function () {
14965
14982
  setCaptureState('FAILED');
14966
14983
  onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout(submissionResponse, livenessCheckRequest);
14967
14984
  }, [onTimeout, livenessCheckRequest, submissionResponse]);
@@ -15006,7 +15023,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
15006
15023
  key: "capture".concat(attempt),
15007
15024
  onCapture: onCapture,
15008
15025
  onSuccess: onSuccessCallback,
15009
- onTimeout: onTimeoutCallback,
15026
+ onTimeout: onFailureOrTimeout,
15010
15027
  onExit: onExitCallback,
15011
15028
  timeoutDurationMs: timeoutDurationMs,
15012
15029
  silentFallback: silentFallback,