@authme/identity-verification 2.4.8 → 2.4.10

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/index.js CHANGED
@@ -4,8 +4,8 @@ import 'core-js/modules/es.object.assign.js';
4
4
  import 'core-js/modules/es.array.includes.js';
5
5
  import 'core-js/modules/es.string.includes.js';
6
6
  import { getTranslateInstance, EventListenerService, TrackingEvent, generateStatus, StatusDescription, StatusView, StatusAction, AuthmeError, ErrorCode, Feature, StatusEvent, setRequestLoggingFunc, setAccessToken } from '@authme/core';
7
- import { EAuthMeFASServiceStatus, EAuthMeIDCardAntiFraudStage as EAuthMeIDCardAntiFraudStage$1, EAuthMeCardClass as EAuthMeCardClass$1, AuthmeFunctionModule, MlEngine, EngineModule, EAuthMeEngineReturnCode } from '@authme/engine';
8
- import { IdRecognitionCardType, CountryCode, EAuthMeCardClass, mapCardtypeToAuthmeClass, cardTypeTitle, cardTypeConfirmTitle, getRecognitionColumnOrder, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeCardOCRStatus, EAuthMeMRZServiceStatus, saveExtraDoc, MRZService, init, initScanDocument, twoWayAuthmeCardClassMap, uploadFrameBase64, ResourceImageType, finishScanDocument, CardOCR, IdCardAntiFraudService, recognitionEncrypt, RecognitionFileType, getCardSubTypes, confirmScan } from '@authme/id-recognition';
7
+ import { EAuthMeFASServiceStatus, EAuthMeIDCardAntiFraudStage as EAuthMeIDCardAntiFraudStage$1, AuthmeFunctionModule, MlEngine, EngineModule, EAuthMeEngineReturnCode } from '@authme/engine';
8
+ import { IdRecognitionCardType, CountryCode, EAuthMeCardClass, getRecognitionColumnOrder, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeCardOCRStatus, EAuthMeMRZServiceStatus, saveExtraDoc, MRZService, init, initScanDocument, twoWayAuthmeCardClassMap, uploadFrameBase64, ResourceImageType, finishScanDocument, CardOCR, IdCardAntiFraudService, recognitionEncrypt, RecognitionFileType, getCardSubTypes, confirmScan } from '@authme/id-recognition';
9
9
  import { getCssVariable, RGBToLottieColor, colorToRGB, Icon, useState, clearCanvas, getImageData, hidePopup, showPopup, waitTime, TIME_UNIT, AuthmeError as AuthmeError$1, ErrorCode as ErrorCode$1, requestCamera, showElement, asyncOnLineShowErrorMessage, getCanvasSize, startSpinner, stopSpinner, showErrorMessage, hideElement, isIphone14proOrProMax, cropByRatio, checkOnlineStatus, asyncShowErrorMessage, switchCamera, UintArrayToBlob, asyncShowPopup, retryPromiseWithCondition, hideErrorMessage, dataURItoBlob, backgroundRequest, debugTools, showErrorMessageEventName, RUN_FUNCTION_NAME, Storage, STORAGE_KEY, splitResult, combineResult, startLoadingSDK, stopLoadingSDK } from '@authme/util';
10
10
  import { mergeMap, animationFrames, filter, tap, map, from, catchError, EMPTY, merge, fromEvent, of, concatAll, takeUntil, Subject, defer, switchMap, throttleTime, take, concatMap, throwError, finalize, shareReplay, switchMapTo, firstValueFrom, takeWhile, mapTo, race } from 'rxjs';
11
11
  import 'core-js/modules/es.regexp.to-string.js';
@@ -80,9 +80,6 @@ const defaultExtraDocumentConfig = {
80
80
  icon: DEFAULT_ICON_URI,
81
81
  headerMode: 1,
82
82
  requestInfoHandler: () => ({}),
83
- showCloseButton: true,
84
- continue: true,
85
- border: undefined,
86
83
  extraText: {
87
84
  title: 'extra.title"',
88
85
  frontSide: 'extra.frontSide"',
@@ -114,8 +111,7 @@ const defaultIdRecognitionConfig = {
114
111
  hotfixIphone14proCameraBlur: true,
115
112
  uploadFullFrame: true,
116
113
  disablePassportConfirm: false,
117
- antiFraudIMetalTagValidCountTh: false,
118
- cardTypes: []
114
+ antiFraudIMetalTagValidCountTh: false
119
115
  };
120
116
 
121
117
  function setCorrectViewHeight() {
@@ -23671,10 +23667,10 @@ const limitFPS = fps => {
23671
23667
  return delta > interval;
23672
23668
  }));
23673
23669
  };
