@authme/identity-verification 2.7.2 → 2.7.3

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.cjs CHANGED
@@ -127,7 +127,8 @@ const defaultIdRecognitionConfig = {
127
127
  disablePassportConfirm: false,
128
128
  antiFraudIMetalTagValidCountTh: false,
129
129
  cardTypes: [],
130
- cardTypeConfigs: []
130
+ cardTypeConfigs: [],
131
+ captureTimeout: -1
131
132
  };
132
133
 
133
134
  function setCorrectViewHeight() {
@@ -23717,8 +23718,8 @@ var RESIZE_EVENT;
23717
23718
  RESIZE_EVENT["PASS"] = "PASS";
23718
23719
  })(RESIZE_EVENT || (RESIZE_EVENT = {}));
23719
23720
  function detectScreenResize$() {
23720
- const initWidth = window.outerWidth;
23721
- const initHeight = window.outerHeight;
23721
+ const initWidth = window.innerWidth;
23722
+ const initHeight = window.innerHeight;
23722
23723
  let resize$;
23723
23724
  if (util.isMobile()) {
23724
23725
  if (!window.visualViewport) {
@@ -23742,7 +23743,7 @@ function detectScreenResize$() {
23742
23743
  if (window.innerWidth < RESIZE_STYLE.RESIZE_WIDTH_LIMIT || window.innerHeight < RESIZE_STYLE.RESIZE_HEIGHT_LIMIT) {
23743
23744
  return RESIZE_EVENT.SCREEN_RESOLUTION_TOO_LOW;
23744
23745
  }
23745
- if (window.outerWidth !== initWidth || window.outerHeight !== initHeight) {
23746
+ if (window.innerWidth !== initWidth || window.innerHeight !== initHeight) {
23746
23747
  return RESIZE_EVENT.SCREEN_SIZE_CHANGED;
23747
23748
  }
23748
23749
  return RESIZE_EVENT.PASS;
@@ -24011,10 +24012,10 @@ function startLiveness(config) {
24011
24012
  result
24012
24013
  }) => applyTextByResult(result)), rxjs.filter(({
24013
24014
  result
24014
- }) => result.eStatus === liveness.FasRecognitionResult.Pass && result.eStage === liveness.EAuthMeFASServiceStage.Done || result.eStatus === liveness.FasRecognitionResult.Failed), rxjs.map(data => {
24015
+ }) => result.eStatus === liveness.FasRecognitionResult.Pass && result.eStage === liveness.EAuthMeFASServiceStage.Passive || result.eStatus === liveness.FasRecognitionResult.Failed), rxjs.map(data => {
24015
24016
  var _a, _b;
24016
24017
  return Object.assign(Object.assign({}, data), {
24017
- isSuccess: ((_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a.eStatus) === liveness.FasRecognitionResult.Pass && ((_b = data === null || data === void 0 ? void 0 : data.result) === null || _b === void 0 ? void 0 : _b.eStage) === liveness.EAuthMeFASServiceStage.Done
24018
+ isSuccess: ((_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a.eStatus) === liveness.FasRecognitionResult.Pass && ((_b = data === null || data === void 0 ? void 0 : data.result) === null || _b === void 0 ? void 0 : _b.eStage) === liveness.EAuthMeFASServiceStage.Passive
24018
24019
  });
24019
24020
  }), rxjs.take(1),
24020
24021
  /**
@@ -24249,21 +24250,6 @@ const initScanAnimation = params => {
24249
24250
  });
24250
24251
  lottie__default["default"].stop('scan');
24251
24252
  };
24252
- const initSuccessAnimation = params => {
24253
- lottie__default["default"].destroy('success');
24254
- lottie__default["default"].loadAnimation({
24255
- container: params.animationContainer,
24256
- renderer: 'svg',
24257
- loop: false,
24258
- autoplay: true,
24259
- name: 'success',
24260
- animationData: success({
24261
- color: '#7CFFF9',
24262
- opacity: 1
24263
- })
24264
- });
24265
- lottie__default["default"].stop('success');
24266
- };
24267
24253
  const renderCameraSwitch = config => {
24268
24254
  const cameraSwitchContainer = document.createElement('div');
24269
24255
  const cameraSwitch = document.createElement('div');
@@ -24313,21 +24299,29 @@ const renderOCRUI = config => {
24313
24299
  // Animation
24314
24300
  const scanAnimationContainer = document.createElement('div');
24315
24301
  scanAnimationContainer.classList.add('scan');
24316
- const successAnimationContainer = document.createElement('div');
24317
- successAnimationContainer.classList.add('success_container');
24318
- const successAnimationDom = document.createElement('div');
24319
- successAnimationDom.classList.add('success');
24302
+ // 完成流程元件
24303
+ const successContainer = document.createElement('div');
24304
+ successContainer.classList.add('success_container');
24305
+ const successBlockDom = document.createElement('div');
24306
+ successBlockDom.classList.add('block');
24307
+ const successDom = document.createElement('div');
24308
+ successDom.classList.add('img');
24309
+ const successText = document.createElement('div');
24310
+ successText.textContent = translateService.translate('sdk.general.done');
24311
+ successBlockDom.appendChild(successDom);
24312
+ successBlockDom.appendChild(successText);
24313
+ successContainer.appendChild(successBlockDom);
24320
24314
  const arrowAnimationContainer = document.createElement('div');
24321
24315
  arrowAnimationContainer.classList.add('arrow_container');
24322
- successAnimationContainer.appendChild(successAnimationDom);
24323
24316
  config.videoContainer.appendChild(titleTextPanel);
24324
24317
  if (config.showStatement) {
24325
24318
  config.videoContainer.appendChild(statementContainer);
24326
24319
  }
24327
24320
  config.videoContainer.appendChild(statusTextPanel);
24328
24321
  config.videoContainer.appendChild(scanAnimationContainer);
24329
- config.videoContainer.appendChild(successAnimationContainer);
24322
+ config.videoContainer.appendChild(successContainer);
24330
24323
  config.videoContainer.appendChild(arrowAnimationContainer);
24324
+ successContainer.classList.add('hide');
24331
24325
  // Anti-fraud Instruction
24332
24326
  const lottieMask = document.createElement('div');
24333
24327
  lottieMask.classList.add('lottie-mask');
@@ -24389,8 +24383,8 @@ const renderOCRUI = config => {
24389
24383
  statusTextPanel,
24390
24384
  lottieMask,
24391
24385
  arrowAnimationContainer,
24392
- successAnimationContainer,
24393
- successAnimationDom,
24386
+ successContainer,
24387
+ successBlockDom,
24394
24388
  scanAnimationContainer,
24395
24389
  antiFraudInstructionAnimationContainer,
24396
24390
  confirmImageContainer,
@@ -25305,7 +25299,8 @@ function renderCardRotateAnimate(container) {
25305
25299
  const captureButton = () => {
25306
25300
  let dom = document.querySelector('#btn_capture');
25307
25301
  if (dom) {
25308
- return dom;
25302
+ // return dom;
25303
+ dom.remove();
25309
25304
  }
25310
25305
  const videoContainer = document.querySelector('.video-container');
25311
25306
  if (!videoContainer) {
@@ -25334,24 +25329,26 @@ const modal = arg => {
25334
25329
  const domModal = document.createElement('div');
25335
25330
  const domHeaderContainer = document.createElement('div');
25336
25331
  const domHeader = document.createElement('div');
25337
- const domContainer = document.createElement('div');
25332
+ const domBodyContainer = document.createElement('div');
25333
+ const domBody = document.createElement('div');
25338
25334
  const domTitle = document.createElement('div');
25339
25335
  const domSubtitle = document.createElement('div');
25340
25336
  const domImage = document.createElement('img');
25341
25337
  const domContent = document.createElement('div');
25342
- const domFooter = document.createElement('div');
25338
+ const domFooterContainer = document.createElement('div');
25343
25339
  const domClose = document.createElement('div');
25344
25340
  const domConfirm = document.createElement('div');
25345
25341
  const domCopyRight = document.createElement('div');
25346
25342
  domModal.classList.add('video-container__modal');
25347
25343
  domHeaderContainer.classList.add('video-container__modal-header-container');
25348
25344
  domHeader.classList.add('video-container__modal-header');
25349
- domContainer.classList.add('video-container__modal-container');
25345
+ domBodyContainer.classList.add('video-container__modal-body-container');
25346
+ domBody.classList.add('video-container__modal-body');
25350
25347
  domTitle.classList.add('video-container__modal-title');
25351
25348
  domSubtitle.classList.add('video-container__modal-subtitle');
25352
25349
  domImage.classList.add('video-container__modal-image');
25353
25350
  domContent.classList.add('video-container__modal-content');
25354
- domFooter.classList.add('video-container__modal-footer');
25351
+ domFooterContainer.classList.add('video-container__modal-footer-container');
25355
25352
  domClose.classList.add('video-container__modal-close');
25356
25353
  domConfirm.classList.add('video-container__modal-confirm');
25357
25354
  domCopyRight.classList.add('video-container__modal-copy-right');
@@ -25377,16 +25374,17 @@ const modal = arg => {
25377
25374
  domHeaderContainer.appendChild(domHeader);
25378
25375
  domHeaderContainer.appendChild(domClose);
25379
25376
  domModal.appendChild(domHeaderContainer);
25380
- domContainer.appendChild(domTitle);
25381
- domContainer.appendChild(domSubtitle);
25382
- domContainer.appendChild(domImage);
25383
- domContainer.appendChild(domContent);
25384
- domModal.appendChild(domContainer);
25385
- domFooter.appendChild(domConfirm);
25386
- domModal.appendChild(domFooter);
25377
+ domBodyContainer.appendChild(domBody);
25378
+ domBody.appendChild(domTitle);
25379
+ domBody.appendChild(domSubtitle);
25380
+ domBody.appendChild(domImage);
25381
+ domBody.appendChild(domContent);
25382
+ domModal.appendChild(domBodyContainer);
25383
+ domFooterContainer.appendChild(domConfirm);
25384
+ domModal.appendChild(domFooterContainer);
25387
25385
  if (arg.copyRight) {
25388
25386
  domCopyRight.innerText = arg.copyRight;
25389
- domFooter.appendChild(domCopyRight);
25387
+ domFooterContainer.appendChild(domCopyRight);
25390
25388
  }
25391
25389
  authmeContainer.appendChild(domModal);
25392
25390
  };
@@ -25414,9 +25412,11 @@ const resetFrame = () => {
25414
25412
  };
25415
25413
  const countdownTimer = (time, doSomething) => {
25416
25414
  let end = false;
25415
+ let timer;
25416
+ let endTime;
25417
25417
  const init = () => {
25418
- const endTime = new Date().getTime() + time * 1000;
25419
- const timer = setInterval(function () {
25418
+ endTime = new Date().getTime() + time * 1000;
25419
+ timer = setInterval(function () {
25420
25420
  const currentTime = new Date().getTime();
25421
25421
  const remainingTime = endTime - currentTime;
25422
25422
  if (remainingTime <= 0) {
@@ -25428,10 +25428,21 @@ const countdownTimer = (time, doSomething) => {
25428
25428
  }
25429
25429
  }, 300);
25430
25430
  };
25431
+ const clear = () => {
25432
+ clearInterval(timer);
25433
+ end = true;
25434
+ return (endTime - new Date().getTime()) / 1000;
25435
+ };
25436
+ const pause = () => {
25437
+ clearInterval(timer);
25438
+ return (endTime - new Date().getTime()) / 1000;
25439
+ };
25431
25440
  const getStatus = () => {
25432
25441
  return end;
25433
25442
  };
25434
25443
  return {
25444
+ pause: pause,
25445
+ clear: clear,
25435
25446
  init: init,
25436
25447
  end: getStatus
25437
25448
  };
@@ -25508,11 +25519,6 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25508
25519
  sendStatusDescription$1(core.StatusDescription.WrongCardType);
25509
25520
  setCardBorderColor('error');
25510
25521
  break;
25511
- case idRecognition.EAuthMeIDCardAntiFraudStatus.CardThicknessFailed:
25512
- statusText.textContent = translateService.translate('sdk.general.verify.error.CardThicknessFailed');
25513
- sendStatusDescription$1(core.StatusDescription.CardThicknessFailed);
25514
- setCardBorderColor('error');
25515
- break;
25516
25522
  case idRecognition.EAuthMeIDCardAntiFraudStatus.Reflective:
25517
25523
  statusText.textContent = translateService.translate('sdk.general.verify.error.reflective');
25518
25524
  sendStatusDescription$1(core.StatusDescription.Reflective);
@@ -25553,22 +25559,11 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25553
25559
  statusText.textContent = translateService.translate('sdk.general.verify.error.cardCutByCamera');
25554
25560
  break;
25555
25561
  case idRecognition.EAuthMeIDCardAntiFraudStatus.CardNotInROI:
25556
- statusText.textContent = translateService.translate('verify.error.CardNotInROI');
25562
+ statusText.textContent = translateService.translate('sdk.general.verify.error.missmatch');
25557
25563
  break;
25558
25564
  case idRecognition.EAuthMeIDCardAntiFraudStatus.CardTooSmall:
25559
25565
  statusText.textContent = translateService.translate('sdk.general.verify.error.getCloser');
25560
25566
  break;
25561
- case idRecognition.EAuthMeIDCardAntiFraudStatus.NeedHoldCard:
25562
- statusText.textContent = translateService.translate('sdk.general.verify.error.needHoldCard');
25563
- break;
25564
- case idRecognition.EAuthMeIDCardAntiFraudStatus.StagePass:
25565
- statusText.textContent = translateService.translate('sdk.general.verify.error.stagePass');
25566
- setCardBorderColor('pass');
25567
- break;
25568
- case idRecognition.EAuthMeIDCardAntiFraudStatus.Pass:
25569
- setCardBorderColor('pass');
25570
- statusText.textContent = translateService.translate('sdk.general.verify.error.pass');
25571
- break;
25572
25567
  case idRecognition.EAuthMeIDCardAntiFraudStatus.Failed:
25573
25568
  setCardBorderColor('error');
25574
25569
  statusText.textContent = translateService.translate('sdk.general.verify.error.pass');
@@ -25611,7 +25606,8 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25611
25606
  onConfirm: () => {
25612
25607
  observer.next(canvasSizeInfo);
25613
25608
  observer.complete();
25614
- }
25609
+ },
25610
+ copyRight: translateService.translate('sdk.general.footer')
25615
25611
  });
25616
25612
  });
25617
25613
  } else {
@@ -25651,6 +25647,8 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25651
25647
  result
25652
25648
  }) => {
25653
25649
  if (thicknessTimer.end()) {
25650
+ util.hideElement(confirmImageContainer);
25651
+ showVideoElement(true);
25654
25652
  util.startSpinner(translateService.translate('sdk.general.uploading'), true);
25655
25653
  videoToCanvas(canvasSizeInfo, result.imageData);
25656
25654
  return config.confirmThickness ? config.confirmThickness(generateImage(), cardType) : rxjs.of(false);
@@ -25686,6 +25684,8 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25686
25684
  // 當 end() 函數返回 false 時繼續
25687
25685
  operators.finalize(() => __awaiter(void 0, void 0, void 0, function* () {
25688
25686
  if (thicknessTimer.end()) {
25687
+ util.hideElement(confirmImageContainer);
25688
+ showVideoElement(true);
25689
25689
  util.startSpinner(translateService.translate('sdk.general.uploading'), true);
25690
25690
  const sizeInfo = yield util.getCanvasSize(video);
25691
25691
  videoToCanvas(sizeInfo);
@@ -25707,8 +25707,8 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25707
25707
  util.hideElement(confirmImageContainer);
25708
25708
  util.stopSpinner();
25709
25709
  showVideoElement(true);
25710
+ checkTimeout.unsubscribe(); // 取消 interval$ 的訂閱
25710
25711
  if (!confirmResp) {
25711
- checkTimeout.unsubscribe(); // 取消 interval$ 的訂閱
25712
25712
  util.hideElement(captureBtn);
25713
25713
  observer.next(canvasSizeInfo);
25714
25714
  }
@@ -25734,6 +25734,63 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
25734
25734
  }
25735
25735
  };
25736
25736
 
25737
+ const toast = arg => {
25738
+ var _a;
25739
+ let timer = null;
25740
+ let clearStatus = false;
25741
+ const message = typeof arg === 'string' ? arg : arg.message;
25742
+ const duration = arg.duration || 4000;
25743
+ const transition = (_a = arg.transition) !== null && _a !== void 0 ? _a : true;
25744
+ const toast = document.createElement('div');
25745
+ toast.style.cssText = `
25746
+ position: fixed;
25747
+ bottom: 50px;
25748
+ left: 50%;
25749
+ box-sizing: border-box;
25750
+ transform: translateX(-50%);
25751
+ width: 90%;
25752
+ padding: 10px 16px;
25753
+ background-color: rgba(0, 0, 0, .6);
25754
+ color: #fff;
25755
+ border-radius: 8px;
25756
+ z-index: 999999;
25757
+ display: flex;
25758
+ align-items: center;
25759
+ column-gap: 16px;
25760
+ opacity: 0;
25761
+ word-break: break-all;
25762
+ `;
25763
+ toast.classList.add('authme-toast');
25764
+ const clear = () => {
25765
+ if (!clearStatus) {
25766
+ clearStatus = true;
25767
+ document.body.removeChild(toast);
25768
+ clearTimeout(timer);
25769
+ }
25770
+ };
25771
+ if (transition) {
25772
+ toast.style.transition = 'opacity .3s ease-in';
25773
+ setTimeout(() => {
25774
+ toast.style.opacity = '1';
25775
+ }, 300);
25776
+ } else {
25777
+ toast.style.opacity = '1';
25778
+ }
25779
+ toast.innerHTML = message;
25780
+ document.body.appendChild(toast);
25781
+ timer = setTimeout(() => {
25782
+ clearStatus = true;
25783
+ toast.style.opacity = '0';
25784
+ toast.style.transition = 'opacity .3s ease-out';
25785
+ setTimeout(() => {
25786
+ document.body.removeChild(toast);
25787
+ }, 500);
25788
+ }, duration);
25789
+ return {
25790
+ clear
25791
+ };
25792
+ };
25793
+
25737
25794
  const initEvenTrackingStatus = ocrConfig => {
25738
25795
  setFeature$1(ocrConfig.needAntiFraud ? core.Feature.OCRFraud : core.Feature.OCR);
25739
25796
  };
@@ -25757,7 +25814,8 @@ function startOCR(config) {
25757
25814
  enableManualUpload: false,
25758
25815
  fraudRetryTimes: 1,
25759
25816
  fraudTimeout: 52,
25760
- fraudMaxFps: 2
25817
+ fraudMaxFps: 2,
25818
+ captureTimeout: config.ocrConfig.captureTimeout
25761
25819
  };
25762
25820
  let cardSizeInfo = {
25763
25821
  width: 0,
@@ -25798,7 +25856,7 @@ function startOCR(config) {
25798
25856
  lottieMask,
25799
25857
  arrowAnimationContainer,
25800
25858
  scanAnimationContainer,
25801
- successAnimationDom,
25859
+ successContainer,
25802
25860
  antiFraudInstructionAnimationContainer,
25803
25861
  confirmImageContainer,
25804
25862
  imageTypeText,
@@ -25833,6 +25891,9 @@ function startOCR(config) {
25833
25891
  stopAnimate
25834
25892
  } = renderCardRotateAnimate(arrowAnimationContainer);
25835
25893
  setCorrectViewHeight();
25894
+ let countdownCaptureTimer;
25895
+ let toastManualCapture = null;
25896
+ let captureTimeoutTimer;
25836
25897
  const canvasSizeInfo$ = rxjs.merge(rxjs.defer(() => util.requestCamera({
25837
25898
  video,
25838
25899
  facingMode: 'back',
@@ -25868,7 +25929,7 @@ function startOCR(config) {
25868
25929
  });
25869
25930
  }), expiredIn * util.TIME_UNIT.SECOND);
25870
25931
  }
25871
- function startAntiFraud(type) {
25932
+ function startAntiFraud(type, cardType) {
25872
25933
  const animateInterval = 2 * util.TIME_UNIT.SECOND;
25873
25934
  const nextAnimateInterval = 6 * util.TIME_UNIT.SECOND;
25874
25935
  let needDeformationCount = 0;
@@ -25954,7 +26015,7 @@ function startOCR(config) {
25954
26015
  statusText.textContent = translateService.translate('sdk.general.verify.error.cardCutByCamera');
25955
26016
  break;
25956
26017
  case idRecognition.EAuthMeIDCardAntiFraudStatus.CardNotInROI:
25957
- statusText.textContent = translateService.translate('verify.error.CardNotInROI');
26018
+ statusText.textContent = translateService.translate('sdk.general.verify.error.missmatch');
25958
26019
  break;
25959
26020
  case idRecognition.EAuthMeIDCardAntiFraudStatus.CardTooSmall:
25960
26021
  statusText.textContent = translateService.translate('sdk.general.verify.error.getCloser');
@@ -25995,7 +26056,7 @@ function startOCR(config) {
25995
26056
  statusText.classList.remove('non-empty');
25996
26057
  }
25997
26058
  };
25998
- const antiFraudStart$ = rxjs.of(true).pipe(rxjs.switchMap(() => util.checkOnlineStatus(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'))), rxjs.switchMap(() => canvasSizeInfo$), rxjs.switchMap(canvasSizeInfo => rxjs.from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(rxjs.switchMap(() => config.antiFraudStart(getCardBorderPoint(), setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successAnimationDom, frameImage, frameText, facingMode)), rxjs.tap(() => __awaiter(this, void 0, void 0, function* () {
26059
+ const antiFraudStart$ = rxjs.of(true).pipe(rxjs.switchMap(() => util.checkOnlineStatus(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'))), rxjs.switchMap(() => canvasSizeInfo$), rxjs.switchMap(canvasSizeInfo => rxjs.from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(rxjs.switchMap(() => config.antiFraudStart(getCardBorderPoint(), setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successContainer, frameImage, frameText, facingMode)), rxjs.tap(() => __awaiter(this, void 0, void 0, function* () {
25999
26060
  setStatusView(core.StatusView.Aligning);
26000
26061
  if (buttonDisable$) {
26001
26062
  const cardMatchROI = config.getCardMatchROI ? yield config.getCardMatchROI() : undefined;
@@ -26036,9 +26097,10 @@ function startOCR(config) {
26036
26097
  statusText.classList.remove('non-empty');
26037
26098
  setCardBorderColor('pass');
26038
26099
  util.hideElement(arrowAnimationContainer);
26039
- lottie__default["default"].play('success');
26100
+ successContainer.classList.remove('hide');
26040
26101
  }), rxjs.switchMap(() => util.waitTime(2000)), rxjs.tap(() => {
26041
- lottie__default["default"].stop('success');
26102
+ setHeaderByType(cardType);
26103
+ successContainer.classList.add('hide');
26042
26104
  }));
26043
26105
  antiFraudStart$.pipe(
26044
26106
  //workaround?: 因目前Frontal timeout會直接Failed,所以不能用$handleError來作為停止條件。
@@ -26056,6 +26118,7 @@ function startOCR(config) {
26056
26118
  if (!config.ocrConfig.needOCR && type === idRecognition.EAuthMeCardClass.TWN_IDCard_Front) {
26057
26119
  return rxjs.of(true);
26058
26120
  }
26121
+ let captureBtn;
26059
26122
  // if (config.ocrConfig.needAntiFraud) {
26060
26123
  const point = getCardBorderPoint();
26061
26124
  setCardPoints(point.map(([x, y]) => ({
@@ -26115,7 +26178,7 @@ function startOCR(config) {
26115
26178
  showCameraSwitchButton(deviceMetas);
26116
26179
  }
26117
26180
  };
26118
- const init = retry => canvasSizeInfo$.pipe(rxjs.take(1), rxjs.switchMap(canvasSizeInfo => rxjs.from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(rxjs.switchMap(() => util.checkOnlineStatus(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'))), rxjs.switchMap(() => config.ocrStart(getCardBorderPoint(), type, setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successAnimationDom, frameImage, frameText, facingMode, cardType, retry)), rxjs.tap(() => {
26181
+ const init = retry => canvasSizeInfo$.pipe(rxjs.take(1), rxjs.switchMap(canvasSizeInfo => rxjs.from(config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight)).pipe(rxjs.switchMap(() => util.checkOnlineStatus(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'))), rxjs.switchMap(() => config.ocrStart(getCardBorderPoint(), type, setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successContainer, frameImage, frameText, facingMode, cardType, retry)), rxjs.tap(() => {
26119
26182
  tiltFrame(false);
26120
26183
  util.stopSpinner();
26121
26184
  util.showElement(scanAnimationContainer);
@@ -26124,41 +26187,163 @@ function startOCR(config) {
26124
26187
  lottie__default["default"].play('scan');
26125
26188
  util.showElement(scanAnimationContainer);
26126
26189
  }), rxjs.map(() => canvasSizeInfo))));
26127
- setCardBorderColor(null);
26128
- const recognition = retry => init(retry).pipe(rxjs.tap(() => {
26129
- setStatusView(core.StatusView.Running);
26130
- if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
26131
- sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
26190
+ const videoToCanvas = (sizeInfo, data) => {
26191
+ const ctx2 = image.getContext('2d');
26192
+ image.width = sizeInfo.canvasWidth;
26193
+ image.height = sizeInfo.canvasHeight;
26194
+ if (data) {
26195
+ const imgData = ctx2.createImageData(image.width, image.height);
26196
+ imgData.data.set(data);
26197
+ ctx2.putImageData(imgData, 0, 0);
26198
+ } else {
26199
+ ctx2.drawImage(video, sizeInfo.startX, sizeInfo.startY, sizeInfo.width, sizeInfo.height, 0, 0, sizeInfo.canvasWidth, sizeInfo.canvasHeight);
26132
26200
  }
26133
- }), rxjs.switchMap(canvasSizeInfo => rxjs.of(canvasSizeInfo).pipe(sendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, 'jpg', cardType, undefined, type), rxjs.tap(x => applyTextByResult(x.result)), rxjs.filter(({
26134
- result
26135
- }) => result.eStatus === idRecognition.EAuthMeCardOCRStatus.Pass || result.eStatus === idRecognition.EAuthMeMRZServiceStatus.Success),
26136
- // ocrEngineConfig.expiredIn
26137
- // ? timeout(ocrEngineConfig.expiredIn * TIME_UNIT.SECOND)
26138
- // : tap(),
26139
- // catchError((err) => {
26140
- // if (err.name === 'TimeoutError') {
26141
- // throw new AuthmeError(ErrorCode.ID_RECOGNITION_TIMEOUT, err);
26142
- // }
26143
- // throw err;
26144
- // }),
26145
- rxjs.take(1), rxjs.tap(() => {
26146
- setCardBorderColor('pass');
26147
- statusText.textContent = translateService.translate('sdk.general.verify.success');
26148
- lottie__default["default"].stop('scan');
26149
- util.hideElement(scanAnimationContainer);
26150
- }), rxjs.switchMap(resp => rxjs.of(true).pipe(rxjs.tap(() => {
26151
- util.hideElement(scanAnimationContainer);
26152
- }), rxjs.map(() => resp))), rxjs.switchMap(({
26153
- result
26154
- }) => rxjs.from(type === idRecognition.EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? rxjs.of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(rxjs.switchMap(needRetry => {
26155
- util.startSpinner(translateService.translate('sdk.general.uploading'));
26156
- return needRetry ? rxjs.of(true) : rxjs.from(config.confirmImage(type, cardType)).pipe(rxjs.tap(() => sendStatusAction$1(core.StatusAction.Uploading)), rxjs.map(confirmResp => !confirmResp));
26157
- }), rxjs.tap(() => {
26158
- util.hideElement(confirmImageContainer);
26159
- util.stopSpinner();
26160
- showVideoElement();
26161
- }), rxjs.switchMap(needRetry => needRetry ? recognition(true) : rxjs.of(true)))))));
26201
+ };
26202
+ const checkConfirmImageManual = (sizeInfo, data) => __awaiter(this, void 0, void 0, function* () {
26203
+ videoToCanvas(sizeInfo, data);
26204
+ showVideoElement(false);
26205
+ util.showElement(confirmImageContainer);
26206
+ const retryEvents = rxjs.fromEvent(retryBtn, 'click').pipe(rxjs.mapTo(true));
26207
+ const confirmEvents = rxjs.fromEvent(completeBtn, 'click').pipe(rxjs.mapTo(false));
26208
+ const allEvents$ = rxjs.merge(retryEvents, confirmEvents);
26209
+ return yield rxjs.firstValueFrom(allEvents$.pipe());
26210
+ });
26211
+ const manualCapture = show => {
26212
+ captureBtn = captureButton();
26213
+ if (captureBtn && show) {
26214
+ util.showElement(captureBtn);
26215
+ toastManualCapture = toast({
26216
+ 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'),
26217
+ transition: !show
26218
+ });
26219
+ }
26220
+ return rxjs.fromEvent(captureBtn, 'click').pipe(rxjs.switchMap(() => util.getCanvasSize(video)), rxjs.switchMap(canvasSizeInfo => {
26221
+ ocrSendFrameAnimation = true;
26222
+ lottie__default["default"].stop('scan');
26223
+ util.hideElement(scanAnimationContainer);
26224
+ if (toastManualCapture) {
26225
+ toastManualCapture.clear();
26226
+ }
26227
+ return rxjs.from(type === idRecognition.EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? rxjs.of(false) : checkConfirmImageManual(canvasSizeInfo)).pipe(rxjs.switchMap(needRetry => {
26228
+ util.startSpinner(translateService.translate('sdk.general.uploading'));
26229
+ if (needRetry) {
26230
+ util.hideElement(confirmImageContainer);
26231
+ util.stopSpinner();
26232
+ showVideoElement();
26233
+ lottie__default["default"].play('scan');
26234
+ util.showElement(scanAnimationContainer);
26235
+ }
26236
+ return needRetry ? rxjs.of(true) : rxjs.from(config.confirmImage({
26237
+ type,
26238
+ cardType,
26239
+ imageData: util.dataURItoBlob(image.toDataURL('image/jpeg', 0.85)),
26240
+ manual: true
26241
+ })).pipe(rxjs.tap(() => sendStatusAction$1(core.StatusAction.Uploading)), rxjs.map(confirmResp => !confirmResp));
26242
+ }), rxjs.switchMap(needRetry => {
26243
+ if (needRetry) {
26244
+ ocrSendFrameAnimation = false;
26245
+ return recognition(true).pipe(rxjs.map(() => true));
26246
+ } else {
26247
+ util.hideElement(captureBtn);
26248
+ util.hideElement(confirmImageContainer);
26249
+ util.stopSpinner();
26250
+ showVideoElement();
26251
+ lottie__default["default"].play('scan');
26252
+ util.showElement(scanAnimationContainer);
26253
+ return rxjs.of(true);
26254
+ }
26255
+ }), rxjs.map(confirmResp => confirmResp));
26256
+ }));
26257
+ };
26258
+ setCardBorderColor(null);
26259
+ let ocrSendFrameAnimation = false;
26260
+ const handleOcrSendFrame = (canvasSizeInfo, canvas, video, frameCallback, fps, bas64Format, imageType, cardType, type) => source$ => {
26261
+ let received = true;
26262
+ const ctx = canvas.getContext('2d');
26263
+ return source$.pipe(rxjs.mergeMap(() => rxjs.animationFrames().pipe(limitFPS(fps), rxjs.filter(() => received && !ocrSendFrameAnimation), rxjs.tap(() => received = false), rxjs.tap(() => util.clearCanvas(canvas)), rxjs.map(() => util.getImageData(canvas, ctx, video, canvasSizeInfo, bas64Format, imageType)), rxjs.mergeMap(imageData => rxjs.from(frameCallback(imageData.data, imageData.base64, cardType, type)).pipe(rxjs.catchError(e => {
26264
+ // send to fast, ignore
26265
+ if (e instanceof core.AuthmeError && e.code === core.ErrorCode.RECOGNITION_NOT_AVAILABLE) {
26266
+ return rxjs.EMPTY;
26267
+ }
26268
+ throw e;
26269
+ }), rxjs.filter(x => !!x), rxjs.map(result => ({
26270
+ imageData,
26271
+ result
26272
+ })), rxjs.tap(() => received = true))))));
26273
+ };
26274
+ const autoCapture = canvasSizeInfo => {
26275
+ return rxjs.of(canvasSizeInfo).pipe(handleOcrSendFrame(canvasSizeInfo, image, video, config.recognition, 30, false, 'jpg', cardType, type), rxjs.tap(x => applyTextByResult(x.result)), rxjs.filter(({
26276
+ result
26277
+ }) => result.eStatus === idRecognition.EAuthMeCardOCRStatus.Pass || result.eStatus === idRecognition.EAuthMeMRZServiceStatus.Success), rxjs.take(1), rxjs.tap(() => {
26278
+ if (countdownCaptureTimer && countdownCaptureTimer.end && !countdownCaptureTimer.end()) {
26279
+ const remainingCountTime = Math.floor(countdownCaptureTimer.pause());
26280
+ captureTimeoutTimer = remainingCountTime;
26281
+ }
26282
+ setCardBorderColor('pass');
26283
+ statusText.textContent = translateService.translate('sdk.general.verify.success');
26284
+ lottie__default["default"].stop('scan');
26285
+ if (toastManualCapture) {
26286
+ toastManualCapture.clear();
26287
+ }
26288
+ util.hideElement(scanAnimationContainer);
26289
+ }), rxjs.switchMap(resp => rxjs.of(true).pipe(rxjs.tap(() => {
26290
+ util.hideElement(scanAnimationContainer);
26291
+ }), rxjs.map(() => resp))), rxjs.switchMap(({
26292
+ result
26293
+ }) => rxjs.from(type === idRecognition.EAuthMeCardClass.Passport && config.ocrConfig.disablePassportConfirm ? rxjs.of(false) : checkConfirmImage(result.imageData, result.iWidth, result.iHeight)).pipe(rxjs.switchMap(needRetry => {
26294
+ if (countdownCaptureTimer && countdownCaptureTimer.end) {
26295
+ if (needRetry && !countdownCaptureTimer.end()) {
26296
+ countdownCaptureTimer = countdownTimer(captureTimeoutTimer, () => {
26297
+ util.showElement(captureBtn);
26298
+ toastManualCapture = toast({
26299
+ 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'),
26300
+ transition: true
26301
+ });
26302
+ });
26303
+ countdownCaptureTimer.init();
26304
+ }
26305
+ if (!needRetry) {
26306
+ countdownCaptureTimer.clear();
26307
+ util.hideElement(captureBtn);
26308
+ }
26309
+ }
26310
+ util.startSpinner(translateService.translate('sdk.general.uploading'));
26311
+ return needRetry ? rxjs.of(true) : rxjs.from(config.confirmImage({
26312
+ type,
26313
+ cardType
26314
+ })).pipe(rxjs.tap(() => sendStatusAction$1(core.StatusAction.Uploading)), rxjs.map(confirmResp => !confirmResp));
26315
+ }), rxjs.tap(() => {
26316
+ util.hideElement(confirmImageContainer);
26317
+ util.stopSpinner();
26318
+ showVideoElement();
26319
+ }), rxjs.switchMap(needRetry => needRetry ? recognition(true) : rxjs.of(true)))));
26320
+ };
26321
+ const recognition = retry => {
26322
+ return init(retry).pipe(rxjs.tap(() => {
26323
+ setStatusView(core.StatusView.Running);
26324
+ if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
26325
+ sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
26326
+ }
26327
+ }), rxjs.switchMap(canvasSizeInfo => {
26328
+ if (type !== idRecognition.EAuthMeCardClass.Passport && !retry) {
26329
+ if (ocrEngineConfig.captureTimeout > 0) {
26330
+ countdownCaptureTimer = countdownTimer(ocrEngineConfig.captureTimeout, () => {
26331
+ util.showElement(captureBtn);
26332
+ toastManualCapture = toast({
26333
+ 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'),
26334
+ transition: true
26335
+ });
26336
+ });
26337
+ countdownCaptureTimer.init();
26338
+ return rxjs.race(manualCapture(false), autoCapture(canvasSizeInfo));
26339
+ }
26340
+ if (ocrEngineConfig.captureTimeout === 0) {
26341
+ return rxjs.race(manualCapture(true), autoCapture(canvasSizeInfo));
26342
+ }
26343
+ }
26344
+ return autoCapture(canvasSizeInfo);
26345
+ }));
26346
+ };
26162
26347
  return recognition(false);
26163
26348
  }
26164
26349
  function createFlowByType(type, cardType, cardTypeConfig) {
@@ -26171,7 +26356,7 @@ function startOCR(config) {
26171
26356
  setUIByType(type, cardType);
26172
26357
  }), rxjs.switchMap(() => {
26173
26358
  if (type === idRecognition.EAuthMeCardClass.TWN_IDCard_Front && config.ocrConfig.needAntiFraud) {
26174
- return rxjs.from(startAntiFraud(type)).pipe(rxjs.switchMap(() => {
26359
+ return rxjs.from(startAntiFraud(type, cardType)).pipe(rxjs.switchMap(() => {
26175
26360
  hideFrameUI(false);
26176
26361
  return startOCR(type, cardType);
26177
26362
  }));
@@ -26183,7 +26368,7 @@ function startOCR(config) {
26183
26368
  thicknessStart: config.thicknessStart,
26184
26369
  onThicknessFrame: config.onThicknessFrame,
26185
26370
  confirmThickness: config.confirmThickness
26186
- }, cardRotateByStage, getCardBorderPoint, setBorderType, setBorderSuccess, scanAnimationContainer, successAnimationDom, frameImage, frameText, facingMode, ocrEngineConfig, sdkFlowTimeout, makeSDKFlowTimeout, image, video, retryBtn, completeBtn, confirmImageContainer);
26371
+ }, cardRotateByStage, getCardBorderPoint, setBorderType, setBorderSuccess, scanAnimationContainer, successContainer, frameImage, frameText, facingMode, ocrEngineConfig, sdkFlowTimeout, makeSDKFlowTimeout, image, video, retryBtn, completeBtn, confirmImageContainer);
26187
26372
  } else if (cardType.toLocaleLowerCase().includes('front')) {
26188
26373
  hideFrameUI(false);
26189
26374
  return startOCR(type, cardType);
@@ -26284,6 +26469,10 @@ function startOCR(config) {
26284
26469
  }), rxjs.takeUntil(unsubscribe$), rxjs.finalize(() => {
26285
26470
  document.body.removeChild(container);
26286
26471
  sendStatusAction$1(core.StatusAction.BtnClose);
26472
+ countdownCaptureTimer && countdownCaptureTimer.clear && countdownCaptureTimer.clear();
26473
+ if (toastManualCapture) {
26474
+ toastManualCapture.clear();
26475
+ }
26287
26476
  }));
26288
26477
  const detectScreenResizeError$ = handleScreenResizeError$(detectScreenResize$(), unsubscribe$, () => !flags.onConfirm);
26289
26478
  return rxjs.merge(flow$, cancel$, detectScreenResizeError$, timeout$).pipe(rxjs.take(1));
@@ -26302,7 +26491,7 @@ function startOCR(config) {
26302
26491
  util.showElement(lottieMask);
26303
26492
  setHeaderText(translateService.translate('verify.idCard'), translateService.translate('sdk.verify.header.stepper', {
26304
26493
  current: 1,
26305
- total: 3
26494
+ total: stepTotal()
26306
26495
  }));
26307
26496
  lottie__default["default"].loadAnimation({
26308
26497
  container: antiFraudInstructionAnimationContainer,
@@ -26404,7 +26593,7 @@ function startOCR(config) {
26404
26593
  }
26405
26594
  function setUIByType(type, cardType) {
26406
26595
  setTextByType(type, cardType);
26407
- setHeaderByType(type);
26596
+ setHeaderByType(cardType);
26408
26597
  setCardSize(type);
26409
26598
  }
26410
26599
  function setTextByType(type, cardType) {
@@ -26452,46 +26641,25 @@ function startOCR(config) {
26452
26641
  }
26453
26642
  imageTypeText.textContent = translateService.translate(titleConfirmKey !== null && titleConfirmKey !== void 0 ? titleConfirmKey : 'verify.confirm.unexpected');
26454
26643
  }
26455
- function setHeaderByType(type) {
26456
- const typeMap = {
26457
- EAuthMeCardClass_Passport: 'sdk.verify.passport.header',
26458
- EAuthMeCardClass_TWN_IDCard_Front: 'sdk.verify.idCard.header',
26459
- EAuthMeCardClass_TWN_IDCard_Back: 'sdk.verify.idCard.header',
26460
- EAuthMeCardClass_TWN_DriverLicense_Front: 'sdk.verify.driverLicense.header',
26461
- EAuthMeCardClass_TWN_DriverLicense_Back: 'sdk.verify.driverLicense.header',
26462
- EAuthMeCardClass_TWN_HealthCard_Front: 'sdk.verify.healthCard.header',
26463
- EAuthMeCardClass_JPN_IDCard_Front: 'sdk.verify.myNumberCard.header',
26464
- EAuthMeCardClass_JPN_IDCard_Back: 'sdk.verify.myNumberCard.header',
26465
- EAuthMeCardClass_JPN_IDCard_Thickness: 'sdk.verify.myNumberCard.header',
26466
- EAuthMeCardClass_TWN_ResidentCard_Front: 'sdk.verify.residentCard.header',
26467
- EAuthMeCardClass_TWN_ResidentCard_Back: 'sdk.verify.residentCard.header'
26468
- };
26469
- if (type.includes('Health') || type.includes('Passport')) {
26470
- setHeaderText(translateService.translate(typeMap[type]), translateService.translate('sdk.verify.header.stepper', {
26471
- current: 1,
26472
- total: 1
26473
- }));
26474
- } else {
26475
- if (type.includes('Front')) {
26476
- const stepNow = type.includes('TWN_IDCard') ? translateService.translate('sdk.verify.header.stepper', {
26477
- current: 2,
26478
- total: 3
26479
- }) : translateService.translate('sdk.verify.header.stepper', {
26480
- current: 1,
26481
- total: 2
26482
- });
26483
- setHeaderText(translateService.translate(typeMap[type]), stepNow);
26484
- } else {
26485
- const stepNow = type.includes('TWN_IDCard') ? translateService.translate('sdk.verify.header.stepper', {
26486
- current: 3,
26487
- total: 3
26488
- }) : translateService.translate('sdk.verify.header.stepper', {
26489
- current: 2,
26490
- total: 2
26491
- });
26492
- setHeaderText(translateService.translate(typeMap[type]), stepNow);
26493
- }
26644
+ const stepTotal = () => {
26645
+ let total = config.cardTypes.length;
26646
+ if (config.ocrConfig.needAntiFraud) {
26647
+ total = total + 1;
26494
26648
  }
26649
+ return total;
26650
+ };
26651
+ const setpCurrent = type => {
26652
+ let current = config.cardTypes.indexOf(type) + 1;
26653
+ if (isTutorialFinish) {
26654
+ current++;
26655
+ }
26656
+ return current;
26657
+ };
26658
+ function setHeaderByType(cardType) {
26659
+ setHeaderText(translateService.translate(idRecognition.cardTypeHeader(cardType)), translateService.translate('sdk.verify.header.stepper', {
26660
+ current: setpCurrent(cardType),
26661
+ total: stepTotal()
26662
+ }));
26495
26663
  }
26496
26664
  function setCardSize(type) {
26497
26665
  var _a, _b;
@@ -26500,17 +26668,22 @@ function startOCR(config) {
26500
26668
  CARD_SIZE[CARD_SIZE["MAX_WIDTH_RATE"] = 0.95] = "MAX_WIDTH_RATE";
26501
26669
  CARD_SIZE[CARD_SIZE["MAX_HEIGHT_RATE"] = 0.6] = "MAX_HEIGHT_RATE";
26502
26670
  CARD_SIZE[CARD_SIZE["MAX_HEIGHT_RATE_IPHONE14PRO"] = 0.235] = "MAX_HEIGHT_RATE_IPHONE14PRO";
26671
+ CARD_SIZE[CARD_SIZE["POSSPORT_MAX_WIDTH_RATE"] = 0.9] = "POSSPORT_MAX_WIDTH_RATE";
26503
26672
  CARD_SIZE[CARD_SIZE["DRIVER_LICENSE_RATIO"] = 1.4166666666666667] = "DRIVER_LICENSE_RATIO";
26504
26673
  CARD_SIZE[CARD_SIZE["ID_CARD_RATIO"] = 1.5740740740740742] = "ID_CARD_RATIO";
26505
26674
  CARD_SIZE[CARD_SIZE["PASSPORT_RATIO"] = 1.4597701149425288] = "PASSPORT_RATIO";
26506
26675
  })(CARD_SIZE || (CARD_SIZE = {}));
26507
26676
  let heightRate = CARD_SIZE.MAX_HEIGHT_RATE;
26677
+ let widthRate = CARD_SIZE.MAX_WIDTH_RATE;
26508
26678
  if (util.isIphone14proOrProMax() && config.ocrConfig.hotfixIphone14proCameraBlur) {
26509
26679
  heightRate = CARD_SIZE.MAX_HEIGHT_RATE_IPHONE14PRO;
26510
26680
  }
26681
+ if (type === idRecognition.EAuthMeCardClass.Passport) {
26682
+ widthRate = CARD_SIZE.POSSPORT_MAX_WIDTH_RATE;
26683
+ }
26511
26684
  const windowWidth = window.innerWidth;
26512
26685
  const windowHeight = window.innerHeight;
26513
- const maxWidth = windowWidth * CARD_SIZE.MAX_WIDTH_RATE;
26686
+ const maxWidth = windowWidth * widthRate;
26514
26687
  const maxHeight = windowHeight * heightRate;
26515
26688
  let ratio = CARD_SIZE.ID_CARD_RATIO;
26516
26689
  if (type === idRecognition.EAuthMeCardClass.TWN_DriverLicense_Back || type === idRecognition.EAuthMeCardClass.TWN_DriverLicense_Front) {
@@ -26565,8 +26738,15 @@ function startOCR(config) {
26565
26738
  } = renderCameraSwitch({
26566
26739
  container: videoContainer
26567
26740
  });
26741
+ let hint = true;
26568
26742
  cameraHint.innerHTML = translateService.translate('sdk.general.verify.error.switchCamera');
26569
26743
  cameraSwitchContainer.addEventListener('click', () => __awaiter(this, void 0, void 0, function* () {
26744
+ if (hint) {
26745
+ setTimeout(() => {
26746
+ cameraHint.outerHTML = '';
26747
+ hint = false;
26748
+ }, 300);
26749
+ }
26570
26750
  const _nextCameraNumber = parseInt(switchText.textContent) + 1;
26571
26751
  const nextCameraNumber = _nextCameraNumber > backCameraList.length ? 1 : _nextCameraNumber;
26572
26752
  switchText.textContent = (nextCameraNumber > backCameraList.length ? 1 : nextCameraNumber) + '';
@@ -27408,7 +27588,6 @@ class LivenessModule {
27408
27588
  function initFrameView(cardPoints, scanId, faceMode, scanView, cardType, cardTypeConfig, setBorderType, setCardBorderColor, setBorderSuccess) {
27409
27589
  return __awaiter(this, void 0, void 0, function* () {
27410
27590
  const scanAnimationContainer = document.querySelector('.scan');
27411
- const successAnimationDom = document.querySelector('.success');
27412
27591
  document.querySelector('#authme_frame_border');
27413
27592
  const videoContainer = document.querySelector('.video-container');
27414
27593
  const windowWidth = videoContainer.offsetWidth;
@@ -27416,9 +27595,6 @@ function initFrameView(cardPoints, scanId, faceMode, scanView, cardType, cardTyp
27416
27595
  const lottieScanSetting = {
27417
27596
  scanAnimationContainer: scanAnimationContainer
27418
27597
  };
27419
- const lottieSuccessSetting = {
27420
- animationContainer: successAnimationDom
27421
- };
27422
27598
  function frameImage(faceMode, zIndex, base64, color, opacity) {
27423
27599
  color = color !== null && color !== void 0 ? color : OcrFrame.imageColor;
27424
27600
  opacity = opacity !== null && opacity !== void 0 ? opacity : OcrFrame.imageOpacity;
@@ -27495,7 +27671,6 @@ function initFrameView(cardPoints, scanId, faceMode, scanView, cardType, cardTyp
27495
27671
  `);
27496
27672
  dom.textContent = text;
27497
27673
  }
27498
- initSuccessAnimation(lottieSuccessSetting);
27499
27674
  const scanViewSetting = {
27500
27675
  document_type: '',
27501
27676
  border: {
@@ -27701,6 +27876,29 @@ class MRZModule {
27701
27876
  // 2. 由於 engine-lib 限制,getFinalResult 必須要在 stop 之後呼叫。
27702
27877
  const finalResult = yield this.mrzService.getFinalResult();
27703
27878
  latestTField = JSON.parse(yield this.mrzService.toJson(finalResult));
27879
+ if (latestTField['birthDateCheckDigit']) {
27880
+ delete latestTField['birthDateCheckDigit'];
27881
+ }
27882
+ if (latestTField['documentNumberCheckDigit']) {
27883
+ delete latestTField['documentNumberCheckDigit'];
27884
+ }
27885
+ if (latestTField['expiryDateCheckDigit']) {
27886
+ delete latestTField['expiryDateCheckDigit'];
27887
+ }
27888
+ if (latestTField['optionaldataCheckDigit']) {
27889
+ delete latestTField['optionaldataCheckDigit'];
27890
+ }
27891
+ if (latestTField['overallCheckDigit']) {
27892
+ delete latestTField['overallCheckDigit'];
27893
+ }
27894
+ switch (latestTField.gender) {
27895
+ case 'M':
27896
+ latestTField.gender = 'male';
27897
+ break;
27898
+ case 'F':
27899
+ latestTField.gender = 'female';
27900
+ break;
27901
+ }
27704
27902
  } else if (uploadFullFrame) {
27705
27903
  const image = util.UintArrayToBlob(frameWidth, frameHeight, data, virtualCanvas);
27706
27904
  const requestImg = yield encryptImageBase64(image);
@@ -27716,14 +27914,14 @@ class MRZModule {
27716
27914
  });
27717
27915
  }
27718
27916
  }),
27719
- confirmImage: type => __awaiter(this, void 0, void 0, function* () {
27720
- const docId = docInfos[type].docId;
27917
+ confirmImage: option => __awaiter(this, void 0, void 0, function* () {
27918
+ const docId = docInfos[option.type].docId;
27721
27919
  if (docId) {
27722
- docInfos[type].docId = '';
27723
- const requestImg = yield encryptImageBase64(docInfos[type].ocrOriginImg);
27920
+ docInfos[option.type].docId = '';
27921
+ const requestImg = yield encryptImageBase64(docInfos[option.type].ocrOriginImg);
27724
27922
  const report = yield this.mrzService.getReport();
27725
27923
  yield SendRequestWithRetry$1(() => idRecognition.uploadFrameBase64(docId, requestImg, frameIndex++, idRecognition.ResourceImageType.Recognition, report));
27726
- yield SendRequestWithRetry$1(() => idRecognition.finishScanDocument(docId, latestTField !== null && latestTField !== void 0 ? latestTField : {}, docInfos[type].fraudResult));
27924
+ yield SendRequestWithRetry$1(() => idRecognition.finishScanDocument(docId, latestTField !== null && latestTField !== void 0 ? latestTField : {}, docInfos[option.type].fraudResult));
27727
27925
  return true;
27728
27926
  } else {
27729
27927
  return false;
@@ -28048,7 +28246,8 @@ class OCRModule {
28048
28246
  }
28049
28247
  yield util.waitTime(100);
28050
28248
  return Object.assign(Object.assign({}, resp.parameters), {
28051
- expiredIn: resp.expiredIn
28249
+ expiredIn: resp.expiredIn,
28250
+ captureTimeout: config.captureTimeout
28052
28251
  });
28053
28252
  }),
28054
28253
  ocrStart: (points, type, setBorderType, setCardBorderColor, setBorderSuccess, scanAnimationContainer, successAnimationContainer, frameImage, frameText, faceMode, cardType, retry = false) => __awaiter(this, void 0, void 0, function* () {
@@ -28095,10 +28294,6 @@ class OCRModule {
28095
28294
  const lottieScanSetting = {
28096
28295
  scanAnimationContainer: scanAnimationContainer
28097
28296
  };
28098
- const lottieSuccessSetting = {
28099
- animationContainer: successAnimationContainer
28100
- };
28101
- initSuccessAnimation(lottieSuccessSetting);
28102
28297
  const scanViewSetting = {
28103
28298
  document_type: '',
28104
28299
  border: {
@@ -28174,8 +28369,9 @@ class OCRModule {
28174
28369
  newParams['timeoutSec'] = 1000;
28175
28370
  newParams['fCardMatchTh'] = 0.5;
28176
28371
  newParams['fImageReflectiveTriggerTh'] = 0.15;
28177
- newParams['fImageThicknessTh'] = 0.3;
28178
- newParams['fCardDeformationTh'] = 12;
28372
+ newParams['fImageThicknessTh'] = 0.4;
28373
+ newParams['fCardDeformationTh'] = 10;
28374
+ newParams['enableCardInROI'] = 1;
28179
28375
  yield _service.setParams(Object.assign(Object.assign({}, oldParams), newParams));
28180
28376
  _service.setOption({
28181
28377
  key: 'thickness_detector',
@@ -28216,10 +28412,6 @@ class OCRModule {
28216
28412
  const lottieScanSetting = {
28217
28413
  scanAnimationContainer: scanAnimationContainer
28218
28414
  };
28219
- const lottieSuccessSetting = {
28220
- animationContainer: successAnimationContainer
28221
- };
28222
- initSuccessAnimation(lottieSuccessSetting);
28223
28415
  const scanViewSetting = {
28224
28416
  document_type: '',
28225
28417
  border: {
@@ -28445,7 +28637,7 @@ class OCRModule {
28445
28637
  status: 'confirm',
28446
28638
  type: type
28447
28639
  });
28448
- } else if (uploadFullFrame) {
28640
+ } else if (uploadFullFrame && docInfos[eClass].docId !== '') {
28449
28641
  const image = ocrOriginImg;
28450
28642
  const requestImg = yield encryptImageBase64(image);
28451
28643
  // downloadImage(image, `${frameIndex}-${docInfos[type as EAuthMeCardClass].docId}-${new Date().getTime().toString()}.jpg`)
@@ -28460,7 +28652,7 @@ class OCRModule {
28460
28652
  durationTimeRecognition.end();
28461
28653
  return result;
28462
28654
  }),
28463
- confirmImage: (type, cardType, imageData) => __awaiter(this, void 0, void 0, function* () {
28655
+ confirmImage: option => __awaiter(this, void 0, void 0, function* () {
28464
28656
  // 將二進位圖片進行加密,目前不需要使用,不確定未來是否需要,先註解
28465
28657
  // const encryptImage = async (blob: Blob): Promise<Blob> => {
28466
28658
  // const imageArrayBuffer = await blobToArrayBuffer(blob);
@@ -28471,18 +28663,23 @@ class OCRModule {
28471
28663
  // );
28472
28664
  // return base64ToBlob(resultEncrypt);
28473
28665
  // };
28474
- const docId = docInfos[cardType].docId;
28666
+ if (option.manual) {
28667
+ this.ocrService.stop();
28668
+ }
28669
+ const docId = docInfos[option.cardType].docId;
28475
28670
  if (docId) {
28476
- const needFraudOption = config.needAntiFraud && type === engine.EAuthMeCardClass.TWN_IDCard_Front;
28671
+ const needFraudOption = config.needAntiFraud && option.type === engine.EAuthMeCardClass.TWN_IDCard_Front;
28477
28672
  let ocrOriginImg;
28478
- if (imageData) {
28479
- ocrOriginImg = imageData;
28673
+ if (option.imageData) {
28674
+ ocrOriginImg = option.imageData;
28480
28675
  } else {
28481
- ocrOriginImg = docInfos[cardType].ocrOriginImg;
28676
+ ocrOriginImg = docInfos[option.cardType].ocrOriginImg;
28482
28677
  }
28678
+ // const base64Image = await blobToBase64(ocrOriginImg);
28679
+ // console.log('confirmImage', base64Image);
28483
28680
  const requestImg = yield encryptImageBase64(ocrOriginImg);
28484
28681
  const report = yield this.ocrService.getReport();
28485
- docInfos[cardType].docId = '';
28682
+ docInfos[option.cardType].docId = '';
28486
28683
  modifyDeubgLog(getDebugLogsLength() - 1, {
28487
28684
  report: report
28488
28685
  });
@@ -28490,7 +28687,7 @@ class OCRModule {
28490
28687
  yield SendRequestWithRetry(() => idRecognition.uploadFrameBase64(docId, requestImg, frameIndex, idRecognition.ResourceImageType.Recognition, report));
28491
28688
  frameIndex = 0;
28492
28689
  try {
28493
- const ocrImg = docInfos[cardType].ocrImg;
28690
+ const ocrImg = option.imageData ? option.imageData : docInfos[option.cardType].ocrImg;
28494
28691
  const _requestImg = yield encryptImageBase64(ocrImg);
28495
28692
  const resp = yield SendRequestWithRetry(() => idRecognition.recognitionEncrypt(docId, _requestImg, report, idRecognition.RecognitionFileType.FlatImage));
28496
28693
  if (resp.retry) {
@@ -28499,12 +28696,12 @@ class OCRModule {
28499
28696
  }
28500
28697
  result = unionMerge(result, resp && resp.details || {});
28501
28698
  yield SendRequestWithRetry(() => idRecognition.finishScanDocument(docId, resp.details, needFraudOption ? this.fraudResult : null));
28502
- delete docInfos[cardType];
28699
+ delete docInfos[option.cardType];
28503
28700
  return true;
28504
28701
  } catch (error) {
28505
28702
  console.log('confirmImage fail,retrying ');
28506
28703
  console.error(error);
28507
- docInfos[cardType].docId = docId;
28704
+ docInfos[option.cardType].docId = docId;
28508
28705
  return false;
28509
28706
  }
28510
28707
  } else {
@@ -28513,7 +28710,7 @@ class OCRModule {
28513
28710
  }
28514
28711
  }),
28515
28712
  ocrCancel: (type, cardType, imageData) => __awaiter(this, void 0, void 0, function* () {
28516
- const docId = docInfos[cardType].docId;
28713
+ const docId = docInfos[cardType] ? docInfos[cardType].docId : '';
28517
28714
  if (docId) {
28518
28715
  let ocrOriginImg;
28519
28716
  if (imageData) {
@@ -28533,7 +28730,8 @@ class OCRModule {
28533
28730
  frameIndex = 0;
28534
28731
  return true;
28535
28732
  } else {
28536
- console.error('didnt find docid , retry');
28733
+ yield this.ocrService.stop();
28734
+ console.warn('didnt find docid , retry');
28537
28735
  return false;
28538
28736
  }
28539
28737
  }),
@@ -28568,10 +28766,6 @@ class OCRModule {
28568
28766
  fraudResult: null
28569
28767
  };
28570
28768
  }
28571
- const lottieSuccessSetting = {
28572
- animationContainer: successAnimationContainer
28573
- };
28574
- initSuccessAnimation(lottieSuccessSetting);
28575
28769
  // TODO 等開始處理防偽的時候再處理
28576
28770
  // if (resp.scanView && resp.scanView.enable) {
28577
28771
  // setBorderType({
@@ -29115,8 +29309,8 @@ class AuthmeIdentityVerification extends engine.AuthmeFunctionModule {
29115
29309
  }
29116
29310
 
29117
29311
  var name = "authme/sdk";
29118
- var version$1 = "2.7.2";
29119
- var date = "2024-10-22T03:50:14+0000";
29312
+ var version$1 = "2.7.3";
29313
+ var date = "2024-10-25T01:07:20+0000";
29120
29314
  var packageInfo = {
29121
29315
  name: name,
29122
29316
  version: version$1,