@authme/identity-verification 2.4.8 → 2.4.11

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
@@ -3,11 +3,11 @@ import 'core-js/modules/web.dom-collections.iterator.js';
3
3
  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
- 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';
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
- 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';
6
+ import { getTranslateInstance, EventListenerService, TrackingEvent, generateStatus, StatusDescription, StatusView, StatusAction, AuthmeError, ErrorCode, Feature, StatusEvent, debugLog, setRequestLoggingFunc, setAccessToken } from '@authme/core';
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
+ 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, debugTools, showErrorMessageEventName, Storage, STORAGE_KEY, splitResult, combineResult, startLoadingSDK, stopLoadingSDK } from '@authme/util';
10
+ import { mergeMap, animationFrames, filter, tap, map, from, catchError, EMPTY, merge, fromEvent, of, concatAll, takeUntil, Subject, defer, switchMap, throttleTime, concatMap, combineLatest, take, throwError, finalize, shareReplay, switchMapTo, firstValueFrom, takeWhile, mapTo, race } from 'rxjs';
11
11
  import 'core-js/modules/es.regexp.to-string.js';
12
12
  import { FasRecognitionResult, EAuthMeFASServiceStage, FasService, LivenessAPI, EAuthMeMouthStatus, LivenessResultStatus } from '@authme/liveness';
13
13
  import 'core-js/modules/es.parse-float.js';
@@ -18,8 +18,6 @@ import lottie from 'lottie-web';
18
18
  import 'core-js/modules/es.array.reduce.js';
19
19
  import 'core-js/modules/es.array.sort.js';
20
20
  import 'core-js/modules/es.parse-int.js';
21
- import 'core-js/modules/es.regexp.exec.js';
22
- import 'core-js/modules/es.string.replace.js';
23
21
  import 'core-js/modules/es.object.from-entries.js';
24
22
  import 'core-js/modules/es.array-buffer.slice.js';
25
23
  import 'core-js/modules/es.typed-array.uint8-array.js';
@@ -27,6 +25,9 @@ import 'core-js/modules/es.typed-array.fill.js';
27
25
  import 'core-js/modules/es.typed-array.set.js';
28
26
  import 'core-js/modules/es.typed-array.sort.js';
29
27
  import 'core-js/modules/es.typed-array.to-locale-string.js';
28
+ import 'core-js/modules/web.url-search-params.js';
29
+ import 'core-js/modules/es.regexp.exec.js';
30
+ import 'core-js/modules/es.string.search.js';
30
31
 
