@authme/util 2.2.1-rc.3 → 2.2.1

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.
Files changed (3) hide show
  1. package/index.cjs +13 -6
  2. package/index.js +13 -6
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -488,6 +488,13 @@ function asyncShowPopup(title, content, showButton = true, button) {
488
488
  });
489
489
  }
490
490
 
491
+ var BROWSER_CAMERA_ERRORS;
492
+ (function (BROWSER_CAMERA_ERRORS) {
493
+ BROWSER_CAMERA_ERRORS["NOT_SUPPORT"] = "NOT_SUPPORT";
494
+ BROWSER_CAMERA_ERRORS["NO_CAMERA"] = "NO_CAMERA";
495
+ BROWSER_CAMERA_ERRORS["NOT_ALLOWED_ERROR"] = "NotAllowedError";
496
+ BROWSER_CAMERA_ERRORS["NOT_FOUND_ERROR"] = "NotFoundError";
497
+ })(BROWSER_CAMERA_ERRORS || (BROWSER_CAMERA_ERRORS = {}));
491
498
  const videoConstraintsFactory = (isPC, facingMode) => {
492
499
  return isPC ? {
493
500
  video: {
@@ -572,7 +579,7 @@ function _requestCamera(video, facingMode) {
572
579
  var _a;
573
580
  return __awaiter(this, void 0, void 0, function* () {
574
581
  if (!('mediaDevices' in navigator)) {
575
- throw 'NOT_SUPPORT';
582
+ throw BROWSER_CAMERA_ERRORS.NOT_SUPPORT;
576
583
  }
577
584
  let isSamsung = false;
578
585
  if (navigator.userAgent.match(/SAMSUNG|Samsung|SGH-[I|N|T]|GT-[I|N]|SM-[A|G|N|P|T|Z|S]|SHV-E|SCH-[I|J|R|S]|SPH-L/i)) {
@@ -640,7 +647,7 @@ function _requestCamera(video, facingMode) {
640
647
  })) === null || _a === void 0 ? void 0 : _a[0];
641
648
  const deviceId = firstDevice.device.deviceId;
642
649
  if (!deviceId) {
643
- throw 'NO_CAMERA';
650
+ throw BROWSER_CAMERA_ERRORS.NO_CAMERA;
644
651
  }
645
652
  const constraints = {
646
653
  video: {
@@ -696,15 +703,15 @@ function requestCamera({
696
703
  try {
697
704
  return yield _requestCamera(video, facingMode);
698
705
  } catch (error) {
699
- if (error === 'NOT_SUPPORT') {
706
+ if (error === BROWSER_CAMERA_ERRORS.NOT_SUPPORT) {
700
707
  showMessage(translate('camera.error.notFound'));
701
708
  throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, 'Browser not support WebRTC, or https required.');
702
709
  }
703
- if (error === 'NO_CAMERA') {
710
+ if (error === BROWSER_CAMERA_ERRORS.NO_CAMERA) {
704
711
  showMessage(translate('camera.error.notFound'));
705
712
  throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, 'camera not found');
706
713
  }
707
- if ((error === null || error === void 0 ? void 0 : error.name) === 'NotAllowedError') {
714
+ if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_ALLOWED_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_FOUND_ERROR) {
708
715
  showMessage(translate('camera.error.notFound'));
709
716
  throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
710
717
  }
@@ -1667,7 +1674,7 @@ function stopLoadingSDK() {
1667
1674
  }
1668
1675
 
1669
1676
  var name = "@authme/util";
1670
- var version$1 = "2.2.1-rc.3";
1677
+ var version$1 = "2.2.1";
1671
1678
  var peerDependencies = {
1672
1679
  "core-js": "^3.6.0"
1673
1680
  };
package/index.js CHANGED
@@ -480,6 +480,13 @@ function asyncShowPopup(title, content, showButton = true, button) {
480
480
  });
481
481
  }
482
482
 
483
+ var BROWSER_CAMERA_ERRORS;
484
+ (function (BROWSER_CAMERA_ERRORS) {
485
+ BROWSER_CAMERA_ERRORS["NOT_SUPPORT"] = "NOT_SUPPORT";
486
+ BROWSER_CAMERA_ERRORS["NO_CAMERA"] = "NO_CAMERA";
487
+ BROWSER_CAMERA_ERRORS["NOT_ALLOWED_ERROR"] = "NotAllowedError";
488
+ BROWSER_CAMERA_ERRORS["NOT_FOUND_ERROR"] = "NotFoundError";
489
+ })(BROWSER_CAMERA_ERRORS || (BROWSER_CAMERA_ERRORS = {}));
483
490
  const videoConstraintsFactory = (isPC, facingMode) => {
484
491
  return isPC ? {
485
492
  video: {
@@ -564,7 +571,7 @@ function _requestCamera(video, facingMode) {
564
571
  var _a;
565
572
  return __awaiter(this, void 0, void 0, function* () {
566
573
  if (!('mediaDevices' in navigator)) {
567
- throw 'NOT_SUPPORT';
574
+ throw BROWSER_CAMERA_ERRORS.NOT_SUPPORT;
568
575
  }
569
576
  let isSamsung = false;
570
577
  if (navigator.userAgent.match(/SAMSUNG|Samsung|SGH-[I|N|T]|GT-[I|N]|SM-[A|G|N|P|T|Z|S]|SHV-E|SCH-[I|J|R|S]|SPH-L/i)) {
@@ -632,7 +639,7 @@ function _requestCamera(video, facingMode) {
632
639
  })) === null || _a === void 0 ? void 0 : _a[0];
633
640
  const deviceId = firstDevice.device.deviceId;
634
641
  if (!deviceId) {
635
- throw 'NO_CAMERA';
642
+ throw BROWSER_CAMERA_ERRORS.NO_CAMERA;
636
643
  }
637
644
  const constraints = {
638
645
  video: {
@@ -688,15 +695,15 @@ function requestCamera({
688
695
  try {
689
696
  return yield _requestCamera(video, facingMode);
690
697
  } catch (error) {
691
- if (error === 'NOT_SUPPORT') {
698
+ if (error === BROWSER_CAMERA_ERRORS.NOT_SUPPORT) {
692
699
  showMessage(translate('camera.error.notFound'));
693
700
  throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, 'Browser not support WebRTC, or https required.');
694
701
  }
695
- if (error === 'NO_CAMERA') {
702
+ if (error === BROWSER_CAMERA_ERRORS.NO_CAMERA) {
696
703
  showMessage(translate('camera.error.notFound'));
697
704
  throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, 'camera not found');
698
705
  }
699
- if ((error === null || error === void 0 ? void 0 : error.name) === 'NotAllowedError') {
706
+ if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_ALLOWED_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_FOUND_ERROR) {
700
707
  showMessage(translate('camera.error.notFound'));
701
708
  throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
702
709
  }
@@ -1659,7 +1666,7 @@ function stopLoadingSDK() {
1659
1666
  }
1660
1667
 
1661
1668
  var name = "@authme/util";
1662
- var version$1 = "2.2.1-rc.3";
1669
+ var version$1 = "2.2.1";
1663
1670
  var peerDependencies = {
1664
1671
  "core-js": "^3.6.0"
1665
1672
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authme/util",
3
- "version": "2.2.1-rc.3",
3
+ "version": "2.2.1",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
6
  "lottie-web": "5.9.6"