@authme/identity-verification 2.7.2 → 2.7.4-patch.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -5,7 +5,7 @@ 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
7
  import { EAuthMeFASServiceStatus, EAuthMeIDCardAntiFraudStage as EAuthMeIDCardAntiFraudStage$1, EAuthMeCardClass as EAuthMeCardClass$1, AuthmeFunctionModule, MlEngine, EngineModule, EAuthMeEngineReturnCode } from '@authme/engine';
8
- import { IdRecognitionCardType, CountryCode, EAuthMeCardClass, EAuthMeIDCardAntiFraudStatus, EAuthMeIDCardAntiFraudStage, thicknessDefaultConfig, mapCardtypeToAuthmeClass, cardTypeTitle, cardTypeConfirmTitle, getRecognitionColumnOrder, EAuthMeCardOCRStatus, EAuthMeMRZServiceStatus, saveExtraDoc, initScanDocumentResourceBase64, MRZService, init, initScanDocument, uploadFrameBase64, ResourceImageType, finishScanDocument, CardOCR, IdCardAntiFraudService, recognitionEncrypt, RecognitionFileType, twoWayAuthmeCardClassMap, getCardSubTypes, getCardTypes, confirmScan } from '@authme/id-recognition';
8
+ import { IdRecognitionCardType, CountryCode, EAuthMeCardClass, EAuthMeIDCardAntiFraudStatus, EAuthMeIDCardAntiFraudStage, thicknessDefaultConfig, mapCardtypeToAuthmeClass, cardTypeTitle, cardTypeConfirmTitle, cardTypeHeader, getRecognitionColumnOrder, EAuthMeCardOCRStatus, EAuthMeMRZServiceStatus, saveExtraDoc, initScanDocumentResourceBase64, MRZService, init, initScanDocument, uploadFrameBase64, ResourceImageType, finishScanDocument, CardOCR, IdCardAntiFraudService, recognitionEncrypt, RecognitionFileType, twoWayAuthmeCardClassMap, getCardSubTypes, getCardTypes, confirmScan } from '@authme/id-recognition';
9
9
  import { getCssVariable, RGBToLottieColor, colorToRGB, Icon, useState, clearCanvas, getImageData, isMobile, hidePopup, showPopup, waitTime, TIME_UNIT, AuthmeError as AuthmeError$1, ErrorCode as ErrorCode$1, requestCamera, showElement, asyncOnLineShowErrorMessage, getCanvasSize, startSpinner, stopSpinner, showErrorMessage, hideElement, dataURItoBlob, checkOnlineStatus, UintArrayToBlob, isIphone14proOrProMax, cropByRatio, asyncShowErrorMessage, switchCamera, asyncShowPopup, retryPromiseWithCondition, hideErrorMessage, 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, of, merge, fromEvent, concatAll, takeUntil, Subject, defer, switchMap, throttleTime, take, concatMap, throwError, finalize, Observable, interval, mapTo, firstValueFrom, shareReplay, switchMapTo, takeWhile as takeWhile$1, race } from 'rxjs';
11
11
  import 'core-js/modules/es.regexp.to-string.js';
@@ -119,7 +119,8 @@ const defaultIdRecognitionConfig = {
119
119
  disablePassportConfirm: false,
120
120
  antiFraudIMetalTagValidCountTh: false,
121
121
  cardTypes: [],
122
- cardTypeConfigs: []
122
+ cardTypeConfigs: [],
123
+ captureTimeout: -1
123
124
  };
124
125
 
