idmission-web-sdk 2.3.123 → 2.3.124

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.
package/dist/sdk2.esm.js CHANGED
@@ -205,7 +205,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
205
205
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
206
206
  };
207
207
 
208
- var webSdkVersion = '2.3.123';
208
+ var webSdkVersion = '2.3.124';
209
209
 
210
210
  function getPlatform() {
211
211
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -803,38 +803,35 @@ function useLogLevel(newLogLevel) {
803
803
  function useDebugLogging(enabled) {
804
804
  useLogLevel(enabled ? LogLevel.Debug : logLevel);
805
805
  }
806
- function debug() {
807
- var parts = [];
806
+ var noop = function noop() {};
807
+ var debug = function debug() {
808
+ var args = [];
808
809
  for (var _i = 0; _i < arguments.length; _i++) {
809
- parts[_i] = arguments[_i];
810
+ args[_i] = arguments[_i];
810
811
  }
811
- if (logLevel < LogLevel.Debug) return;
812
- console.debug.apply(console, parts); // eslint-disable-line no-console
813
- }
814
- function log() {
815
- var parts = [];
812
+ return (logLevel >= LogLevel.Debug ? console.debug : noop).apply(void 0, args);
813
+ }; // eslint-disable-line no-console
814
+ var log = function log() {
815
+ var args = [];
816
816
  for (var _i = 0; _i < arguments.length; _i++) {
817
- parts[_i] = arguments[_i];
817
+ args[_i] = arguments[_i];
818
818
  }
819
- if (logLevel < LogLevel.Info) return;
820
- console.log.apply(console, parts); // eslint-disable-line no-console
821
- }
822
- function warn() {
823
- var parts = [];
819
+ return (logLevel >= LogLevel.Info ? console.log : noop).apply(void 0, args);
820
+ }; // eslint-disable-line no-console
821
+ var warn = function warn() {
822
+ var args = [];
824
823
  for (var _i = 0; _i < arguments.length; _i++) {
825
- parts[_i] = arguments[_i];
824
+ args[_i] = arguments[_i];
826
825
  }
827
- if (logLevel < LogLevel.Warn) return;
828
- console.warn.apply(console, parts); // eslint-disable-line no-console
829
- }
830
- function error() {
831
- var parts = [];
826
+ return (logLevel >= LogLevel.Warn ? console.warn : noop).apply(void 0, args);
827
+ }; // eslint-disable-line no-console
828
+ var error = function error() {
829
+ var args = [];
832
830
  for (var _i = 0; _i < arguments.length; _i++) {
833
- parts[_i] = arguments[_i];
831
+ args[_i] = arguments[_i];
834
832
  }
835
- if (logLevel < LogLevel.Error) return;
836
- console.error.apply(console, parts); // eslint-disable-line no-console
837
- }
833
+ return (logLevel >= LogLevel.Error ? console.error : noop).apply(void 0, args);
834
+ }; // eslint-disable-line no-console
838
835
 
839
836
  var defaultAuthUrl = 'https://portal-api.idmission.com';
840
837
  var allowedAuthUrls = ['https://portal-api.idmission.com', 'https://portal-api-uat.idmission.com', 'https://portal-api-demo.idmission.com', 'https://portal-api-dev.idmission.com', 'http://localhost:10000'];
@@ -3139,6 +3136,7 @@ function useFrameLoop(fn, options) {
3139
3136
  };
3140
3137
  }
3141
3138
 
3139
+ var LOG_TAG$1 = 'camera:Camera';
3142
3140
  function listAvailableCameras(facingMode_1) {
3143
3141
  return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
3144
3142
  var cameraEnumerationStream, allDevices, allowedVideoDevices;
@@ -3201,21 +3199,24 @@ var getDeviceLabel = function getDeviceLabel(deviceInfo) {
3201
3199
  var currentCamera;
3202
3200
  function obtainCameraAccess(stream, deviceLabel, video) {
3203
3201
  releaseCameraAccess();
3204
- log('obtaining camera access...');
3202
+ log("".concat(LOG_TAG$1, " obtaining camera access..."));
3205
3203
  var _a = stream.getVideoTracks()[0].getSettings(),
3206
3204
  width = _a.width,
3207
3205
  height = _a.height;
3208
- log('camera dimensions', width, height);
3206
+ log("".concat(LOG_TAG$1, " camera dimensions"), width, height);
3209
3207
  var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
3210
- log('camera label', label);
3208
+ log("".concat(LOG_TAG$1, " camera label"), label);
3211
3209
  var isRearFacing = cameraLabelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearCameraLabels, true), backUltraWideCameraLabels, true), ['iphone'], false));
