@authme/identity-verification 2.8.14 → 2.8.15

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 +56 -10
  2. package/index.js +57 -11
  3. package/package.json +6 -6
package/index.cjs CHANGED
@@ -28431,7 +28431,18 @@ function startLiveness(config) {
28431
28431
  }
28432
28432
  };
28433
28433
  // Register Event
28434
- rxjs.fromEvent(window, 'offline').pipe(rxjs.switchMap(() => util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), false)), rxjs.takeUntil(unsubscribe$)).subscribe();
28434
+ // fromEvent(window, 'offline')
28435
+ // .pipe(
28436
+ // switchMap(() =>
28437
+ // asyncOnLineShowErrorMessage(
28438
+ // translateService.translate('sdk.general.error.alert.offline'),
28439
+ // translateService.translate('sdk.general.error.retry'),
28440
+ // false
28441
+ // )
28442
+ // ),
28443
+ // takeUntil(unsubscribe$)
28444
+ // )
28445
+ // .subscribe();
28435
28446
  rxjs.fromEvent(window, 'resize').pipe(rxjs.throttleTime(100), rxjs.switchMap(() => util.getCanvasSize(uiComponentBasic.video)), rxjs.tap(canvasSizeInfo => {
28436
28447
  config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight);
28437
28448
  const maskHeight = window.outerHeight * 0.48;
@@ -28558,7 +28569,19 @@ function startLiveness(config) {
28558
28569
  isSuccess: true
28559
28570
  });
28560
28571
  }), rxjs.raceWith(timeout$) // 確保 timeout 之後一定會有失敗結果