125
126
  function setCorrectViewHeight() {
@@ -23231,6 +23232,7 @@ const renderBasicUI = userConfig => {
23231
23232
  video.playsInline = true;
23232
23233
  video.loop = true;
23233
23234
  video.setAttribute('webkit-playsinline', '');
23235
+ video.setAttribute('poster', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUAAAADwCAYAAABxLb1rAAAABmJLR0QA/wD/AP+gvaeTAAADKUlEQVR4nO3UMQEAIAzAsIF/zyBjRxMFvXpm5g1A0N0OANhigECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkGCGQZIJBlgECWAQJZBghkGSCQZYBAlgECWQYIZBkgkGWAQJYBAlkfVV0C319akPEAAAAASUVORK5CYII=');
23234
23236
  const lottieScreen = document.createElement('div');
23235
23237
  lottieScreen.classList.add('lottie-screen');
23236
23238
  const pictureIcon = document.createElement('div');
@@ -23709,8 +23711,8 @@ var RESIZE_EVENT;
23709
23711
  RESIZE_EVENT["PASS"] = "PASS";
23710
23712
  })(RESIZE_EVENT || (RESIZE_EVENT = {}));
23711
23713
  function detectScreenResize$() {
23712
- const initWidth = window.outerWidth;
23713
- const initHeight = window.outerHeight;
23714
+ const initWidth = window.innerWidth;
23715
+ const initHeight = window.innerHeight;
23714
23716
  let resize$;
23715
23717
  if (isMobile()) {
23716
23718
  if (!window.visualViewport) {
@@ -23734,7 +23736,7 @@ function detectScreenResize$() {
23734
23736
  if (window.innerWidth < RESIZE_STYLE.RESIZE_WIDTH_LIMIT || window.innerHeight < RESIZE_STYLE.RESIZE_HEIGHT_LIMIT) {
23735
23737
  return RESIZE_EVENT.SCREEN_RESOLUTION_TOO_LOW;
23736
23738
  }
23737
- if (window.outerWidth !== initWidth || window.outerHeight !== initHeight) {
23739
+ if (window.innerWidth !== initWidth || window.innerHeight !== initHeight) {
23738
23740
  return RESIZE_EVENT.SCREEN_SIZE_CHANGED;
23739
23741
  }
23740
23742
  return RESIZE_EVENT.PASS;
@@ -24003,10 +24005,10 @@ function startLiveness(config) {
24003
24005
  result
24004
24006
  }) => applyTextByResult(result)), filter(({
24005
24007
  result
24006
- }) => result.eStatus === FasRecognitionResult.Pass && result.eStage === EAuthMeFASServiceStage.Done || result.eStatus === FasRecognitionResult.Failed), map(data => {
24008
+ }) => result.eStatus === FasRecognitionResult.Pass && result.eStage === EAuthMeFASServiceStage.Passive || result.eStatus === FasRecognitionResult.Failed), map(data => {
24007
24009
  var _a, _b;
24008
24010
  return Object.assign(Object.assign({}, data), {
24009
- isSuccess: ((_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a.eStatus) === FasRecognitionResult.Pass && ((_b = data === null || data === void 0 ? void 0 : data.result) === null || _b === void 0 ? void 0 : _b.eStage) === EAuthMeFASServiceStage.Done
24011
+ isSuccess: ((_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a.eStatus) === FasRecognitionResult.Pass && ((_b = data === null || data === void 0 ? void 0 : data.result) === null || _b === void 0 ? void 0 : _b.eStage) === EAuthMeFASServiceStage.Passive
24010
24012
  });
24011
24013
  }), take(1),
24012
24014
  /**
@@ -24241,21 +24243,6 @@ const initScanAnimation = params => {
24241
24243
  });
24242
24244
  lottie.stop('scan');
24243
24245
  };
24244
- const initSuccessAnimation = params => {
24245
- lottie.destroy('success');
24246
- lottie.loadAnimation({
24247
- container: params.animationContainer,
24248
- renderer: 'svg',
24249
- loop: false,
24250
- autoplay: true,
24251
- name: 'success',
24252
- animationData: success({
24253
- color: '#7CFFF9',
24254
- opacity: 1
24255
- })
24256
- });
24257
- lottie.stop('success');
24258
- };
24259
24246
  const renderCameraSwitch = config => {
24260
24247
  const cameraSwitchContainer = document.createElement('div');
24261
24248
  const cameraSwitch = document.createElement('div');
@@ -24305,21 +24292,29 @@ const renderOCRUI = config => {
24305
24292
  // Animation
24306
24293
  const scanAnimationContainer = document.createElement('div');
24307
24294
  scanAnimationContainer.classList.add('scan');
24308
- const successAnimationContainer = document.createElement('div');
24309
- successAnimationContainer.classList.add('success_container');
24310
- const successAnimationDom = document.createElement('div');
24311
- successAnimationDom.classList.add('success');
24295
+ // 完成流程元件
24296
+ const successContainer = document.createElement('div');
24297
+ successContainer.classList.add('success_container');
24298
+ const successBlockDom = document.createElement('div');
24299
+ successBlockDom.classList.add('block');
24300
+ const successDom = document.createElement('div');
24301
+ successDom.classList.add('img');
24302
+ const successText = document.createElement('div');
24303
+ successText.textContent = translateService.translate('sdk.general.done');
24304
+ successBlockDom.appendChild(successDom);
24305
+ successBlockDom.appendChild(successText);
24306
+ successContainer.appendChild(successBlockDom);
24312
24307
  const arrowAnimationContainer = document.createElement('div');
24313
24308
  arrowAnimationContainer.classList.add('arrow_container');
24314
- successAnimationContainer.appendChild(successAnimationDom);
24315
24309
  config.videoContainer.appendChild(titleTextPanel);
24316
24310
  if (config.showStatement) {
24317
24311
  config.videoContainer.appendChild(statementContainer);
24318
24312
  }
24319
24313
  config.videoContainer.appendChild(statusTextPanel);
24320
24314
  config.videoContainer.appendChild(scanAnimationContainer);
24321
- config.videoContainer.appendChild(successAnimationContainer);
24315
+ config.videoContainer.appendChild(successContainer);
24322
24316
  config.videoContainer.appendChild(arrowAnimationContainer);
24317
+ successContainer.classList.add('hide');
24323
24318
  // Anti-fraud Instruction
24324
24319
  const lottieMask = document.createElement('div');
24325
24320
  lottieMask.classList.add('lottie-mask');
@@ -24343,6 +24338,8 @@ const renderOCRUI = config => {
24343
24338
  config.container.appendChild(lottieMask);
24344
24339
  config.container.appendChild(antiFraudInstructionContainer);
24345
24340
  // Picture
24341
+ const confirmContainer = document.createElement('div');
24342
+ confirmContainer.classList.add('confirm_container');
24346
24343
  const confirmImageContainer = document.createElement('div');
24347
24344
  confirmImageContainer.classList.add('confirm-image-container');
24348
24345
  const imageTypeText = document.createElement('div');
@@ -24371,7 +24368,8 @@ const renderOCRUI = config => {
24371
24368
  confirmImageContainer.appendChild(imageContainer);
24372
24369
  confirmImageContainer.appendChild(imageLineLineDesktop);
24373
24370
  confirmImageContainer.appendChild(imageFooter);
24374
- config.container.appendChild(confirmImageContainer);
24371
+ confirmContainer.appendChild(confirmImageContainer);
24372
+ config.container.appendChild(confirmContainer);
24375
24373
  return {
24376
24374
  antiFraudInstructionContainer,
24377
24375
  titleTextPanel,
@@ -24381,11 +24379,12 @@ const renderOCRUI = config => {
24381
24379
  statusTextPanel,
24382
24380
  lottieMask,
24383
24381
  arrowAnimationContainer,
24384
- successAnimationContainer,
24385
- successAnimationDom,
24382
+ successContainer,
24383
+ successBlockDom,
24386
24384
  scanAnimationContainer,
24387
24385
  antiFraudInstructionAnimationContainer,
24388
24386
  confirmImageContainer,
24387
+ confirmContainer,
24389
24388
  imageTypeText,
24390
24389
  // cardborder,
24391
24390
  // cardborderContainer,
@@ -25297,7 +25296,8 @@ function renderCardRotateAnimate(container) {
25297
25296
  const captureButton = () => {
25298
25297
  let dom = document.querySelector('#btn_capture');
25299
25298
  if (dom) {
25300
- return dom;
25299
+ // return dom;
25300
+ dom.remove();
25301
25301
  }
25302
25302
  const videoContainer = document.querySelector('.video-container');
25303
25303
  if (!videoContainer) {
@@ -25326,24 +25326,26 @@ const modal = arg => {
25326
25326
  const domModal = document.createElement('div');
25327
25327
  const domHeaderContainer = document.createElement('div');
25328
25328
  const domHeader = document.createElement('div');
25329
- const domContainer = document.createElement('div');
25329
+ const domBodyContainer = document.createElement('div');
25330
+ const domBody = document.createElement('div');
25330
25331
  const domTitle = document.createElement('div');
25331
25332
  const domSubtitle = document.createElement('div');
25332
25333
  const domImage = document.createElement('img');
25333
25334
  const domContent = document.createElement('div');
25334
- const domFooter = document.createElement('div');
25335
+ const domFooterContainer = document.createElement('div');
25335
25336
  const domClose = document.createElement('div');
25336
25337
  const domConfirm = document.createElement('div');
25337
25338
  const domCopyRight = document.createElement('div');
25338
25339
  domModal.classList.add('video-container__modal');
25339
25340
  domHeaderContainer.classList.add('video-container__modal-header-container');
25340
25341
  domHeader.classList.add('video-container__modal-header');
25341
- domContainer.classList.add('video-container__modal-container');
25342
+ domBodyContainer.classList.add('video-container__modal-body-container');
25343
+ domBody.classList.add('video-container__modal-body');
25342
25344
  domTitle.classList.add('video-container__modal-title');
25343
25345
  domSubtitle.classList.add('video-container__modal-subtitle');
25344
25346
  domImage.classList.add('video-container__modal-image');
25345
25347
  domContent.classList.add('video-container__modal-content');
25346
- domFooter.classList.add('video-container__modal-footer');
25348
+ domFooterContainer.classList.add('video-container__modal-footer-container');
25347
25349
  domClose.classList.add('video-container__modal-close');
25348
25350
  domConfirm.classList.add('video-container__modal-confirm');
25349
25351
  domCopyRight.classList.add('video-container__modal-copy-right');
@@ -25369,16 +25371,17 @@ const modal = arg => {
25369
25371
  domHeaderContainer.appendChild(domHeader);
25370
25372
  domHeaderContainer.appendChild(domClose);
25371
25373
  domModal.appendChild(domHeaderContainer);
25372
- domContainer.appendChild(domTitle);
25373
- domContainer.appendChild(domSubtitle);
25374
- domContainer.appendChild(domImage);
25375
- domContainer.appendChild(domContent);
25376
- domModal.appendChild(domContainer);
25377
- domFooter.appendChild(domConfirm);
25378
- domModal.appendChild(domFooter);
25374
+ domBodyContainer.appendChild(domBody);
25375
+ domBody.appendChild(domTitle);
25376
+ domBody.appendChild(domSubtitle);
25377
+ domBody.appendChild(domImage);
25378
+ domBody.appendChild(domContent);
25379
+ domModal.appendChild(domBodyContainer);
25380
+ domFooterContainer.appendChild(domConfirm);
25381
+ domModal.appendChild(domFooterContainer);
25379
25382
  if (arg.copyRight) {
25380
25383
  domCopyRight.innerText = arg.copyRight;
25381
- domFooter.appendChild(domCopyRight);
25384
+ domFooterContainer.appendChild(domCopyRight);
25382
25385
  }
25383
25386
  authmeContainer.appendChild(domModal);
25384
25387
  };
@@ -25406,9 +25409,11 @@ const resetFrame = () => {
25406
25409
  };
25407
25410
  const countdownTimer = (time, doSomething) => {
25408
25411
  let end = false;
25412
+ let timer;
25413
+ let endTime;
25409
25414
  const init = () => {
25410
- const endTime = new Date().getTime() + time * 1000;
25411
- const timer = setInterval(function () {
25415
+ endTime = new Date().getTime() + time * 1000;
25416
+ timer = setInterval(function () {
25412
25417
  const currentTime = new Date().getTime();
25413
25418
  const remainingTime = endTime - currentTime;
25414
25419
  if (remainingTime <= 0) {
@@ -25420,10 +25425,21 @@ const countdownTimer = (time, doSomething) => {
25420
25425
  }
25421
25426
  }, 300);
25422
25427
  };
25428
+ const clear = () => {
25429
+ clearInterval(timer);
25430
+ end = true;
25431
+ return (endTime - new Date().getTime()) / 1000;
25432
+ };
25433
+ const pause = () => {
25434
+ clearInterval(timer);
25435
+ return (endTime - new Date().getTime()) / 1000;
25436
+ };
25423
25437
  const getStatus = () => {
25424
25438
  return end;
25425
25439
  };
25426
25440
  return {
25441
+ pause: pause,
25442
+ clear: clear,
25427
25443
  init: init,
25428
25444
  end: getStatus
25429
25445
  };
@@ -25431,7 +25447,7 @@ const countdownTimer = (time, doSomething) => {
25431
25447
 
25432
25448
  const translateService = getTranslateInstance();
25433
25449
  // TODO 處理參數
25434
- const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCardPoints, setCardBorderColor, statusText, canvasSizeInfo$, showVideoElement, config, cardRotateByStage, getCardBorderPoint, setBorderType, setBorderSuccess, scanAnimationContainer, successAnimationContainer, frameImage, frameText, facingMode, ocrEngineConfig, sdkFlowTimeout = undefined, makeSDKFlowTimeout, image, video, retryBtn, completeBtn, confirmImageContainer) => {
25450
+ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCardPoints, setCardBorderColor, statusText, canvasSizeInfo$, showVideoElement, config, cardRotateByStage, getCardBorderPoint, setBorderType, setBorderSuccess, scanAnimationContainer, successAnimationContainer, frameImage, frameText, facingMode, ocrEngineConfig, sdkFlowTimeout = undefined, makeSDKFlowTimeout, image, video, retryBtn, completeBtn, confirmImageContainer, confrimContainer) => {
25435
25451
  const videoToCanvas = (sizeInfo, data) => {
25436
25452
  const ctx2 = image.getContext('2d');
25437
25453
  image.width = sizeInfo.canvasWidth;
@@ -25448,6 +25464,7 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25448
25464
  videoToCanvas(sizeInfo, data);
25449
25465
  showVideoElement(false);
25450
25466
  showElement(confirmImageContainer);
25467
+ showElement(confrimContainer);
25451
25468
  const retryEvents = fromEvent(retryBtn, 'click').pipe(mapTo(true));
25452
25469
  const confirmEvents = fromEvent(completeBtn, 'click').pipe(mapTo(false));
25453
25470
  const allEvents$ = merge(retryEvents, confirmEvents);
@@ -25500,11 +25517,6 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25500
25517
  sendStatusDescription$1(StatusDescription.WrongCardType);
25501
25518
  setCardBorderColor('error');
25502
25519
  break;
25503
- case EAuthMeIDCardAntiFraudStatus.CardThicknessFailed:
25504
- statusText.textContent = translateService.translate('sdk.general.verify.error.CardThicknessFailed');
25505
- sendStatusDescription$1(StatusDescription.CardThicknessFailed);
25506
- setCardBorderColor('error');
25507
- break;
25508
25520
  case EAuthMeIDCardAntiFraudStatus.Reflective:
25509
25521
  statusText.textContent = translateService.translate('sdk.general.verify.error.reflective');
25510
25522
  sendStatusDescription$1(StatusDescription.Reflective);
@@ -25545,22 +25557,11 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25545
25557
  statusText.textContent = translateService.translate('sdk.general.verify.error.cardCutByCamera');
25546
25558
  break;
25547
25559
  case EAuthMeIDCardAntiFraudStatus.CardNotInROI:
25548
- statusText.textContent = translateService.translate('verify.error.CardNotInROI');
25560
+ statusText.textContent = translateService.translate('sdk.general.verify.error.missmatch');
25549
25561
  break;
25550
25562
  case EAuthMeIDCardAntiFraudStatus.CardTooSmall:
25551
25563
  statusText.textContent = translateService.translate('sdk.general.verify.error.getCloser');
25552
25564
  break;
25553
- case EAuthMeIDCardAntiFraudStatus.NeedHoldCard:
25554
- statusText.textContent = translateService.translate('sdk.general.verify.error.needHoldCard');
25555
- break;
25556
- case EAuthMeIDCardAntiFraudStatus.StagePass:
25557
- statusText.textContent = translateService.translate('sdk.general.verify.error.stagePass');
25558
- setCardBorderColor('pass');
25559
- break;
25560
- case EAuthMeIDCardAntiFraudStatus.Pass:
25561
- setCardBorderColor('pass');
25562
- statusText.textContent = translateService.translate('sdk.general.verify.error.pass');
25563
- break;
25564
25565
  case EAuthMeIDCardAntiFraudStatus.Failed:
25565
25566
  setCardBorderColor('error');
25566
25567
  statusText.textContent = translateService.translate('sdk.general.verify.error.pass');
@@ -25603,7 +25604,8 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25603
25604
  onConfirm: () => {
25604
25605
  observer.next(canvasSizeInfo);
25605
25606
  observer.complete();
25606
- }
25607
+ },
25608
+ copyRight: translateService.translate('sdk.general.footer')
25607
25609
  });
25608
25610
  });
25609
25611
  } else {
@@ -25643,6 +25645,9 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25643
25645
  result
25644
25646
  }) => {
25645
25647
  if (thicknessTimer.end()) {
25648
+ hideElement(confirmImageContainer);
25649
+ hideElement(confrimContainer);
25650
+ showVideoElement(true);
25646
25651
  startSpinner(translateService.translate('sdk.general.uploading'), true);
25647
25652
  videoToCanvas(canvasSizeInfo, result.imageData);
25648
25653
  return config.confirmThickness ? config.confirmThickness(generateImage(), cardType) : of(false);
@@ -25653,6 +25658,7 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25653
25658
  }), switchMap(confirmResp => {
25654
25659
  showVideoElement(true);
25655
25660
  hideElement(confirmImageContainer);
25661
+ hideElement(confrimContainer);
25656
25662
  stopSpinner();
25657
25663
  if (confirmResp) {
25658
25664
  return autoDetectProcess(true);
@@ -25678,6 +25684,9 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25678
25684
  // 當 end() 函數返回 false 時繼續
25679
25685
  finalize$1(() => __awaiter(void 0, void 0, void 0, function* () {
25680
25686
  if (thicknessTimer.end()) {
25687
+ hideElement(confirmImageContainer);
25688
+ hideElement(confrimContainer);
25689
+ showVideoElement(true);
25681
25690
  startSpinner(translateService.translate('sdk.general.uploading'), true);
25682
25691
  const sizeInfo = yield getCanvasSize(video);
25683
25692
  videoToCanvas(sizeInfo);
@@ -25697,10 +25706,11 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25697
25706
  return needRetry ? of(true) : from(config.confirmThickness ? config.confirmThickness(generateImage(), cardType) : of(false)).pipe(tap(() => sendStatusAction$1(StatusAction.Uploading)), map(confirmResp => !confirmResp));
25698
25707
  }), tap(confirmResp => {
25699
25708
  hideElement(confirmImageContainer);
25709
+ hideElement(confrimContainer);
25700
25710
  stopSpinner();
25701
25711
  showVideoElement(true);
25712
+ checkTimeout.unsubscribe(); // 取消 interval$ 的訂閱
25702
25713
  if (!confirmResp) {
25703
- checkTimeout.unsubscribe(); // 取消 interval$ 的訂閱
25704
25714
  hideElement(captureBtn);
25705
25715
  observer.next(canvasSizeInfo);
25706
25716
  }
@@ -25726,6 +25736,63 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25726
25736
  }
25727
25737
  };
25728
25738
 
25739
+ const toast = arg => {
25740
+ var _a;
25741
+ let timer = null;
25742
+ let clearStatus = false;
25743
+ const message = typeof arg === 'string' ? arg : arg.message;
25744
+ const duration = arg.duration || 4000;
25745
+ const transition = (_a = arg.transition) !== null && _a !== void 0 ? _a : true;
25746
+ const toast = document.createElement('div');
25747
+ toast.style.cssText = `
25748
+ position: fixed;
25749
+ bottom: 50px;
25750
+ left: 50%;
25751
+ box-sizing: border-box;
25752
+ transform: translateX(-50%);
25753
+ width: 90%;
25754
+ padding: 10px 16px;
25755
+ background-color: rgba(0, 0, 0, .6);
25756
+ color: #fff;
25757
+ border-radius: 8px;
25758
+ z-index: 999999;
25759
+ display: flex;
25760
+ align-items: center;
25761
+ column-gap: 16px;
25762
+ opacity: 0;
25763
+ word-break: break-all;
25764
+ `;
25765
+ toast.classList.add('authme-toast');
25766
+ const clear = () => {
25767
+ if (!clearStatus) {
25768
+ clearStatus = true;
25769
+ document.body.removeChild(toast);
25770
+ clearTimeout(timer);
25771
+ }
25772
+ };
25773
+ if (transition) {
25774
+ toast.style.transition = 'opacity .3s ease-in';
25775
+ setTimeout(() => {
25776
+ toast.style.opacity = '1';
25777
+ }, 300);
25778
+ } else {
25779
+ toast.style.opacity = '1';
25780
+ }
25781
+ toast.innerHTML = message;
25782
+ document.body.appendChild(toast);
25783
+ timer = setTimeout(() => {
25784
+ clearStatus = true;
25785
+ toast.style.opacity = '0';
25786
+ toast.style.transition = 'opacity .3s ease-out';
25787
+ setTimeout(() => {
25788
+ document.body.removeChild(toast);
25789
+ }, 500);
25790
+ }, duration);
25791
+ return {
25792
+ clear
25793
+ };
25794
+ };
25795
+
25729
25796
  const initEvenTrackingStatus = ocrConfig => {
25730
25797
  setFeature$1(ocrConfig.needAntiFraud ? Feature.OCRFraud : Feature.OCR);
25731
25798
  };
@@ -25749,7 +25816,8 @@ function startOCR(config) {
25749
25816
  enableManualUpload: false,
25750
25817
  fraudRetryTimes: 1,
25751
25818
  fraudTimeout: 52,
25752
- fraudMaxFps: 2
25819
+ fraudMaxFps: 2,
25820
+ captureTimeout: config.ocrConfig.captureTimeout
25753
25821
  };
25754
25822
  let cardSizeInfo = {
25755
25823
  width: 0,
@@ -25790,9 +25858,10 @@ function startOCR(config) {
25790
25858
  lottieMask,
25791
25859
  arrowAnimationContainer,
25792
25860
  scanAnimationContainer,
25793
- successAnimationDom,
25861
+ successContainer,
25794
25862
  antiFraudInstructionAnimationContainer,
25795
25863
  confirmImageContainer,
25864
+ confirmContainer,
25796
25865
  imageTypeText,
25797
25866
  retryBtn,
25798
25867
  confirmBtn,
@@ -25825,6 +25894,9 @@ function startOCR(config) {
25825
25894
  stopAnimate
25826
25895
  } = renderCardRotateAnimate(arrowAnimationContainer);
25827
25896
  setCorrectViewHeight();
25897
+ let countdownCaptureTimer;
25898
+ let toastManualCapture = null;
25899
+ let captureTimeoutTimer;
25828
25900
  const canvasSizeInfo$ = merge(defer(() => requestCamera({
25829
25901
  video,
25830
25902
  facingMode: 'back',
@@ -25860,7 +25932,7 @@ function startOCR(config) {
25860
25932
  });
25861
25933
  }), expiredIn * TIME_UNIT.SECOND);
25862
25934
  }
25863
- function startAntiFraud(type) {
25935
+ function startAntiFraud(type, cardType) {
25864
25936
  const animateInterval = 2 * TIME_UNIT.SECOND;
25865
25937
  const nextAnimateInterval = 6 * TIME_UNIT.SECOND;
25866
25938
  let needDeformationCount = 0;
@@ -25946,7 +26018,7 @@ function startOCR(config) {
25946
26018
  statusText.textContent = translateService.translate('sdk.general.verify.error.cardCutByCamera');
25947
26019
  break;
25948
26020
  case EAuthMeIDCardAntiFraudStatus.CardNotInROI:
25949
- statusText.textContent = translateService.translate('verify.error.CardNotInROI');
26021
+ statusText.textContent = translateService.translate('sdk.general.verify.error.missmatch');
25950
26022
  break;
25951
26023
  case EAuthMeIDCardAntiFraudStatus.CardTooSmall:
25952
26024
  statusText.textContent = translateService.translate('sdk.general.verify.error.getCloser');
@@ -25987,7 +26059,7 @@ function startOCR(config) {
25987
26059
  statusText.classList.remove('non-empty');
25988
26060
  }
25989
26061
  };
25990
- const antiFraudStart$ = of(true).pipe(switchMap(() => checkOnlineStatus(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'))), switchMap(() => canvasSizeInfo$), switchMap(canvasSizeInfo => from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(switchMap(() => config.antiFraudStart(getCardBorderPoint(), setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successAnimationDom, frameImage, frameText, facingMode)), tap(() => __awaiter(this, void 0, void 0, function* () {
26062
+ const antiFraudStart$ = of(true).pipe(switchMap(() => checkOnlineStatus(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'))), switchMap(() => canvasSizeInfo$), switchMap(canvasSizeInfo => from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(switchMap(() => config.antiFraudStart(getCardBorderPoint(), setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successContainer, frameImage, frameText, facingMode)), tap(() => __awaiter(this, void 0, void 0, function* () {
25991
26063
  setStatusView(StatusView.Aligning);
25992
26064
  if (buttonDisable$) {
25993
26065
  const cardMatchROI = config.getCardMatchROI ? yield config.getCardMatchROI() : undefined;
@@ -26028,9 +26100,10 @@ function startOCR(config) {
26028
26100
  statusText.classList.remove('non-empty');
26029
26101
  setCardBorderColor('pass');
26030
26102
  hideElement(arrowAnimationContainer);
26031
- lottie.play('success');
26103
+ successContainer.classList.remove('hide');
26032
26104
  }), switchMap(() => waitTime(2000)), tap(() => {
26033
- lottie.stop('success');
26105
+ setHeaderByType(cardType);
26106
+ successContainer.classList.add('hide');
26034
26107
  }));
26035
26108
  antiFraudStart$.pipe(
26036
26109
  //workaround?: 因目前Frontal timeout會直接Failed,所以不能用$handleError來作為停止條件。
@@ -26048,6 +26121,7 @@ function startOCR(config) {
26048
26121
  if (!config.ocrConfig.needOCR && type === EAuthMeCardClass.TWN_IDCard_Front) {
26049
26122
  return of(true);
26050
26123
  }
26124
+ let captureBtn;
26051
26125
  // if (config.ocrConfig.needAntiFraud) {
26052
26126
  const point = getCardBorderPoint();
26053
26127
  setCardPoints(point.map(([x, y]) => ({
@@ -26107,7 +26181,7 @@ function startOCR(config) {
26107
26181
  showCameraSwitchButton(deviceMetas);
26108
26182
  }
26109
26183
  };
26110
- const init = retry => canvasSizeInfo$.pipe(take(1), switchMap(canvasSizeInfo => from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(switchMap(() => checkOnlineStatus(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'))), switchMap(() => config.ocrStart(getCardBorderPoint(), type, setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successAnimationDom, frameImage, frameText, facingMode, cardType, retry)), tap(() => {
26184
+ const init = retry => canvasSizeInfo$.pipe(take(1), switchMap(canvasSizeInfo => from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(switchMap(() => checkOnlineStatus(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'))), switchMap(() => config.ocrStart(getCardBorderPoint(), type, setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successContainer, frameImage, frameText, facingMode, cardType, retry)), tap(() => {
26111
26185
  tiltFrame(false);
26112
26186
  stopSpinner();
26113
26187
  showElement(scanAnimationContainer);
@@ -26116,41 +26190,167 @@ function startOCR(config) {
26116
26190
  lottie.play('scan');
26117
26191
  showElement(scanAnimationContainer);
26118
26192
  }), map(() => canvasSizeInfo))));
26119
- setCardBorderColor(null);
26120
- const recognition = retry => init(retry).pipe(tap(() => {
26121
- setStatusView(StatusView.Running);
26122
- if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
26123
- sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
26193
+ const videoToCanvas = (sizeInfo, data) => {
26194
+ const ctx2 = image.getContext('2d');
26195
+ image.width = sizeInfo.canvasWidth;
26196
+ image.height = sizeInfo.canvasHeight;
26197
+ if (data) {
26198
+ const imgData = ctx2.createImageData(image.width, image.height);
26199
+ imgData.data.set(data);
26200
+ ctx2.putImageData(imgData, 0, 0);
26201
+ } else {
26202
+ ctx2.drawImage(video, sizeInfo.startX, sizeInfo.startY, sizeInfo.width, sizeInfo.height, 0, 0, sizeInfo.canvasWidth, sizeInfo.canvasHeight);
26124
26203
  }
26125
- }), switchMap(canvasSizeInfo => of(canvasSizeInfo).pipe(sendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, 'jpg', cardType, undefined, type), tap(x => applyTextByResult(x.result)), filter(({
26126
- result
26127
- }) => result.eStatus === EAuthMeCardOCRStatus.Pass || result.eStatus === EAuthMeMRZServiceStatus.Success),
26128
- // ocrEngineConfig.expiredIn
26129
- // ? timeout(ocrEngineConfig.expiredIn * TIME_UNIT.SECOND)
26130
- // : tap(),
26131
- // catchError((err) => {
26132
- // if (err.name === 'TimeoutError') {
26133
- // throw new AuthmeError(ErrorCode.ID_RECOGNITION_TIMEOUT, err);
26134
- // }
26135
- // throw err;
26136
- // }),
26137
- take(1), tap(() => {
26138
- setCardBorderColor('pass');
26139
- statusText.textContent = translateService.translate('sdk.general.verify.success');
26140
- lottie.stop('scan');
26141
- hideElement(scanAnimationContainer);
26142
- }), switchMap(resp => of(true).pipe(tap(() => {
26143
- hideElement(scanAnimationContainer);
26144
- }), map(() => resp))), switchMap(({
26145
- result
26146
- }) => from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(switchMap(needRetry => {
26147
- startSpinner(translateService.translate('sdk.general.uploading'));
26148
- return needRetry ? of(true) : from(config.confirmImage(type, cardType)).pipe(tap(() => sendStatusAction$1(StatusAction.Uploading)), map(confirmResp => !confirmResp));
26149
- }), tap(() => {
26150
- hideElement(confirmImageContainer);
26151
- stopSpinner();
26152
- showVideoElement();
26153
- }), switchMap(needRetry => needRetry ? recognition(true) : of(true)))))));
26204
+ };
26205
+ const checkConfirmImageManual = (sizeInfo, data) => __awaiter(this, void 0, void 0, function* () {
26206
+ videoToCanvas(sizeInfo, data);
26207
+ showVideoElement(false);
26208
+ showElement(confirmImageContainer);
26209
+ showElement(confirmContainer);
26210
+ const retryEvents = fromEvent(retryBtn, 'click').pipe(mapTo(true));
26211
+ const confirmEvents = fromEvent(completeBtn, 'click').pipe(mapTo(false));
26212
+ const allEvents$ = merge(retryEvents, confirmEvents);
26213
+ return yield firstValueFrom(allEvents$.pipe());
26214
+ });
26215
+ const manualCapture = show => {
26216
+ captureBtn = captureButton();
26217
+ if (captureBtn && show) {
26218
+ showElement(captureBtn);
26219
+ toastManualCapture = toast({
26220
+ message: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_19494_3109)"><path d="M19.5 19.5H4.5C4.10218 19.5 3.72064 19.342 3.43934 19.0607C3.15804 18.7794 3 18.3978 3 18V7.5C3 7.10218 3.15804 6.72064 3.43934 6.43934C3.72064 6.15804 4.10218 6 4.5 6H7.5L9 3.75H15L16.5 6H19.5C19.8978 6 20.2794 6.15804 20.5607 6.43934C20.842 6.72064 21 7.10218 21 7.5V18C21 18.3978 20.842 18.7794 20.5607 19.0607C20.2794 19.342 19.8978 19.5 19.5 19.5Z" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 15.75C13.864 15.75 15.375 14.239 15.375 12.375C15.375 10.511 13.864 9 12 9C10.136 9 8.625 10.511 8.625 12.375C8.625 14.239 10.136 15.75 12 15.75Z" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_19494_3109"><rect width="24" height="24" fill="white"/></clipPath></defs></svg>' + translateService.translate('sdk.general.manualCapture'),
26221
+ transition: !show
26222
+ });
26223
+ }
26224
+ return fromEvent(captureBtn, 'click').pipe(switchMap(() => getCanvasSize(video)), switchMap(canvasSizeInfo => {
26225
+ ocrSendFrameAnimation = true;
26226
+ lottie.stop('scan');
26227
+ hideElement(scanAnimationContainer);
26228
+ if (toastManualCapture) {
26229
+ toastManualCapture.clear();
26230
+ }
26231
+ return from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? of(false) : checkConfirmImageManual(canvasSizeInfo)).pipe(switchMap(needRetry => {
26232
+ startSpinner(translateService.translate('sdk.general.uploading'));
26233
+ if (needRetry) {
26234
+ hideElement(confirmImageContainer);
26235
+ hideElement(confirmContainer);
26236
+ stopSpinner();
26237
+ showVideoElement();
26238
+ lottie.play('scan');
26239
+ showElement(scanAnimationContainer);
26240
+ }
26241
+ return needRetry ? of(true) : from(config.confirmImage({
26242
+ type,
26243
+ cardType,
26244
+ imageData: dataURItoBlob(image.toDataURL('image/jpeg', 0.85)),
26245
+ manual: true
26246
+ })).pipe(tap(() => sendStatusAction$1(StatusAction.Uploading)), map(confirmResp => !confirmResp));
26247
+ }), switchMap(needRetry => {
26248
+ if (needRetry) {
26249
+ ocrSendFrameAnimation = false;
26250
+ return recognition(true).pipe(map(() => true));
26251
+ } else {
26252
+ hideElement(captureBtn);
26253
+ hideElement(confirmImageContainer);
26254
+ hideElement(confirmContainer);
26255
+ stopSpinner();
26256
+ showVideoElement();
26257
+ lottie.play('scan');
26258
+ showElement(scanAnimationContainer);
26259
+ return of(true);
26260
+ }
26261
+ }), map(confirmResp => confirmResp));
26262
+ }));
26263
+ };
26264
+ setCardBorderColor(null);
26265
+ let ocrSendFrameAnimation = false;
26266
+ const handleOcrSendFrame = (canvasSizeInfo, canvas, video, frameCallback, fps, bas64Format, imageType, cardType, type) => source$ => {
26267
+ let received = true;
26268
+ const ctx = canvas.getContext('2d');
26269
+ return source$.pipe(mergeMap(() => animationFrames().pipe(limitFPS(fps), filter(() => received && !ocrSendFrameAnimation), 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 => {
26270
+ // send to fast, ignore
26271
+ if (e instanceof AuthmeError && e.code === ErrorCode.RECOGNITION_NOT_AVAILABLE) {
26272
+ return EMPTY;
26273
+ }
26274
+ throw e;
26275
+ }), filter(x => !!x), map(result => ({
26276
+ imageData,
26277
+ result
26278
+ })), tap(() => received = true))))));
26279
+ };
26280
+ const autoCapture = canvasSizeInfo => {
26281
+ return of(canvasSizeInfo).pipe(handleOcrSendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, 'jpg', cardType, type), tap(x => applyTextByResult(x.result)), filter(({
26282
+ result
26283
+ }) => result.eStatus === EAuthMeCardOCRStatus.Pass || result.eStatus === EAuthMeMRZServiceStatus.Success), take(1), tap(() => {
26284
+ if (countdownCaptureTimer && countdownCaptureTimer.end && !countdownCaptureTimer.end()) {
26285
+ const remainingCountTime = Math.floor(countdownCaptureTimer.pause());
26286
+ captureTimeoutTimer = remainingCountTime;
26287
+ }
26288
+ setCardBorderColor('pass');
26289
+ statusText.textContent = translateService.translate('sdk.general.verify.success');
26290
+ lottie.stop('scan');
26291
+ if (toastManualCapture) {
26292
+ toastManualCapture.clear();
26293
+ }
26294
+ hideElement(scanAnimationContainer);
26295
+ }), switchMap(resp => of(true).pipe(tap(() => {
26296
+ hideElement(scanAnimationContainer);
26297
+ }), map(() => resp))), switchMap(({
26298
+ result
26299
+ }) => from(type === EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(switchMap(needRetry => {
26300
+ if (countdownCaptureTimer && countdownCaptureTimer.end) {
26301
+ if (needRetry && !countdownCaptureTimer.end()) {
26302
+ countdownCaptureTimer = countdownTimer(captureTimeoutTimer, () => {
26303
+ showElement(captureBtn);
26304
+ toastManualCapture = toast({
26305
+ message: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_19494_3109)"><path d="M19.5 19.5H4.5C4.10218 19.5 3.72064 19.342 3.43934 19.0607C3.15804 18.7794 3 18.3978 3 18V7.5C3 7.10218 3.15804 6.72064 3.43934 6.43934C3.72064 6.15804 4.10218 6 4.5 6H7.5L9 3.75H15L16.5 6H19.5C19.8978 6 20.2794 6.15804 20.5607 6.43934C20.842 6.72064 21 7.10218 21 7.5V18C21 18.3978 20.842 18.7794 20.5607 19.0607C20.2794 19.342 19.8978 19.5 19.5 19.5Z" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 15.75C13.864 15.75 15.375 14.239 15.375 12.375C15.375 10.511 13.864 9 12 9C10.136 9 8.625 10.511 8.625 12.375C8.625 14.239 10.136 15.75 12 15.75Z" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_19494_3109"><rect width="24" height="24" fill="white"/></clipPath></defs></svg>' + translateService.translate('sdk.general.manualCapture'),
26306
+ transition: true
26307
+ });
26308
+ });
26309
+ countdownCaptureTimer.init();
26310
+ }
26311
+ if (!needRetry) {
26312
+ countdownCaptureTimer.clear();
26313
+ hideElement(captureBtn);
26314
+ }
26315
+ }
26316
+ startSpinner(translateService.translate('sdk.general.uploading'));
26317
+ return needRetry ? of(true) : from(config.confirmImage({
26318
+ type,
26319
+ cardType
26320
+ })).pipe(tap(() => sendStatusAction$1(StatusAction.Uploading)), map(confirmResp => !confirmResp));
26321
+ }), tap(() => {
26322
+ hideElement(confirmImageContainer);
26323
+ hideElement(confirmContainer);
26324
+ stopSpinner();
26325
+ showVideoElement();
26326
+ }), switchMap(needRetry => needRetry ? recognition(true) : of(true)))));
26327
+ };
26328
+ const recognition = retry => {
26329
+ return init(retry).pipe(tap(() => {
26330
+ setStatusView(StatusView.Running);
26331
+ if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
26332
+ sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
26333
+ }
26334
+ }), switchMap(canvasSizeInfo => {
26335
+ if (type !== EAuthMeCardClass.Passport && !retry) {
26336
+ if (ocrEngineConfig.captureTimeout > 0) {
26337
+ countdownCaptureTimer = countdownTimer(ocrEngineConfig.captureTimeout, () => {
26338
+ showElement(captureBtn);
26339
+ toastManualCapture = toast({
26340
+ message: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_19494_3109)"><path d="M19.5 19.5H4.5C4.10218 19.5 3.72064 19.342 3.43934 19.0607C3.15804 18.7794 3 18.3978 3 18V7.5C3 7.10218 3.15804 6.72064 3.43934 6.43934C3.72064 6.15804 4.10218 6 4.5 6H7.5L9 3.75H15L16.5 6H19.5C19.8978 6 20.2794 6.15804 20.5607 6.43934C20.842 6.72064 21 7.10218 21 7.5V18C21 18.3978 20.842 18.7794 20.5607 19.0607C20.2794 19.342 19.8978 19.5 19.5 19.5Z" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 15.75C13.864 15.75 15.375 14.239 15.375 12.375C15.375 10.511 13.864 9 12 9C10.136 9 8.625 10.511 8.625 12.375C8.625 14.239 10.136 15.75 12 15.75Z" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_19494_3109"><rect width="24" height="24" fill="white"/></clipPath></defs></svg>' + translateService.translate('sdk.general.manualCapture'),
26341
+ transition: true
26342
+ });
26343
+ });
26344
+ countdownCaptureTimer.init();
26345
+ return race(manualCapture(false), autoCapture(canvasSizeInfo));
26346
+ }
26347
+ if (ocrEngineConfig.captureTimeout === 0) {
26348
+ return race(manualCapture(true), autoCapture(canvasSizeInfo));
26349
+ }
26350
+ }
26351
+ return autoCapture(canvasSizeInfo);
26352
+ }));
26353
+ };
26154
26354
  return recognition(false);
26155
26355
  }
26156
26356
  function createFlowByType(type, cardType, cardTypeConfig) {
@@ -26163,7 +26363,7 @@ function startOCR(config) {
26163
26363
  setUIByType(type, cardType);
26164
26364
  }), switchMap(() => {
26165
26365
  if (type === EAuthMeCardClass.TWN_IDCard_Front && config.ocrConfig.needAntiFraud) {
26166
- return from(startAntiFraud(type)).pipe(switchMap(() => {
26366
+ return from(startAntiFraud(type, cardType)).pipe(switchMap(() => {
26167
26367
  hideFrameUI(false);
26168
26368
  return startOCR(type, cardType);
26169
26369
  }));
@@ -26175,7 +26375,7 @@ function startOCR(config) {
26175
26375
  thicknessStart: config.thicknessStart,
26176
26376
  onThicknessFrame: config.onThicknessFrame,
26177
26377
  confirmThickness: config.confirmThickness
26178
- }, cardRotateByStage, getCardBorderPoint, setBorderType, setBorderSuccess, scanAnimationContainer, successAnimationDom, frameImage, frameText, facingMode, ocrEngineConfig, sdkFlowTimeout, makeSDKFlowTimeout, image, video, retryBtn, completeBtn, confirmImageContainer);
26378
+ }, cardRotateByStage, getCardBorderPoint, setBorderType, setBorderSuccess, scanAnimationContainer, successContainer, frameImage, frameText, facingMode, ocrEngineConfig, sdkFlowTimeout, makeSDKFlowTimeout, image, video, retryBtn, completeBtn, confirmImageContainer, confirmContainer);
26179
26379
  } else if (cardType.toLocaleLowerCase().includes('front')) {
26180
26380
  hideFrameUI(false);
26181
26381
  return startOCR(type, cardType);
@@ -26276,6 +26476,10 @@ function startOCR(config) {
26276
26476
  }), takeUntil(unsubscribe$), finalize(() => {
26277
26477
  document.body.removeChild(container);
26278
26478
  sendStatusAction$1(StatusAction.BtnClose);
26479
+ countdownCaptureTimer && countdownCaptureTimer.clear && countdownCaptureTimer.clear();
26480
+ if (toastManualCapture) {
26481
+ toastManualCapture.clear();
26482
+ }
26279
26483
  }));
26280
26484
  const detectScreenResizeError$ = handleScreenResizeError$(detectScreenResize$(), unsubscribe$, () => !flags.onConfirm);
26281
26485
  return merge(flow$, cancel$, detectScreenResizeError$, timeout$).pipe(take(1));
@@ -26294,7 +26498,7 @@ function startOCR(config) {
26294
26498
  showElement(lottieMask);
26295
26499
  setHeaderText(translateService.translate('verify.idCard'), translateService.translate('sdk.verify.header.stepper', {
26296
26500
  current: 1,
26297
- total: 3
26501
+ total: stepTotal()
26298
26502
  }));
26299
26503
  lottie.loadAnimation({
26300
26504
  container: antiFraudInstructionAnimationContainer,
@@ -26348,6 +26552,7 @@ function startOCR(config) {
26348
26552
  tap(() => sendStatusAction$1(StatusAction.Show));
26349
26553
  showVideoElement(false);
26350
26554
  showElement(confirmImageContainer);
26555
+ showElement(confirmContainer);
26351
26556
  if (data) {
26352
26557
  const ctx2 = image.getContext('2d');
26353
26558
  image.width = width;
@@ -26396,7 +26601,7 @@ function startOCR(config) {
26396
26601
  }
26397
26602
  function setUIByType(type, cardType) {
26398
26603
  setTextByType(type, cardType);
26399
- setHeaderByType(type);
26604
+ setHeaderByType(cardType);
26400
26605
  setCardSize(type);
26401
26606
  }
26402
26607
  function setTextByType(type, cardType) {
@@ -26444,46 +26649,25 @@ function startOCR(config) {
26444
26649
  }
26445
26650
  imageTypeText.textContent = translateService.translate(titleConfirmKey !== null && titleConfirmKey !== void 0 ? titleConfirmKey : 'verify.confirm.unexpected');
26446
26651
  }
26447
- function setHeaderByType(type) {
26448
- const typeMap = {
26449
- EAuthMeCardClass_Passport: 'sdk.verify.passport.header',
26450
- EAuthMeCardClass_TWN_IDCard_Front: 'sdk.verify.idCard.header',
26451
- EAuthMeCardClass_TWN_IDCard_Back: 'sdk.verify.idCard.header',
26452
- EAuthMeCardClass_TWN_DriverLicense_Front: 'sdk.verify.driverLicense.header',
26453
- EAuthMeCardClass_TWN_DriverLicense_Back: 'sdk.verify.driverLicense.header',
26454
- EAuthMeCardClass_TWN_HealthCard_Front: 'sdk.verify.healthCard.header',
26455
- EAuthMeCardClass_JPN_IDCard_Front: 'sdk.verify.myNumberCard.header',
26456
- EAuthMeCardClass_JPN_IDCard_Back: 'sdk.verify.myNumberCard.header',
26457
- EAuthMeCardClass_JPN_IDCard_Thickness: 'sdk.verify.myNumberCard.header',
26458
- EAuthMeCardClass_TWN_ResidentCard_Front: 'sdk.verify.residentCard.header',
26459
- EAuthMeCardClass_TWN_ResidentCard_Back: 'sdk.verify.residentCard.header'
26460
- };
26461
- if (type.includes('Health') || type.includes('Passport')) {
26462
- setHeaderText(translateService.translate(typeMap[type]), translateService.translate('sdk.verify.header.stepper', {
26463
- current: 1,
26464
- total: 1
26465
- }));
26466
- } else {
26467
- if (type.includes('Front')) {
26468
- const stepNow = type.includes('TWN_IDCard') ? translateService.translate('sdk.verify.header.stepper', {
26469
- current: 2,
26470
- total: 3
26471
- }) : translateService.translate('sdk.verify.header.stepper', {
26472
- current: 1,
26473
- total: 2
26474
- });
26475
- setHeaderText(translateService.translate(typeMap[type]), stepNow);
26476
- } else {
26477
- const stepNow = type.includes('TWN_IDCard') ? translateService.translate('sdk.verify.header.stepper', {
26478
- current: 3,
26479
- total: 3
26480
- }) : translateService.translate('sdk.verify.header.stepper', {
26481
- current: 2,
26482
- total: 2
26483
- });
26484
- setHeaderText(translateService.translate(typeMap[type]), stepNow);
26485
- }
26652
+ const stepTotal = () => {
26653
+ let total = config.cardTypes.length;
26654
+ if (config.ocrConfig.needAntiFraud) {
26655
+ total = total + 1;
26486
26656
  }
26657
+ return total;
26658
+ };
26659
+ const setpCurrent = type => {
26660
+ let current = config.cardTypes.indexOf(type) + 1;
26661
+ if (isTutorialFinish) {
26662
+ current++;
26663
+ }
26664
+ return current;
26665
+ };
26666
+ function setHeaderByType(cardType) {
26667
+ setHeaderText(translateService.translate(cardTypeHeader(cardType)), translateService.translate('sdk.verify.header.stepper', {
26668
+ current: setpCurrent(cardType),
26669
+ total: stepTotal()
26670
+ }));
26487
26671
  }
26488
26672
  function setCardSize(type) {
26489
26673
  var _a, _b;
@@ -26492,17 +26676,22 @@ function startOCR(config) {
26492
26676
  CARD_SIZE[CARD_SIZE["MAX_WIDTH_RATE"] = 0.95] = "MAX_WIDTH_RATE";
26493
26677
  CARD_SIZE[CARD_SIZE["MAX_HEIGHT_RATE"] = 0.6] = "MAX_HEIGHT_RATE";
26494
26678
  CARD_SIZE[CARD_SIZE["MAX_HEIGHT_RATE_IPHONE14PRO"] = 0.235] = "MAX_HEIGHT_RATE_IPHONE14PRO";
26679
+ CARD_SIZE[CARD_SIZE["POSSPORT_MAX_WIDTH_RATE"] = 0.9] = "POSSPORT_MAX_WIDTH_RATE";
26495
26680
  CARD_SIZE[CARD_SIZE["DRIVER_LICENSE_RATIO"] = 1.4166666666666667] = "DRIVER_LICENSE_RATIO";
26496
26681
  CARD_SIZE[CARD_SIZE["ID_CARD_RATIO"] = 1.5740740740740742] = "ID_CARD_RATIO";
26497
26682
  CARD_SIZE[CARD_SIZE["PASSPORT_RATIO"] = 1.4597701149425288] = "PASSPORT_RATIO";
26498
26683
  })(CARD_SIZE || (CARD_SIZE = {}));
26499
26684
  let heightRate = CARD_SIZE.MAX_HEIGHT_RATE;
26685
+ let widthRate = CARD_SIZE.MAX_WIDTH_RATE;
26500
26686
  if (isIphone14proOrProMax() && config.ocrConfig.hotfixIphone14proCameraBlur) {
26501
26687
  heightRate = CARD_SIZE.MAX_HEIGHT_RATE_IPHONE14PRO;
26502
26688
  }
26689
+ if (type === EAuthMeCardClass.Passport) {
26690
+ widthRate = CARD_SIZE.POSSPORT_MAX_WIDTH_RATE;
26691
+ }
26503
26692
  const windowWidth = window.innerWidth;
26504
26693
  const windowHeight = window.innerHeight;
26505
- const maxWidth = windowWidth * CARD_SIZE.MAX_WIDTH_RATE;
26694
+ const maxWidth = windowWidth * widthRate;
26506
26695
  const maxHeight = windowHeight * heightRate;
26507
26696
  let ratio = CARD_SIZE.ID_CARD_RATIO;
26508
26697
  if (type === EAuthMeCardClass.TWN_DriverLicense_Back || type === EAuthMeCardClass.TWN_DriverLicense_Front) {
@@ -26557,8 +26746,15 @@ function startOCR(config) {
26557
26746
  } = renderCameraSwitch({
26558
26747
  container: videoContainer
26559
26748
  });
26749
+ let hint = true;
26560
26750
  cameraHint.innerHTML = translateService.translate('sdk.general.verify.error.switchCamera');
26561
26751
  cameraSwitchContainer.addEventListener('click', () => __awaiter(this, void 0, void 0, function* () {
26752
+ if (hint) {
26753
+ setTimeout(() => {
26754
+ cameraHint.outerHTML = '';
26755
+ hint = false;
26756
+ }, 300);
26757
+ }
26562
26758
  const _nextCameraNumber = parseInt(switchText.textContent) + 1;
26563
26759
  const nextCameraNumber = _nextCameraNumber > backCameraList.length ? 1 : _nextCameraNumber;
26564
26760
  switchText.textContent = (nextCameraNumber > backCameraList.length ? 1 : nextCameraNumber) + '';
@@ -26685,6 +26881,8 @@ const renderExtraUI = config => {
26685
26881
  // Set init text
26686
26882
  titleText.innerHTML = translateService.translate('extra.title');
26687
26883
  // Picture
26884
+ const confirmContainer = document.createElement('div');
26885
+ confirmContainer.classList.add('confirm_container');
26688
26886
  const confirmImageContainer = document.createElement('div');
26689
26887
  confirmImageContainer.classList.add('confirm-image-container', 'confirm-image-container-extra');
26690
26888
  const confirmImageWapper = document.createElement('div');
@@ -26716,7 +26914,8 @@ const renderExtraUI = config => {
26716
26914
  confirmImageWapper.appendChild(imageContainer);
26717
26915
  //confirmImageContainer.appendChild(imageLineLineDesktop);
26718
26916
  confirmImageWapper.appendChild(imageFooter);
26719
- config.container.appendChild(confirmImageContainer);
26917
+ confirmContainer.appendChild(confirmImageContainer);
26918
+ config.container.appendChild(confirmContainer);
26720
26919
  // Other picture
26721
26920
  const checkOtherImageContainer = document.createElement('div');
26722
26921
  checkOtherImageContainer.classList.add('check-other-image-container', 'check-other-image-container-extra');
@@ -26746,6 +26945,7 @@ const renderExtraUI = config => {
26746
26945
  titleTextPanel,
26747
26946
  titleText,
26748
26947
  confirmImageContainer,
26948
+ confirmContainer,
26749
26949
  checkOtherImageContainer,
26750
26950
  imageTypeText,
26751
26951
  retryBtn,
@@ -26781,6 +26981,7 @@ function startExtra(config) {
26781
26981
  const {
26782
26982
  titleTextPanel,
26783
26983
  confirmImageContainer,
26984
+ confirmContainer,
26784
26985
  checkOtherImageContainer,
26785
26986
  retryBtn,
26786
26987
  completeBtn,
@@ -26824,6 +27025,7 @@ function startExtra(config) {
26824
27025
  }
26825
27026
  showVideoElement();
26826
27027
  hideElement(confirmImageContainer);
27028
+ hideElement(confirmContainer);
26827
27029
  }))), switchMap(needRetry => needRetry ? of(true) : config.extraConfig.continue === false ? reset() : from(takeOtherImage()).pipe(switchMap(needContinue => needContinue ? of(true) : of(false)), tap(() => {
26828
27030
  if (config.extraConfig.border == 'none') {
26829
27031
  hideElement(cardborderContainer);
@@ -26865,6 +27067,7 @@ function startExtra(config) {
26865
27067
  const height = sizeInfo.canvasHeight;
26866
27068
  showVideoElement(false);
26867
27069
  showElement(confirmImageContainer);
27070
+ showElement(confirmContainer);
26868
27071
  const ctx2 = image.getContext('2d');
26869
27072
  image.width = width;
26870
27073
  image.height = height;
@@ -27400,7 +27603,6 @@ class LivenessModule {
27400
27603
  function initFrameView(cardPoints, scanId, faceMode, scanView, cardType, cardTypeConfig, setBorderType, setCardBorderColor, setBorderSuccess) {
27401
27604
  return __awaiter(this, void 0, void 0, function* () {
27402
27605
  const scanAnimationContainer = document.querySelector('.scan');
27403
- const successAnimationDom = document.querySelector('.success');
27404
27606
  document.querySelector('#authme_frame_border');
27405
27607
  const videoContainer = document.querySelector('.video-container');
27406
27608
  const windowWidth = videoContainer.offsetWidth;
@@ -27408,9 +27610,6 @@ function initFrameView(cardPoints, scanId, faceMode, scanView, cardType, cardTyp
27408
27610
  const lottieScanSetting = {
27409
27611
  scanAnimationContainer: scanAnimationContainer
27410
27612
  };
27411
- const lottieSuccessSetting = {
27412
- animationContainer: successAnimationDom
27413
- };
27414
27613
  function frameImage(faceMode, zIndex, base64, color, opacity) {
27415
27614
  color = color !== null && color !== void 0 ? color : OcrFrame.imageColor;
27416
27615
  opacity = opacity !== null && opacity !== void 0 ? opacity : OcrFrame.imageOpacity;
@@ -27487,7 +27686,6 @@ function initFrameView(cardPoints, scanId, faceMode, scanView, cardType, cardTyp
27487
27686
  `);
27488
27687
  dom.textContent = text;
27489
27688
  }
27490
- initSuccessAnimation(lottieSuccessSetting);
27491
27689
  const scanViewSetting = {
27492
27690
  document_type: '',
27493
27691
  border: {
@@ -27693,6 +27891,29 @@ class MRZModule {
27693
27891
  // 2. 由於 engine-lib 限制,getFinalResult 必須要在 stop 之後呼叫。
27694
27892
  const finalResult = yield this.mrzService.getFinalResult();
27695
27893
  latestTField = JSON.parse(yield this.mrzService.toJson(finalResult));
27894
+ if (latestTField['birthDateCheckDigit']) {
27895
+ delete latestTField['birthDateCheckDigit'];
27896
+ }
27897
+ if (latestTField['documentNumberCheckDigit']) {
27898
+ delete latestTField['documentNumberCheckDigit'];
27899
+ }
27900
+ if (latestTField['expiryDateCheckDigit']) {
27901
+ delete latestTField['expiryDateCheckDigit'];
27902
+ }
27903
+ if (latestTField['optionaldataCheckDigit']) {
27904
+ delete latestTField['optionaldataCheckDigit'];
27905
+ }
27906
+ if (latestTField['overallCheckDigit']) {
27907
+ delete latestTField['overallCheckDigit'];
27908
+ }
27909
+ switch (latestTField.gender) {
27910
+ case 'M':
27911
+ latestTField.gender = 'male';
27912
+ break;
27913
+ case 'F':
27914
+ latestTField.gender = 'female';
27915
+ break;
27916
+ }
27696
27917
  } else if (uploadFullFrame) {
27697
27918
  const image = UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
27698
27919
  const requestImg = yield encryptImageBase64(image);
@@ -27708,14 +27929,14 @@ class MRZModule {
27708
27929
  });
27709
27930
  }
27710
27931
  }),
27711
- confirmImage: type => __awaiter(this, void 0, void 0, function* () {
27712
- const docId = docInfos[type].docId;
27932
+ confirmImage: option => __awaiter(this, void 0, void 0, function* () {
27933
+ const docId = docInfos[option.type].docId;
27713
27934
  if (docId) {
27714
- docInfos[type].docId = '';
27715
- const requestImg = yield encryptImageBase64(docInfos[type].ocrOriginImg);
27935
+ docInfos[option.type].docId = '';
27936
+ const requestImg = yield encryptImageBase64(docInfos[option.type].ocrOriginImg);
27716
27937
  const report = yield this.mrzService.getReport();
27717
27938
  yield SendRequestWithRetry$1(() => uploadFrameBase64(docId, requestImg, frameIndex++, ResourceImageType.Recognition, report));
27718
- yield SendRequestWithRetry$1(() => finishScanDocument(docId, latestTField !== null && latestTField !== void 0 ? latestTField : {}, docInfos[type].fraudResult));
27939
+ yield SendRequestWithRetry$1(() => finishScanDocument(docId, latestTField !== null && latestTField !== void 0 ? latestTField : {}, docInfos[option.type].fraudResult));
27719
27940
  return true;
27720
27941
  } else {
27721
27942
  return false;
@@ -28040,7 +28261,8 @@ class OCRModule {
28040
28261
  }
28041
28262
  yield waitTime(100);
28042
28263
  return Object.assign(Object.assign({}, resp.parameters), {
28043
- expiredIn: resp.expiredIn
28264
+ expiredIn: resp.expiredIn,
28265
+ captureTimeout: config.captureTimeout
28044
28266
  });
28045
28267
  }),
28046
28268
  ocrStart: (points, type, setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successAnimationContainer, frameImage, frameText, faceMode, cardType, retry = false) => __awaiter(this, void 0, void 0, function* () {
@@ -28087,10 +28309,6 @@ class OCRModule {
28087
28309
  const lottieScanSetting = {
28088
28310
  scanAnimationContainer: scanAnimationContainer
28089
28311
  };
28090
- const lottieSuccessSetting = {
28091
- animationContainer: successAnimationContainer
28092
- };
28093
- initSuccessAnimation(lottieSuccessSetting);
28094
28312
  const scanViewSetting = {
28095
28313
  document_type: '',
28096
28314
  border: {
@@ -28166,8 +28384,9 @@ class OCRModule {
28166
28384
  newParams['timeoutSec'] = 1000;
28167
28385
  newParams['fCardMatchTh'] = 0.5;
28168
28386
  newParams['fImageReflectiveTriggerTh'] = 0.15;
28169
- newParams['fImageThicknessTh'] = 0.3;
28170
- newParams['fCardDeformationTh'] = 12;
28387
+ newParams['fImageThicknessTh'] = 0.4;
28388
+ newParams['fCardDeformationTh'] = 10;
28389
+ newParams['enableCardInROI'] = 1;
28171
28390
  yield _service.setParams(Object.assign(Object.assign({}, oldParams), newParams));
28172
28391
  _service.setOption({
28173
28392
  key: 'thickness_detector',
@@ -28208,10 +28427,6 @@ class OCRModule {
28208
28427
  const lottieScanSetting = {
28209
28428
  scanAnimationContainer: scanAnimationContainer
28210
28429
  };
28211
- const lottieSuccessSetting = {
28212
- animationContainer: successAnimationContainer
28213
- };
28214
- initSuccessAnimation(lottieSuccessSetting);
28215
28430
  const scanViewSetting = {
28216
28431
  document_type: '',
28217
28432
  border: {
@@ -28437,7 +28652,7 @@ class OCRModule {
28437
28652
  status: 'confirm',
28438
28653
  type: type
28439
28654
  });
28440
- } else if (uploadFullFrame) {
28655
+ } else if (uploadFullFrame && docInfos[eClass].docId !== '') {
28441
28656
  const image = ocrOriginImg;
28442
28657
  const requestImg = yield encryptImageBase64(image);
28443
28658
  // downloadImage(image, `${frameIndex}-${docInfos[type as EAuthMeCardClass].docId}-${new Date().getTime().toString()}.jpg`)
@@ -28452,7 +28667,7 @@ class OCRModule {
28452
28667
  durationTimeRecognition.end();
28453
28668
  return result;
28454
28669
  }),
28455
- confirmImage: (type, cardType, imageData) => __awaiter(this, void 0, void 0, function* () {
28670
+ confirmImage: option => __awaiter(this, void 0, void 0, function* () {
28456
28671
  // 將二進位圖片進行加密,目前不需要使用,不確定未來是否需要,先註解
28457
28672
  // const encryptImage = async (blob: Blob): Promise<Blob> => {
28458
28673
  // const imageArrayBuffer = await blobToArrayBuffer(blob);
@@ -28463,18 +28678,23 @@ class OCRModule {
28463
28678
  // );
28464
28679
  // return base64ToBlob(resultEncrypt);
28465
28680
  // };
28466
- const docId = docInfos[cardType].docId;
28681
+ if (option.manual) {
28682
+ this.ocrService.stop();
28683
+ }
28684
+ const docId = docInfos[option.cardType].docId;
28467
28685
  if (docId) {
28468
- const needFraudOption = config.needAntiFraud && type === EAuthMeCardClass$1.TWN_IDCard_Front;
28686
+ const needFraudOption = config.needAntiFraud && option.type === EAuthMeCardClass$1.TWN_IDCard_Front;
28469
28687
  let ocrOriginImg;
28470
- if (imageData) {
28471
- ocrOriginImg = imageData;
28688
+ if (option.imageData) {
28689
+ ocrOriginImg = option.imageData;
28472
28690
  } else {
28473
- ocrOriginImg = docInfos[cardType].ocrOriginImg;
28691
+ ocrOriginImg = docInfos[option.cardType].ocrOriginImg;
28474
28692
  }
28693
+ // const base64Image = await blobToBase64(ocrOriginImg);
28694
+ // console.log('confirmImage', base64Image);
28475
28695
  const requestImg = yield encryptImageBase64(ocrOriginImg);
28476
28696
  const report = yield this.ocrService.getReport();
28477
- docInfos[cardType].docId = '';
28697
+ docInfos[option.cardType].docId = '';
28478
28698
  modifyDeubgLog(getDebugLogsLength() - 1, {
28479
28699
  report: report
28480
28700
  });
@@ -28482,7 +28702,7 @@ class OCRModule {
28482
28702
  yield SendRequestWithRetry(() => uploadFrameBase64(docId, requestImg, frameIndex, ResourceImageType.Recognition, report));
28483
28703
  frameIndex = 0;
28484
28704
  try {
28485
- const ocrImg = docInfos[cardType].ocrImg;
28705
+ const ocrImg = option.imageData ? option.imageData : docInfos[option.cardType].ocrImg;
28486
28706
  const _requestImg = yield encryptImageBase64(ocrImg);
28487
28707
  const resp = yield SendRequestWithRetry(() => recognitionEncrypt(docId, _requestImg, report, RecognitionFileType.FlatImage));
28488
28708
  if (resp.retry) {
@@ -28491,12 +28711,12 @@ class OCRModule {
28491
28711
  }
28492
28712
  result = unionMerge(result, resp && resp.details || {});
28493
28713
  yield SendRequestWithRetry(() => finishScanDocument(docId, resp.details, needFraudOption ? this.fraudResult : null));
28494
- delete docInfos[cardType];
28714
+ delete docInfos[option.cardType];
28495
28715
  return true;
28496
28716
  } catch (error) {
28497
28717
  console.log('confirmImage fail,retrying ');
28498
28718
  console.error(error);
28499
- docInfos[cardType].docId = docId;
28719
+ docInfos[option.cardType].docId = docId;
28500
28720
  return false;
28501
28721
  }
28502
28722
  } else {
@@ -28505,7 +28725,7 @@ class OCRModule {
28505
28725
  }
28506
28726
  }),
28507
28727
  ocrCancel: (type, cardType, imageData) => __awaiter(this, void 0, void 0, function* () {
28508
- const docId = docInfos[cardType].docId;
28728
+ const docId = docInfos[cardType] ? docInfos[cardType].docId : '';
28509
28729
  if (docId) {
28510
28730
  let ocrOriginImg;
28511
28731
  if (imageData) {
@@ -28525,7 +28745,8 @@ class OCRModule {
28525
28745
  frameIndex = 0;
28526
28746
  return true;
28527
28747
  } else {
28528
- console.error('didnt find docid , retry');
28748
+ yield this.ocrService.stop();
28749
+ console.warn('didnt find docid , retry');
28529
28750
  return false;
28530
28751
  }
28531
28752
  }),
@@ -28560,10 +28781,6 @@ class OCRModule {
28560
28781
  fraudResult: null
28561
28782
  };
28562
28783
  }
28563
- const lottieSuccessSetting = {
28564
- animationContainer: successAnimationContainer
28565
- };
28566
- initSuccessAnimation(lottieSuccessSetting);
28567
28784
  // TODO 等開始處理防偽的時候再處理
28568
28785
  // if (resp.scanView && resp.scanView.enable) {
28569
28786
  // setBorderType({
@@ -29107,8 +29324,8 @@ class AuthmeIdentityVerification extends AuthmeFunctionModule {
29107
29324
  }
29108
29325
 
29109
29326
  var name = "authme/sdk";
29110
- var version$1 = "2.7.2";
29111
- var date = "2024-10-22T03:50:14+0000";
29327
+ var version$1 = "2.7.4-patch.1";
29328
+ var date = "2025-08-28T04:22:37+0000";
29112
29329
  var packageInfo = {
29113
29330
  name: name,
29114
29331
  version: version$1,