3212
- log('is rear facing?', isRearFacing);
3210
+ log("".concat(LOG_TAG$1, " is rear facing?"), isRearFacing);
3213
3211
  var release = function release() {
3212
+ debug("".concat(LOG_TAG$1, " camera releasing stream"), stream);
3214
3213
  stream.getTracks().forEach(function (track) {
3215
3214
  track.enabled = false;
3215
+ debug("".concat(LOG_TAG$1, " camera stopping stream track"), track);
3216
3216
  track.stop();
3217
3217
  });
3218
3218
  if (video) {
3219
+ debug("".concat(LOG_TAG$1, " camera releasing video element"), video);
3219
3220
  video.pause();
3220
3221
  video.srcObject = null;
3221
3222
  video.src = '';
@@ -3231,14 +3232,14 @@ function obtainCameraAccess(stream, deviceLabel, video) {
3231
3232
  isRearFacing: isRearFacing,
3232
3233
  release: release
3233
3234
  };
3234
- log('camera access granted');
3235
+ log("".concat(LOG_TAG$1, " camera access granted"), currentCamera);
3235
3236
  // if (video) video.srcObject = stream
3236
3237
  // log('video source initialized')
3237
3238
  return currentCamera;
3238
3239
  }
3239
3240
  function releaseCameraAccess() {
3240
3241
  if (!currentCamera) return;
3241
- log('releasing camera access...');
3242
+ log("".concat(LOG_TAG$1, " releasing camera access..."));
3242
3243
  currentCamera.release();
3243
3244
  currentCamera = undefined;
3244
3245
  }
@@ -4390,6 +4391,7 @@ function useTranslations(verbiage, fallbacks) {
4390
4391
  }, [fallbacks, i18n.language, t, verbiage]);
4391
4392
  }
4392
4393
 
4394
+ var LOG_TAG = 'camera:store';
4393
4395
  var camera = null;
4394
4396
  var videoStream = null;
4395
4397
  var audioStream = null;
