idmission-web-sdk 0.0.23 → 0.0.24

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.
@@ -10651,57 +10651,6 @@ function smallerSideIos() {
10651
10651
  return window.screen.width < window.screen.height ? window.screen.width : window.screen.height;
10652
10652
  }
10653
10653
 
10654
- var quickScan = [{
10655
- label: '1080p(FHD)',
10656
- width: 1920,
10657
- height: 1080,
10658
- ratio: '16:9'
10659
- }, {
10660
- label: 'UXGA',
10661
- width: 1600,
10662
- height: 1200,
10663
- ratio: '4:3'
10664
- }, {
10665
- label: '720p(HD)',
10666
- width: 1280,
10667
- height: 720,
10668
- ratio: '16:9'
10669
- }, {
10670
- label: 'SVGA',
10671
- width: 800,
10672
- height: 600,
10673
- ratio: '4:3'
10674
- }, {
10675
- label: 'VGA',
10676
- width: 640,
10677
- height: 480,
10678
- ratio: '4:3'
10679
- }, {
10680
- label: '360p(nHD)',
10681
- width: 640,
10682
- height: 360,
10683
- ratio: '16:9'
10684
- }, {
10685
- label: 'CIF',
10686
- width: 352,
10687
- height: 288,
10688
- ratio: '4:3'
10689
- }, {
10690
- label: 'QVGA',
10691
- width: 320,
10692
- height: 240,
10693
- ratio: '4:3'
10694
- }, {
10695
- label: 'QCIF',
10696
- width: 176,
10697
- height: 144,
10698
- ratio: '4:3'
10699
- }, {
10700
- label: 'QQVGA',
10701
- width: 160,
10702
- height: 120,
10703
- ratio: '4:3'
10704
- }];
10705
10654
  var streamToCamera = function streamToCamera(stream, deviceLabel) {
10706
10655
  var _a = stream.getVideoTracks()[0].getSettings(),
10707
10656
  width = _a.width,
@@ -10724,6 +10673,32 @@ var streamToCamera = function streamToCamera(stream, deviceLabel) {
10724
10673
  release: release
10725
10674
  };
10726
10675
  };
10676
+ function listAvailableCameras() {
10677
+ return tslib.__awaiter(this, void 0, void 0, function () {
10678
+ var cameraEnumerationStream, videoDevices;
10679
+ return tslib.__generator(this, function (_a) {
10680
+ switch (_a.label) {
10681
+ case 0:
10682
+ return [4, navigator.mediaDevices.getUserMedia({
10683
+ video: true,
10684
+ audio: false
10685
+ })];
10686
+ case 1:
10687
+ cameraEnumerationStream = _a.sent();
10688
+ return [4, navigator.mediaDevices.enumerateDevices()];
10689
+ case 2:
10690
+ videoDevices = _a.sent().filter(function (_a) {
10691
+ var kind = _a.kind;
10692
+ return kind === 'videoinput';
10693
+ });
10694
+ cameraEnumerationStream.getVideoTracks().forEach(function (track) {
10695
+ track.stop();
10696
+ });
10697
+ return [2, videoDevices];
10698
+ }
10699
+ });
10700
+ });
10701
+ }
10727
10702
  var getDeviceLabel = function getDeviceLabel(deviceInfo) {
10728
10703
  return deviceInfo.label.toLocaleLowerCase().split(' ').join('');
10729
10704
  };
@@ -10737,10 +10712,10 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
10737
10712
  preferContinuityCamera = _b.preferContinuityCamera,
10738
10713
  requestMicrophoneAccess = _b.requestMicrophoneAccess;
10739
10714
  var videoRef = React.useRef(null);
10715
+ var cameraRef = React.useRef(null);
10740
10716
  var _c = React.useState(null),
10741
10717
  videoDevice = _c[0],
10742
10718
  setVideoDevice = _c[1];
10743
- var cameraRef = React.useRef(null);
10744
10719
  var _d = React.useState(false),
10745
10720
  videoLoaded = _d[0],
10746
10721
  setVideoLoaded = _d[1];
@@ -10770,79 +10745,43 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
10770
10745
  setCameraAccessDenied(false);