28561
- )))), rxjs.switchMap(resp => window.navigator.onLine ? rxjs.of(resp) : rxjs.from(util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), false)).pipe(rxjs.map(() => resp))), rxjs.tap(res => {
28572
+ )))),
28573
+ // switchMap((resp) =>
28574
+ // window.navigator.onLine
28575
+ // ? of(resp)
28576
+ // : from(
28577
+ // asyncOnLineShowErrorMessage(
28578
+ // translateService.translate('sdk.general.error.alert.offline'),
28579
+ // translateService.translate('sdk.general.error.retry'),
28580
+ // false
28581
+ // )
28582
+ // ).pipe(map(() => resp))
28583
+ // ),
28584
+ rxjs.tap(res => {
28562
28585
  // console.log('res', res);
28563
28586
  if (res.isSuccess) {
28564
28587
  sendStatusDescription$2(core.StatusDescription.UploadingStart);
@@ -33054,16 +33077,39 @@ class LivenessModule {
33054
33077
  frameHeight = canvasSizeInfoCan.canvasHeight;
33055
33078
  const params = yield this.fasService.getParams();
33056
33079
  const oldROI = params.faceROI;
33057
- const actualHight = frameHeight * (oldROI.fBottom - oldROI.fTop);
33080
+ const actualHeight = frameHeight * (oldROI.fBottom - oldROI.fTop);
33058
33081
  const actualWidth = frameWidth * (oldROI.fRight - oldROI.fLeft);
33059
33082
  let targetWidth = actualWidth;
33060
- //we change the ROI when horizontal view for desktop camera.
33061
- if (actualWidth > actualHight) {
33062
- targetWidth = actualHight;
33083
+ // //we change the ROI when horizontal view for desktop camera.
33084
+ // if (actualWidth > actualHeight) {
33085
+ // targetWidth = actualHeight;
33086
+ // const widthPercent = targetWidth / frameWidth;
33087
+ // params.faceROI.fLeft = (1 - widthPercent) / 2;
33088
+ // params.faceROI.fRight = 1 - (1 - widthPercent) / 2;
33089
+ // }
33090
+ // 如果是橫向模式 (寬度大於高度)
33091
+ if (actualWidth > actualHeight) {
33092
+ // 計算目標寬度,使得高度與寬度的比例為 9:16
33093
+ // 即 actualHeight : targetWidth = 9 : 16
33094
+ // 所以 targetWidth = (16 / 9) * actualHeight
33095
+ targetWidth = 3 / 4 * actualHeight;
33096
+ // 計算寬度比例
33063
33097
  const widthPercent = targetWidth / frameWidth;
33064
- params.faceROI.fLeft = (1 - widthPercent) / 2;
33065
- params.faceROI.fRight = 1 - (1 - widthPercent) / 2;
33098
+ // 如果計算出的寬度比例小於1,表示需要在兩側留白
33099
+ if (widthPercent < 1) {
33100
+ // 調整左右邊界,使ROI在中間
33101
+ params.faceROI.fLeft = (1 - widthPercent) / 2;
33102
+ params.faceROI.fRight = 1 - (1 - widthPercent) / 2;
33103
+ }
33104
+ // 如果計算出的寬度比例大於1,表示需要裁剪寬度
33105
+ else {
33106
+ // 維持完整的寬度,但可能需要調整其他參數以保持9:16的比例
33107
+ params.faceROI.fLeft = 0;
33108
+ params.faceROI.fRight = 1;
33109
+ // 這裡可能需要調整垂直方向的ROI,根據實際需求添加
33110
+ }
33066
33111
  }
33112
+
33067
33113
  yield this.fasService.setParams(params);
33068
33114
  yield this.fasService.setFrameSize(frameWidth, frameHeight);
33069
33115
  yield this.fasService.startSession();
@@ -35719,8 +35765,8 @@ class AuthmeIdentityVerification extends engine.AuthmeFunctionModule {
35719
35765
  }
35720
35766
 
35721
35767
  var name = "authme/sdk";
35722
- var version$1 = "2.8.14";
35723
- var date = "2025-05-09T02:19:43+0000";
35768
+ var version$1 = "2.8.15";
35769
+ var date = "2025-05-15T12:22:35+0000";
35724
35770
  var packageInfo = {
35725
35771
  name: name,
35726
35772
  version: version$1,
package/index.js CHANGED
@@ -8,7 +8,7 @@ import { getTranslateInstance, EventListenerService, TrackingEvent, generateStat
8
8
  import { EAuthMeFASServiceStatus, EAuthMeIDCardAntiFraudStage as EAuthMeIDCardAntiFraudStage$1, EAuthMeCardClass as EAuthMeCardClass$1, AuthmeFunctionModule, MlEngine, EngineModule, EAuthMeEngineReturnCode, AuthmeEngineModuleBase } from '@authme/engine';
9
9
  import { IdRecognitionCardType, CountryCode, EAuthMeCardClass, EAuthMeIDCardAntiFraudStatus, EAuthMeIDCardAntiFraudStage, thicknessDefaultConfig, mapCardtypeToAuthmeClass, getRecognitionColumnOrder, cardTypeTitle, cardTypeConfirmTitle, cardTypeHeader, EAuthMeCardOCRStatus, EAuthMeMRZServiceStatus, saveExtraDoc, initScanDocumentResourceBase64, MRZService, option, themeUI, initScan, initScanDocument, ResourceImageType, uploadFrameBase64, finishScanDocument, CardOCR, IdCardAntiFraudService, twoWayAuthmeCardClassMap, RecognitionFileType, recognizeBase64, getCardSubTypes, getCardTypes, confirmScan } from '@authme/id-recognition';
10
10
  import { getCssVariable, RGBToLottieColor, colorToRGB, Storage, useState, uiThemeText, uiThemeHint, clearCanvas, getImageData, isMobile, hidePopup, showPopup, waitTime, TIME_UNIT, AuthmeError as AuthmeError$1, ErrorCode as ErrorCode$1, uiThemeButton, uiThemeSmallButton, requestCamera, showElement, asyncOnLineShowErrorMessage, getCanvasSize, startSpinner, stopSpinner, themeConfigDefault, fontWeight, hideElement, dataURItoBlob, showErrorMessage, checkOnlineStatus, dropMenu, UintArrayToBlob, isIphone14proOrProMax, cropByRatio, switchCamera, asyncShowPopup, retryPromiseWithCondition, asyncShowErrorMessage, hideErrorMessage, uploadModal, backgroundRequest, debugTools, showErrorMessageEventName, RUN_FUNCTION_NAME, STORAGE_KEY, splitResult, DEVICE_TYPE, combineResult, startLoadingSDK, stopLoadingSDK } from '@authme/util';
11
- import { mergeMap, animationFrames, filter, tap, map, from, catchError, EMPTY, of, merge, fromEvent, concatAll, takeUntil, Subject, defer, switchMap, throttleTime, raceWith, concatMap, throwError, finalize, timer, Observable, take, interval, mapTo, firstValueFrom, shareReplay, switchMapTo, takeWhile as takeWhile$1, race } from 'rxjs';
11
+ import { mergeMap, animationFrames, filter, tap, map, from, catchError, EMPTY, of, merge, fromEvent, concatAll, takeUntil, Subject, defer, throttleTime, switchMap, raceWith, concatMap, throwError, finalize, timer, Observable, take, interval, mapTo, firstValueFrom, shareReplay, switchMapTo, takeWhile as takeWhile$1, race } from 'rxjs';
12
12
  import 'core-js/modules/es.regexp.to-string.js';
13
13
  import { FasRecognitionResult, EAuthMeFASServiceStage, FasService, LivenessAPI, EAuthMeMouthStatus, LivenessResultStatus } from '@authme/liveness';
14
14
  import 'core-js/modules/es.parse-float.js';
@@ -28423,7 +28423,18 @@ function startLiveness(config) {
28423
28423
  }
28424
28424
  };
28425
28425
  // Register Event
28426
- fromEvent(window, 'offline').pipe(switchMap(() => asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), false)), takeUntil(unsubscribe$)).subscribe();
28426
+ // fromEvent(window, 'offline')
28427
+ // .pipe(
28428
+ // switchMap(() =>
28429
+ // asyncOnLineShowErrorMessage(
28430
+ // translateService.translate('sdk.general.error.alert.offline'),
28431
+ // translateService.translate('sdk.general.error.retry'),
28432
+ // false
28433
+ // )
28434
+ // ),
28435
+ // takeUntil(unsubscribe$)
28436
+ // )
28437
+ // .subscribe();
28427
28438
  fromEvent(window, 'resize').pipe(throttleTime(100), switchMap(() => getCanvasSize(uiComponentBasic.video)), tap(canvasSizeInfo => {
28428
28439
  config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight);
28429
28440
  const maskHeight = window.outerHeight * 0.48;
@@ -28550,7 +28561,19 @@ function startLiveness(config) {
28550
28561
  isSuccess: true
28551
28562
  });
28552
28563
  }), raceWith(timeout$) // 確保 timeout 之後一定會有失敗結果
28553
- )))), switchMap(resp => window.navigator.onLine ? of(resp) : from(asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), false)).pipe(map(() => resp))), tap(res => {
28564
+ )))),
28565
+ // switchMap((resp) =>
28566
+ // window.navigator.onLine
28567
+ // ? of(resp)
28568
+ // : from(
28569
+ // asyncOnLineShowErrorMessage(
28570
+ // translateService.translate('sdk.general.error.alert.offline'),
28571
+ // translateService.translate('sdk.general.error.retry'),
28572
+ // false
28573
+ // )
28574
+ // ).pipe(map(() => resp))
28575
+ // ),
28576
+ tap(res => {
28554
28577
  // console.log('res', res);
28555
28578
  if (res.isSuccess) {
28556
28579
  sendStatusDescription$2(StatusDescription.UploadingStart);
@@ -33046,16 +33069,39 @@ class LivenessModule {
33046
33069
  frameHeight = canvasSizeInfoCan.canvasHeight;
33047
33070
  const params = yield this.fasService.getParams();
33048
33071
  const oldROI = params.faceROI;
33049
- const actualHight = frameHeight * (oldROI.fBottom - oldROI.fTop);
33072
+ const actualHeight = frameHeight * (oldROI.fBottom - oldROI.fTop);
33050
33073
  const actualWidth = frameWidth * (oldROI.fRight - oldROI.fLeft);
33051
33074
  let targetWidth = actualWidth;
33052
- //we change the ROI when horizontal view for desktop camera.
33053
- if (actualWidth > actualHight) {
33054
- targetWidth = actualHight;
33075
+ // //we change the ROI when horizontal view for desktop camera.
33076
+ // if (actualWidth > actualHeight) {
33077
+ // targetWidth = actualHeight;
33078
+ // const widthPercent = targetWidth / frameWidth;
33079
+ // params.faceROI.fLeft = (1 - widthPercent) / 2;
33080
+ // params.faceROI.fRight = 1 - (1 - widthPercent) / 2;
33081
+ // }
33082
+ // 如果是橫向模式 (寬度大於高度)
33083
+ if (actualWidth > actualHeight) {
33084
+ // 計算目標寬度,使得高度與寬度的比例為 9:16
33085
+ // 即 actualHeight : targetWidth = 9 : 16
33086
+ // 所以 targetWidth = (16 / 9) * actualHeight
33087
+ targetWidth = 3 / 4 * actualHeight;
33088
+ // 計算寬度比例
33055
33089
  const widthPercent = targetWidth / frameWidth;
33056
- params.faceROI.fLeft = (1 - widthPercent) / 2;
33057
- params.faceROI.fRight = 1 - (1 - widthPercent) / 2;
33090
+ // 如果計算出的寬度比例小於1,表示需要在兩側留白
33091
+ if (widthPercent < 1) {
33092
+ // 調整左右邊界,使ROI在中間
33093
+ params.faceROI.fLeft = (1 - widthPercent) / 2;
33094
+ params.faceROI.fRight = 1 - (1 - widthPercent) / 2;
33095
+ }
33096
+ // 如果計算出的寬度比例大於1,表示需要裁剪寬度
33097
+ else {
33098
+ // 維持完整的寬度,但可能需要調整其他參數以保持9:16的比例
33099
+ params.faceROI.fLeft = 0;
33100
+ params.faceROI.fRight = 1;
33101
+ // 這裡可能需要調整垂直方向的ROI,根據實際需求添加
33102
+ }
33058
33103
  }
33104
+
33059
33105
  yield this.fasService.setParams(params);
33060
33106
  yield this.fasService.setFrameSize(frameWidth, frameHeight);
33061
33107
  yield this.fasService.startSession();
@@ -35711,8 +35757,8 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
35711
35757
  }
35712
35758
 
35713
35759
  var name = "authme/sdk";
35714
- var version$1 = "2.8.14";
35715
- var date = "2025-05-09T02:19:43+0000";
35760
+ var version$1 = "2.8.15";
35761
+ var date = "2025-05-15T12:22:35+0000";
35716
35762
  var packageInfo = {
35717
35763
  name: name,
35718
35764
  version: version$1,
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@authme/identity-verification",
3
- "version": "2.8.14",
3
+ "version": "2.8.15",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
6
  "lottie-web": "^5.9.2",
7
7
  "rxjs": "^7.4.0",
8
- "@authme/core": "2.8.14",
9
- "@authme/engine": "2.8.14",
10
- "@authme/id-recognition": "2.8.14",
11
- "@authme/liveness": "2.8.14",
12
- "@authme/util": "2.8.14"
8
+ "@authme/core": "2.8.15",
9
+ "@authme/engine": "2.8.15",
10
+ "@authme/id-recognition": "2.8.15",
11
+ "@authme/liveness": "2.8.15",
12
+ "@authme/util": "2.8.15"
13
13
  },
14
14
  "module": "./index.js",
15
15
  "main": "./index.cjs",