@@ -4415,7 +4417,8 @@ var createCameraStore = function createCameraStore(config) {
4415
4417
  var store = createStore(function (set, get) {
4416
4418
  return _assign(_assign(_assign({}, initialState$6), config), {
4417
4419
  reset: function reset() {
4418
- return set(_assign(_assign({}, initialState$6), config));
4420
+ debug("".concat(LOG_TAG, " reset"));
4421
+ set(_assign(_assign({}, initialState$6), config));
4419
4422
  },
4420
4423
  setConfig: function setConfig(config) {
4421
4424
  return set(config);
@@ -4446,6 +4449,7 @@ var createCameraStore = function createCameraStore(config) {
4446
4449
  return __generator(this, function (_f) {
4447
4450
  switch (_f.label) {
4448
4451
  case 0:
4452
+ debug("".concat(LOG_TAG, " requestCameraAccess"), new Error().stack);
4449
4453
  _a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
4450
4454
  releaseCameraAccess();
4451
4455
  _f.label = 1;
@@ -4455,9 +4459,9 @@ var createCameraStore = function createCameraStore(config) {
4455
4459
  case 2:
4456
4460
  availableCameras = _f.sent();
4457
4461
  selectedCamera = void 0;
4458
- debug('availableCameras', availableCameras);
4462
+ debug("".concat(LOG_TAG, " availableCameras"), availableCameras);
4459
4463
  platform_1 = getPlatform();
4460
- debug('platformDetails', platform_1);
4464
+ debug("".concat(LOG_TAG, " platformDetails"), platform_1);
4461
4465
  if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
4462
4466
  iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
4463
4467
  return cameraLabelMatches(deviceInfo, 'iphone');
@@ -4474,7 +4478,7 @@ var createCameraStore = function createCameraStore(config) {
4474
4478
  availableCameras = availableCameras.sort(function (a, b) {
4475
4479
  return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
4476
4480
  });
4477
- debug('cameras have been sorted', availableCameras);
4481
+ debug("".concat(LOG_TAG, " cameras have been sorted"), availableCameras);
4478
4482
  }
4479
4483
  if (preferFrontFacingCamera) {
4480
4484
  selectedCamera = availableCameras.find(function (deviceInfo) {
@@ -4498,7 +4502,7 @@ var createCameraStore = function createCameraStore(config) {
4498
4502
  selectedCamera || (selectedCamera = availableCameras[1]);
4499
4503
  }
4500
4504
  selectedCamera || (selectedCamera = availableCameras[0]);
4501
- debug('selectedCamera', selectedCamera);
4505
+ debug("".concat(LOG_TAG, " selectedCamera"), selectedCamera);
4502
4506
  set({
4503
4507
  videoDevice: selectedCamera
4504
4508
  });
@@ -4526,7 +4530,7 @@ var createCameraStore = function createCameraStore(config) {
4526
4530
  _f.label = 3;
4527
4531
  case 3:
4528
4532
  _f.trys.push([3, 5,, 6]);
4529
- debug('obtaining camera access with constraints', constraints);
4533
+ debug("".concat(LOG_TAG, " obtaining camera access with constraints"), constraints);
4530
4534
  return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
4531
4535
  case 4:
4532
4536
  stream_1 = _f.sent();
@@ -4558,21 +4562,21 @@ var createCameraStore = function createCameraStore(config) {
4558
4562
  })];
4559
4563
  case 8:
4560
4564
  stream_1 = _f.sent();
4561
- debug('opened stream with no width and height constraints');
4565
+ debug("".concat(LOG_TAG, " opened stream with no width and height constraints"));
4562
4566
  return [3 /*break*/, 10];
4563
4567
  case 9:
4564
4568
  e_2 = _f.sent();
4565
- debug('cannot open stream at all', e_2);
4569
+ debug("".concat(LOG_TAG, " cannot open stream at all"), e_2);
4566
4570
  return [3 /*break*/, 10];
4567
4571
  case 10:
4568
4572
  if (!stream_1) {
4569
- error('failed to open camera');
4573
+ error("".concat(LOG_TAG, " failed to open camera"));
4570
4574
  throw new Error('failed to open camera: ');
4571
4575
  }
4572
- debug('camera access granted with constraints', constraints);
4576
+ debug("".concat(LOG_TAG, " camera access requested with constraints"), constraints);
4573
4577
  handleStreamEnded_1 = function handleStreamEnded_1() {
4574
4578
  if (preferIphoneContinuityCamera && get().iphoneContinuityCameraAvailable) {
4575
- debug('someone unplugged the continuity camera');
4579
+ debug("".concat(LOG_TAG, " someone unplugged the continuity camera"), camera);
4576
4580
  videoStream = null;
4577
4581
  set({
4578
4582
  videoDevice: null,
@@ -4580,10 +4584,8 @@ var createCameraStore = function createCameraStore(config) {
4580
4584
  iphoneContinuityCameraAvailable: false,
4581
4585
  iphoneContinuityCameraDenied: true
4582
4586
  });
4583
- get().requestCameraAccess();
4584
4587
  } else {
4585
- debug('someone unplugged the webcam');
4586
- get().releaseCameraAccess();
4588
+ debug("".concat(LOG_TAG, " someone unplugged the webcam"), camera);
4587
4589
  videoStream = null;
4588
4590
  set({
4589
4591
  videoDevice: null,
@@ -4593,16 +4595,25 @@ var createCameraStore = function createCameraStore(config) {
4593
4595
  });
4594
4596
  }
4595
4597
  };
4596
- (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
4598
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', function () {
4599
+ debug("".concat(LOG_TAG, ":handleStreamEnded HTMLVideoElement ended event"));
4600
+ handleStreamEnded_1();
4601
+ });
4597
4602
  videoTrack_1 = stream_1.getVideoTracks()[0];
4598
- videoTrack_1.onended = handleStreamEnded_1;
4603
+ videoTrack_1.onended = function () {
4604
+ debug("".concat(LOG_TAG, ":handleStreamEnded MediaStreamTrack onended"), 'videoStream', videoStream, 'videoTrack', videoTrack_1, 'camera', camera);
4605
+ handleStreamEnded_1();
4606
+ };
4599
4607
  camera = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
4600
4608
  setTimeout(function () {
4601
4609
  var _a;
4602
4610
  // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
4603
4611
  // when the camera access is being requested. This delay is a workaround for that.
4604
4612
  videoTrack_1.onmute = function () {
4605
- if (videoTrack_1.readyState !== 'live') handleStreamEnded_1();
4613
+ if (videoTrack_1.readyState !== 'live') {
4614
+ debug("".concat(LOG_TAG, ":handleStreamEnded MediaStreamTrack onmute"), 'videoStream', videoStream, 'videoTrack', videoTrack_1);
4615
+ handleStreamEnded_1();
4616
+ }
4606
4617
  };
4607
4618
  videoStream = stream_1;
4608
4619
  var isRearFacing = (_a = camera === null || camera === void 0 ? void 0 : camera.isRearFacing) !== null && _a !== void 0 ? _a : false;
@@ -4616,12 +4627,12 @@ var createCameraStore = function createCameraStore(config) {
4616
4627
  case 11:
4617
4628
  e_3 = _f.sent();
4618
4629
  if (e_3.name === 'NotAllowedError' || ((_e = e_3.message) === null || _e === void 0 ? void 0 : _e.includes('Could not start video source'))) {
4619
- error('camera access has been blocked by the user', e_3);
4630
+ error("".concat(LOG_TAG, " camera access has been blocked by the user"), e_3);
4620
4631
  set({
4621
4632
  cameraAccessDenied: true
4622
4633
  });
4623
4634
  } else {
4624
- error('camera access encountered some other error', e_3);
4635
+ error("".concat(LOG_TAG, " camera access encountered some other error"), e_3);
4625
4636
  throw e_3;
4626
4637
  }
4627
4638
  return [3 /*break*/, 12];
@@ -4634,12 +4645,10 @@ var createCameraStore = function createCameraStore(config) {
4634
4645
  releaseCameraAccess: function releaseCameraAccess() {
4635
4646
  return __awaiter(this, void 0, void 0, function () {
4636
4647
  return __generator(this, function (_a) {
4648
+ debug("".concat(LOG_TAG, " release camera access"), 'camera', camera, 'videoStream', videoStream);
4637
4649
  if (!camera) return [2 /*return*/];
4638
- camera.release();
4650
+ camera.release(); // NOTE calls stop Camera tracks internally as noted above
4639
4651
  camera = null;
4640
- videoStream === null || videoStream === void 0 ? void 0 : videoStream.getTracks().forEach(function (track) {
4641
- track.stop();
4642
- });
4643
4652
  videoStream = null;
4644
4653
  set({
4645
4654
  cameraReady: false,
@@ -4694,7 +4703,7 @@ var createCameraStore = function createCameraStore(config) {
4694
4703
  return [3 /*break*/, 4];
4695
4704
  case 3:
4696
4705
  e_4 = _a.sent();
4697
- debug('failed to open microphone', e_4);
4706
+ debug("".concat(LOG_TAG, " failed to open microphone"), e_4);
4698
4707
  set({
4699
4708
  microphoneAccessDenied: true
4700
4709
  });
@@ -4721,6 +4730,7 @@ var createCameraStore = function createCameraStore(config) {
4721
4730
  });
4722
4731
  });
4723
4732
  if (config.requestAccessAutomatically) {
4733
+ debug("".concat(LOG_TAG, " requesting camera access automatically"));
4724
4734
  void store.getState().requestCameraAccess();
4725
4735
  }
4726
4736
  return _assign(_assign({}, store), {
@@ -16601,7 +16611,6 @@ var IdVideoCaptureSuccess = function IdVideoCaptureSuccess(props) {
16601
16611
  idFrontText: 'ID Front Image',
16602
16612
  idBackText: 'ID Back Image'
16603
16613
  });
16604
- var requestCameraAccess = useCameraStore().requestCameraAccess;
16605
16614
  return /*#__PURE__*/React__default.createElement(OverlayContainer, {
16606
16615
  className: classNames.container
16607
16616
  }, /*#__PURE__*/React__default.createElement(OverlayInner$2, {
@@ -16660,7 +16669,6 @@ var IdVideoCaptureSuccess = function IdVideoCaptureSuccess(props) {
16660
16669
  variant: "warning",
16661
16670
  className: classNames.retryBtn,
16662
16671
  onClick: function onClick() {
16663
- void requestCameraAccess();
16664
16672
  return onRetryClick === null || onRetryClick === void 0 ? void 0 : onRetryClick();
16665
16673
  },
16666
16674
  colors: colors.retryBtn,