10771
10746
  }, []);
10772
10747
  React.useEffect(function () {
10773
- (function () {
10774
- return tslib.__awaiter(void 0, void 0, void 0, function () {
10775
- var stream, e_1, videoDevices, videoDevice, iphoneContinuityCamera;
10776
- return tslib.__generator(this, function (_a) {
10777
- switch (_a.label) {
10778
- case 0:
10779
- if (cameraAccessDenied) return [2];
10780
- _a.label = 1;
10781
- case 1:
10782
- _a.trys.push([1, 3,, 4]);
10783
- return [4, navigator.mediaDevices.getUserMedia({
10784
- video: true,
10785
- audio: false
10786
- })];
10787
- case 2:
10788
- stream = _a.sent();
10789
- return [3, 4];
10790
- case 3:
10791
- e_1 = _a.sent();
10792
- if (e_1.name === 'NotAllowedError') {
10793
- console.error('caught the block!!', e_1);
10794
- setCameraAccessDenied(true);
10795
- return [2];
10796
- }
10797
- throw e_1;
10798
- case 4:
10799
- return [4, navigator.mediaDevices.enumerateDevices()];
10800
- case 5:
10801
- videoDevices = _a.sent().filter(function (deviceInfo) {
10802
- return deviceInfo.kind === 'videoinput';
10803
- });
10804
- if (!iphoneContinuityCameraDenied) {
10805
- iphoneContinuityCamera = videoDevices.find(function (deviceInfo) {
10806
- return getDeviceLabel(deviceInfo).includes('iphonecamera');
10807
- });
10808
- setIphoneContinuityCameraAvailable(!!iphoneContinuityCamera);
10809
- if (iphoneContinuityCameraAllowed) {
10810
- videoDevice = iphoneContinuityCamera;
10811
- }
10812
- }
10813
- if (preferFrontFacingCamera) {
10814
- videoDevice = videoDevices.find(function (deviceInfo) {
10815
- return getDeviceLabel(deviceInfo).includes('front');
10816
- });
10817
- }
10818
- if (!videoDevice) {
10819
- if (wideAngleIsBetter()) {
10820
- videoDevice = videoDevices.find(function (deviceInfo) {
10821
- return getDeviceLabel(deviceInfo).includes('backultrawidecamera');
10822
- });
10823
- } else {
10824
- videoDevice = videoDevices.find(function (deviceInfo) {
10825
- return getDeviceLabel(deviceInfo).includes('back') && !getDeviceLabel(deviceInfo).includes('backultrawidecamera');
10826
- });
10827
- }
10828
- }
10829
- if (!videoDevice) {
10830
- videoDevice = videoDevices.find(function (deviceInfo) {
10831
- return getDeviceLabel(deviceInfo).includes('back');
10832
- });
10833
- }
10834
- if (!videoDevice) {
10835
- videoDevice = videoDevices[0];
10836
- }
10837
- setVideoDevice(videoDevice);
10838
- stream.getVideoTracks().forEach(function (track) {
10839
- track.stop();
10840
- });
10841
- return [2];
10842
- }
10748
+ if (cameraAccessDenied) return;
10749
+ listAvailableCameras().then(function (availableCameras) {
10750
+ var selectedCamera;
10751
+ if (!iphoneContinuityCameraDenied) {
10752
+ var iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
10753
+ return getDeviceLabel(deviceInfo).includes('iphonecamera');
10843
10754
  });
10844
- });
10845
- })();
10755
+ setIphoneContinuityCameraAvailable(!!iphoneContinuityCamera);
10756
+ if (iphoneContinuityCamera && iphoneContinuityCameraAllowed) {
10757
+ selectedCamera = iphoneContinuityCamera;
10758
+ }
10759
+ }
10760
+ if (preferFrontFacingCamera) {
10761
+ selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
10762
+ return getDeviceLabel(deviceInfo).includes('front');
10763
+ }));
10764
+ }
10765
+ if (wideAngleIsBetter()) {
10766
+ selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
10767
+ return getDeviceLabel(deviceInfo).includes('backultrawidecamera');
10768
+ }));
10769
+ } else {
10770
+ selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
10771
+ return getDeviceLabel(deviceInfo).includes('back') && !getDeviceLabel(deviceInfo).includes('backultrawidecamera');
10772
+ }));
10773
+ }
10774
+ selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
10775
+ return getDeviceLabel(deviceInfo).includes('back');
10776
+ }));
10777
+ selectedCamera || (selectedCamera = availableCameras[0]);
10778
+ setVideoDevice(selectedCamera);
10779
+ })["catch"](function (e) {
10780
+ if (e.name === 'NotAllowedError') {
10781
+ console.error('camera access has been blocked by the user', e);
10782
+ setCameraAccessDenied(true);
10783
+ } else throw e;
10784
+ });
10846
10785
  }, [cameraAccessDenied, iphoneContinuityCameraAllowed, iphoneContinuityCameraDenied, preferFrontFacingCamera]);