23674
- const sendFrame = (canvasSizeInfo, canvas, video, frameCallback, fps, bas64Format, imageType, cardType, flags, type) => source$ => {
23670
+ const sendFrame = (canvasSizeInfo, canvas, video, frameCallback, fps, bas64Format, imageType, flags, type) => source$ => {
23675
23671
  let received = true;
23676
23672
  const ctx = canvas.getContext('2d');
23677
- return source$.pipe(mergeMap(() => animationFrames().pipe(limitFPS(fps), filter(() => received && !(flags === null || flags === void 0 ? void 0 : flags.animating)), tap(() => received = false), tap(() => clearCanvas(canvas)), map(() => getImageData(canvas, ctx, video, canvasSizeInfo, bas64Format, imageType)), mergeMap(imageData => from(frameCallback(imageData.data, imageData.base64, cardType, type)).pipe(catchError(e => {
23673
+ return source$.pipe(mergeMap(() => animationFrames().pipe(limitFPS(fps), filter(() => received && !(flags === null || flags === void 0 ? void 0 : flags.animating)), tap(() => received = false), tap(() => clearCanvas(canvas)), map(() => getImageData(canvas, ctx, video, canvasSizeInfo, bas64Format, imageType)), mergeMap(imageData => from(frameCallback(imageData.data, imageData.base64, type)).pipe(catchError(e => {
23678
23674
  // send to fast, ignore
23679
23675
  if (e instanceof AuthmeError && e.code === ErrorCode.RECOGNITION_NOT_AVAILABLE) {
23680
23676
  return EMPTY;
@@ -23969,7 +23965,7 @@ function startLiveness(config) {
23969
23965
  titleTextPanel,
23970
23966
  statusTextPanel
23971
23967
  });
23972
- })).pipe(sendFrame(canvasSizeInfo, canvas, video, config.onFrame, livenessConfig.fasMaxFps, true, 'all', undefined, frameFlags), tap(({
23968
+ })).pipe(sendFrame(canvasSizeInfo, canvas, video, config.onFrame, livenessConfig.fasMaxFps, true, 'all', frameFlags), tap(({
23973
23969
  result
23974
23970
  }) => applyTextByResult(result)), filter(({
23975
23971
  result
@@ -24482,7 +24478,6 @@ const renderOCRMask = params => {
24482
24478
  svg.style.position = 'absolute';
24483
24479
  svg.style.top = '0';
24484
24480
  svg.style.left = '0';
24485
- svg.style.boxShadow = 'rgba(0, 0, 0, 0.65) 0 0 0 2000px';
24486
24481
  // 創建遮罩
24487
24482
  const defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
24488
24483
  const mask = document.createElementNS('http://www.w3.org/2000/svg', 'mask');
@@ -24512,6 +24507,8 @@ const renderOCRMask = params => {
24512
24507
  svg.appendChild(pathOfFrame);
24513
24508
  // 添加SVG到容器
24514
24509
  container.appendChild(svg);
24510
+ const windowWidth = window.innerWidth;
24511
+ const windowHeight = window.innerHeight;
24515
24512
  const radius = 10;
24516
24513
  const setCardPoints = (_newCardPoints, mirrored = false) => {
24517
24514
  const newCardPoints = mirrored ? mirrorPoints(_newCardPoints) : _newCardPoints;
@@ -24521,8 +24518,6 @@ const renderOCRMask = params => {
24521
24518
  }, index) => {
24522
24519
  var _a, _b;
24523
24520
  const command = index === 0 ? 'M' : 'L'; // 第一個點用'M',其餘的點用'L'
24524
- const windowWidth = container.offsetWidth;
24525
- const windowHeight = container.offsetHeight;
24526
24521
  const previosPoint = (_a = newCardPoints[index - 1]) !== null && _a !== void 0 ? _a : newCardPoints[newCardPoints.length - 1];
24527
24522
  const nextPoint = (_b = newCardPoints[index + 1]) !== null && _b !== void 0 ? _b : newCardPoints[0];
24528
24523
  const _x1 = windowWidth * previosPoint.x;
@@ -24555,8 +24550,6 @@ const renderOCRMask = params => {
24555
24550
  const lineRotio = 2;
24556
24551
  const previosPoint = (_a = newCardPoints[index - 1]) !== null && _a !== void 0 ? _a : newCardPoints[newCardPoints.length - 1];
24557
24552
  const nextPoint = (_b = newCardPoints[index + 1]) !== null && _b !== void 0 ? _b : newCardPoints[0];
24558
- const windowWidth = container.offsetWidth;
24559
- const windowHeight = container.offsetHeight;
24560
24553
  const _x1 = windowWidth * previosPoint.x;
24561
24554
  const _y1 = windowHeight * previosPoint.y;
24562
24555
  const _x2 = windowWidth * x;
@@ -25093,7 +25086,7 @@ function startOCR(config) {
25093
25086
  initEvenTrackingStatus(config.ocrConfig);
25094
25087
  const getCardBorderPoint = () => {
25095
25088
  if (cardSizeInfo.width === 0 || cardSizeInfo.height === 0) {
25096
- setCardSize(mapCardtypeToAuthmeClass(config.cardTypes[0]));
25089
+ setCardSize(config.acceptTypes[0]);
25097
25090
  }
25098
25091
  const windowCenterX = window.innerWidth / 2;
25099
25092
  const windowCenterY = window.innerHeight / 2;
@@ -25316,7 +25309,7 @@ function startOCR(config) {
25316
25309
  if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
25317
25310
  sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
25318
25311
  }
25319
- })), sendFrame(canvasSizeInfo, image, video, config.onAntiFraudFrame, ocrEngineConfig.fraudMaxFps, false, 'jpg', undefined), map(x => x.result), tap(x => {
25312
+ })), sendFrame(canvasSizeInfo, image, video, config.onAntiFraudFrame, ocrEngineConfig.fraudMaxFps, false, 'jpg'), map(x => x.result), tap(x => {
25320
25313
  applyTextByResult(x);
25321
25314
  cardRotateByStage(x.eStage);
25322
25315
  cardRotateTextProcess(x.eStage);
@@ -25364,7 +25357,7 @@ function startOCR(config) {
25364
25357
  // workaround?: 將animation$作為停止。
25365
25358
  return merge(handleSuccess$).pipe(take(1));
25366
25359
  }
25367
- function startOCR(type, cardType) {
25360
+ function startOCR(type) {
25368
25361
  if (!config.ocrConfig.needOCR && type === EAuthMeCardClass.TWN_IDCard_Front) {
25369
25362
  return of(true);
25370
25363
  }
@@ -25427,7 +25420,7 @@ function startOCR(config) {
25427
25420
  showCameraSwitchButton(deviceMetas);
25428
25421
  }
25429
25422
  };
25430
- const init = retry => canvasSizeInfo$.pipe(take(1), switchMap(canvasSizeInfo => from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(switchMap(() => checkOnlineStatus(translateService.translate('network.error.offline'))), switchMap(() => config.ocrStart(getCardBorderPoint(), type, cardType, retry)), tap(() => {
25423
+ const init = retry => canvasSizeInfo$.pipe(take(1), switchMap(canvasSizeInfo => from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(switchMap(() => checkOnlineStatus(translateService.translate('network.error.offline'))), switchMap(() => config.ocrStart(getCardBorderPoint(), type, retry)), tap(() => {
25431
25424
  stopSpinner();
25432
25425
  showElement(scanAnimationContainer);
25433
25426
  scanAnimationContainer.style.width = `${cardSizeInfo.width + scanPadding}px`;
@@ -25441,7 +25434,7 @@ function startOCR(config) {
25441
25434
  if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
25442
25435
  sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
25443
25436
  }
25444
- }), switchMap(canvasSizeInfo => of(canvasSizeInfo).pipe(sendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, 'jpg', cardType, undefined, type), tap(x => applyTextByResult(x.result)), filter(({
25437
+ }), switchMap(canvasSizeInfo => of(canvasSizeInfo).pipe(sendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, 'jpg', undefined, type), tap(x => applyTextByResult(x.result)), filter(({
25445
25438
  result
25446
25439
  }) => result.eStatus === EAuthMeCardOCRStatus.Pass || result.eStatus === EAuthMeMRZServiceStatus.Success),
25447
25440
  // ocrEngineConfig.expiredIn
@@ -25464,21 +25457,21 @@ function startOCR(config) {
25464
25457
  result
25465
25458
  }) => from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(switchMap(needRetry => {
25466
25459
  startSpinner(translateService.translate('verify.uploading'));
25467
- return needRetry ? of(true) : from(config.confirmImage(type, cardType)).pipe(tap(() => sendStatusAction$1(StatusAction.Uploading)), map(confirmResp => !confirmResp));
25460
+ return needRetry ? of(true) : from(config.confirmImage(type)).pipe(tap(() => sendStatusAction$1(StatusAction.Uploading)), map(confirmResp => !confirmResp));
25468
25461
  }), tap(() => {
25469
25462
  hideElement(confirmImageContainer);
25470
25463
  showVideoElement();
25471
25464
  }), switchMap(needRetry => needRetry ? recognition(true) : of(true)))))));
25472
25465
  return recognition(false);
25473
25466
  }
25474
- function createFlowByType(type, cardType) {
25467
+ function createFlowByType(type) {
25475
25468
  return of(true).pipe(tap(() => {
25476
25469
  setStatusEvent$1(cardClassMapping(type));
25477
- setUIByType(type, cardType);
25470
+ setUIByType(type);
25478
25471
  }), switchMap(() => startAntiFraud(type)), tap(() => {
25479
25472
  setStatusEvent$1(cardClassMapping(type));
25480
- setUIByType(type, cardType);
25481
- }), switchMap(() => startOCR(type, cardType)));
25473
+ setUIByType(type);
25474
+ }), switchMap(() => startOCR(type)));
25482
25475
  }
25483
25476
  function main() {
25484
25477
  const flags = {
@@ -25493,8 +25486,8 @@ function startOCR(config) {
25493
25486
  } else {
25494
25487
  startSpinner(translateService.translate('general.loading'));
25495
25488
  }
25496
- const flow$ = config.cardTypes.map(x => createFlowByType(mapCardtypeToAuthmeClass(x), x)).reduce((prev, cur) => prev.pipe(switchMap(() => cur)), canvasSizeInfo$.pipe(take(1), tap(() => {
25497
- setUIByType(mapCardtypeToAuthmeClass(config.cardTypes[0]), config.cardTypes[0]);
25489
+ const flow$ = config.acceptTypes.map(x => createFlowByType(x)).reduce((prev, cur) => prev.pipe(switchMap(() => cur)), canvasSizeInfo$.pipe(take(1), tap(() => {
25490
+ setUIByType(config.acceptTypes[0]);
25498
25491
  }), switchMap(canvasSizeInfo => from(config.init(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(tap(x => ocrEngineConfig = x), tap(() => __awaiter(this, void 0, void 0, function* () {
25499
25492
  if (config.ocrConfig.needAntiFraud) return;
25500
25493
  stopSpinner();
@@ -25639,13 +25632,13 @@ function startOCR(config) {
25639
25632
  function setTopText(title) {
25640
25633
  titleText.textContent = title;
25641
25634
  }
25642
- function setUIByType(type, cardType) {
25643
- setTextByType(type, cardType);
25635
+ function setUIByType(type) {
25636
+ setTextByType(type);
25644
25637
  setHeaderByType(type);
25645
25638
  setCardSize(type);
25646
25639
  }
25647
- function setTextByType(type, cardType) {
25648
- var _a, _b, _c;
25640
+ function setTextByType(type) {
25641
+ var _a, _b;
25649
25642
  const _typeMap = {
25650
25643
  EAuthMeCardClass_Passport: 'verify.passportFrontSide',
25651
25644
  EAuthMeCardClass_TWN_IDCard_Front: 'verify.idCardFrontSide',
@@ -25658,12 +25651,7 @@ function startOCR(config) {
25658
25651
  EAuthMeCardClass_TWN_VehiclesLicense_Front: 'verify.vehiclesLicenseFrontSide'
25659
25652
  };
25660
25653
  const typeMap = _typeMap;
25661
- let titleKey = typeMap[`${type}`];
25662
- if (typeMap[`${type}`] == null) {
25663
- titleText.textContent = translateService.translate((_a = typeMap[`${type}`]) !== null && _a !== void 0 ? _a : 'verify.unexpected');
25664
- titleKey = (_b = cardTypeTitle(cardType !== null && cardType !== void 0 ? cardType : '')) !== null && _b !== void 0 ? _b : '';
25665
- }
25666
- titleText.textContent = translateService.translate(titleKey !== null && titleKey !== void 0 ? titleKey : 'verify.unexpected');
25654
+ titleText.textContent = translateService.translate((_a = typeMap[`${type}`]) !== null && _a !== void 0 ? _a : 'verify.unexpected');
25667
25655
  statusText.textContent = '';
25668
25656
  statusText.classList.remove('non-empty');
25669
25657
  hintText.textContent = type.includes('Back') ? translateService.translate('verify.backSide') : translateService.translate('verify.frontSide');
@@ -25679,11 +25667,7 @@ function startOCR(config) {
25679
25667
  EAuthMeCardClass_TWN_VehiclesLicense_Front: 'verify.confirmVehiclesLicenseFrontSide'
25680
25668
  };
25681
25669
  const typeConfirmTextMap = _typeConfirmTextMap;
25682
- let titleConfirmKey = typeConfirmTextMap[type];
25683
- if (titleConfirmKey == null) {
25684
- titleConfirmKey = (_c = cardTypeConfirmTitle(cardType !== null && cardType !== void 0 ? cardType : '')) !== null && _c !== void 0 ? _c : '';
25685
- }
25686
- imageTypeText.textContent = translateService.translate(titleConfirmKey !== null && titleConfirmKey !== void 0 ? titleConfirmKey : 'verify.confirm.unexpected');
25670
+ imageTypeText.textContent = translateService.translate((_b = typeConfirmTextMap[type]) !== null && _b !== void 0 ? _b : 'verify.confirm.unexpected');
25687
25671
  }
25688
25672
  function setHeaderByType(type) {
25689
25673
  const typeMap = {
@@ -25980,8 +25964,7 @@ const renderExtraUI = config => {
25980
25964
  endBtn,
25981
25965
  completeBtn,
25982
25966
  continueBtn,
25983
- image,
25984
- cardborderContainer
25967
+ image
25985
25968
  };
25986
25969
  };
25987
25970
 
@@ -26003,8 +25986,7 @@ function startExtra(config) {
26003
25986
  } = renderBasicUI({
26004
25987
  headerIcon: config.extraConfig.icon,
26005
25988
  headerMode: config.extraConfig.headerMode,
26006
- showPictureButton: true,
26007
- showCloseButton: config.extraConfig.showCloseButton
25989
+ showPictureButton: true
26008
25990
  });
26009
25991
  const {
26010
25992
  titleTextPanel,
@@ -26014,50 +25996,38 @@ function startExtra(config) {
26014
25996
  completeBtn,
26015
25997
  endBtn,
26016
25998
  continueBtn,
26017
- image,
26018
- cardborderContainer
25999
+ image
26019
26000
  } = renderExtraUI({
26020
26001
  videoContainer,
26021
26002
  container
26022
26003
  });
26023
- if (config.extraConfig.border == 'none') {
26024
- hideElement(cardborderContainer);
26025
- } else {
26026
- showElement(cardborderContainer);
26027
- }
26028
26004
  const canvas = document.createElement('canvas');
26029
26005
  // Register Event
26030
- const requestCamera$ = of(true).pipe(tap(() => {
26006
+ of(true).pipe(tap(() => {
26031
26007
  startSpinner(translateService.translate('general.loading'));
26032
26008
  }), switchMap(() => from(requestCamera({
26033
26009
  video,
26034
26010
  facingMode: 'back',
26035
26011
  translate: key => translateService.translate(key),
26036
26012
  showMessage: message => alert(message)
26037
- })).pipe(catchError(() => {
26038
- reset();
26039
- throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT);
26013
+ })).pipe(catchError(error => {
26014
+ if (error instanceof OverconstrainedError) {
26015
+ alert(translateService.translate('camera.error.notFound'));
26016
+ } else {
26017
+ alert(translateService.translate('camera.error.notFound'));
26018
+ }
26019
+ return throwError(() => new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT));
26040
26020
  }))), tap(() => {
26041
26021
  stopSpinner();
26042
26022
  showElement(videoContainer);
26043
- }));
26023
+ })).subscribe();
26044
26024
  fromEvent(window, 'offline').pipe(switchMap(() => asyncOnLineShowErrorMessage(translateService.translate('network.error.offline'), true)), takeUntil(unsubscribe$)).subscribe();
26045
26025
  fromEvent(window, 'resize').pipe(throttleTime(100), switchMap(() => getCanvasSize(video)), takeUntil(unsubscribe$)).subscribe();
26046
26026
  fromEvent(closeIcon, 'click').pipe(switchMap(() => reset()), takeUntil(unsubscribe$)).subscribe();
26047
26027
  fromEvent(pictureIcon, 'click').pipe(switchMap(() => getCanvasSize(video)), switchMap(canvasSizeInfo => from(checkConfirmImage(canvasSizeInfo)).pipe(switchMap(needRetry => needRetry ? of(true) : from(config.confirmImage(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight, imageData, canvas)).pipe(map(confirmResp => !confirmResp))), tap(() => {
26048
- if (config.extraConfig.border == 'none') {
26049
- hideElement(cardborderContainer);
26050
- } else {
26051
- showElement(cardborderContainer);
26052
- }
26053
26028
  showVideoElement();
26054
26029
  hideElement(confirmImageContainer);
26055
- }))), switchMap(needRetry => needRetry ? of(true) : config.extraConfig.continue === false ? reset() : from(takeOtherImage()).pipe(switchMap(needContinue => needContinue ? of(true) : of(false)), tap(() => {
26056
- if (config.extraConfig.border == 'none') {
26057
- hideElement(cardborderContainer);
26058
- } else {
26059
- showElement(cardborderContainer);
26060
- }
26030
+ }))), switchMap(needRetry => needRetry ? of(true) : from(takeOtherImage()).pipe(switchMap(needContinue => needContinue ? of(true) : of(false)), tap(() => {
26061
26031
  showVideoElement();
26062
26032
  hideElement(checkOtherImageContainer);
26063
26033
  }), switchMap(needContinue => needContinue ? of(true) : reset()))), takeUntil(unsubscribe$)).subscribe();
@@ -26073,7 +26043,7 @@ function startExtra(config) {
26073
26043
  message: new AuthmeError(ErrorCode.USER_CANCEL).message,
26074
26044
  data: {}
26075
26045
  })), takeUntil(unsubscribe$));
26076
- return requestCamera$.pipe(switchMap(() => cancel$)).pipe(take(1));
26046
+ return merge(cancel$).pipe(take(1));
26077
26047
  }
26078
26048
  return main();
26079
26049
  function showVideoElement(isShow = true) {
@@ -26681,7 +26651,7 @@ class MRZModule {
26681
26651
  var _a, _b;
26682
26652
  frameWidth = width;
26683
26653
  frameHeight = height;
26684
- const resp = yield SendRequestWithRetry$1(() => init(config.type, config.country, config.needConfirm, config.cardTypes));
26654
+ const resp = yield SendRequestWithRetry$1(() => init(config.type, config.country, config.needConfirm));
26685
26655
  pubKey = resp.parameters.pubKey;
26686
26656
  scanId = resp.scanId;
26687
26657
  uploadFullFrame = (_b = (_a = resp.parameters.fraud) === null || _a === void 0 ? void 0 : _a.collectAllFrames) !== null && _b !== void 0 ? _b : config.uploadFullFrame;
@@ -26694,7 +26664,7 @@ class MRZModule {
26694
26664
  expiredIn: resp.expiredIn
26695
26665
  });
26696
26666
  }),
26697
- ocrStart: (points, type, cardType, retry = false) => __awaiter(this, void 0, void 0, function* () {
26667
+ ocrStart: (points, type, retry = false) => __awaiter(this, void 0, void 0, function* () {
26698
26668
  yield this.mrzService.init();
26699
26669
  yield this.mrzService.setFrameSize(frameWidth, frameHeight);
26700
26670
  yield this.mrzService.setMaskPosition(points.map(([x, y]) => [Number(x.toFixed(2)), Number(y.toFixed(2))]));
@@ -26767,7 +26737,6 @@ class MRZModule {
26767
26737
  return false;
26768
26738
  }
26769
26739
  }),
26770
- cardTypes: config.cardTypes,
26771
26740
  antiFraudStart: () => __awaiter(this, void 0, void 0, function* () {
26772
26741
  throw 'MRZ Fraud Not Supported.';
26773
26742
  }),
@@ -26989,7 +26958,7 @@ class OCRModule {
26989
26958
  yield this.antiFraudInstance.destroy();
26990
26959
  });
26991
26960
  }
26992
- run(config, cardTypes) {
26961
+ run(config, acceptTypes) {
26993
26962
  return __awaiter(this, void 0, void 0, function* () {
26994
26963
  let scanId = '';
26995
26964
  let frameHeight = 0;
@@ -27040,9 +27009,7 @@ class OCRModule {
27040
27009
  var _a, _b, _c, _d;
27041
27010
  frameWidth = width;
27042
27011
  frameHeight = height;
27043
- const resp = yield SendRequestWithRetry(() => {
27044
- return init(config.type, config.country, config.needConfirm, config.cardTypes);
27045
- }, {
27012
+ const resp = yield SendRequestWithRetry(() => init(config.type, config.country, config.needConfirm), {
27046
27013
  onErrorHandler(e) {
27047
27014
  var _a, _b, _c;
27048
27015
  const _error = e;
@@ -27087,8 +27054,8 @@ class OCRModule {
27087
27054
  expiredIn: resp.expiredIn
27088
27055
  });
27089
27056
  }),
27090
- ocrStart: (points, type, cardType, retry = false) => __awaiter(this, void 0, void 0, function* () {
27091
- const _service = type === EAuthMeCardClass$1.TWN_ResidentCard_Back // workaround: resident card need MRZ, refactor later.
27057
+ ocrStart: (points, type, retry = false) => __awaiter(this, void 0, void 0, function* () {
27058
+ const _service = type === EAuthMeCardClass.TWN_ResidentCard_Back // workaround: resident card need MRZ, refactor later.
27092
27059
  ? this.residentCardMrzService : this.ocrService;
27093
27060
  yield _service.init();
27094
27061
  yield _service.setFrameSize(frameWidth, frameHeight);
@@ -27097,29 +27064,17 @@ class OCRModule {
27097
27064
  const newParams = {};
27098
27065
  const oldParams = yield this.ocrService.getParams();
27099
27066
  newParams[F_IMAGE_BLUE_TH] = 750;
27100
- newParams['fCardMatchTh'] = 0.5;
27101
27067
  yield this.ocrService.setParams(Object.assign(Object.assign({}, oldParams), newParams));
27102
- if (cardTypes.map(mapCardtypeToAuthmeClass).filter(n => n == EAuthMeCardClass$1.Unknown).length > 0) {
27103
- this.ocrService.setOption({
27104
- key: 'ignore_card_type_checking',
27105
- value: 'enable'
27106
- });
27107
- } else {
27108
- this.ocrService.setOption({
27109
- key: 'ignore_card_type_checking',
27110
- value: 'disable'
27111
- });
27112
- }
27113
27068
  yield _service.startSession();
27114
27069
  if (retry) {
27115
- docInfos[cardType].ocrImg = null;
27116
- docInfos[cardType].ocrOriginImg = null;
27070
+ docInfos[type].ocrImg = null;
27071
+ docInfos[type].ocrOriginImg = null;
27117
27072
  } else {
27118
- const resp = yield SendRequestWithRetry(() => initScanDocument(scanId, cardType));
27119
- if (docInfos[cardType]) {
27120
- docInfos[cardType].docId = resp.scanDocumentId;
27073
+ const resp = yield SendRequestWithRetry(() => initScanDocument(scanId, twoWayAuthmeCardClassMap.toServer(type)));
27074
+ if (docInfos[type]) {
27075
+ docInfos[type].docId = resp.scanDocumentId;
27121
27076
  } else {
27122
- docInfos[cardType] = {
27077
+ docInfos[type] = {
27123
27078
  docId: resp.scanDocumentId,
27124
27079
  ocrImg: null,
27125
27080
  ocrOriginImg: null,
@@ -27130,12 +27085,11 @@ class OCRModule {
27130
27085
  }
27131
27086
  return true;
27132
27087
  }),
27133
- cardTypes,
27134
- acceptTypes: cardTypes.map(mapCardtypeToAuthmeClass),
27135
- recognition: (data, _base64, cardType, type) => __awaiter(this, void 0, void 0, function* () {
27088
+ acceptTypes,
27089
+ recognition: (data, _base64, type) => __awaiter(this, void 0, void 0, function* () {
27136
27090
  const durationTimeRecognition = setTimeDuration(`ocr_recognition_${type}`);
27137
27091
  nextDebugRound(type);
27138
- const _service = type === EAuthMeCardClass$1.TWN_ResidentCard_Back // workaround: resident card need MRZ, refactor later.
27092
+ const _service = type === EAuthMeCardClass.TWN_ResidentCard_Back // workaround: resident card need MRZ, refactor later.
27139
27093
  ? this.residentCardMrzService : this.ocrService;
27140
27094
  const result = yield functionLogging(() => __awaiter(this, void 0, void 0, function* () {
27141
27095
  return yield _service.recognition(data);
@@ -27161,12 +27115,10 @@ class OCRModule {
27161
27115
  height: frameHeight
27162
27116
  });
27163
27117
  const ocrOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
27164
- // console.log("cardType:" + cardType + ":" + docInfos[cardType ?? ""]);
27165
- const eClass = cardType !== null && cardType !== void 0 ? cardType : '';
27166
- if (result.eStatus === EAuthMeCardOCRStatus.Pass && result.imageData && !!docInfos[eClass].docId) {
27118
+ if (result.eStatus === EAuthMeCardOCRStatus.Pass && result.imageData && !!docInfos[result.info.cardClass.eClass].docId) {
27167
27119
  const resultOcrImg = UintArrayToBlob(result.iWidth, result.iHeight, result === null || result === void 0 ? void 0 : result.imageData, virtualCanvas);
27168
- docInfos[eClass].ocrImg = resultOcrImg;
27169
- docInfos[eClass].ocrOriginImg = ocrOriginImg;
27120
+ docInfos[result.info.cardClass.eClass].ocrImg = resultOcrImg;
27121
+ docInfos[result.info.cardClass.eClass].ocrOriginImg = ocrOriginImg;
27170
27122
  yield _service.stop();
27171
27123
  pushNewDebugImage(ocrOriginImg, {
27172
27124
  result: result,
@@ -27183,7 +27135,7 @@ class OCRModule {
27183
27135
  const requestImg = yield encryptImageBase64(image);
27184
27136
  // downloadImage(image, `${frameIndex}-${docInfos[type as EAuthMeCardClass].docId}-${new Date().getTime().toString()}.jpg`)
27185
27137
  frameIndex++;
27186
- backgroundRequest(() => uploadFrameBase64(docInfos[cardType !== null && cardType !== void 0 ? cardType : ''].docId, requestImg, frameIndex));
27138
+ backgroundRequest(() => uploadFrameBase64(docInfos[type].docId, requestImg, frameIndex));
27187
27139
  pushNewDebugImage(ocrOriginImg, {
27188
27140
  result: result,
27189
27141
  status: 'recognition',
@@ -27193,7 +27145,7 @@ class OCRModule {
27193
27145
  durationTimeRecognition.end();
27194
27146
  return result;
27195
27147
  }),
27196
- confirmImage: (type, cardType) => __awaiter(this, void 0, void 0, function* () {
27148
+ confirmImage: type => __awaiter(this, void 0, void 0, function* () {
27197
27149
  // 將二進位圖片進行加密,目前不需要使用,不確定未來是否需要,先註解
27198
27150
  // const encryptImage = async (blob: Blob): Promise<Blob> => {
27199
27151
  // const imageArrayBuffer = await blobToArrayBuffer(blob);
@@ -27204,13 +27156,13 @@ class OCRModule {
27204
27156
  // );
27205
27157
  // return base64ToBlob(resultEncrypt);
27206
27158
  // };
27207
- const docId = docInfos[cardType].docId;
27159
+ const docId = docInfos[type].docId;
27208
27160
  if (docId) {
27209
- const needFraudOption = config.needAntiFraud && type === EAuthMeCardClass$1.TWN_IDCard_Front;
27210
- const ocrOriginImg = docInfos[cardType].ocrOriginImg;
27161
+ const needFraudOption = config.needAntiFraud && type === EAuthMeCardClass.TWN_IDCard_Front;
27162
+ const ocrOriginImg = docInfos[type].ocrOriginImg;
27211
27163
  const requestImg = yield encryptImageBase64(ocrOriginImg);
27212
27164
  const report = yield this.ocrService.getReport();
27213
- docInfos[cardType].docId = '';
27165
+ docInfos[type].docId = '';
27214
27166
  modifyDeubgLog(getDebugLogsLength() - 1, {
27215
27167
  report: report
27216
27168
  });
@@ -27218,25 +27170,22 @@ class OCRModule {
27218
27170
  yield SendRequestWithRetry(() => uploadFrameBase64(docId, requestImg, frameIndex, ResourceImageType.Recognition, report));
27219
27171
  frameIndex = 0;
27220
27172
  try {
27221
- const ocrImg = docInfos[cardType].ocrImg;
27173
+ const ocrImg = docInfos[type].ocrImg;
27222
27174
  const _requestImg = yield encryptImageBase64(ocrImg);
27223
27175
  const resp = yield SendRequestWithRetry(() => recognitionEncrypt(docId, _requestImg, report, RecognitionFileType.FlatImage));
27224
27176
  if (resp.retry) {
27225
27177
  yield asyncShowPopup(translateService.translate('verify.error.blur'), translateService.translate('verify.error.blurDescribe'), true);
27226
27178
  throw 'recognition failed';
27227
27179
  }
27228
- result = unionMerge(result, resp && resp.details || {});
27180
+ result = unionMerge(result, resp.details);
27229
27181
  yield SendRequestWithRetry(() => finishScanDocument(docId, resp.details, needFraudOption ? this.fraudResult : null));
27230
- delete docInfos[cardType];
27182
+ delete docInfos[type];
27231
27183
  return true;
27232
27184
  } catch (error) {
27233
- console.log('confirmImage fail,retrying ');
27234
- console.error(error);
27235
- docInfos[cardType].docId = docId;
27185
+ docInfos[type].docId = docId;
27236
27186
  return false;
27237
27187
  }
27238
27188
  } else {
27239
- console.error('didnt find docid , retry ');
27240
27189
  return false;
27241
27190
  }
27242
27191
  }),
@@ -27251,19 +27200,18 @@ class OCRModule {
27251
27200
  yield this.antiFraudInstance.setParams(Object.assign(Object.assign({}, oldParams), newParams));
27252
27201
  yield this.antiFraudInstance.setStage(antiFraudStageList);
27253
27202
  yield this.antiFraudInstance.startSession();
27254
- const twnidCardFront = EAuthMeCardClass$1.TWN_IDCard_Front;
27255
- docInfos[twnidCardFront] = {
27203
+ docInfos[EAuthMeCardClass.TWN_IDCard_Front] = {
27256
27204
  docId: '',
27257
27205
  ocrImg: null,
27258
27206
  ocrOriginImg: null,
27259
27207
  fraudOriginImg: null,
27260
27208
  fraudResult: false
27261
27209
  };
27262
- const resp = yield SendRequestWithRetry(() => initScanDocument(scanId, twoWayAuthmeCardClassMap.toServer(twnidCardFront)));
27263
- if (docInfos[twnidCardFront]) {
27264
- docInfos[twnidCardFront].docId = resp.scanDocumentId;
27210
+ const resp = yield SendRequestWithRetry(() => initScanDocument(scanId, twoWayAuthmeCardClassMap.toServer(EAuthMeCardClass.TWN_IDCard_Front)));
27211
+ if (docInfos[EAuthMeCardClass.TWN_IDCard_Front]) {
27212
+ docInfos[EAuthMeCardClass.TWN_IDCard_Front].docId = resp.scanDocumentId;
27265
27213
  } else {
27266
- docInfos[twnidCardFront] = {
27214
+ docInfos[EAuthMeCardClass.TWN_IDCard_Front] = {
27267
27215
  docId: resp.scanDocumentId,
27268
27216
  ocrImg: null,
27269
27217
  ocrOriginImg: null,
@@ -27275,7 +27223,7 @@ class OCRModule {
27275
27223
  }),
27276
27224
  onAntiFraudFrame: data => __awaiter(this, void 0, void 0, function* () {
27277
27225
  var _e, _f;
27278
- const type = EAuthMeCardClass$1.TWN_IDCard_Front;
27226
+ const type = EAuthMeCardClass.TWN_IDCard_Front;
27279
27227
  nextDebugRound(type);
27280
27228
  const antiFraudRecogitionResult = yield functionLogging(() => __awaiter(this, void 0, void 0, function* () {
27281
27229
  var _g;
@@ -27326,7 +27274,7 @@ class OCRModule {
27326
27274
  frameIndex = 0;
27327
27275
  yield this.antiFraudInstance.destroy();
27328
27276
  } else if (uploadFullFrame) {
27329
- const _type = EAuthMeCardClass$1.TWN_IDCard_Front;
27277
+ const _type = EAuthMeCardClass.TWN_IDCard_Front;
27330
27278
  const docId = docInfos[_type].docId;
27331
27279
  const requestImg = yield encryptImageBase64(fraudOriginImg);
27332
27280
  pushNewDebugImage(fraudOriginImg, {
@@ -27387,7 +27335,6 @@ class OCRModule {
27387
27335
  throw new AuthmeError(ErrorCode.EVENT_NAME_WRONG);
27388
27336
  }))).pipe(tap(downloadDebugLogs)));
27389
27337
  } catch (error) {
27390
- console.error(error);
27391
27338
  const catchedError = error instanceof AuthmeError ? error : new AuthmeError(ErrorCode.SDK_INTERNAL_ERROR, error);
27392
27339
  downloadDebugLogs();
27393
27340
  return {
@@ -27420,8 +27367,7 @@ function renderCardTypeAndCountryConfig(config) {
27420
27367
  setStatusEvent(StatusEvent.SelectCardTypeAndCountry);
27421
27368
  setStatusView$1(StatusView.Select);
27422
27369
  sendStatusAction(StatusAction.Show);
27423
- const allCardTypes = Object.values(IdRecognitionCardType);
27424
- config.supportCardTypes(config.defaultCountry);
27370
+ const cardTypes = config.supportCardTypes(CountryCode.TWN);
27425
27371
  const translate = key => getTranslateInstance().translate(key);
27426
27372
  const extraInfoWeapMap = new WeakMap();
27427
27373
  const componentElem = _render('div', elem => elem.classList.add('authme-select-container'), [_render('div', elem => elem.classList.add('menu-header'), [_render('div', elem => elem.classList.add('menu-header-left'), [_render('i', elem => elem.classList.add('menu-header-back'))]), _render('div', elem => elem.classList.add('menu-header-title'), [_render('div', elem => {
@@ -27437,10 +27383,8 @@ function renderCardTypeAndCountryConfig(config) {
27437
27383
  })])]), _render('div', elem => elem.classList.add('card-type-select'), [_render('label', elem => {
27438
27384
  elem.classList.add('card-type-select-label');
27439
27385
  elem.innerText = translate('verify.menu.card.type');
27440
- }), ...allCardTypes.map(cardType => _render('div', elem => {
27386
+ }), ...cardTypes.map(cardType => _render('div', elem => {
27441
27387
  elem.classList.add('card-out-frame');
27442
- elem.classList.add('card-frame');
27443
- elem.classList.add('card-frame-' + cardType.toLowerCase());
27444
27388
  extraInfoWeapMap.set(elem, {
27445
27389
  cardType
27446
27390
  });
@@ -27470,21 +27414,14 @@ function renderCardTypeAndCountryConfig(config) {
27470
27414
  const countryList = config.supportCountries;
27471
27415
  const dropdownCountryList = componentElem.querySelector('.authme-select-container .dropdown-country-list');
27472
27416
  removeAllChild(dropdownCountryList);
27473
- const frames = document.querySelectorAll('.card-frame');
27474
- for (let i = 0; i < frames.length; i++) {
27475
- frames[i].style.display = 'none';
27476
- }
27477
- const cardtypes = config.supportCardTypes(currentCountry);
27478
- cardtypes.forEach(cardType => {
27479
- const node = componentElem.querySelector('.card-frame-' + cardType.toLowerCase());
27480
- node.style.display = '';
27481
- });
27482
27417
  countryList.filter(country => country !== currentCountry).forEach(country => {
27483
27418
  const countryElem = _render('div', elem => {
27484
27419
  elem.classList.add('dropdown-country-list-item');
27485
27420
  extraInfoWeapMap.set(elem, {
27486
27421
  country
27487
27422
  });
27423
+ }, [_render('div', elem => {
27424
+ elem.classList.add('dropdown-country-list-item-frame');
27488
27425
  elem.addEventListener('click', event => {
27489
27426
  event.stopPropagation();
27490
27427
  setCurrentCountry(country);
@@ -27492,8 +27429,6 @@ function renderCardTypeAndCountryConfig(config) {
27492
27429
  country
27493
27430
  });
27494
27431
  });
27495
- }, [_render('div', elem => {
27496
- elem.classList.add('dropdown-country-list-item-frame');
27497
27432
  }, [_render('div', elem => {
27498
27433
  elem.classList.add('dropdown-country-list-item-text');
27499
27434
  elem.innerText = translate(`verify.menu.country.${country}`);
@@ -27543,15 +27478,6 @@ function renderCardTypeAndCountryConfig(config) {
27543
27478
  return new Promise((resolve, reject) => {
27544
27479
  const cardTypeElems = [].slice.call(componentElem.querySelectorAll('.authme-select-container .card-out-frame'));
27545
27480
  const confirmBtn = componentElem.querySelector('.authme-select-container .menu-content-footer .footer-confirm-button');
27546
- const frames = componentElem.querySelectorAll('.card-frame');
27547
- for (let i = 0; i < frames.length; i++) {
27548
- frames[i].style.display = 'none';
27549
- }
27550
- const cardtypes = config.supportCardTypes(config.defaultCountry);
27551
- cardtypes.forEach(cardType => {
27552
- const node = componentElem.querySelector('.card-frame-' + cardType.toLowerCase());
27553
- node.style.display = '';
27554
- });
27555
27481
  initCountrySelectDropdown();
27556
27482
  cardTypeElems.map(cardTypeElem => {
27557
27483
  cardTypeElem.addEventListener('click', () => {
@@ -27690,7 +27616,7 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
27690
27616
  getCardTypeAndCountry(userConfig) {
27691
27617
  var _a, _b;
27692
27618
  return __awaiter(this, void 0, void 0, function* () {
27693
- const defaultCountries = [CountryCode.TWN, CountryCode.JPN, CountryCode.ZAF, CountryCode.USA, CountryCode.CHN, CountryCode.PHL, CountryCode.GBR, CountryCode.KOR, CountryCode.HKG, CountryCode.FRA, CountryCode.ESP, CountryCode.MEX, CountryCode.ITA, CountryCode.IND, CountryCode.COL, CountryCode.RUS, CountryCode.DEU, CountryCode.TUR, CountryCode.CAN, CountryCode.AUS];
27619
+ const defaultCountries = [CountryCode.TWN];
27694
27620
  const defaultCountry = userConfig.defaultCountry !== undefined && defaultCountries.includes(userConfig.defaultCountry) ? userConfig.defaultCountry : defaultCountries[0];
27695
27621
  return renderCardTypeAndCountryConfig({
27696
27622
  supportCountries: (_a = userConfig.supportCountries) !== null && _a !== void 0 ? _a : defaultCountries,
@@ -27723,15 +27649,8 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
27723
27649
  };
27724
27650
  }
27725
27651
  const config = Object.assign(Object.assign({}, defaultIdRecognitionConfig), userConfig);
27726
- let cardSubTypes = [];
27727
- if (config.cardTypes.length > 0) {
27728
- cardSubTypes = config.cardTypes.map(mapCardtypeToAuthmeClass);
27729
- } else {
27730
- cardSubTypes = getCardSubTypes(config.type, config.country);
27731
- const defaultCardTypes = cardSubTypes.map(c => twoWayAuthmeCardClassMap.toServer(c));
27732
- config.cardTypes = defaultCardTypes;
27733
- }
27734
- return config.type === IdRecognitionCardType.Passport ? this.mrzModule.run(config, cardSubTypes) : this.ocrModule.run(config, config.cardTypes);
27652
+ const acceptTypes = getCardSubTypes(config.type, config.country);
27653
+ return config.type === IdRecognitionCardType.Passport ? this.mrzModule.run(config, acceptTypes) : this.ocrModule.run(config, acceptTypes);
27735
27654
  });
27736
27655
  }
27737
27656
  confirmOCRResult(data) {
@@ -27782,13 +27701,17 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
27782
27701
  }
27783
27702
  }
27784
27703
 
27785
- var name = "authme/sdk";
27786
- var version$1 = "2.4.8";
27787
- var date = "2023-12-20T07:24:47+0000";
27704
+ var name = "@authme/identity-verification";
27705
+ var version$1 = "2.4.10";
27706
+ var peerDependencies = {
27707
+ "core-js": "^3.6.0",
27708
+ "lottie-web": "^5.9.2",
27709
+ rxjs: "^7.4.0"
27710
+ };
27788
27711
  var packageInfo = {
27789
27712
  name: name,
27790
27713
  version: version$1,
27791
- date: date
27714
+ peerDependencies: peerDependencies
27792
27715
  };
27793
27716
 
27794
27717
  var _a;