idmission-web-sdk 1.0.109 → 1.0.112

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.
@@ -1,7 +1,7 @@
1
1
  import { FC, PropsWithChildren, ReactNode } from 'react';
2
2
  import { ThemeInput } from '../../themes';
3
3
  import { LangOption } from '../../lib/locales';
4
- import { SubmissionRequest, SubmissionResponse } from '../../contexts/SubmissionContext';
4
+ import { SubmissionRequest } from '../../contexts/SubmissionContext';
5
5
  import { DocumentCaptureWizardClassNames } from '../document_capture/DocumentCaptureWizard';
6
6
  import { CameraFeedMode } from '../document_capture/DocumentCaptureScreen';
7
7
  export type DocumentCaptureClassNames = DocumentCaptureWizardClassNames;
@@ -19,7 +19,7 @@ export interface DocumentCaptureProps extends PropsWithChildren {
19
19
  /** Callback function that fires when the user has completed the flow instead of making a call to IDmission's servers, allowing customers to specify their own submission logic. Arguments: the request payload that would have been dispatched to IDmission's API, which contains the images/documents/video submitted by the user. Note that when this parameter is supplied, `onComplete` will never fire, and the customer will need to implement their own error handling/retry logic. Use at your own risk! */
20
20
  onSubmit?: (req: SubmissionRequest) => void;
21
21
  /** Callback function that fires when the user completes the DocumentCapture flow. Arguments: the SubmissionResponse from IDmission's API is passed as an argument to the customer's application for further handling, which indicates whether the user passed the validation check, and the request payload dispatched to IDmission's API, which contains the images submitted by the user. */
22
- onComplete?: (resp: SubmissionResponse, req: SubmissionRequest) => void;
22
+ onComplete?: () => void;
23
23
  /** Callback function that fires when the user clicks the exit button during ID or selfie capture. */
24
24
  onExitCapture?: () => void;
25
25
  /** Callback function that fires when the user clicks the exit button from the loading overlay, declining to engage with IDmission. Binding this callback results in the cancel button being rendered on the loading overlay. */
@@ -47,7 +47,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
47
47
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
48
48
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
49
49
 
50
- var webSdkVersion = '1.0.109';
50
+ var webSdkVersion = '1.0.112';
51
51
 
52
52
  function getPlatform() {
53
53
  if (typeof window === 'undefined') return;
@@ -733,78 +733,80 @@ var SubmissionProvider = function SubmissionProvider(_a) {
733
733
  _t = _a.webhooksFireOnReview,
734
734
  webhooksFireOnReview = _t === void 0 ? false : _t,
735
735
  precapturedDocuments = _a.precapturedDocuments,
736
- documentServiceUrl = _a.documentServiceUrl,
736
+ _u = _a.documentServiceUrl,
737
+ documentServiceUrl = _u === void 0 ? 'https://portal-api-dev.idmission.com/files/' : _u,
738
+ // 'http://localhost:10000/files/',
737
739
  onSubmit = _a.onSubmit,
738
740
  onBeforeSubmit = _a.onBeforeSubmit,
739
741
  onBeforeLivenessCheck = _a.onBeforeLivenessCheck,
740
742
  onResponseReceived = _a.onResponseReceived,
741
743
  onRequestFailure = _a.onRequestFailure;
742
- var _u = React.useState(SubmissionStatus.READY),
743
- submissionStatus = _u[0],
744
- setSubmissionStatus = _u[1];
745
- var _v = React.useState(null),
746
- submissionRequest = _v[0],
747
- setSubmissionRequest = _v[1];
744
+ var _v = React.useState(SubmissionStatus.READY),
745
+ submissionStatus = _v[0],
746
+ setSubmissionStatus = _v[1];
748
747
  var _w = React.useState(null),
749
- submissionResponse = _w[0],
750
- setSubmissionResponse = _w[1];
748
+ submissionRequest = _w[0],
749
+ setSubmissionRequest = _w[1];
751
750
  var _x = React.useState(null),
752
- submissionError = _x[0],
753
- setSubmissionError = _x[1];
751
+ submissionResponse = _x[0],
752
+ setSubmissionResponse = _x[1];
754
753
  var _y = React.useState(null),
755
- retrySubmission = _y[0],
756
- setRetrySubmission = _y[1];
754
+ submissionError = _y[0],
755
+ setSubmissionError = _y[1];
757
756
  var _z = React.useState(null),
758
- livenessCheckRequest = _z[0],
759
- setLivenessCheckRequest = _z[1];
757
+ retrySubmission = _z[0],
758
+ setRetrySubmission = _z[1];
760
759
  var _0 = React.useState(null),
761
- idFrontImage = _0[0],
762
- setIdFrontImage = _0[1];
760
+ livenessCheckRequest = _0[0],
761
+ setLivenessCheckRequest = _0[1];
763
762
  var _1 = React.useState(null),
764
- idBackImage = _1[0],
765
- setIdBackImage = _1[1];
763
+ idFrontImage = _1[0],
764
+ setIdFrontImage = _1[1];
766
765
  var _2 = React.useState(null),
767
- passportImage = _2[0],
768
- setPassportImage = _2[1];
766
+ idBackImage = _2[0],
767
+ setIdBackImage = _2[1];
769
768
  var _3 = React.useState(null),
770
- selfieImage = _3[0],
771
- setSelfieImage = _3[1];
769
+ passportImage = _3[0],
770
+ setPassportImage = _3[1];
772
771
  var _4 = React.useState(null),
773
- signatureData = _4[0],
774
- setSignatureData = _4[1];
772
+ selfieImage = _4[0],
773
+ setSelfieImage = _4[1];
775
774
  var _5 = React.useState(null),
776
- signatureVideoUrl = _5[0],
777
- setSignatureVideoUrl = _5[1];
775
+ signatureData = _5[0],
776
+ setSignatureData = _5[1];
778
777
  var _6 = React.useState(null),
779
- idCaptureVideoUrl = _6[0],
780
- setIdCaptureVideoUrl = _6[1];
778
+ signatureVideoUrl = _6[0],
779
+ setSignatureVideoUrl = _6[1];
781
780
  var _7 = React.useState(null),
782
- idCaptureVideoIdFrontImage = _7[0],
783
- setIdCaptureVideoIdFrontImage = _7[1];
781
+ idCaptureVideoUrl = _7[0],
782
+ setIdCaptureVideoUrl = _7[1];
784
783
  var _8 = React.useState(null),
785
- idCaptureVideoIdBackImage = _8[0],
786
- setIdCaptureVideoIdBackImage = _8[1];
784
+ idCaptureVideoIdFrontImage = _8[0],
785
+ setIdCaptureVideoIdFrontImage = _8[1];
787
786
  var _9 = React.useState(null),
788
- additionalDocuments = _9[0],
789
- setAdditionalDocuments = _9[1];
787
+ idCaptureVideoIdBackImage = _9[0],
788
+ setIdCaptureVideoIdBackImage = _9[1];
790
789
  var _10 = React.useState(null),
791
- geolocationResult = _10[0],
792
- setGeolocationResult = _10[1];
793
- var _11 = React.useState(0),
794
- geolocationAttempts = _11[0],
795
- setGeolocationAttempts = _11[1];
796
- var _12 = React.useState(false),
797
- geolocationBlocked = _12[0],
798
- setGeolocationBlocked = _12[1];
799
- var _13 = React.useState([]),
800
- idFrontCaptureAttempts = _13[0],
801
- setIdFrontCaptureAttempts = _13[1];
790
+ additionalDocuments = _10[0],
791
+ setAdditionalDocuments = _10[1];
792
+ var _11 = React.useState(null),
793
+ geolocationResult = _11[0],
794
+ setGeolocationResult = _11[1];
795
+ var _12 = React.useState(0),
796
+ geolocationAttempts = _12[0],
797
+ setGeolocationAttempts = _12[1];
798
+ var _13 = React.useState(false),
799
+ geolocationBlocked = _13[0],
800
+ setGeolocationBlocked = _13[1];
802
801
  var _14 = React.useState([]),
803
- idBackCaptureAttempts = _14[0],
804
- setIdBackCaptureAttempts = _14[1];
802
+ idFrontCaptureAttempts = _14[0],
803
+ setIdFrontCaptureAttempts = _14[1];
805
804
  var _15 = React.useState([]),
806
- selfieCaptureAttempts = _15[0],
807
- setSelfieCaptureAttempts = _15[1];
805
+ idBackCaptureAttempts = _15[0],
806
+ setIdBackCaptureAttempts = _15[1];
807
+ var _16 = React.useState([]),
808
+ selfieCaptureAttempts = _16[0],
809
+ setSelfieCaptureAttempts = _16[1];
808
810
  var logIdFrontCaptureAttempt = React.useCallback(function (attempt) {
809
811
  setIdFrontCaptureAttempts(function (attempts) {
810
812
  return tslib.__spreadArray(tslib.__spreadArray([], attempts, true), [attempt], false);
@@ -1165,12 +1167,12 @@ var SubmissionProvider = function SubmissionProvider(_a) {
1165
1167
  setSubmissionStatus(SubmissionStatus.READY);
1166
1168
  retrySubmission();
1167
1169
  }, [retrySubmission]);
1168
- var _16 = React.useState('NOT_PARSED'),
1169
- tokenState = _16[0],
1170
- setTokenState = _16[1];
1171
- var _17 = React.useState(null),
1172
- tokenError = _17[0],
1173
- setTokenError = _17[1];
1170
+ var _17 = React.useState('NOT_PARSED'),
1171
+ tokenState = _17[0],
1172
+ setTokenState = _17[1];
1173
+ var _18 = React.useState(null),
1174
+ tokenError = _18[0],
1175
+ setTokenError = _18[1];
1174
1176
  React.useEffect(function () {
1175
1177
  if (typeof window === 'undefined') return;
1176
1178
  (function () {
@@ -16422,10 +16424,12 @@ var documentCaptureStateReducer = function documentCaptureStateReducer(state, ac
16422
16424
  };
16423
16425
  var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
16424
16426
  var children = _a.children;
16425
- var cameraRef = React.useContext(CameraStateContext).cameraRef;
16426
- var _b = React.useReducer(documentCaptureStateReducer, documentCaptureInitialState),
16427
- state = _b[0],
16428
- dispatch = _b[1];
16427
+ var _b = React.useContext(CameraStateContext),
16428
+ cameraRef = _b.cameraRef,
16429
+ videoRef = _b.videoRef;
16430
+ var _c = React.useReducer(documentCaptureStateReducer, documentCaptureInitialState),
16431
+ state = _c[0],
16432
+ dispatch = _c[1];
16429
16433
  var onResize = useDebounce.useDebouncedCallback(function () {
16430
16434
  dispatch({
16431
16435
  type: 'redrawRequested'
@@ -16438,10 +16442,12 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
16438
16442
  window.removeEventListener('resize', onResize);
16439
16443
  };
16440
16444
  }, [onResize]);
16445
+ var videoTag = videoRef.current;
16441
16446
  React.useEffect(function () {
16442
16447
  if (!state.capturing) return;
16443
16448
  if (!cameraRef.current) return;
16444
- new ImageCapture(cameraRef.current.stream.getTracks()[0]).takePhoto().then(function (imageBlob) {
16449
+ function onComplete(imageBlob) {
16450
+ if (!imageBlob) return;
16445
16451
  var imageUrl = URL.createObjectURL(imageBlob);
16446
16452
  dispatch({
16447
16453
  type: 'captureCompleted',
@@ -16450,8 +16456,15 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
16450
16456
  imageBlob: imageBlob
16451
16457
  }
16452
16458
  });
16453
- })["catch"](function () {});
16454
- }, [cameraRef, state.capturing]);
16459
+ }
16460
+ if (typeof ImageCapture !== 'undefined') {
16461
+ new ImageCapture(cameraRef.current.stream.getTracks()[0]).takePhoto().then(onComplete)["catch"](function () {});
16462
+ } else if (videoTag) {
16463
+ var canvas = document.createElement('canvas');
16464
+ drawToCanvas(canvas, videoTag);
16465
+ canvas.toBlob(onComplete);
16466
+ }
16467
+ }, [cameraRef, state.capturing, videoTag]);
16455
16468
  return /*#__PURE__*/React__default['default'].createElement(DocumentCaptureStateContext.Provider, {
16456
16469
  value: state
16457
16470
  }, /*#__PURE__*/React__default['default'].createElement(DocumentCaptureDispatchContext.Provider, {
@@ -16746,8 +16759,7 @@ var DocumentCapture = function DocumentCapture(_a) {
16746
16759
  lang = _b === void 0 ? 'auto' : _b,
16747
16760
  submissionToken = _a.submissionToken,
16748
16761
  submissionUrl = _a.submissionUrl,
16749
- _c = _a.documentServiceUrl,
16750
- documentServiceUrl = _c === void 0 ? 'http://localhost:10000/files/' : _c,
16762
+ documentServiceUrl = _a.documentServiceUrl,
16751
16763
  onBeforeSubmit = _a.onBeforeSubmit,
16752
16764
  onSubmit = _a.onSubmit,
16753
16765
  onComplete = _a.onComplete,
@@ -16756,10 +16768,10 @@ var DocumentCapture = function DocumentCapture(_a) {
16756
16768
  aspectRatio = _a.aspectRatio,
16757
16769
  cameraFeedMode = _a.cameraFeedMode,
16758
16770
  instructions = _a.instructions,
16759
- _d = _a.theme,
16760
- theme = _d === void 0 ? 'default' : _d,
16761
- _e = _a.classNames,
16762
- classNames = _e === void 0 ? {} : _e;
16771
+ _c = _a.theme,
16772
+ theme = _c === void 0 ? 'default' : _c,
16773
+ _d = _a.classNames,
16774
+ classNames = _d === void 0 ? {} : _d;
16763
16775
  useLanguage(lang);
16764
16776
  return /*#__PURE__*/React__default['default'].createElement(ThemeProvider, {
16765
16777
  theme: theme
@@ -16769,11 +16781,11 @@ var DocumentCapture = function DocumentCapture(_a) {
16769
16781
  token: submissionToken,
16770
16782
  documentServiceUrl: documentServiceUrl,
16771
16783
  onBeforeSubmit: onBeforeSubmit,
16772
- onSubmit: onSubmit,
16773
- onResponseReceived: onComplete
16784
+ onSubmit: onSubmit
16774
16785
  }, /*#__PURE__*/React__default['default'].createElement(CameraProvider, {
16775
16786
  preferContinuityCamera: true
16776
16787
  }, /*#__PURE__*/React__default['default'].createElement(DocumentCaptureWizard, {
16788
+ onSuccess: onComplete,
16777
16789
  onExitCapture: onExitCapture,
16778
16790
  onUserCancel: onUserCancel,
16779
16791
  aspectRatio: aspectRatio,