31
32
  /******************************************************************************
32
33
  Copyright (c) Microsoft Corporation.
@@ -80,9 +81,6 @@ const defaultExtraDocumentConfig = {
80
81
  icon: DEFAULT_ICON_URI,
81
82
  headerMode: 1,
82
83
  requestInfoHandler: () => ({}),
83
- showCloseButton: true,
84
- continue: true,
85
- border: undefined,
86
84
  extraText: {
87
85
  title: 'extra.title"',
88
86
  frontSide: 'extra.frontSide"',
@@ -103,7 +101,7 @@ const defaultIdRecognitionConfig = {
103
101
  type: IdRecognitionCardType.IDCard,
104
102
  country: CountryCode.TWN,
105
103
  needConfirm: true,
106
- needAntiFraud: false,
104
+ needAntiFraud: true,
107
105
  needOCR: true,
108
106
  displayResultPage: false,
109
107
  showStatement: true,
@@ -114,13 +112,11 @@ const defaultIdRecognitionConfig = {
114
112
  hotfixIphone14proCameraBlur: true,
115
113
  uploadFullFrame: true,
116
114
  disablePassportConfirm: false,
117
- antiFraudIMetalTagValidCountTh: false,
118
- cardTypes: []
115
+ antiFraudIMetalTagValidCountTh: false
119
116
  };
120
117
 
121
118
  function setCorrectViewHeight() {
122
- // window.innerHeight iOS chrome 會有延遲的問題。
123
- const windowsVH = window.document.documentElement.clientHeight / 100;
119
+ const windowsVH = window.innerHeight / 100;
124
120
  document.documentElement.style.setProperty('--authMe-vh', windowsVH + 'px');
125
121
  }
126
122
  setCorrectViewHeight();
@@ -7075,7 +7071,7 @@ const card_ud = () => ({
7075
7071
  });
7076
7072
 
7077
7073
  const success = () => {
7078
- const authmeScannerSuccess = getCssVariable('--authme__upload_success', 'authme-container');
7074
+ const authmeScannerSuccess = getCssVariable('--authme-scanner-success', 'authme-container');
7079
7075
  const lottieColor = authmeScannerSuccess ? RGBToLottieColor(colorToRGB(authmeScannerSuccess)) : [];
7080
7076
  return {
7081
7077
  v: '5.7.4',
@@ -8620,8 +8616,8 @@ const arrow_down = () => {
8620
8616
  };
8621
8617
 
8622
8618
  const scan = () => {
8623
- const authmeScannning = getCssVariable('--authme__scanning', 'authme-container');
8624
- const lottieColor = authmeScannning ? RGBToLottieColor(colorToRGB(authmeScannning)) : [];
8619
+ const authmeScannerSuccess = getCssVariable('--authme-scanner-scanning', 'authme-container');
8620
+ const lottieColor = authmeScannerSuccess ? RGBToLottieColor(colorToRGB(authmeScannerSuccess)) : [];
8625
8621
  const [r, g, b] = lottieColor.map(c => parseFloat(c.toFixed(3)));
8626
8622
  const lottieGradient = [0, r, g, b, 0.5, r, g, b, 1, r, g, b, 0, 0.03, 0.5, 0.515, 1, 1];
8627
8623
  return {
@@ -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;
@@ -23793,39 +23789,9 @@ function startLiveness(config) {
23793
23789
  // 不能使用 from 替代 defer 的原因:
23794
23790
  // 不能假設流程開始就馬上觸發 config.init,活體前可能會有介紹頁,
23795
23791
  // 需要等到介紹頁完成後,才開始執行 config.init (engine init 流程)。
23796
- const init$ = defer(() => config.init()).pipe(tap(config => livenessConfig = config), catchError(error => __awaiter(this, void 0, void 0, function* () {
23797
- var _a, _b, _c, _d, _e, _f;
23798
- const EVENT_NAME_ERROR_CODE = 7;
23799
- const INIT_RESPONSE_ERROR_MESSAGE__LivenessInavailable = 'Liveness Inavailable';
23800
- const INIT_RESPONSE_ERROR_MESSAGE__NotAllowedNewEvent = 'Not allowed new event';
23801
- const SHOW_ERROR_MESSAGE_INTERVAL = 3000;
23802
- // 針對 event name 沒有開啟 liveness 的相關處理
23803
- if (((_c = (_b = (_a = error.cause) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.responseContent) === null || _c === void 0 ? void 0 : _c.code) === EVENT_NAME_ERROR_CODE) {
23804
- let throwError = new AuthmeError(ErrorCode.EVENT_NAME_WRONG, error.cause);
23805
- let errorMessage = undefined;
23806
- switch ((_f = (_e = (_d = error.cause) === null || _d === void 0 ? void 0 : _d.meta) === null || _e === void 0 ? void 0 : _e.responseContent) === null || _f === void 0 ? void 0 : _f.message) {
23807
- case INIT_RESPONSE_ERROR_MESSAGE__LivenessInavailable:
23808
- errorMessage = 'eventName.invalid.functionNotEnabled';
23809
- throwError = new AuthmeError(ErrorCode.EVENT_NAME_WRONG, INIT_RESPONSE_ERROR_MESSAGE__LivenessInavailable);
23810
- break;
23811
- case INIT_RESPONSE_ERROR_MESSAGE__NotAllowedNewEvent:
23812
- errorMessage = 'eventName.invalid.notAllowedNewEvent';
23813
- throwError = new AuthmeError(ErrorCode.EVENT_NAME_WRONG, INIT_RESPONSE_ERROR_MESSAGE__NotAllowedNewEvent);
23814
- break;
23815
- }
23816
- if (errorMessage) {
23817
- yield asyncOnLineShowErrorMessage(translateService.translate(errorMessage), false);
23818
- } else {
23819
- const defaultErrorMessage = `${translateService.translate('eventName.invalid.promptTitle')} : ${translateService.translate('eventName.invalid.promptText')}`;
23820
- yield asyncOnLineShowErrorMessage(defaultErrorMessage, false);
23821
- }
23822
- yield waitTime(SHOW_ERROR_MESSAGE_INTERVAL);
23823
- throw throwError;
23824
- }
23825
- throw error;
23826
- })));
23792
+ const init$ = defer(() => config.init()).pipe(tap(config => livenessConfig = config));
23827
23793
  const applyTextByResult = result => {
23828
- // debugLog('fas-response', result);
23794
+ debugLog('fas-response', result);
23829
23795
  sendStatusDescription$2(fasRecognitionResultMapping(result.eStatus));
23830
23796
  switch (result.eStatus) {
23831
23797
  case FasRecognitionResult.NoFace:
@@ -23916,14 +23882,7 @@ function startLiveness(config) {
23916
23882
  headerSubtitle.textContent = translateService.translate(config.livenessConfig.subtitle);
23917
23883
  }
23918
23884
  setCorrectViewHeight();
23919
- }),
23920
- /**
23921
- * 如果採用 concatMap(() => combineLatest([requestCamera$, init$])) 的方式非同步執行,
23922
- * 會導致在 init$ 拋出錯誤時 camera 還沒請求完畢, reset 沒辦法正確 stop 所有的 stream。
23923
- */
23924
- switchMap(() => init$), switchMap(() => requestCamera$),
23925
- // 原實作 concatMap(() => combineLatest([requestCamera$, init$])),
23926
- tap(() => {
23885
+ }), concatMap(() => combineLatest([requestCamera$, init$])), tap(() => {
23927
23886
  engineInited = true;
23928
23887
  }), switchMap(() => from(waitTime(1)).pipe(tap(() => videoContainer.style.zIndex = '101'))), switchMap(() => from(getCanvasSize(video))), switchMap(canvasSizeInfo => from(config.onStart(canvasSizeInfo)).pipe(
23929
23888
  /*
@@ -23969,7 +23928,7 @@ function startLiveness(config) {
23969
23928
  titleTextPanel,
23970
23929
  statusTextPanel
23971
23930
  });
23972
- })).pipe(sendFrame(canvasSizeInfo, canvas, video, config.onFrame, livenessConfig.fasMaxFps, true, 'all', undefined, frameFlags), tap(({
23931
+ })).pipe(sendFrame(canvasSizeInfo, canvas, video, config.onFrame, livenessConfig.fasMaxFps, true, 'all', frameFlags), tap(({
23973
23932
  result
23974
23933
  }) => applyTextByResult(result)), filter(({
23975
23934
  result
@@ -24098,11 +24057,10 @@ function startLiveness(config) {
24098
24057
  video.srcObject.getTracks().forEach(stream => stream.stop());
24099
24058
  } catch (error) {
24100
24059
  // no video, ignore
24101
- } finally {
24102
- video.srcObject = null;
24103
24060
  }
24104
24061
  eventListenerService$2.stop();
24105
24062
  container.remove();
24063
+ video.srcObject = null;
24106
24064
  unsubscribe$.next();
24107
24065
  unsubscribe$.complete();
24108
24066
  if (engineInited) {
@@ -24363,15 +24321,8 @@ function renderConfirmUI({
24363
24321
  })]), _render('div', elem => {
24364
24322
  elem.classList.add('data-confirm');
24365
24323
  }, [_render('div', elem => {
24366
- const keyMapping = {
24367
- [IdRecognitionCardType.IDCard]: 'idCard',
24368
- [IdRecognitionCardType.DriverLicense]: 'driverLicense',
24369
- [IdRecognitionCardType.HealthCard]: 'healthCard',
24370
- [IdRecognitionCardType.ResidentCard]: 'residentCard',
24371
- [IdRecognitionCardType.Passport]: 'passport'
24372
- };
24373
24324
  elem.classList.add('data-type');
24374
- elem.textContent = translate(cardType ? `confirm.${keyMapping[cardType]}` : '');
24325
+ elem.textContent = translate(cardType !== null && cardType !== void 0 ? cardType : '');
24375
24326
  }), _render('div', elem => {
24376
24327
  elem.classList.add('data');
24377
24328
  }, items.columns.map(column => _render('div', elem => {
@@ -24476,13 +24427,11 @@ const renderOCRMask = params => {
24476
24427
  const _cardPoints = params.mirrored ? mirrorPoints(cardPoints) : cardPoints;
24477
24428
  // 創建SVG元素
24478
24429
  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
24479
- svg.setAttribute('id', 'authme-mask-svg');
24480
24430
  svg.setAttribute('width', '100%');
24481
24431
  svg.setAttribute('height', '100%');
24482
24432
  svg.style.position = 'absolute';
24483
24433
  svg.style.top = '0';
24484
24434
  svg.style.left = '0';
24485
- svg.style.boxShadow = 'rgba(0, 0, 0, 0.65) 0 0 0 2000px';
24486
24435
  // 創建遮罩
24487
24436
  const defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
24488
24437
  const mask = document.createElementNS('http://www.w3.org/2000/svg', 'mask');
@@ -24493,7 +24442,6 @@ const renderOCRMask = params => {
24493
24442
  rect.setAttribute('fill', 'white');
24494
24443
  mask.appendChild(rect);
24495
24444
  const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
24496
- path.setAttribute('id', 'authme-mask-path');
24497
24445
  path.setAttribute('fill', 'black');
24498
24446
  mask.appendChild(path);
24499
24447
  defs.appendChild(mask);
@@ -24512,6 +24460,8 @@ const renderOCRMask = params => {
24512
24460
  svg.appendChild(pathOfFrame);
24513
24461
  // 添加SVG到容器
24514
24462
  container.appendChild(svg);
24463
+ const windowWidth = window.innerWidth;
24464
+ const windowHeight = window.innerHeight;
24515
24465
  const radius = 10;
24516
24466
  const setCardPoints = (_newCardPoints, mirrored = false) => {
24517
24467
  const newCardPoints = mirrored ? mirrorPoints(_newCardPoints) : _newCardPoints;
@@ -24521,8 +24471,6 @@ const renderOCRMask = params => {
24521
24471
  }, index) => {
24522
24472
  var _a, _b;
24523
24473
  const command = index === 0 ? 'M' : 'L'; // 第一個點用'M',其餘的點用'L'
24524
- const windowWidth = container.offsetWidth;
24525
- const windowHeight = container.offsetHeight;
24526
24474
  const previosPoint = (_a = newCardPoints[index - 1]) !== null && _a !== void 0 ? _a : newCardPoints[newCardPoints.length - 1];
24527
24475
  const nextPoint = (_b = newCardPoints[index + 1]) !== null && _b !== void 0 ? _b : newCardPoints[0];
24528
24476
  const _x1 = windowWidth * previosPoint.x;
@@ -24555,8 +24503,6 @@ const renderOCRMask = params => {
24555
24503
  const lineRotio = 2;
24556
24504
  const previosPoint = (_a = newCardPoints[index - 1]) !== null && _a !== void 0 ? _a : newCardPoints[newCardPoints.length - 1];
24557
24505
  const nextPoint = (_b = newCardPoints[index + 1]) !== null && _b !== void 0 ? _b : newCardPoints[0];
24558
- const windowWidth = container.offsetWidth;
24559
- const windowHeight = container.offsetHeight;
24560
24506
  const _x1 = windowWidth * previosPoint.x;
24561
24507
  const _y1 = windowHeight * previosPoint.y;
24562
24508
  const _x2 = windowWidth * x;
@@ -24589,7 +24535,7 @@ const renderOCRMask = params => {
24589
24535
  color = 'var(--authme-scanner-error-color)';
24590
24536
  break;
24591
24537
  case 'pass':
24592
- color = 'var(--authme-scanning_color)';
24538
+ color = 'var(--authme-scanner-pass-color)';
24593
24539
  break;
24594
24540
  default:
24595
24541
  color = '#fff';
@@ -25000,7 +24946,7 @@ function renderCardRotateAnimate(container) {
25000
24946
  });
25001
24947
  }
25002
24948
  function fadeAnimate(inOrOut) {
25003
- container.style.opacity = inOrOut === 'in' ? '0.8' : '0';
24949
+ container.style.opacity = inOrOut === 'in' ? '1' : '0';
25004
24950
  return new Promise(resolve => {
25005
24951
  setTimeout(() => {
25006
24952
  resolve(true);
@@ -25093,7 +25039,7 @@ function startOCR(config) {
25093
25039
  initEvenTrackingStatus(config.ocrConfig);
25094
25040
  const getCardBorderPoint = () => {
25095
25041
  if (cardSizeInfo.width === 0 || cardSizeInfo.height === 0) {
25096
- setCardSize(mapCardtypeToAuthmeClass(config.cardTypes[0]));
25042
+ setCardSize(config.acceptTypes[0]);
25097
25043
  }
25098
25044
  const windowCenterX = window.innerWidth / 2;
25099
25045
  const windowCenterY = window.innerHeight / 2;
@@ -25147,7 +25093,6 @@ function startOCR(config) {
25147
25093
  })),
25148
25094
  container: videoContainer
25149
25095
  });
25150
- setHintTextLocale();
25151
25096
  const {
25152
25097
  rotateCard,
25153
25098
  getIsRotateCardAnimating,
@@ -25316,7 +25261,7 @@ function startOCR(config) {
25316
25261
  if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
25317
25262
  sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
25318
25263
  }
25319
- })), sendFrame(canvasSizeInfo, image, video, config.onAntiFraudFrame, ocrEngineConfig.fraudMaxFps, false, 'jpg', undefined), map(x => x.result), tap(x => {
25264
+ })), sendFrame(canvasSizeInfo, image, video, config.onAntiFraudFrame, ocrEngineConfig.fraudMaxFps, false, 'jpg'), map(x => x.result), tap(x => {
25320
25265
  applyTextByResult(x);
25321
25266
  cardRotateByStage(x.eStage);
25322
25267
  cardRotateTextProcess(x.eStage);
@@ -25364,7 +25309,7 @@ function startOCR(config) {
25364
25309
  // workaround?: 將animation$作為停止。
25365
25310
  return merge(handleSuccess$).pipe(take(1));
25366
25311
  }
25367
- function startOCR(type, cardType) {
25312
+ function startOCR(type) {
25368
25313
  if (!config.ocrConfig.needOCR && type === EAuthMeCardClass.TWN_IDCard_Front) {
25369
25314
  return of(true);
25370
25315
  }
@@ -25374,7 +25319,6 @@ function startOCR(config) {
25374
25319
  x,
25375
25320
  y
25376
25321
  })));
25377
- setHintTextLocale();
25378
25322
  }
25379
25323
  const applyTextByResult = result => {
25380
25324
  statusText.classList.add('non-empty');
@@ -25427,7 +25371,7 @@ function startOCR(config) {
25427
25371
  showCameraSwitchButton(deviceMetas);
25428
25372
  }
25429
25373
  };
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(() => {
25374
+ 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
25375
  stopSpinner();
25432
25376
  showElement(scanAnimationContainer);
25433
25377
  scanAnimationContainer.style.width = `${cardSizeInfo.width + scanPadding}px`;
@@ -25441,7 +25385,7 @@ function startOCR(config) {
25441
25385
  if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
25442
25386
  sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
25443
25387
  }
25444
- }), switchMap(canvasSizeInfo => of(canvasSizeInfo).pipe(sendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, 'jpg', cardType, undefined, type), tap(x => applyTextByResult(x.result)), filter(({
25388
+ }), switchMap(canvasSizeInfo => of(canvasSizeInfo).pipe(sendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, 'jpg', undefined, type), tap(x => applyTextByResult(x.result)), filter(({
25445
25389
  result
25446
25390
  }) => result.eStatus === EAuthMeCardOCRStatus.Pass || result.eStatus === EAuthMeMRZServiceStatus.Success),
25447
25391
  // ocrEngineConfig.expiredIn
@@ -25464,21 +25408,21 @@ function startOCR(config) {
25464
25408
  result
25465
25409
  }) => from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(switchMap(needRetry => {
25466
25410
  startSpinner(translateService.translate('verify.uploading'));
25467
- return needRetry ? of(true) : from(config.confirmImage(type, cardType)).pipe(tap(() => sendStatusAction$1(StatusAction.Uploading)), map(confirmResp => !confirmResp));
25411
+ return needRetry ? of(true) : from(config.confirmImage(type)).pipe(tap(() => sendStatusAction$1(StatusAction.Uploading)), map(confirmResp => !confirmResp));
25468
25412
  }), tap(() => {
25469
25413
  hideElement(confirmImageContainer);
25470
25414
  showVideoElement();
25471
25415
  }), switchMap(needRetry => needRetry ? recognition(true) : of(true)))))));
25472
25416
  return recognition(false);
25473
25417
  }
25474
- function createFlowByType(type, cardType) {
25418
+ function createFlowByType(type) {
25475
25419
  return of(true).pipe(tap(() => {
25476
25420
  setStatusEvent$1(cardClassMapping(type));
25477
- setUIByType(type, cardType);
25421
+ setUIByType(type);
25478
25422
  }), switchMap(() => startAntiFraud(type)), tap(() => {
25479
25423
  setStatusEvent$1(cardClassMapping(type));
25480
- setUIByType(type, cardType);
25481
- }), switchMap(() => startOCR(type, cardType)));
25424
+ setUIByType(type);
25425
+ }), switchMap(() => startOCR(type)));
25482
25426
  }
25483
25427
  function main() {
25484
25428
  const flags = {
@@ -25493,8 +25437,8 @@ function startOCR(config) {
25493
25437
  } else {
25494
25438
  startSpinner(translateService.translate('general.loading'));
25495
25439
  }
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]);
25440
+ const flow$ = config.acceptTypes.map(x => createFlowByType(x)).reduce((prev, cur) => prev.pipe(switchMap(() => cur)), canvasSizeInfo$.pipe(take(1), tap(() => {
25441
+ setUIByType(config.acceptTypes[0]);
25498
25442
  }), switchMap(canvasSizeInfo => from(config.init(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(tap(x => ocrEngineConfig = x), tap(() => __awaiter(this, void 0, void 0, function* () {
25499
25443
  if (config.ocrConfig.needAntiFraud) return;
25500
25444
  stopSpinner();
@@ -25639,13 +25583,13 @@ function startOCR(config) {
25639
25583
  function setTopText(title) {
25640
25584
  titleText.textContent = title;
25641
25585
  }
25642
- function setUIByType(type, cardType) {
25643
- setTextByType(type, cardType);
25586
+ function setUIByType(type) {
25587
+ setTextByType(type);
25644
25588
  setHeaderByType(type);
25645
25589
  setCardSize(type);
25646
25590
  }
25647
- function setTextByType(type, cardType) {
25648
- var _a, _b, _c;
25591
+ function setTextByType(type) {
25592
+ var _a, _b;
25649
25593
  const _typeMap = {
25650
25594
  EAuthMeCardClass_Passport: 'verify.passportFrontSide',
25651
25595
  EAuthMeCardClass_TWN_IDCard_Front: 'verify.idCardFrontSide',
@@ -25658,12 +25602,7 @@ function startOCR(config) {
25658
25602
  EAuthMeCardClass_TWN_VehiclesLicense_Front: 'verify.vehiclesLicenseFrontSide'
25659
25603
  };
25660
25604
  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');
25605
+ titleText.textContent = translateService.translate((_a = typeMap[`${type}`]) !== null && _a !== void 0 ? _a : 'verify.unexpected');
25667
25606
  statusText.textContent = '';
25668
25607
  statusText.classList.remove('non-empty');
25669
25608
  hintText.textContent = type.includes('Back') ? translateService.translate('verify.backSide') : translateService.translate('verify.frontSide');
@@ -25679,11 +25618,7 @@ function startOCR(config) {
25679
25618
  EAuthMeCardClass_TWN_VehiclesLicense_Front: 'verify.confirmVehiclesLicenseFrontSide'
25680
25619
  };
25681
25620
  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');
25621
+ imageTypeText.textContent = translateService.translate((_b = typeConfirmTextMap[type]) !== null && _b !== void 0 ? _b : 'verify.confirm.unexpected');
25687
25622
  }
25688
25623
  function setHeaderByType(type) {
25689
25624
  const typeMap = {
@@ -25810,7 +25745,6 @@ function startOCR(config) {
25810
25745
  if (!cardMatchROI) throw new AuthmeError(ErrorCode.SDK_INTERNAL_ERROR, 'getCardMatchROI is null');
25811
25746
  setCardBorderColor('error');
25812
25747
  setCardPoints(cardMatchROI, facingMode === 'front');
25813
- setHintTextLocale();
25814
25748
  currentAntiFraudStage = stage;
25815
25749
  if (isTutorialFinish && !getIsRotateCardAnimating() || mandatoryRotate) {
25816
25750
  yield stopAnimate();
@@ -25864,27 +25798,17 @@ function startOCR(config) {
25864
25798
  video.srcObject.getTracks().forEach(stream => stream.stop());
25865
25799
  } catch (error) {
25866
25800
  // no video, ignore
25867
- } finally {
25868
- video.srcObject = null;
25869
25801
  }
25870
25802
  yield config.onDestroy();
25871
25803
  if (sdkFlowTimeout) clearTimeout(sdkFlowTimeout);
25872
25804
  eventListenerService$1.stop();
25873
25805
  hidePopup();
25806
+ video.srcObject = null;
25874
25807
  container.remove();
25875
25808
  unsubscribe$.next();
25876
25809
  unsubscribe$.complete();
25877
25810
  });
25878
25811
  }
25879
- function setHintTextLocale() {
25880
- var _a;
25881
- const TITLE_TOP_RANGE = 40;
25882
- const ORIGINAL_TITLE_CLIENT_HEIGHT = window.getComputedStyle(titleText).getPropertyValue('line-height');
25883
- const titleClientHight = parseInt(ORIGINAL_TITLE_CLIENT_HEIGHT.replace('px', ''));
25884
- const maskRect = (_a = document.querySelector('#authme-mask-svg path')) === null || _a === void 0 ? void 0 : _a.getClientRects();
25885
- if (!maskRect || (maskRect === null || maskRect === void 0 ? void 0 : maskRect.length) <= 0) return;
25886
- titleTextPanel.style.top = `${maskRect[0].top - TITLE_TOP_RANGE - titleClientHight}px`;
25887
- }
25888
25812
  return main();
25889
25813
  }
25890
25814
 
@@ -25980,8 +25904,7 @@ const renderExtraUI = config => {
25980
25904
  endBtn,
25981
25905
  completeBtn,
25982
25906
  continueBtn,
25983
- image,
25984
- cardborderContainer
25907
+ image
25985
25908
  };
25986
25909
  };
25987
25910
 
@@ -26003,8 +25926,7 @@ function startExtra(config) {
26003
25926
  } = renderBasicUI({
26004
25927
  headerIcon: config.extraConfig.icon,
26005
25928
  headerMode: config.extraConfig.headerMode,
26006
- showPictureButton: true,
26007
- showCloseButton: config.extraConfig.showCloseButton
25929
+ showPictureButton: true
26008
25930
  });
26009
25931
  const {
26010
25932
  titleTextPanel,
@@ -26014,50 +25936,38 @@ function startExtra(config) {
26014
25936
  completeBtn,
26015
25937
  endBtn,
26016
25938
  continueBtn,
26017
- image,
26018
- cardborderContainer
25939
+ image
26019
25940
  } = renderExtraUI({
26020
25941
  videoContainer,
26021
25942
  container
26022
25943
  });
26023
- if (config.extraConfig.border == 'none') {
26024
- hideElement(cardborderContainer);
26025
- } else {
26026
- showElement(cardborderContainer);
26027
- }
26028
25944
  const canvas = document.createElement('canvas');
26029
25945
  // Register Event
26030
- const requestCamera$ = of(true).pipe(tap(() => {
25946
+ of(true).pipe(tap(() => {
26031
25947
  startSpinner(translateService.translate('general.loading'));
26032
25948
  }), switchMap(() => from(requestCamera({
26033
25949
  video,
26034
25950
  facingMode: 'back',
26035
25951
  translate: key => translateService.translate(key),
26036
25952
  showMessage: message => alert(message)
26037
- })).pipe(catchError(() => {
26038
- reset();
26039
- throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT);
25953
+ })).pipe(catchError(error => {
25954
+ if (error instanceof OverconstrainedError) {
25955
+ alert(translateService.translate('camera.error.notFound'));
25956
+ } else {
25957
+ alert(translateService.translate('camera.error.notFound'));
25958
+ }
25959
+ return throwError(() => new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT));
26040
25960
  }))), tap(() => {
26041
25961
  stopSpinner();
26042
25962
  showElement(videoContainer);
26043
- }));
25963
+ })).subscribe();
26044
25964
  fromEvent(window, 'offline').pipe(switchMap(() => asyncOnLineShowErrorMessage(translateService.translate('network.error.offline'), true)), takeUntil(unsubscribe$)).subscribe();
26045
25965
  fromEvent(window, 'resize').pipe(throttleTime(100), switchMap(() => getCanvasSize(video)), takeUntil(unsubscribe$)).subscribe();
26046
25966
  fromEvent(closeIcon, 'click').pipe(switchMap(() => reset()), takeUntil(unsubscribe$)).subscribe();
26047
25967
  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
25968
  showVideoElement();
26054
25969
  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
- }
25970
+ }))), switchMap(needRetry => needRetry ? of(true) : from(takeOtherImage()).pipe(switchMap(needContinue => needContinue ? of(true) : of(false)), tap(() => {
26061
25971
  showVideoElement();
26062
25972
  hideElement(checkOtherImageContainer);
26063
25973
  }), switchMap(needContinue => needContinue ? of(true) : reset()))), takeUntil(unsubscribe$)).subscribe();
@@ -26073,7 +25983,7 @@ function startExtra(config) {
26073
25983
  message: new AuthmeError(ErrorCode.USER_CANCEL).message,
26074
25984
  data: {}
26075
25985
  })), takeUntil(unsubscribe$));
26076
- return requestCamera$.pipe(switchMap(() => cancel$)).pipe(take(1));
25986
+ return merge(cancel$).pipe(take(1));
26077
25987
  }
26078
25988
  return main();
26079
25989
  function showVideoElement(isShow = true) {
@@ -26120,10 +26030,9 @@ function startExtra(config) {
26120
26030
  video.srcObject.getTracks().forEach(stream => stream.stop());
26121
26031
  } catch (error) {
26122
26032
  // no video, ignore
26123
- } finally {
26124
- video.srcObject = null;
26125
26033
  }
26126
26034
  yield config.onDestroy();
26035
+ video.srcObject = null;
26127
26036
  document.body.removeChild(container);
26128
26037
  unsubscribe$.next();
26129
26038
  unsubscribe$.complete();
@@ -26681,7 +26590,7 @@ class MRZModule {
26681
26590
  var _a, _b;
26682
26591
  frameWidth = width;
26683
26592
  frameHeight = height;
26684
- const resp = yield SendRequestWithRetry$1(() => init(config.type, config.country, config.needConfirm, config.cardTypes));
26593
+ const resp = yield SendRequestWithRetry$1(() => init(config.type, config.country, config.needConfirm));
26685
26594
  pubKey = resp.parameters.pubKey;
26686
26595
  scanId = resp.scanId;
26687
26596
  uploadFullFrame = (_b = (_a = resp.parameters.fraud) === null || _a === void 0 ? void 0 : _a.collectAllFrames) !== null && _b !== void 0 ? _b : config.uploadFullFrame;
@@ -26694,7 +26603,7 @@ class MRZModule {
26694
26603
  expiredIn: resp.expiredIn
26695
26604
  });
26696
26605
  }),
26697
- ocrStart: (points, type, cardType, retry = false) => __awaiter(this, void 0, void 0, function* () {
26606
+ ocrStart: (points, type, retry = false) => __awaiter(this, void 0, void 0, function* () {
26698
26607
  yield this.mrzService.init();
26699
26608
  yield this.mrzService.setFrameSize(frameWidth, frameHeight);
26700
26609
  yield this.mrzService.setMaskPosition(points.map(([x, y]) => [Number(x.toFixed(2)), Number(y.toFixed(2))]));
@@ -26743,7 +26652,7 @@ class MRZModule {
26743
26652
  const image = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
26744
26653
  const requestImg = yield encryptImageBase64(image);
26745
26654
  // downloadImage(image, `${frameIndex}-${docInfos[type as EAuthMeCardClass].docId}-${new Date().getTime().toString()}.jpg`)
26746
- backgroundRequest(() => uploadFrameBase64(docInfos[EAuthMeCardClass.Passport].docId, requestImg, frameIndex++));
26655
+ yield SendRequestWithRetry$1(() => uploadFrameBase64(docInfos[EAuthMeCardClass.Passport].docId, requestImg, frameIndex++));
26747
26656
  }
26748
26657
  const tField = latestTField;
26749
26658
  if (!tField) {
@@ -26767,7 +26676,6 @@ class MRZModule {
26767
26676
  return false;
26768
26677
  }
26769
26678
  }),
26770
- cardTypes: config.cardTypes,
26771
26679
  antiFraudStart: () => __awaiter(this, void 0, void 0, function* () {
26772
26680
  throw 'MRZ Fraud Not Supported.';
26773
26681
  }),
@@ -26808,7 +26716,6 @@ class MRZModule {
26808
26716
  }
26809
26717
  }
26810
26718
 
26811
- const F_IMAGE_BLUE_TH = 'fImageBlurTh';
26812
26719
  const DEFAULT_ANTI_FRAUD_TIMEOUT = 40;
26813
26720
  function unionMerge(a, b) {
26814
26721
  const entries = Object.entries(a).concat(Object.entries(b));
@@ -26822,6 +26729,25 @@ function unionMerge(a, b) {
26822
26729
  }
26823
26730
  return result;
26824
26731
  }
26732
+ function blobToBase64(image) {
26733
+ return new Promise((resolve, reject) => {
26734
+ // Use FileReader to convert Blob to base64
26735
+ const reader = new FileReader();
26736
+ reader.onloadend = function () {
26737
+ if (reader.result) {
26738
+ // Strip off the data URL prefix to get just the base64-encoded bytes
26739
+ const base64String = reader.result.split(',')[1];
26740
+ resolve(base64String);
26741
+ } else {
26742
+ reject(new Error('Failed to convert Blob to base64'));
26743
+ }
26744
+ };
26745
+ reader.onerror = function (error) {
26746
+ reject(error);
26747
+ };
26748
+ reader.readAsDataURL(image);
26749
+ });
26750
+ }
26825
26751
  function SendRequestWithRetry(promiseFactory, options = {}) {
26826
26752
  return retryPromiseWithCondition(promiseFactory, e => __awaiter(this, void 0, void 0, function* () {
26827
26753
  var _a, _b, _c;
@@ -26989,7 +26915,7 @@ class OCRModule {
26989
26915
  yield this.antiFraudInstance.destroy();
26990
26916
  });
26991
26917
  }
26992
- run(config, cardTypes) {
26918
+ run(config, acceptTypes) {
26993
26919
  return __awaiter(this, void 0, void 0, function* () {
26994
26920
  let scanId = '';
26995
26921
  let frameHeight = 0;
@@ -26999,22 +26925,21 @@ class OCRModule {
26999
26925
  let frameIndex = 0;
27000
26926
  let uploadFullFrame = false;
27001
26927
  let fraudTimeout = DEFAULT_ANTI_FRAUD_TIMEOUT;
26928
+ const debugMode = new URLSearchParams(location.search).get('authme-debug') === 'true';
27002
26929
  const {
26930
+ pushNewDebugLog,
27003
26931
  getDebugLogsLength,
27004
26932
  modifyDeubgLog,
27005
26933
  downloadDebugLogs,
27006
26934
  functionLogging,
27007
- nextDebugRound,
27008
- pushNewDebugImage,
27009
- setTimeDuration,
27010
- saveDebugImage,
26935
+ nextDebugRound
26936
+ } = debugTools({
27011
26937
  debugMode
27012
- } = debugTools();
26938
+ });
26939
+ const antiFraudStageList = rendomGetAntiFraudStage();
27013
26940
  if (debugMode) {
27014
26941
  setRequestLoggingFunc(functionLogging);
27015
26942
  }
27016
- const durationTime = setTimeDuration('ocr_flow');
27017
- const antiFraudStageList = rendomGetAntiFraudStage();
27018
26943
  const virtualCanvas = document.createElement('canvas');
27019
26944
  const docInfos = {};
27020
26945
  const encryptImageBase64 = blob => __awaiter(this, void 0, void 0, function* () {
@@ -27040,9 +26965,7 @@ class OCRModule {
27040
26965
  var _a, _b, _c, _d;
27041
26966
  frameWidth = width;
27042
26967
  frameHeight = height;
27043
- const resp = yield SendRequestWithRetry(() => {
27044
- return init(config.type, config.country, config.needConfirm, config.cardTypes);
27045
- }, {
26968
+ const resp = yield SendRequestWithRetry(() => init(config.type, config.country, config.needConfirm), {
27046
26969
  onErrorHandler(e) {
27047
26970
  var _a, _b, _c;
27048
26971
  const _error = e;
@@ -27087,39 +27010,25 @@ class OCRModule {
27087
27010
  expiredIn: resp.expiredIn
27088
27011
  });
27089
27012
  }),
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.
27013
+ ocrStart: (points, type, retry = false) => __awaiter(this, void 0, void 0, function* () {
27014
+ const _service = type === EAuthMeCardClass.TWN_ResidentCard_Back // workaround: resident card need MRZ, refactor later.
27092
27015
  ? this.residentCardMrzService : this.ocrService;
27093
27016
  yield _service.init();
27094
27017
  yield _service.setFrameSize(frameWidth, frameHeight);
27095
27018
  yield _service.setMaskPosition(points.map(([x, y]) => [Number(x.toFixed(2)), Number(y.toFixed(2))]));
27096
- _service instanceof CardOCR ? yield _service.setType(type) : null;
27097
- const newParams = {};
27098
- const oldParams = yield this.ocrService.getParams();
27099
- newParams[F_IMAGE_BLUE_TH] = 750;
27100
- newParams['fCardMatchTh'] = 0.5;
27101
- 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
- }
27019
+ _service instanceof CardOCR ? yield _service.setType(type, {
27020
+ fCardMatchTh: 0.7
27021
+ }) : null;
27113
27022
  yield _service.startSession();
27114
27023
  if (retry) {
27115
- docInfos[cardType].ocrImg = null;
27116
- docInfos[cardType].ocrOriginImg = null;
27024
+ docInfos[type].ocrImg = null;
27025
+ docInfos[type].ocrOriginImg = null;
27117
27026
  } else {
27118
- const resp = yield SendRequestWithRetry(() => initScanDocument(scanId, cardType));
27119
- if (docInfos[cardType]) {
27120
- docInfos[cardType].docId = resp.scanDocumentId;
27027
+ const resp = yield SendRequestWithRetry(() => initScanDocument(scanId, twoWayAuthmeCardClassMap.toServer(type)));
27028
+ if (docInfos[type]) {
27029
+ docInfos[type].docId = resp.scanDocumentId;
27121
27030
  } else {
27122
- docInfos[cardType] = {
27031
+ docInfos[type] = {
27123
27032
  docId: resp.scanDocumentId,
27124
27033
  ocrImg: null,
27125
27034
  ocrOriginImg: null,
@@ -27130,17 +27039,15 @@ class OCRModule {
27130
27039
  }
27131
27040
  return true;
27132
27041
  }),
27133
- cardTypes,
27134
- acceptTypes: cardTypes.map(mapCardtypeToAuthmeClass),
27135
- recognition: (data, _base64, cardType, type) => __awaiter(this, void 0, void 0, function* () {
27136
- const durationTimeRecognition = setTimeDuration(`ocr_recognition_${type}`);
27042
+ acceptTypes,
27043
+ recognition: (data, _base64, type) => __awaiter(this, void 0, void 0, function* () {
27137
27044
  nextDebugRound(type);
27138
- const _service = type === EAuthMeCardClass$1.TWN_ResidentCard_Back // workaround: resident card need MRZ, refactor later.
27045
+ const _service = type === EAuthMeCardClass.TWN_ResidentCard_Back // workaround: resident card need MRZ, refactor later.
27139
27046
  ? this.residentCardMrzService : this.ocrService;
27140
27047
  const result = yield functionLogging(() => __awaiter(this, void 0, void 0, function* () {
27141
27048
  return yield _service.recognition(data);
27142
27049
  }), {
27143
- runFunction: RUN_FUNCTION_NAME.RECOGNITION
27050
+ runFunction: 'service.recognition'
27144
27051
  });
27145
27052
  if (this.canvas) {
27146
27053
  const debugData = yield _service === null || _service === void 0 ? void 0 : _service.getDebugImageData(data);
@@ -27152,28 +27059,15 @@ class OCRModule {
27152
27059
  imgData.data.set(debugData);
27153
27060
  ctx.putImageData(imgData, 0, 0);
27154
27061
  }
27155
- saveDebugImage({
27156
- data,
27157
- type,
27158
- getDebugImageData: _service === null || _service === void 0 ? void 0 : _service.getDebugImageData.bind(_service),
27159
- result,
27160
- width: frameWidth,
27161
- height: frameHeight
27162
- });
27163
27062
  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) {
27063
+ if (result.eStatus === EAuthMeCardOCRStatus.Pass && result.imageData && !!docInfos[result.info.cardClass.eClass].docId) {
27167
27064
  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;
27065
+ docInfos[result.info.cardClass.eClass].ocrImg = resultOcrImg;
27066
+ docInfos[result.info.cardClass.eClass].ocrOriginImg = ocrOriginImg;
27170
27067
  yield _service.stop();
27171
- pushNewDebugImage(ocrOriginImg, {
27172
- result: result,
27173
- status: 'confirm',
27174
- type: type
27175
- });
27176
- pushNewDebugImage(resultOcrImg, {
27068
+ pushNewDebugLog({
27069
+ image: yield blobToBase64(ocrOriginImg),
27070
+ resultOcrImg: yield blobToBase64(resultOcrImg),
27177
27071
  result: result,
27178
27072
  status: 'confirm',
27179
27073
  type: type
@@ -27183,17 +27077,17 @@ class OCRModule {
27183
27077
  const requestImg = yield encryptImageBase64(image);
27184
27078
  // downloadImage(image, `${frameIndex}-${docInfos[type as EAuthMeCardClass].docId}-${new Date().getTime().toString()}.jpg`)
27185
27079
  frameIndex++;
27186
- backgroundRequest(() => uploadFrameBase64(docInfos[cardType !== null && cardType !== void 0 ? cardType : ''].docId, requestImg, frameIndex));
27187
- pushNewDebugImage(ocrOriginImg, {
27080
+ yield uploadFrameBase64(docInfos[type].docId, requestImg, frameIndex);
27081
+ pushNewDebugLog({
27082
+ image: yield blobToBase64(ocrOriginImg),
27188
27083
  result: result,
27189
27084
  status: 'recognition',
27190
27085
  type: type
27191
27086
  });
27192
27087
  }
27193
- durationTimeRecognition.end();
27194
27088
  return result;
27195
27089
  }),
27196
- confirmImage: (type, cardType) => __awaiter(this, void 0, void 0, function* () {
27090
+ confirmImage: type => __awaiter(this, void 0, void 0, function* () {
27197
27091
  // 將二進位圖片進行加密,目前不需要使用,不確定未來是否需要,先註解
27198
27092
  // const encryptImage = async (blob: Blob): Promise<Blob> => {
27199
27093
  // const imageArrayBuffer = await blobToArrayBuffer(blob);
@@ -27204,13 +27098,13 @@ class OCRModule {
27204
27098
  // );
27205
27099
  // return base64ToBlob(resultEncrypt);
27206
27100
  // };
27207
- const docId = docInfos[cardType].docId;
27101
+ const docId = docInfos[type].docId;
27208
27102
  if (docId) {
27209
- const needFraudOption = config.needAntiFraud && type === EAuthMeCardClass$1.TWN_IDCard_Front;
27210
- const ocrOriginImg = docInfos[cardType].ocrOriginImg;
27103
+ const needFraudOption = config.needAntiFraud && type === EAuthMeCardClass.TWN_IDCard_Front;
27104
+ const ocrOriginImg = docInfos[type].ocrOriginImg;
27211
27105
  const requestImg = yield encryptImageBase64(ocrOriginImg);
27212
27106
  const report = yield this.ocrService.getReport();
27213
- docInfos[cardType].docId = '';
27107
+ docInfos[type].docId = '';
27214
27108
  modifyDeubgLog(getDebugLogsLength() - 1, {
27215
27109
  report: report
27216
27110
  });
@@ -27218,25 +27112,22 @@ class OCRModule {
27218
27112
  yield SendRequestWithRetry(() => uploadFrameBase64(docId, requestImg, frameIndex, ResourceImageType.Recognition, report));
27219
27113
  frameIndex = 0;
27220
27114
  try {
27221
- const ocrImg = docInfos[cardType].ocrImg;
27115
+ const ocrImg = docInfos[type].ocrImg;
27222
27116
  const _requestImg = yield encryptImageBase64(ocrImg);
27223
27117
  const resp = yield SendRequestWithRetry(() => recognitionEncrypt(docId, _requestImg, report, RecognitionFileType.FlatImage));
27224
27118
  if (resp.retry) {
27225
27119
  yield asyncShowPopup(translateService.translate('verify.error.blur'), translateService.translate('verify.error.blurDescribe'), true);
27226
27120
  throw 'recognition failed';
27227
27121
  }
27228
- result = unionMerge(result, resp && resp.details || {});
27122
+ result = unionMerge(result, resp.details);
27229
27123
  yield SendRequestWithRetry(() => finishScanDocument(docId, resp.details, needFraudOption ? this.fraudResult : null));
27230
- delete docInfos[cardType];
27124
+ delete docInfos[type];
27231
27125
  return true;
27232
27126
  } catch (error) {
27233
- console.log('confirmImage fail,retrying ');
27234
- console.error(error);
27235
- docInfos[cardType].docId = docId;
27127
+ docInfos[type].docId = docId;
27236
27128
  return false;
27237
27129
  }
27238
27130
  } else {
27239
- console.error('didnt find docid , retry ');
27240
27131
  return false;
27241
27132
  }
27242
27133
  }),
@@ -27251,19 +27142,18 @@ class OCRModule {
27251
27142
  yield this.antiFraudInstance.setParams(Object.assign(Object.assign({}, oldParams), newParams));
27252
27143
  yield this.antiFraudInstance.setStage(antiFraudStageList);
27253
27144
  yield this.antiFraudInstance.startSession();
27254
- const twnidCardFront = EAuthMeCardClass$1.TWN_IDCard_Front;
27255
- docInfos[twnidCardFront] = {
27145
+ docInfos[EAuthMeCardClass.TWN_IDCard_Front] = {
27256
27146
  docId: '',
27257
27147
  ocrImg: null,
27258
27148
  ocrOriginImg: null,
27259
27149
  fraudOriginImg: null,
27260
27150
  fraudResult: false
27261
27151
  };
27262
- const resp = yield SendRequestWithRetry(() => initScanDocument(scanId, twoWayAuthmeCardClassMap.toServer(twnidCardFront)));
27263
- if (docInfos[twnidCardFront]) {
27264
- docInfos[twnidCardFront].docId = resp.scanDocumentId;
27152
+ const resp = yield SendRequestWithRetry(() => initScanDocument(scanId, twoWayAuthmeCardClassMap.toServer(EAuthMeCardClass.TWN_IDCard_Front)));
27153
+ if (docInfos[EAuthMeCardClass.TWN_IDCard_Front]) {
27154
+ docInfos[EAuthMeCardClass.TWN_IDCard_Front].docId = resp.scanDocumentId;
27265
27155
  } else {
27266
- docInfos[twnidCardFront] = {
27156
+ docInfos[EAuthMeCardClass.TWN_IDCard_Front] = {
27267
27157
  docId: resp.scanDocumentId,
27268
27158
  ocrImg: null,
27269
27159
  ocrOriginImg: null,
@@ -27274,14 +27164,14 @@ class OCRModule {
27274
27164
  return true;
27275
27165
  }),
27276
27166
  onAntiFraudFrame: data => __awaiter(this, void 0, void 0, function* () {
27277
- var _e, _f;
27278
- const type = EAuthMeCardClass$1.TWN_IDCard_Front;
27167
+ var _e;
27168
+ const type = EAuthMeCardClass.TWN_IDCard_Front;
27279
27169
  nextDebugRound(type);
27280
27170
  const antiFraudRecogitionResult = yield functionLogging(() => __awaiter(this, void 0, void 0, function* () {
27281
- var _g;
27282
- return yield (_g = this.antiFraudInstance) === null || _g === void 0 ? void 0 : _g.recognition(data);
27171
+ var _f;
27172
+ return yield (_f = this.antiFraudInstance) === null || _f === void 0 ? void 0 : _f.recognition(data);
27283
27173
  }), {
27284
- runFunction: RUN_FUNCTION_NAME.ANTI_FARUD_RECOGNITION,
27174
+ runFunction: 'antiFraudInstance.recognition',
27285
27175
  isAntiFraud: true
27286
27176
  });
27287
27177
  if (!antiFraudRecogitionResult) {
@@ -27297,14 +27187,6 @@ class OCRModule {
27297
27187
  imgData.data.set(debugData);
27298
27188
  ctx.putImageData(imgData, 0, 0);
27299
27189
  }
27300
- saveDebugImage({
27301
- data,
27302
- type,
27303
- getDebugImageData: (_f = this.antiFraudInstance) === null || _f === void 0 ? void 0 : _f.getDebugImageData.bind(this.antiFraudInstance),
27304
- result,
27305
- width: frameWidth,
27306
- height: frameHeight
27307
- });
27308
27190
  const fraudOriginImg = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
27309
27191
  if (antiFraudRecogitionResult.eStatus === EAuthMeIDCardAntiFraudStatus.Pass || antiFraudRecogitionResult.eStatus === EAuthMeIDCardAntiFraudStatus.Failed) {
27310
27192
  docInfos[type].fraudOriginImg = fraudOriginImg;
@@ -27314,7 +27196,8 @@ class OCRModule {
27314
27196
  const docId = docInfos[type].docId;
27315
27197
  const requestImg = yield encryptImageBase64(ocrImg);
27316
27198
  const report = yield this.antiFraudInstance.getReport();
27317
- pushNewDebugImage(fraudOriginImg, {
27199
+ pushNewDebugLog({
27200
+ image: yield blobToBase64(fraudOriginImg),
27318
27201
  result: result,
27319
27202
  status: 'confirm',
27320
27203
  type: type,
@@ -27326,17 +27209,18 @@ class OCRModule {
27326
27209
  frameIndex = 0;
27327
27210
  yield this.antiFraudInstance.destroy();
27328
27211
  } else if (uploadFullFrame) {
27329
- const _type = EAuthMeCardClass$1.TWN_IDCard_Front;
27212
+ const _type = EAuthMeCardClass.TWN_IDCard_Front;
27330
27213
  const docId = docInfos[_type].docId;
27331
27214
  const requestImg = yield encryptImageBase64(fraudOriginImg);
27332
- pushNewDebugImage(fraudOriginImg, {
27215
+ pushNewDebugLog({
27216
+ image: yield blobToBase64(fraudOriginImg),
27333
27217
  result: result,
27334
27218
  status: 'recognition',
27335
27219
  type: _type,
27336
27220
  isAntiFraud: true
27337
27221
  });
27338
27222
  frameIndex++;
27339
- backgroundRequest(() => uploadFrameBase64(docId, requestImg, frameIndex, ResourceImageType.Fraud));
27223
+ yield uploadFrameBase64(docId, requestImg, frameIndex, ResourceImageType.Fraud);
27340
27224
  }
27341
27225
  return antiFraudRecogitionResult;
27342
27226
  }),
@@ -27344,30 +27228,30 @@ class OCRModule {
27344
27228
  return antiFraudStageList;
27345
27229
  },
27346
27230
  setFrameSize: (width, height, points) => __awaiter(this, void 0, void 0, function* () {
27347
- var _h, _j, _k, _l;
27231
+ var _g, _h, _j, _k;
27348
27232
  frameWidth = width;
27349
27233
  frameHeight = height;
27350
- yield (_h = this.ocrService) === null || _h === void 0 ? void 0 : _h.setFrameSize(width, height);
27351
- yield (_j = this.antiFraudInstance) === null || _j === void 0 ? void 0 : _j.setFrameSize(width, height);
27234
+ yield (_g = this.ocrService) === null || _g === void 0 ? void 0 : _g.setFrameSize(width, height);
27235
+ yield (_h = this.antiFraudInstance) === null || _h === void 0 ? void 0 : _h.setFrameSize(width, height);
27352
27236
  if (config.type === IdRecognitionCardType.ResidentCard) {
27353
27237
  // workaround: resident card need MRZ, refactor later.
27354
- yield (_k = this.residentCardMrzService) === null || _k === void 0 ? void 0 : _k.setFrameSize(width, height);
27238
+ yield (_j = this.residentCardMrzService) === null || _j === void 0 ? void 0 : _j.setFrameSize(width, height);
27355
27239
  }
27356
27240
  if (points) {
27357
- yield (_l = this.ocrService) === null || _l === void 0 ? void 0 : _l.setMaskPosition(points.map(([x, y]) => [Number(x.toFixed(2)), Number(y.toFixed(2))]));
27241
+ yield (_k = this.ocrService) === null || _k === void 0 ? void 0 : _k.setMaskPosition(points.map(([x, y]) => [Number(x.toFixed(2)), Number(y.toFixed(2))]));
27358
27242
  }
27359
27243
  }),
27360
27244
  onSuccess: () => __awaiter(this, void 0, void 0, function* () {
27361
- var _m, _o, _p;
27362
- durationTime.end();
27245
+ var _l, _m, _o;
27363
27246
  const ocrIdcardResultFormat = Storage.getItem(STORAGE_KEY['OCR_IDCARD_RESULT_FORMAT']);
27364
- (_m = this.antiFraudInstance) === null || _m === void 0 ? void 0 : _m.destroy();
27365
- (_o = this.ocrService) === null || _o === void 0 ? void 0 : _o.destroy();
27247
+ (_l = this.antiFraudInstance) === null || _l === void 0 ? void 0 : _l.destroy();
27248
+ (_m = this.ocrService) === null || _m === void 0 ? void 0 : _m.destroy();
27366
27249
  // workaround: resident card need MRZ, refactor later.
27367
- (_p = this.residentCardMrzService) === null || _p === void 0 ? void 0 : _p.destroy();
27250
+ (_o = this.residentCardMrzService) === null || _o === void 0 ? void 0 : _o.destroy();
27368
27251
  if (config.type === IdRecognitionCardType.IDCard && ocrIdcardResultFormat === 'splitDateAndAddress') {
27369
27252
  result = splitResult(result);
27370
27253
  }
27254
+ downloadDebugLogs();
27371
27255
  yield waitTime(1000);
27372
27256
  return {
27373
27257
  scanId: scanId,
@@ -27375,21 +27259,18 @@ class OCRModule {
27375
27259
  };
27376
27260
  }),
27377
27261
  onDestroy: () => __awaiter(this, void 0, void 0, function* () {
27378
- var _q, _r;
27379
- durationTime.end();
27380
- yield (_q = this.ocrService) === null || _q === void 0 ? void 0 : _q.destroy();
27381
- yield (_r = this.antiFraudInstance) === null || _r === void 0 ? void 0 : _r.destroy();
27262
+ var _p, _q;
27263
+ yield (_p = this.ocrService) === null || _p === void 0 ? void 0 : _p.destroy();
27264
+ yield (_q = this.antiFraudInstance) === null || _q === void 0 ? void 0 : _q.destroy();
27382
27265
  }),
27383
27266
  getCardMatchROI: () => __awaiter(this, void 0, void 0, function* () {
27384
27267
  return yield this.antiFraudInstance.getCardMatchROI();
27385
27268
  })
27386
27269
  }), eventNameWrong$.pipe(tap(() => {
27387
27270
  throw new AuthmeError(ErrorCode.EVENT_NAME_WRONG);
27388
- }))).pipe(tap(downloadDebugLogs)));
27271
+ }))));
27389
27272
  } catch (error) {
27390
- console.error(error);
27391
27273
  const catchedError = error instanceof AuthmeError ? error : new AuthmeError(ErrorCode.SDK_INTERNAL_ERROR, error);
27392
- downloadDebugLogs();
27393
27274
  return {
27394
27275
  isSuccess: false,
27395
27276
  code: `${catchedError.code}`,
@@ -27420,8 +27301,7 @@ function renderCardTypeAndCountryConfig(config) {
27420
27301
  setStatusEvent(StatusEvent.SelectCardTypeAndCountry);
27421
27302
  setStatusView$1(StatusView.Select);
27422
27303
  sendStatusAction(StatusAction.Show);
27423
- const allCardTypes = Object.values(IdRecognitionCardType);
27424
- config.supportCardTypes(config.defaultCountry);
27304
+ const cardTypes = config.supportCardTypes(CountryCode.TWN);
27425
27305
  const translate = key => getTranslateInstance().translate(key);
27426
27306
  const extraInfoWeapMap = new WeakMap();
27427
27307
  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 +27317,8 @@ function renderCardTypeAndCountryConfig(config) {
27437
27317
  })])]), _render('div', elem => elem.classList.add('card-type-select'), [_render('label', elem => {
27438
27318
  elem.classList.add('card-type-select-label');
27439
27319
  elem.innerText = translate('verify.menu.card.type');
27440
- }), ...allCardTypes.map(cardType => _render('div', elem => {
27320
+ }), ...cardTypes.map(cardType => _render('div', elem => {
27441
27321
  elem.classList.add('card-out-frame');
27442
- elem.classList.add('card-frame');
27443
- elem.classList.add('card-frame-' + cardType.toLowerCase());
27444
27322
  extraInfoWeapMap.set(elem, {
27445
27323
  cardType
27446
27324
  });
@@ -27470,21 +27348,14 @@ function renderCardTypeAndCountryConfig(config) {
27470
27348
  const countryList = config.supportCountries;
27471
27349
  const dropdownCountryList = componentElem.querySelector('.authme-select-container .dropdown-country-list');
27472
27350
  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
27351
  countryList.filter(country => country !== currentCountry).forEach(country => {
27483
27352
  const countryElem = _render('div', elem => {
27484
27353
  elem.classList.add('dropdown-country-list-item');
27485
27354
  extraInfoWeapMap.set(elem, {
27486
27355
  country
27487
27356
  });
27357
+ }, [_render('div', elem => {
27358
+ elem.classList.add('dropdown-country-list-item-frame');
27488
27359
  elem.addEventListener('click', event => {
27489
27360
  event.stopPropagation();
27490
27361
  setCurrentCountry(country);
@@ -27492,8 +27363,6 @@ function renderCardTypeAndCountryConfig(config) {
27492
27363
  country
27493
27364
  });
27494
27365
  });
27495
- }, [_render('div', elem => {
27496
- elem.classList.add('dropdown-country-list-item-frame');
27497
27366
  }, [_render('div', elem => {
27498
27367
  elem.classList.add('dropdown-country-list-item-text');
27499
27368
  elem.innerText = translate(`verify.menu.country.${country}`);
@@ -27543,15 +27412,6 @@ function renderCardTypeAndCountryConfig(config) {
27543
27412
  return new Promise((resolve, reject) => {
27544
27413
  const cardTypeElems = [].slice.call(componentElem.querySelectorAll('.authme-select-container .card-out-frame'));
27545
27414
  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
27415
  initCountrySelectDropdown();
27556
27416
  cardTypeElems.map(cardTypeElem => {
27557
27417
  cardTypeElem.addEventListener('click', () => {
@@ -27631,7 +27491,6 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
27631
27491
  });
27632
27492
  var _a, _b, _c, _d, _e, _f;
27633
27493
  return __awaiter(this, void 0, void 0, function* () {
27634
- if (!config.token) throw new AuthmeError(ErrorCode.INVALID_AUTH_ERROR, 'token is required');
27635
27494
  try {
27636
27495
  yield _super.init.call(this, config);
27637
27496
  config = Object.assign(Object.assign({}, defaultIdentityVerificationConfig), config);
@@ -27690,7 +27549,7 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
27690
27549
  getCardTypeAndCountry(userConfig) {
27691
27550
  var _a, _b;
27692
27551
  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];
27552
+ const defaultCountries = [CountryCode.TWN];
27694
27553
  const defaultCountry = userConfig.defaultCountry !== undefined && defaultCountries.includes(userConfig.defaultCountry) ? userConfig.defaultCountry : defaultCountries[0];
27695
27554
  return renderCardTypeAndCountryConfig({
27696
27555
  supportCountries: (_a = userConfig.supportCountries) !== null && _a !== void 0 ? _a : defaultCountries,
@@ -27723,15 +27582,8 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
27723
27582
  };
27724
27583
  }
27725
27584
  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);
27585
+ const acceptTypes = getCardSubTypes(config.type, config.country);
27586
+ return config.type === IdRecognitionCardType.Passport ? this.mrzModule.run(config, acceptTypes) : this.ocrModule.run(config, acceptTypes);
27735
27587
  });
27736
27588
  }
27737
27589
  confirmOCRResult(data) {
@@ -27782,13 +27634,17 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
27782
27634
  }
27783
27635
  }
27784
27636
 
27785
- var name = "authme/sdk";
27786
- var version$1 = "2.4.8";
27787
- var date = "2023-12-20T07:24:47+0000";
27637
+ var name = "@authme/identity-verification";
27638
+ var version$1 = "2.4.11";
27639
+ var peerDependencies = {
27640
+ "core-js": "^3.6.0",
27641
+ "lottie-web": "^5.9.2",
27642
+ rxjs: "^7.4.0"
27643
+ };
27788
27644
  var packageInfo = {
27789
27645
  name: name,
27790
27646
  version: version$1,
27791
- date: date
27647
+ peerDependencies: peerDependencies
27792
27648
  };
27793
27649
 
27794
27650
  var _a;