10847
10786
  var videoReady = !!videoRef.current;
10848
10787
  React.useEffect(function () {
@@ -10855,46 +10794,37 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
10855
10794
  setVideoLoaded(false);
10856
10795
  };
10857
10796
  if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) return cleanup;
10858
- console.log('loading camera!');
10859
- var stream = null;
10860
10797
  (function () {
10861
10798
  return tslib.__awaiter(void 0, void 0, void 0, function () {
10862
- var i, constraints, e_2, i, constraints;
10799
+ var isPortrait, stream, e_1;
10863
10800
  return tslib.__generator(this, function (_a) {
10864
10801
  switch (_a.label) {
10865
10802
  case 0:
10866
- i = 0;
10803
+ isPortrait = window.innerWidth < window.innerHeight;
10804
+ stream = null;
10867
10805
  _a.label = 1;
10868
10806
  case 1:
10869
- if (!(i !== quickScan.length)) return [3, 6];
10870
- constraints = {
10807
+ _a.trys.push([1, 3,, 4]);
10808
+ return [4, navigator.mediaDevices.getUserMedia({
10871
10809
  audio: requestMicrophoneAccess,
10872
10810
  video: {
10873
10811
  deviceId: {
10874
10812
  exact: videoDevice.deviceId
10875
10813
  },
10876
10814
  width: {
10877
- exact: quickScan[i].width
10815
+ ideal: isPortrait ? 1080 : 1920
10878
10816
  },
10879
10817
  height: {
10880
- exact: quickScan[i].height
10818
+ ideal: isPortrait ? 1920 : 1080
10881
10819
  }
10882
10820
  }
10883
- };
10884
- _a.label = 2;
10821
+ })];
10885
10822
  case 2:
10886
- _a.trys.push([2, 4,, 5]);
10887
- stream === null || stream === void 0 ? void 0 : stream.getVideoTracks().forEach(function (track) {
10888
- track.stop();
10889
- });
10890
- return [4, navigator.mediaDevices.getUserMedia(constraints)];
10891
- case 3:
10892
10823
  stream = _a.sent();
10893
- console.log('it can do', quickScan[i].label);
10894
- return [3, 6];
10895
- case 4:
10896
- e_2 = _a.sent();
10897
- if (e_2.name === 'NotAllowedError') {
10824
+ return [3, 4];
10825
+ case 3:
10826
+ e_1 = _a.sent();
10827
+ if (e_1.name === 'NotAllowedError') {
10898
10828
  if (iphoneContinuityCameraAllowed) {
10899
10829
  setIphoneContinuityCameraAvailable(false);
10900
10830
  setIphoneContinuityCameraDenied(true);
@@ -10902,69 +10832,26 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
10902
10832
  setCameraAccessDenied(true);
10903
10833
  }
10904
10834
  return [2];
10905
- } else {
10906
- console.log('well, it cant do', quickScan[i].label);
10907
10835
  }
10908
- return [3, 5];
10836
+ return [3, 4];
10837
+ case 4:
10838
+ if (!!stream) return [3, 8];
10839
+ _a.label = 5;
10909
10840
  case 5:
10910
- ++i;
10911
- return [3, 1];
10912
- case 6:
10913
- if (!!stream) return [3, 12];
10914
- i = 0;
10915
- _a.label = 7;
10916
- case 7:
10917
- if (!(i !== quickScan.length)) return [3, 12];
10918
- constraints = {
10919
- audio: false,
10920
- video: {
10921
- deviceId: {
10922
- exact: videoDevice.deviceId
10923
- },
10924
- width: {
10925
- ideal: quickScan[i].width
10926
- },
10927
- height: {
10928
- ideal: quickScan[i].height
10929
- }
10930
- }
10931
- };
10932
- _a.label = 8;
10933
- case 8:
10934
- _a.trys.push([8, 10,, 11]);
10935
- stream === null || stream === void 0 ? void 0 : stream.getVideoTracks().forEach(function (track) {
10936
- track.stop();
10937
- });
10938
- return [4, navigator.mediaDevices.getUserMedia(constraints)];
10939
- case 9:
10940
- stream = _a.sent();
10941
- console.log('it can do', quickScan[i].label);
10942
- return [3, 12];
10943
- case 10:
10944
- _a.sent();
10945
- console.log('well, it cant do', quickScan[i].label);
10946
- return [3, 11];
10947
- case 11:
10948
- ++i;
10949
- return [3, 7];
10950
- case 12:
10951
- if (!!stream) return [3, 16];
10952
- _a.label = 13;
10953
- case 13:
10954
- _a.trys.push([13, 15,, 16]);
10841
+ _a.trys.push([5, 7,, 8]);
10955
10842
  return [4, navigator.mediaDevices.getUserMedia({
10956
10843
  audio: false,
10957
10844
  video: true
10958
10845
  })];
10959
- case 14:
10846
+ case 6:
10960
10847
  stream = _a.sent();
10961
10848
  console.log('opened stream with no width and height constraints');
10962
- return [3, 16];
10963
- case 15:
10849
+ return [3, 8];
10850
+ case 7:
10964
10851
  _a.sent();
10965
10852
  console.log('cannot open stream at all');
10966
- return [3, 16];
10967
- case 16:
10853
+ return [3, 8];
10854
+ case 8:
10968
10855
  if (!stream) {
10969
10856
  throw new Error('failed to open camera');
10970
10857
  }
@@ -11868,11 +11755,14 @@ var CompositeWizardComponent = function CompositeWizardComponent(_a) {
11868
11755
  }, function () {
11869
11756
  switch (checks[checkIndex]) {
11870
11757
  case 'IdCapture':
11871
- return /*#__PURE__*/React__default['default'].createElement(CameraProvider, null, /*#__PURE__*/React__default['default'].createElement(GuideOrientationProvider, null, /*#__PURE__*/React__default['default'].createElement(IdCaptureWizard, tslib.__assign({}, idCaptureProps, {
11758
+ return /*#__PURE__*/React__default['default'].createElement(CameraProvider, {
11759
+ key: "IdCaptureCamera"
11760
+ }, /*#__PURE__*/React__default['default'].createElement(GuideOrientationProvider, null, /*#__PURE__*/React__default['default'].createElement(IdCaptureWizard, tslib.__assign({}, idCaptureProps, {
11872
11761
  onSuccess: onIdCaptureSuccess
11873
11762
  }))));
11874
11763
  case 'FaceLiveness':
11875
11764
  return /*#__PURE__*/React__default['default'].createElement(CameraProvider, {
11765
+ key: "FaceLivenessCamera",
11876
11766
  preferFrontFacingCamera: true,
11877
11767
  preferContinuityCamera: false
11878
11768
  }, /*#__PURE__*/React__default['default'].createElement(HighPerformanceSelfieGuidanceModelsProvider, null, /*#__PURE__*/React__default['default'].createElement(FaceLivenessWizard, tslib.__assign({}, faceLivenessProps, {
@@ -11884,6 +11774,7 @@ var CompositeWizardComponent = function CompositeWizardComponent(_a) {
11884
11774
  }));
11885
11775
  case 'SignatureKYC':
11886
11776
  return /*#__PURE__*/React__default['default'].createElement(CameraProvider, {
11777
+ key: "SignatureKycCamera",
11887
11778
  preferContinuityCamera: false,
11888
11779
  preferFrontFacingCamera: true,
11889
11780
  requestMicrophoneAccess: true