@authme/identity-verification 2.8.2 → 2.8.4

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
@@ -32,6 +32,8 @@ require('core-js/modules/es.typed-array.fill.js');
32
32
  require('core-js/modules/es.typed-array.set.js');
33
33
  require('core-js/modules/es.typed-array.sort.js');
34
34
  require('core-js/modules/es.typed-array.to-locale-string.js');
35
+ require('core-js/modules/es.string.pad-start.js');
36
+ require('core-js/modules/es.regexp.constructor.js');
35
37
  require('core-js/modules/es.typed-array.uint8-array.js');
36
38
 
37
39
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -104,7 +106,7 @@ const defaultLivenessConfig = {
104
106
  active: true,
105
107
  icon: DEFAULT_ICON_URI,
106
108
  // showIntroPage: false,
107
- headerMode: 1,
109
+ headerMode: 0,
108
110
  showCloseButton: true,
109
111
  subtitle: null,
110
112
  uploadFullFrame: false,
@@ -120,7 +122,7 @@ const defaultIdRecognitionConfig = {
120
122
  needOCR: true,
121
123
  displayResultPage: false,
122
124
  showStatement: true,
123
- headerMode: 1,
125
+ headerMode: 0,
124
126
  blockFraud: false,
125
127
  showCloseButton: true,
126
128
  disableTutorial: false,
@@ -27549,7 +27551,7 @@ const renderBasicUI = userConfig => {
27549
27551
  // header container
27550
27552
  const header = document.createElement('div');
27551
27553
  header.classList.add('authme-header');
27552
- if (userConfig.headerMode) {
27554
+ if (userConfig.headerMode === 0 || userConfig.headerMode) {
27553
27555
  header.classList.add(`headerMode${userConfig.headerMode}`);
27554
27556
  }
27555
27557
  // header Title
@@ -27923,7 +27925,9 @@ const limitFPS = fps => {
27923
27925
  };
27924
27926
  const sendFrame = (canvasSizeInfo, canvas, video, frameCallback, fps, bas64Format, imageType, cardType, flags, type) => source$ => {
27925
27927
  let received = true;
27926
- const ctx = canvas.getContext('2d');
27928
+ const ctx = canvas.getContext('2d', {
27929
+ willReadFrequently: true
27930
+ });
27927
27931
  return source$.pipe(rxjs.mergeMap(() => rxjs.animationFrames().pipe(limitFPS(fps), rxjs.filter(() => received && !(flags === null || flags === void 0 ? void 0 : flags.animating)), 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 => {
27928
27932
  // send to fast, ignore
27929
27933
  if (e instanceof core.AuthmeError && e.code === core.ErrorCode.RECOGNITION_NOT_AVAILABLE) {
@@ -28086,6 +28090,72 @@ const modal = arg => {
28086
28090
  authmeContainer.appendChild(domModal);
28087
28091
  };
28088
28092
 
28093
+ const popupView = arg => {
28094
+ const authmeContainer = document.querySelector('.authme-container');
28095
+ if (!authmeContainer) {
28096
+ console.error('modal: authmeContainer not found');
28097
+ return;
28098
+ }
28099
+ const uiThemeConfig = util.Storage.getItem('themeConfig');
28100
+ function removePopview() {
28101
+ var _a;
28102
+ (_a = document.querySelector('.video-container__popupview')) === null || _a === void 0 ? void 0 : _a.remove();
28103
+ }
28104
+ const domPopupView = document.createElement('div');
28105
+ const domPopupViewContainer = document.createElement('div');
28106
+ const domTitleContainer = document.createElement('div');
28107
+ const domTitle = document.createElement('div');
28108
+ const domContentContainer = document.createElement('div');
28109
+ const domContent = document.createElement('div');
28110
+ const domFooterContainer = document.createElement('div');
28111
+ const domConfirm = document.createElement('div');
28112
+ const domCancel = document.createElement('div');
28113
+ domPopupView.classList.add('video-container__popupview');
28114
+ domPopupViewContainer.classList.add('video-container__popupview-container');
28115
+ domTitleContainer.classList.add('video-container__popupview-title-container');
28116
+ domTitle.classList.add('video-container__popupview-title');
28117
+ domContentContainer.classList.add('video-container__popupview-content-container');
28118
+ domContent.classList.add('video-container__popupview-content');
28119
+ domFooterContainer.classList.add('video-container__popupview-footer-container');
28120
+ domConfirm.classList.add('video-container__popupview-confirm');
28121
+ domCancel.classList.add('video-container__popupview-cancel');
28122
+ domPopupViewContainer.style.backgroundColor = uiThemeConfig.popupView.backgroundColor;
28123
+ domPopupViewContainer.style.borderRadius = `${uiThemeConfig.popupView.cornerRadius}px`;
28124
+ util.uiThemeText(domTitle, uiThemeConfig.titleOne);
28125
+ util.uiThemeText(domContent, uiThemeConfig.bodyTwo);
28126
+ util.uiThemeSmallButton(domConfirm, uiThemeConfig.smallermMajorButton);
28127
+ if (arg.cancel) {
28128
+ util.uiThemeSmallButton(domCancel, uiThemeConfig.smallerMinorButton);
28129
+ domCancel.innerHTML = arg.cancel;
28130
+ domCancel.addEventListener('click', () => __awaiter(void 0, void 0, void 0, function* () {
28131
+ if (arg.onCancel) {
28132
+ arg.onCancel();
28133
+ }
28134
+ removePopview();
28135
+ }));
28136
+ }
28137
+ domConfirm.addEventListener('click', () => __awaiter(void 0, void 0, void 0, function* () {
28138
+ if (arg.onConfirm) {
28139
+ arg.onConfirm();
28140
+ }
28141
+ removePopview();
28142
+ }));
28143
+ domTitle.innerHTML = arg.title;
28144
+ domContent.innerHTML = arg.content;
28145
+ domConfirm.innerHTML = arg.confirm;
28146
+ domPopupViewContainer.appendChild(domTitleContainer);
28147
+ domTitleContainer.appendChild(domTitle);
28148
+ domPopupViewContainer.appendChild(domContentContainer);
28149
+ domContentContainer.appendChild(domContent);
28150
+ domPopupViewContainer.appendChild(domFooterContainer);
28151
+ if (arg.cancel) {
28152
+ domFooterContainer.appendChild(domCancel);
28153
+ }
28154
+ domFooterContainer.appendChild(domConfirm);
28155
+ domPopupView.appendChild(domPopupViewContainer);
28156
+ authmeContainer.appendChild(domPopupView);
28157
+ };
28158
+
28089
28159
  function startLiveness(config) {
28090
28160
  return __awaiter(this, void 0, void 0, function* () {
28091
28161
  const translateService = core.getTranslateInstance();
@@ -28147,18 +28217,43 @@ function startLiveness(config) {
28147
28217
  };
28148
28218
  const canvas = document.createElement('canvas');
28149
28219
  let uiThemeConfig = util.themeConfigDefault;
28150
- let sdkFlowTimeout;
28220
+ // let sdkFlowTimeout: NodeJS.Timeout;
28221
+ let sdkFlowTimeout = null;
28151
28222
  const timeout$ = new rxjs.Subject();
28223
+ // function makeSDKFlowTimeout(expiredIn: number) {
28224
+ // return setTimeout(async () => {
28225
+ // asyncShowErrorMessage(
28226
+ // translateService.translate('sdk.general.error.timeout.content'),
28227
+ // false
28228
+ // );
28229
+ // await waitTime(3 * TIME_UNIT.SECOND);
28230
+ // timeout$.next({
28231
+ // isSuccess: false as const,
28232
+ // code: `${ErrorCode.ID_RECOGNITION_TIMEOUT}`,
28233
+ // message: new AuthmeError(ErrorCode.ID_RECOGNITION_TIMEOUT).message,
28234
+ // });
28235
+ // }, expiredIn * TIME_UNIT.SECOND);
28236
+ // }
28152
28237
  function makeSDKFlowTimeout(expiredIn) {
28153
- return setTimeout(() => __awaiter(this, void 0, void 0, function* () {
28154
- util.asyncShowErrorMessage(translateService.translate('sdk.general.error.timeout.content'), false);
28155
- yield util.waitTime(3 * util.TIME_UNIT.SECOND);
28238
+ return rxjs.timer(expiredIn * util.TIME_UNIT.SECOND).pipe(rxjs.switchMap(() => new rxjs.Observable(observer => {
28239
+ config.onDestroy();
28240
+ popupView({
28241
+ title: translateService.translate('sdk.general.error.timeout.title'),
28242
+ content: translateService.translate('sdk.general.error.timeout.content'),
28243
+ confirm: translateService.translate('sdk.general.confirm'),
28244
+ onConfirm: () => {
28245
+ observer.next(true);
28246
+ observer.complete();
28247
+ }
28248
+ });
28249
+ }))).subscribe(() => {
28156
28250
  timeout$.next({
28157
28251
  isSuccess: false,
28158
28252
  code: `${core.ErrorCode.ID_RECOGNITION_TIMEOUT}`,
28159
- message: new core.AuthmeError(core.ErrorCode.ID_RECOGNITION_TIMEOUT).message
28253
+ message: new core.AuthmeError(core.ErrorCode.ID_RECOGNITION_TIMEOUT).message,
28254
+ data: {}
28160
28255
  });
28161
- }), expiredIn * util.TIME_UNIT.SECOND);
28256
+ });
28162
28257
  }
28163
28258
  function initOptions() {
28164
28259
  return __awaiter(this, void 0, void 0, function* () {
@@ -28291,7 +28386,7 @@ function startLiveness(config) {
28291
28386
  }
28292
28387
  };
28293
28388
  // Register Event
28294
- rxjs.fromEvent(window, 'offline').pipe(rxjs.switchMap(() => util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), true)), rxjs.takeUntil(unsubscribe$)).subscribe();
28389
+ rxjs.fromEvent(window, 'offline').pipe(rxjs.switchMap(() => util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), false)), rxjs.takeUntil(unsubscribe$)).subscribe();
28295
28390
  rxjs.fromEvent(window, 'resize').pipe(rxjs.throttleTime(100), rxjs.switchMap(() => util.getCanvasSize(uiComponentBasic.video)), rxjs.tap(canvasSizeInfo => {
28296
28391
  config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight);
28297
28392
  const maskHeight = window.outerHeight * 0.48;
@@ -28418,7 +28513,7 @@ function startLiveness(config) {
28418
28513
  isSuccess: true
28419
28514
  });
28420
28515
  }), rxjs.raceWith(timeout$) // 確保 timeout 之後一定會有失敗結果
28421
- )))), rxjs.switchMap(resp => window.navigator.onLine ? rxjs.of(resp) : rxjs.from(util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), true)).pipe(rxjs.map(() => resp))), rxjs.tap(res => {
28516
+ )))), rxjs.switchMap(resp => window.navigator.onLine ? rxjs.of(resp) : rxjs.from(util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), false)).pipe(rxjs.map(() => resp))), rxjs.tap(res => {
28422
28517
  // console.log('res', res);
28423
28518
  if (res.isSuccess) {
28424
28519
  sendStatusDescription$2(core.StatusDescription.UploadingStart);
@@ -28536,7 +28631,11 @@ function startLiveness(config) {
28536
28631
  } finally {
28537
28632
  uiComponentBasic.video.srcObject = null;
28538
28633
  }
28539
- if (sdkFlowTimeout) clearTimeout(sdkFlowTimeout);
28634
+ // if (sdkFlowTimeout) clearTimeout(sdkFlowTimeout);
28635
+ if (sdkFlowTimeout) {
28636
+ sdkFlowTimeout.unsubscribe();
28637
+ sdkFlowTimeout = null;
28638
+ }
28540
28639
  eventListenerService$2.stop();
28541
28640
  uiComponentBasic.container.remove();
28542
28641
  unsubscribe$.next();
@@ -28671,7 +28770,6 @@ const renderCameraSwitch = config => {
28671
28770
  };
28672
28771
  const renderOCRUI = config => {
28673
28772
  const uiThemeConfig = util.Storage.getItem('themeConfig');
28674
- console.log('uiThemeConfig', uiThemeConfig);
28675
28773
  const translateService = core.getTranslateInstance();
28676
28774
  const createTextPanel = () => {
28677
28775
  const ele = document.createElement('div');
@@ -29826,7 +29924,9 @@ const imageDataToBase64 = (data, width, height, mimeType = 'image/png') => {
29826
29924
  const canvas = document.createElement('canvas');
29827
29925
  canvas.width = width;
29828
29926
  canvas.height = height;
29829
- const ctx = canvas.getContext('2d');
29927
+ const ctx = canvas.getContext('2d', {
29928
+ willReadFrequently: true
29929
+ });
29830
29930
  // 2. 建立 ImageData,填充像素數據
29831
29931
  const imgData = ctx.createImageData(width, height);
29832
29932
  imgData.data.set(new Uint8ClampedArray(data)); // 確保格式正確
@@ -29838,7 +29938,9 @@ const videoToBase64 = (video, sizeInfo) => __awaiter(void 0, void 0, void 0, fun
29838
29938
  const canvas = document.createElement('canvas');
29839
29939
  canvas.width = sizeInfo.canvasWidth;
29840
29940
  canvas.height = sizeInfo.canvasHeight;
29841
- const ctx = canvas.getContext('2d');
29941
+ const ctx = canvas.getContext('2d', {
29942
+ willReadFrequently: true
29943
+ });
29842
29944
  if (!ctx) {
29843
29945
  throw new Error('Failed to get 2d context from canvas');
29844
29946
  }
@@ -29887,7 +29989,7 @@ const modifiedData2Result = modifiedResult => {
29887
29989
 
29888
29990
  const translateService = core.getTranslateInstance();
29889
29991
  // TODO 處理參數
29890
- 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) => {
29992
+ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCardPoints, setCardBorderColor, statusText, canvasSizeInfo$, showVideoElement, config, cardRotateByStage, getCardBorderPoint, setBorderType, setBorderSuccess, scanAnimationContainer, successAnimationContainer, frameImage, frameText, facingMode, ocrEngineConfig, sdkFlowTimeout = null, makeSDKFlowTimeout, image, video, retryBtn, completeBtn, confirmImageContainer, confrimContainer) => {
29891
29993
  const videoToCanvas = (sizeInfo, data) => {
29892
29994
  const ctx2 = image.getContext('2d');
29893
29995
  image.width = sizeInfo.canvasWidth;
@@ -29975,7 +30077,7 @@ const startThickness = (type, cardType, cardTypeConfig, setHintTextLocale, setCa
29975
30077
  break;
29976
30078
  case idRecognition.EAuthMeIDCardAntiFraudStatus.Error:
29977
30079
  statusText.textContent = translateService.translate('sdk.general.error.alert.serverError');
29978
- util.showErrorMessage(translateService.translate('sdk.general.error.alert.serverError'), true);
30080
+ util.showErrorMessage(translateService.translate('sdk.general.error.alert.serverError'), false);
29979
30081
  sendStatusDescription$1(core.StatusDescription.Error);
29980
30082
  break;
29981
30083
  case idRecognition.EAuthMeIDCardAntiFraudStatus.NeedDeformationFrontal:
@@ -30254,7 +30356,6 @@ const toast = arg => {
30254
30356
  };
30255
30357
 
30256
30358
  const confirmPopup = arg => {
30257
- console.log('confirmPopup', arg);
30258
30359
  const authmeContainer = document.querySelector('.authme-container');
30259
30360
  if (!authmeContainer) {
30260
30361
  console.error('confirmPopup: authmeContainer not found');
@@ -30446,6 +30547,343 @@ const fraudScanIntroPage = arg => {
30446
30547
  authmeContainer.appendChild(domModal);
30447
30548
  };
30448
30549
 
30550
+ const ocrResultModal = arg => {
30551
+ let modifiedDetails = {};
30552
+ const authmeContainer = document.querySelector('.authme-container');
30553
+ if (!authmeContainer) {
30554
+ console.error('modal: authmeContainer not found');
30555
+ return;
30556
+ }
30557
+ const translateService = core.getTranslateInstance();
30558
+ const uiThemeConfig = util.Storage.getItem('themeConfig');
30559
+ function removeOcrResultModal() {
30560
+ var _a;
30561
+ (_a = document.querySelector('.video-container__ocrResultModal')) === null || _a === void 0 ? void 0 : _a.remove();
30562
+ }
30563
+ function formatTime(seconds) {
30564
+ const m = Math.floor(seconds % 3600 / 60);
30565
+ const s = seconds % 60;
30566
+ return [m, s].map(unit => String(unit).padStart(2, '0')).join(':');
30567
+ }
30568
+ function groupInput({
30569
+ name,
30570
+ label,
30571
+ value
30572
+ }) {
30573
+ const domGroupItem = document.createElement('div');
30574
+ domGroupItem.classList.add('video-container__ocrResultModal-group-item');
30575
+ domGroupItem.id = name;
30576
+ const domLabel = document.createElement('label');
30577
+ const domInput = document.createElement('input');
30578
+ const domError = document.createElement('div');
30579
+ domLabel.classList.add('video-container__ocrResultModal-label');
30580
+ domInput.classList.add('video-container__ocrResultModal-input');
30581
+ domError.classList.add('video-container__ocrResultModal-error');
30582
+ domError.classList.add('hidden');
30583
+ domLabel.innerText = `${label}`;
30584
+ domInput.type = 'text';
30585
+ domInput.value = value;
30586
+ domError.innerText = `${label}格式不符`;
30587
+ domInput.addEventListener('input', () => {
30588
+ validateFields() ? btnConfirmStatus(false) : btnConfirmStatus(true);
30589
+ // btnConfirmStatus(Object.values(validateMap).some((i: any) => i.validate === false));
30590
+ });
30591
+
30592
+ domGroupItem.appendChild(domLabel);
30593
+ domGroupItem.appendChild(domInput);
30594
+ domGroupItem.appendChild(domError);
30595
+ return domGroupItem;
30596
+ }
30597
+ function groupDropMenu({
30598
+ name,
30599
+ label,
30600
+ value,
30601
+ selections
30602
+ }) {
30603
+ const domGroupItem = document.createElement('div');
30604
+ domGroupItem.classList.add('video-container__ocrResultModal-group-item');
30605
+ domGroupItem.id = name;
30606
+ const domLabel = document.createElement('label');
30607
+ domLabel.classList.add('video-container__ocrResultModal-label');
30608
+ domLabel.innerText = `${label}`;
30609
+ const domDropMenu = document.createElement('div');
30610
+ domDropMenu.classList.add('drop_menu_container');
30611
+ const domDropMenuTitle = document.createElement('div');
30612
+ domDropMenuTitle.classList.add('drop_menu_title');
30613
+ domDropMenuTitle.setAttribute('data-value', value);
30614
+ domDropMenuTitle.innerHTML = `<span class="ellipsis">${selections.find(i => i.value === value) ? selections.find(i => i.value === value).name : '請選擇'}</span>
30615
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 7L10.07 14L17 7" stroke="#343434" stroke-width="2" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
30616
+ const domError = document.createElement('div');
30617
+ domError.classList.add('video-container__ocrResultModal-error');
30618
+ domError.classList.add('hidden');
30619
+ domError.innerText = `${label}格式不符`;
30620
+ let domDropMenuCancel = null;
30621
+ if (window.innerWidth < 1440) {
30622
+ // mobile
30623
+ domDropMenuCancel = document.createElement('div');
30624
+ domDropMenuCancel.classList.add('drop_menu_cancel');
30625
+ domDropMenuCancel.innerText = arg.cancelText;
30626
+ }
30627
+ const domDropMenuulSection = document.createElement('section');
30628
+ domDropMenuulSection.classList.add('drop_menu_ul_section');
30629
+ const domDropMenuUlContainer = document.createElement('div');
30630
+ domDropMenuUlContainer.classList.add('drop_menu_ul_container');
30631
+ const domDropMenuUl = document.createElement('ul');
30632
+ domDropMenuulSection.classList.add('hide');
30633
+ selections.forEach(selection => {
30634
+ const domDropMenuLi = document.createElement('li');
30635
+ domDropMenuLi.classList.add('drop_menu_item');
30636
+ if (selection.value === value) {
30637
+ domDropMenuLi.classList.add('active');
30638
+ }
30639
+ domDropMenuLi.setAttribute('data-value', selection.value);
30640
+ domDropMenuLi.innerHTML = `<span>${selection.name}</span>`;
30641
+ domDropMenuUl.appendChild(domDropMenuLi);
30642
+ });
30643
+ domDropMenu.appendChild(domDropMenuTitle);
30644
+ domDropMenuUlContainer.appendChild(domDropMenuUl);
30645
+ if (domDropMenuCancel) {
30646
+ domDropMenuUlContainer.appendChild(domDropMenuCancel);
30647
+ }
30648
+ domDropMenuulSection.appendChild(domDropMenuUlContainer);
30649
+ domDropMenu.appendChild(domDropMenuulSection);
30650
+ util.dropMenu(domDropMenu, dom => {
30651
+ domDropMenuTitle.setAttribute('data-value', dom.getAttribute('data-value'));
30652
+ validateFields() ? btnConfirmStatus(false) : btnConfirmStatus(true);
30653
+ });
30654
+ domGroupItem.appendChild(domLabel);
30655
+ domGroupItem.appendChild(domDropMenu);
30656
+ domGroupItem.appendChild(domError);
30657
+ return domGroupItem;
30658
+ }
30659
+ function formatDate(dateString, format) {
30660
+ // 解析日期字串為 Date 物件
30661
+ const date = new Date(dateString);
30662
+ const year = date.getFullYear(); // 取得年份
30663
+ const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 取得月份並補齊兩位
30664
+ const day = date.getDate().toString().padStart(2, '0'); // 取得日期並補齊兩位
30665
+ // 根據傳入的 format 來替換字串
30666
+ return format.replace('YYYY', year.toString()) // 替換 "YYYY" 為年份
30667
+ .replace('yyyy', year.toString()) // 替換 "yyyy" 為年份
30668
+ .replace('MM', month) // 替換 "MM" 為月份
30669
+ .replace('dd', day) // 替換 "dd" 為日期
30670
+ .replace('yyyy', year.toString()); // 處理 "yyyy" 格式
30671
+ }
30672
+
30673
+ function isValidDateFormat(dateStr) {
30674
+ const regex = /^\d{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])$/;
30675
+ return regex.test(dateStr);
30676
+ }
30677
+ function checkModifiedData() {
30678
+ const items = domModal.querySelectorAll('.video-container__ocrResultModal-group-item');
30679
+ items.forEach(item => {
30680
+ const input = item.querySelector('input');
30681
+ if (input) {
30682
+ const key = item.id;
30683
+ const value = input.value;
30684
+ let valueOrigin = arg.items.find(i => i.name === key).value;
30685
+ const dateFormat = arg.items.find(i => i.name === key).dateFormat;
30686
+ if (dateFormat) {
30687
+ valueOrigin = formatDate(valueOrigin, dateFormat);
30688
+ }
30689
+ modifiedDetails[key] = {
30690
+ isModified: value !== valueOrigin ? true : false,
30691
+ value
30692
+ };
30693
+ } else if (item.querySelector('.drop_menu_title')) {
30694
+ // drop menu
30695
+ const key = item.id;
30696
+ const value = item.querySelector('.drop_menu_title').getAttribute('data-value');
30697
+ const valueOrigin = arg.items.find(i => i.name === key).value;
30698
+ modifiedDetails[key] = {
30699
+ isModified: value !== valueOrigin ? true : false,
30700
+ value
30701
+ };
30702
+ }
30703
+ });
30704
+ }
30705
+ function btnConfirmStatus(flag) {
30706
+ domConfirm.disabled = flag;
30707
+ util.uiThemeButton(domConfirm, uiThemeConfig.majorButton, flag);
30708
+ }
30709
+ function validateFields() {
30710
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
30711
+ for (const key in validateMap) {
30712
+ const item = validateMap[key];
30713
+ const domItem = domModal.querySelector(`#${key}`);
30714
+ if (domItem) {
30715
+ const input = domItem.querySelector('input');
30716
+ if (input && item.regex) {
30717
+ if (item.regex.test(input.value)) {
30718
+ item.validate = true;
30719
+ (_a = domItem.querySelector('.video-container__ocrResultModal-input')) === null || _a === void 0 ? void 0 : _a.classList.remove('error');
30720
+ (_b = domItem.querySelector('.video-container__ocrResultModal-error')) === null || _b === void 0 ? void 0 : _b.classList.add('hidden');
30721
+ } else {
30722
+ item.validate = false;
30723
+ (_c = domItem.querySelector('.video-container__ocrResultModal-input')) === null || _c === void 0 ? void 0 : _c.classList.add('error');
30724
+ (_d = domItem.querySelector('.video-container__ocrResultModal-error')) === null || _d === void 0 ? void 0 : _d.classList.remove('hidden');
30725
+ }
30726
+ } else if (item.regex) {
30727
+ // drop menu
30728
+ const domDropMenu = domItem.querySelector('.drop_menu_title');
30729
+ if (domDropMenu) {
30730
+ if (domDropMenu.getAttribute('data-value') !== '') {
30731
+ item.validate = true;
30732
+ domDropMenu.classList.remove('error');
30733
+ (_e = domItem.querySelector('.video-container__ocrResultModal-error')) === null || _e === void 0 ? void 0 : _e.classList.add('hidden');
30734
+ } else {
30735
+ item.validate = false;
30736
+ domDropMenu.classList.add('error');
30737
+ (_f = domItem.querySelector('.video-container__ocrResultModal-error')) === null || _f === void 0 ? void 0 : _f.classList.remove('hidden');
30738
+ }
30739
+ }
30740
+ } else if (input && item.dateFormat) {
30741
+ if (isValidDateFormat(input.value)) {
30742
+ // if (item.dateFormat.test(input.value)) {
30743
+ item.validate = true;
30744
+ (_g = domItem.querySelector('.video-container__ocrResultModal-input')) === null || _g === void 0 ? void 0 : _g.classList.remove('error');
30745
+ (_h = domItem.querySelector('.video-container__ocrResultModal-error')) === null || _h === void 0 ? void 0 : _h.classList.add('hidden');
30746
+ } else {
30747
+ item.validate = false;
30748
+ (_j = domItem.querySelector('.video-container__ocrResultModal-input')) === null || _j === void 0 ? void 0 : _j.classList.add('error');
30749
+ (_k = domItem.querySelector('.video-container__ocrResultModal-error')) === null || _k === void 0 ? void 0 : _k.classList.remove('hidden');
30750
+ }
30751
+ }
30752
+ }
30753
+ }
30754
+ const isPass = Object.values(validateMap).every(item => item.validate === true);
30755
+ return isPass;
30756
+ }
30757
+ modifiedDetails = arg.items.reduce((acc, item) => {
30758
+ acc[item.name] = {
30759
+ isModified: false,
30760
+ value: item.value
30761
+ };
30762
+ return acc;
30763
+ }, {});
30764
+ let timer = Math.floor((arg.countDownTime - new Date().getTime()) / 1000);
30765
+ const validateMap = {};
30766
+ const domModal = document.createElement('div');
30767
+ const domHeaderContainer = document.createElement('div');
30768
+ const domBodyContainer = document.createElement('div');
30769
+ const domBody = document.createElement('div');
30770
+ const domTitle = document.createElement('div');
30771
+ const domSubtitle = document.createElement('div');
30772
+ const domFooterContainer = document.createElement('div');
30773
+ const domCountDownContainer = document.createElement('div');
30774
+ const domCountDown = document.createElement('div');
30775
+ const domHint = document.createElement('div');
30776
+ const domClose = document.createElement('div');
30777
+ const domConfirm = document.createElement('button');
30778
+ domModal.classList.add('video-container__ocrResultModal');
30779
+ domHeaderContainer.classList.add('video-container__ocrResultModal-header-container');
30780
+ domBodyContainer.classList.add('video-container__ocrResultModal-body-container');
30781
+ domBody.classList.add('video-container__ocrResultModal-body');
30782
+ domTitle.classList.add('video-container__ocrResultModal-title');
30783
+ domSubtitle.classList.add('video-container__ocrResultModal-subtitle');
30784
+ domFooterContainer.classList.add('video-container__ocrResultModal-footer-container');
30785
+ domCountDownContainer.classList.add('video-container__ocrResultModal-countdown-container');
30786
+ domCountDown.classList.add('video-container__ocrResultModal-countdown');
30787
+ domHint.classList.add('video-container__ocrResultModal-hint');
30788
+ domClose.classList.add('video-container__ocrResultModal-close');
30789
+ domConfirm.classList.add('video-container__ocrResultModal-confirm');
30790
+ btnConfirmStatus(true);
30791
+ // uiThemeButton(domConfirm, uiThemeConfig.majorButton);
30792
+ util.uiThemeText(domTitle, uiThemeConfig.resultTitle);
30793
+ util.uiThemeText(domSubtitle, uiThemeConfig.resultBody);
30794
+ domTitle.innerText = arg.title;
30795
+ domSubtitle.innerText = arg.subtitle;
30796
+ domHint.innerHTML = arg.hintText;
30797
+ domCountDownContainer.innerHTML = `${arg.countDown1Text} <span class="video-container__ocrResultModal-countdown" style="color: ${uiThemeConfig.resultTime};font-size:${uiThemeConfig.fontSize}px;font-weight:${util.fontWeight[uiThemeConfig.textWeight]}"> ${formatTime(timer)} </span> ${arg.countDown2Text}`;
30798
+ domConfirm.innerText = arg.confirmText;
30799
+ domClose.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19.1943 6.41714C19.6393 5.97216 19.6393 5.2507 19.1943 4.80571C18.7493 4.36073 18.0278 4.36073 17.5829 4.80571L12 10.3886L6.41714 4.80572C5.97216 4.36073 5.2507 4.36073 4.80571 4.80571C4.36073 5.2507 4.36073 5.97216 4.80571 6.41714L10.3886 12L4.80571 17.5829C4.36073 18.0278 4.36073 18.7493 4.80571 19.1943C5.2507 19.6393 5.97216 19.6393 6.41714 19.1943L12 13.6114L17.5829 19.1943C18.0278 19.6393 18.7493 19.6393 19.1943 19.1943C19.6393 18.7493 19.6393 18.0278 19.1943 17.5829L13.6114 12L19.1943 6.41714Z" fill="${uiThemeConfig.nonEkycCloseButton.contentColor}" fill-opacity="${uiThemeConfig.nonEkycCloseButton.contentOpacity}" /></svg>`;
30800
+ const countdownInterval = setInterval(() => {
30801
+ timer -= 1;
30802
+ const countdownEl = domModal.querySelector('.video-container__ocrResultModal-countdown');
30803
+ if (countdownEl) {
30804
+ countdownEl.innerHTML = formatTime(timer);
30805
+ }
30806
+ if (timer <= 0) {
30807
+ clearInterval(countdownInterval);
30808
+ }
30809
+ }, 1000);
30810
+ // form start
30811
+ arg.items.sort((a, b) => {
30812
+ var _a, _b;
30813
+ return ((_a = a.order) !== null && _a !== void 0 ? _a : Infinity) - ((_b = b.order) !== null && _b !== void 0 ? _b : Infinity);
30814
+ });
30815
+ arg.items.forEach(item => {
30816
+ // init validateMap
30817
+ if (item.regex) {
30818
+ validateMap[item.name] = {
30819
+ validate: false,
30820
+ regex: new RegExp(item.regex.slice(1, -1))
30821
+ };
30822
+ } else if (item.selections) {
30823
+ validateMap[item.name] = {
30824
+ validate: false,
30825
+ regex: /\S+/
30826
+ };
30827
+ } else if (item.dateFormat) {
30828
+ validateMap[item.name] = {
30829
+ validate: false,
30830
+ dateFormat: new RegExp(item.dateFormat.slice(1, -1))
30831
+ };
30832
+ }
30833
+ // init UI
30834
+ if (!item.hidden) {
30835
+ if (item.selections) {
30836
+ const domDropMenu = groupDropMenu({
30837
+ name: item.name,
30838
+ label: item.name === 'issueReason' ? translateService.translate('sdk.ocr.verify.result.issueType') : translateService.translate(`sdk.ocr.verify.result.${item.name}`),
30839
+ value: item.value,
30840
+ selections: item.selections
30841
+ });
30842
+ domBody.appendChild(domDropMenu);
30843
+ } else {
30844
+ const domGroupItem = groupInput({
30845
+ name: item.name,
30846
+ label: item.name === 'issueReason' ? translateService.translate('sdk.ocr.verify.result.issueType') : translateService.translate(`sdk.ocr.verify.result.${item.name}`),
30847
+ value: item.dateFormat ? formatDate(item.value, item.dateFormat) : item.value
30848
+ });
30849
+ domBody.appendChild(domGroupItem);
30850
+ }
30851
+ }
30852
+ });
30853
+ // form end
30854
+ domHeaderContainer.appendChild(domTitle);
30855
+ domHeaderContainer.appendChild(domSubtitle);
30856
+ domModal.appendChild(domHeaderContainer);
30857
+ domModal.appendChild(domClose);
30858
+ domModal.appendChild(domBodyContainer);
30859
+ // domBodyContainer.appendChild(domTitle);
30860
+ // domBodyContainer.appendChild(domSubtitle);
30861
+ domBodyContainer.appendChild(domBody);
30862
+ domModal.appendChild(domFooterContainer);
30863
+ domFooterContainer.appendChild(domCountDownContainer);
30864
+ domFooterContainer.appendChild(domHint);
30865
+ domFooterContainer.appendChild(domConfirm);
30866
+ authmeContainer.appendChild(domModal);
30867
+ validateFields() ? btnConfirmStatus(false) : btnConfirmStatus(true);
30868
+ return new Promise(resolve => {
30869
+ domClose.addEventListener('click', () => __awaiter(void 0, void 0, void 0, function* () {
30870
+ if (arg.onClose) {
30871
+ yield arg.onClose();
30872
+ }
30873
+ removeOcrResultModal();
30874
+ resolve('close');
30875
+ }));
30876
+ domConfirm.addEventListener('click', () => __awaiter(void 0, void 0, void 0, function* () {
30877
+ checkModifiedData();
30878
+ if (arg.onConfirm) {
30879
+ yield arg.onConfirm(modifiedDetails);
30880
+ }
30881
+ removeOcrResultModal();
30882
+ resolve(modifiedDetails);
30883
+ }));
30884
+ });
30885
+ };
30886
+
30449
30887
  const initEvenTrackingStatus = ocrConfig => {
30450
30888
  setFeature$1(ocrConfig.needAntiFraud ? core.Feature.OCRFraud : core.Feature.OCR);
30451
30889
  };
@@ -30454,7 +30892,9 @@ function startOCR(config) {
30454
30892
  return __awaiter(this, void 0, void 0, function* () {
30455
30893
  const translateService = core.getTranslateInstance();
30456
30894
  const timeout$ = new rxjs.Subject();
30457
- let sdkFlowTimeout;
30895
+ // let sdkFlowTimeout: NodeJS.Timeout;
30896
+ let sdkFlowTimeout = null;
30897
+ let countDownTime = 0;
30458
30898
  let deviceMetas;
30459
30899
  // anti fraud
30460
30900
  let currentAntiFraudStage;
@@ -30667,17 +31107,41 @@ function startOCR(config) {
30667
31107
  return data;
30668
31108
  };
30669
31109
  })();
31110
+ // function makeSDKFlowTimeout(expiredIn: number) {
31111
+ // return setTimeout(async () => {
31112
+ // asyncShowErrorMessage(
31113
+ // translateService.translate('sdk.general.error.timeout.content'),
31114
+ // false
31115
+ // );
31116
+ // await waitTime(3 * TIME_UNIT.SECOND);
31117
+ // timeout$.next({
31118
+ // isSuccess: false as const,
31119
+ // code: `${ErrorCode.ID_RECOGNITION_TIMEOUT}`,
31120
+ // message: new AuthmeError(ErrorCode.ID_RECOGNITION_TIMEOUT).message,
31121
+ // data: {},
31122
+ // });
31123
+ // }, expiredIn * TIME_UNIT.SECOND);
31124
+ // }
30670
31125
  function makeSDKFlowTimeout(expiredIn) {
30671
- return setTimeout(() => __awaiter(this, void 0, void 0, function* () {
30672
- util.asyncShowErrorMessage(translateService.translate('sdk.general.error.timeout.content'), false);
30673
- yield util.waitTime(3 * util.TIME_UNIT.SECOND);
31126
+ return rxjs.timer(expiredIn * util.TIME_UNIT.SECOND).pipe(rxjs.switchMap(() => new rxjs.Observable(observer => {
31127
+ config.onDestroy();
31128
+ popupView({
31129
+ title: translateService.translate('sdk.general.error.timeout.title'),
31130
+ content: translateService.translate('sdk.general.error.timeout.content'),
31131
+ confirm: translateService.translate('sdk.general.confirm'),
31132
+ onConfirm: () => {
31133
+ observer.next(true);
31134
+ observer.complete();
31135
+ }
31136
+ });
31137
+ }))).subscribe(() => {
30674
31138
  timeout$.next({
30675
31139
  isSuccess: false,
30676
31140
  code: `${core.ErrorCode.ID_RECOGNITION_TIMEOUT}`,
30677
31141
  message: new core.AuthmeError(core.ErrorCode.ID_RECOGNITION_TIMEOUT).message,
30678
31142
  data: {}
30679
31143
  });
30680
- }), expiredIn * util.TIME_UNIT.SECOND);
31144
+ });
30681
31145
  }
30682
31146
  function startAntiFraud(type, cardType) {
30683
31147
  const animateInterval = 2 * util.TIME_UNIT.SECOND;
@@ -30738,7 +31202,7 @@ function startOCR(config) {
30738
31202
  break;
30739
31203
  case idRecognition.EAuthMeIDCardAntiFraudStatus.Error:
30740
31204
  uiComponentOCR.statusText.textContent = translateService.translate('sdk.general.error.alert.serverError');
30741
- util.showErrorMessage(translateService.translate('sdk.general.error.alert.serverError'), true);
31205
+ util.showErrorMessage(translateService.translate('sdk.general.error.alert.serverError'), false);
30742
31206
  sendStatusDescription$1(core.StatusDescription.Error);
30743
31207
  break;
30744
31208
  case idRecognition.EAuthMeIDCardAntiFraudStatus.NeedDeformationFrontal:
@@ -30813,6 +31277,7 @@ function startOCR(config) {
30813
31277
  buttonDisable$(cardMatchROI);
30814
31278
  }
30815
31279
  if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
31280
+ countDownTime = new Date().getTime() + ocrEngineConfig.expiredIn * util.TIME_UNIT.SECOND;
30816
31281
  sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
30817
31282
  }
30818
31283
  })), sendFrame(canvasSizeInfo, uiComponentOCR.image, uiComponentBasic.video, config.onAntiFraudFrame, ocrEngineConfig.fraudMaxFps, false, 'jpg', undefined), rxjs.map(x => x.result), rxjs.tap(x => {
@@ -31050,7 +31515,9 @@ function startOCR(config) {
31050
31515
  let ocrSendFrameAnimation = false;
31051
31516
  const handleOcrSendFrame = (canvasSizeInfo, canvas, video, frameCallback, fps, bas64Format, imageType, cardType, type) => source$ => {
31052
31517
  let received = true;
31053
- const ctx = canvas.getContext('2d');
31518
+ const ctx = canvas.getContext('2d', {
31519
+ willReadFrequently: true
31520
+ });
31054
31521
  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 => {
31055
31522
  // send to fast, ignore
31056
31523
  if (e instanceof core.AuthmeError && e.code === core.ErrorCode.RECOGNITION_NOT_AVAILABLE) {
@@ -31118,6 +31585,7 @@ function startOCR(config) {
31118
31585
  return init(retry).pipe(rxjs.tap(() => {
31119
31586
  setStatusView(core.StatusView.Running);
31120
31587
  if (ocrEngineConfig.expiredIn && !sdkFlowTimeout) {
31588
+ countDownTime = new Date().getTime() + ocrEngineConfig.expiredIn * util.TIME_UNIT.SECOND;
31121
31589
  sdkFlowTimeout = makeSDKFlowTimeout(ocrEngineConfig.expiredIn);
31122
31590
  }
31123
31591
  }), rxjs.switchMap(canvasSizeInfo => {
@@ -31308,26 +31776,66 @@ function startOCR(config) {
31308
31776
  }), rxjs.switchMap(() => config.onSuccess()), rxjs.tap(() => {
31309
31777
  setStatusEvent$1(cardClassResultMapping(config.acceptTypes[config.acceptTypes.length - 1]));
31310
31778
  util.stopSpinner();
31311
- uiComponentBasic.container.style.display = 'none';
31779
+ // only for TWN IDCard handle ocr result page
31780
+ if (config.cardTypes[0].includes(idRecognition.IdRecognitionCardType.IDCard) && config.cardTypes[0].includes(idRecognition.CountryCode.TWN)) ; else {
31781
+ uiComponentBasic.container.style.display = 'none';
31782
+ }
31312
31783
  }), rxjs.concatMap(result => __awaiter(this, void 0, void 0, function* () {
31313
31784
  setStatusView(core.StatusView.Confirm);
31314
31785
  let modifiedData = result2ModifiedData(result.details);
31315
31786
  if (config.ocrConfig.displayResultPage) {
31316
- modifiedData = yield renderConfirmUI({
31317
- cardType: config.ocrConfig.type,
31318
- items: {
31319
- columns: Object.keys(result.details).sort((a, b) => {
31320
- const aScore = idRecognition.getRecognitionColumnOrder(a);
31321
- const bScore = idRecognition.getRecognitionColumnOrder(b);
31322
- return aScore - bScore || a.localeCompare(b);
31323
- }),
31324
- details: result.details
31325
- },
31326
- options: {
31327
- headerIcon: config.ocrConfig.icon,
31328
- translate: key => translateService.translate(key)
31787
+ // only for TWN IDCard
31788
+ if (config.cardTypes[0].includes(idRecognition.IdRecognitionCardType.IDCard) && config.cardTypes[0].includes(idRecognition.CountryCode.TWN)) {
31789
+ const keyMapping = {
31790
+ [idRecognition.IdRecognitionCardType.IDCard]: 'idCard',
31791
+ [idRecognition.IdRecognitionCardType.DriverLicense]: 'driverLicense',
31792
+ [idRecognition.IdRecognitionCardType.HealthCard]: 'HealthCard',
31793
+ [idRecognition.IdRecognitionCardType.ResidentCard]: 'residentCard',
31794
+ [idRecognition.IdRecognitionCardType.Passport]: 'passport'
31795
+ };
31796
+ const res = yield ocrResultModal({
31797
+ title: `${'請確認'}${translateService.translate(config.ocrConfig.type ? `sdk.ocr.verify.result.title.${keyMapping[config.ocrConfig.type]}` : '')}`,
31798
+ subtitle: '若資料有錯誤,可點擊內容進行修改',
31799
+ items: result.ocrResultFilds,
31800
+ confirmText: translateService.translate('sdk.general.confirm'),
31801
+ hintText: '逾時將自動轉跳至選單頁並無法保存此次紀錄',
31802
+ countDown1Text: '請在',
31803
+ countDown2Text: '內完成確認',
31804
+ countDownTime,
31805
+ cancelText: translateService.translate('sdk.general.cancel'),
31806
+ onConfirm: result => {
31807
+ modifiedData = result;
31808
+ },
31809
+ onClose: () => {
31810
+ // console.log('onClose');
31811
+ }
31812
+ });
31813
+ if (res === 'close') {
31814
+ const cancelResultObj = {
31815
+ isSuccess: false,
31816
+ code: `${core.ErrorCode.USER_CANCEL}`,
31817
+ message: new core.AuthmeError(core.ErrorCode.USER_CANCEL).message,
31818
+ data: {}
31819
+ };
31820
+ return cancelResultObj;
31329
31821
  }
31330
- });
31822
+ } else {
31823
+ modifiedData = yield renderConfirmUI({
31824
+ cardType: config.ocrConfig.type,
31825
+ items: {
31826
+ columns: Object.keys(result.details).sort((a, b) => {
31827
+ const aScore = idRecognition.getRecognitionColumnOrder(a);
31828
+ const bScore = idRecognition.getRecognitionColumnOrder(b);
31829
+ return aScore - bScore || a.localeCompare(b);
31830
+ }),
31831
+ details: result.details
31832
+ },
31833
+ options: {
31834
+ headerIcon: config.ocrConfig.icon,
31835
+ translate: key => translateService.translate(key)
31836
+ }
31837
+ });
31838
+ }
31331
31839
  }
31332
31840
  flags.onConfirm = true;
31333
31841
  util.Storage.setItem('scanId', result.scanId);
@@ -31374,7 +31882,7 @@ function startOCR(config) {
31374
31882
  const detectScreenResizeError$ = handleScreenResizeError$(detectScreenResize$(), unsubscribe$, () => !flags.onConfirm);
31375
31883
  return rxjs.merge(flow$, cancel$, detectScreenResizeError$, timeout$).pipe(rxjs.take(1));
31376
31884
  }
31377
- rxjs.fromEvent(window, 'offline').pipe(rxjs.switchMap(() => util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), true)), rxjs.takeUntil(unsubscribe$)).subscribe();
31885
+ rxjs.fromEvent(window, 'offline').pipe(rxjs.switchMap(() => util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), false)), rxjs.takeUntil(unsubscribe$)).subscribe();
31378
31886
  // resize
31379
31887
  rxjs.fromEvent(window, 'resize').pipe(rxjs.switchMapTo(util.getCanvasSize(uiComponentBasic.video)), rxjs.switchMap(canvasSizeInfo => config.setFrameSize(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight, getCardBorderPoint())), rxjs.tap(() => {
31380
31888
  uiComponentOCR.scanAnimationContainer.style.width = `${cardSizeInfo.width + scanPadding}px`;
@@ -31756,7 +32264,12 @@ function startOCR(config) {
31756
32264
  uiComponentBasic.video.srcObject = null;
31757
32265
  }
31758
32266
  yield config.onDestroy();
31759
- if (sdkFlowTimeout) clearTimeout(sdkFlowTimeout);
32267
+ // if (sdkFlowTimeout) clearTimeout(sdkFlowTimeout);
32268
+ if (sdkFlowTimeout) {
32269
+ sdkFlowTimeout.unsubscribe();
32270
+ sdkFlowTimeout = null;
32271
+ }
32272
+ countDownTime = 0;
31760
32273
  eventListenerService$1.stop();
31761
32274
  util.hidePopup();
31762
32275
  uiComponentBasic.container.remove();
@@ -31965,7 +32478,7 @@ function startExtra(config) {
31965
32478
  util.stopSpinner();
31966
32479
  util.showElement(uiComponentBasic.videoContainer);
31967
32480
  }));
31968
- rxjs.fromEvent(window, 'offline').pipe(rxjs.switchMap(() => util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), true)), rxjs.takeUntil(unsubscribe$)).subscribe();
32481
+ rxjs.fromEvent(window, 'offline').pipe(rxjs.switchMap(() => util.asyncOnLineShowErrorMessage(translateService.translate('sdk.general.error.alert.offline'), translateService.translate('sdk.general.error.retry'), false)), rxjs.takeUntil(unsubscribe$)).subscribe();
31969
32482
  rxjs.fromEvent(window, 'resize').pipe(rxjs.throttleTime(100), rxjs.switchMap(() => util.getCanvasSize(uiComponentBasic.video)), rxjs.takeUntil(unsubscribe$)).subscribe();
31970
32483
  rxjs.fromEvent(uiComponentBasic.pictureIcon, 'click').pipe(rxjs.switchMap(() => util.getCanvasSize(uiComponentBasic.video)), rxjs.switchMap(canvasSizeInfo => rxjs.from(checkConfirmImage(canvasSizeInfo)).pipe(rxjs.switchMap(needRetry => needRetry ? rxjs.of(true) : rxjs.from(config.confirmImage(canvasSizeInfo.canvasWidth, canvasSizeInfo.canvasHeight, imageData, canvas)).pipe(rxjs.map(confirmResp => !confirmResp))), rxjs.tap(() => {
31971
32484
  if (config.extraConfig.border == 'none') {
@@ -32077,7 +32590,7 @@ function startExtra(config) {
32077
32590
 
32078
32591
  function SendRequestWithRetry$3(promiseFactory) {
32079
32592
  return util.retryPromiseWithCondition(promiseFactory, () => __awaiter(this, void 0, void 0, function* () {
32080
- return util.asyncShowErrorMessage(core.getTranslateInstance().translate('sdk.general.error.alert.serverError'), true);
32593
+ return util.asyncShowErrorMessage(core.getTranslateInstance().translate('sdk.general.error.alert.serverError'), false);
32081
32594
  }));
32082
32595
  }
32083
32596
  class ExtraModule {
@@ -32139,7 +32652,7 @@ class ExtraModule {
32139
32652
 
32140
32653
  function SendRequestWithRetry$2(promiseFactory) {
32141
32654
  return util.retryPromiseWithCondition(promiseFactory, () => __awaiter(this, void 0, void 0, function* () {
32142
- return util.asyncShowErrorMessage(core.getTranslateInstance().translate('sdk.general.error.alert.serverError'), true);
32655
+ return util.asyncShowErrorMessage(core.getTranslateInstance().translate('sdk.general.error.alert.serverError'), false);
32143
32656
  }));
32144
32657
  }
32145
32658
  class LivenessVerifyModule {
@@ -32250,7 +32763,9 @@ class LivenessVerifyModule {
32250
32763
  const result = yield this.fasService.recognition(data);
32251
32764
  if (this.canvas) {
32252
32765
  const debugData = yield (_c = this.fasService) === null || _c === void 0 ? void 0 : _c.getDebugImageData(data);
32253
- const ctx = this.canvas.getContext('2d');
32766
+ const ctx = this.canvas.getContext('2d', {
32767
+ willReadFrequently: true
32768
+ });
32254
32769
  this.canvas.width = frameWidth;
32255
32770
  this.canvas.height = frameHeight;
32256
32771
  ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
@@ -32497,7 +33012,9 @@ class LivenessModule {
32497
33012
  const result = yield this.fasService.recognition(data);
32498
33013
  if (this.canvas) {
32499
33014
  const debugData = yield (_b = this.fasService) === null || _b === void 0 ? void 0 : _b.getDebugImageData(data);
32500
- const ctx = this.canvas.getContext('2d');
33015
+ const ctx = this.canvas.getContext('2d', {
33016
+ willReadFrequently: true
33017
+ });
32501
33018
  this.canvas.width = frameWidth;
32502
33019
  this.canvas.height = frameHeight;
32503
33020
  ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
@@ -32863,7 +33380,7 @@ function initFrameView(cardPoints, scanId, faceMode, scanView, cardType, cardTyp
32863
33380
 
32864
33381
  function SendRequestWithRetry$1(promiseFactory) {
32865
33382
  return util.retryPromiseWithCondition(promiseFactory, () => __awaiter(this, void 0, void 0, function* () {
32866
- return util.asyncShowErrorMessage(core.getTranslateInstance().translate('sdk.general.error.alert.serverError'), true);
33383
+ return util.asyncShowErrorMessage(core.getTranslateInstance().translate('sdk.general.error.alert.serverError'), false);
32867
33384
  }));
32868
33385
  }
32869
33386
  class MRZModule {
@@ -32995,7 +33512,9 @@ class MRZModule {
32995
33512
  const mrzResult = yield this.mrzService.recognition(data);
32996
33513
  if (this.canvas) {
32997
33514
  const debugData = yield (_d = this.mrzService) === null || _d === void 0 ? void 0 : _d.getDebugImageData(data);
32998
- const ctx = this.canvas.getContext('2d');
33515
+ const ctx = this.canvas.getContext('2d', {
33516
+ willReadFrequently: true
33517
+ });
32999
33518
  this.canvas.width = frameWidth;
33000
33519
  this.canvas.height = frameHeight;
33001
33520
  ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
@@ -33156,7 +33675,8 @@ class MRZModule {
33156
33675
  yield util.waitTime(1000);
33157
33676
  return {
33158
33677
  scanId: scanId,
33159
- details: latestTField !== null && latestTField !== void 0 ? latestTField : {}
33678
+ details: latestTField !== null && latestTField !== void 0 ? latestTField : {},
33679
+ ocrResultFilds: []
33160
33680
  };
33161
33681
  }),
33162
33682
  onDestroy: () => __awaiter(this, void 0, void 0, function* () {
@@ -33216,7 +33736,9 @@ function SendRequestWithRetry(promiseFactory, options = {}) {
33216
33736
  var _a, _b, _c;
33217
33737
  const errorParams = (options === null || options === void 0 ? void 0 : options.onErrorHandler) ? options === null || options === void 0 ? void 0 : options.onErrorHandler(e) : {};
33218
33738
  util.stopSpinner();
33219
- return util.asyncShowErrorMessage(core.getTranslateInstance().translate((_a = errorParams === null || errorParams === void 0 ? void 0 : errorParams.errorText) !== null && _a !== void 0 ? _a : 'sdk.general.error.alert.serverError'), errorParams.showRetryButton, {
33739
+ return util.asyncShowErrorMessage(core.getTranslateInstance().translate((_a = errorParams === null || errorParams === void 0 ? void 0 : errorParams.errorText) !== null && _a !== void 0 ? _a : 'sdk.general.error.alert.serverError'),
33740
+ // errorParams.showRetryButton,
33741
+ false, {
33220
33742
  callback: errorParams === null || errorParams === void 0 ? void 0 : errorParams.onButtonClick,
33221
33743
  buttonText: core.getTranslateInstance().translate((_b = errorParams === null || errorParams === void 0 ? void 0 : errorParams.buttonText) !== null && _b !== void 0 ? _b : 'sdk.general.error.retry'),
33222
33744
  titleText: core.getTranslateInstance().translate((_c = errorParams === null || errorParams === void 0 ? void 0 : errorParams.titleText) !== null && _c !== void 0 ? _c : ''),
@@ -33407,6 +33929,7 @@ class OCRModule {
33407
33929
  let backImage = null;
33408
33930
  let frontCropImage = null;
33409
33931
  let backCropImage = null;
33932
+ let ocrResultFilds = [];
33410
33933
  const {
33411
33934
  getDebugLogsLength,
33412
33935
  modifyDeubgLog,
@@ -33497,7 +34020,6 @@ class OCRModule {
33497
34020
  ocrConfig: config,
33498
34021
  getOptionConfig: () => __awaiter(this, void 0, void 0, function* () {
33499
34022
  const res = yield idRecognition.option();
33500
- console.log('themeId:', res.themeId);
33501
34023
  const themeId = res.themeId;
33502
34024
  if (!themeId) {
33503
34025
  return {};
@@ -33827,13 +34349,13 @@ class OCRModule {
33827
34349
  border: {
33828
34350
  enable: uiThemeConfig.scanFrame.isEnabled,
33829
34351
  type: uiThemeConfig.scanFrame.style,
33830
- color: uiThemeConfig.scanFrame.scanFrame.undetectedColor,
33831
- opacity: uiThemeConfig.scanFrame.scanFrame.opacity
34352
+ color: uiThemeConfig.scanFrame.undetectedColor,
34353
+ opacity: uiThemeConfig.scanFrame.opacity
33832
34354
  },
33833
34355
  success: {
33834
34356
  enable: uiThemeConfig.scanFrame.isEnabled,
33835
34357
  color: uiThemeConfig.scanFrame.detectedColor,
33836
- opacity: uiThemeConfig.scanFrame.scanFrame.opacity
34358
+ opacity: uiThemeConfig.scanFrame.opacity
33837
34359
  },
33838
34360
  content: scanView ? resp.scanView.content : [],
33839
34361
  line: {
@@ -33928,7 +34450,9 @@ class OCRModule {
33928
34450
  }
33929
34451
  if (this.canvas) {
33930
34452
  const debugData = yield (_f = this.antiFraudInstance) === null || _f === void 0 ? void 0 : _f.getDebugImageData(data);
33931
- const ctx = this.canvas.getContext('2d');
34453
+ const ctx = this.canvas.getContext('2d', {
34454
+ willReadFrequently: true
34455
+ });
33932
34456
  this.canvas.width = frameWidth;
33933
34457
  this.canvas.height = frameHeight;
33934
34458
  ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
@@ -34055,7 +34579,9 @@ class OCRModule {
34055
34579
  });
34056
34580
  if (this.canvas) {
34057
34581
  const debugData = yield _service === null || _service === void 0 ? void 0 : _service.getDebugImageData(data);
34058
- const ctx = this.canvas.getContext('2d');
34582
+ const ctx = this.canvas.getContext('2d', {
34583
+ willReadFrequently: true
34584
+ });
34059
34585
  this.canvas.width = frameWidth;
34060
34586
  this.canvas.height = frameHeight;
34061
34587
  ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
@@ -34094,7 +34620,6 @@ class OCRModule {
34094
34620
  // downloadImage(image, `${frameIndex}-${docInfos[type as EAuthMeCardClass].docId}-${new Date().getTime().toString()}.jpg`)
34095
34621
  frameIndex++;
34096
34622
  util.backgroundRequest(() => __awaiter(this, void 0, void 0, function* () {
34097
- console.log('recognition', docInfos[cardType !== null && cardType !== void 0 ? cardType : ''].docId);
34098
34623
  if (docInfos[eClass].docId === '') {
34099
34624
  console.warn('didnt find docid, retry');
34100
34625
  return false;
@@ -34253,7 +34778,7 @@ class OCRModule {
34253
34778
  throw 'recognition failed';
34254
34779
  }
34255
34780
  result = unionMerge(result, resp && resp.details || {});
34256
- yield SendRequestWithRetry(() => __awaiter(this, void 0, void 0, function* () {
34781
+ const res = yield SendRequestWithRetry(() => __awaiter(this, void 0, void 0, function* () {
34257
34782
  const postData = {
34258
34783
  scanDocumentId: docId,
34259
34784
  details: resp === null || resp === void 0 ? void 0 : resp.details,
@@ -34274,7 +34799,11 @@ class OCRModule {
34274
34799
  // needFraudOption ? this.fraudResult : null
34275
34800
  // )
34276
34801
  );
34277
-
34802
+ // ocrResultFilds = res.fields.concat(ocrResultFilds);
34803
+ ocrResultFilds = ocrResultFilds.map(item1 => {
34804
+ const item2 = res.fields.find(item => item.name === item1.name);
34805
+ return item2 ? Object.assign(Object.assign({}, item1), item2) : item1;
34806
+ }).concat(res.fields.filter(item2 => !ocrResultFilds.some(item1 => item1.name === item2.name)));
34278
34807
  delete docInfos[option.cardType];
34279
34808
  return true;
34280
34809
  } catch (error) {
@@ -34450,7 +34979,9 @@ class OCRModule {
34450
34979
  }
34451
34980
  if (this.canvas) {
34452
34981
  const debugData = yield (_j = this.antiFraudInstance) === null || _j === void 0 ? void 0 : _j.getDebugImageData(data);
34453
- const ctx = this.canvas.getContext('2d');
34982
+ const ctx = this.canvas.getContext('2d', {
34983
+ willReadFrequently: true
34984
+ });
34454
34985
  this.canvas.width = frameWidth;
34455
34986
  this.canvas.height = frameHeight;
34456
34987
  ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
@@ -34597,7 +35128,8 @@ class OCRModule {
34597
35128
  frontImage,
34598
35129
  backImage,
34599
35130
  frontCropImage,
34600
- backCropImage
35131
+ backCropImage,
35132
+ ocrResultFilds
34601
35133
  };
34602
35134
  }),
34603
35135
  onDestroy: () => __awaiter(this, void 0, void 0, function* () {
@@ -34659,7 +35191,7 @@ function renderCardTypeAndCountryConfig(config) {
34659
35191
  currentCardTypeAndCountry = Object.assign(Object.assign({}, currentCardTypeAndCountry), {
34660
35192
  country
34661
35193
  });
34662
- countrySelectDropdownText.innerText = translate(`sdk.home.selectCountry.${country}`);
35194
+ countrySelectDropdownText.innerText = translate(`sdk.general.country.${country}`);
34663
35195
  };
34664
35196
  const dropdownSwitch = switchTarget => {
34665
35197
  const closeDropdown = () => {
@@ -34696,7 +35228,7 @@ function renderCardTypeAndCountryConfig(config) {
34696
35228
  <label class="country-select-label">${translate('sdk.home.selectCountry')}</label>
34697
35229
  <div class="country-select-dropdown">
34698
35230
  <div class="country-select-dropdown-frame">
34699
- <div class="country-select-dropdown-text">${translate(`sdk.home.selectCountry.${config.defaultCountry}`)}</div>
35231
+ <div class="country-select-dropdown-text">${translate(`sdk.general.country.${config.defaultCountry}`)}</div>
34700
35232
  <div class="country-select-dropdown-icon"></div>
34701
35233
  </div>
34702
35234
  <div class="dropdown-country-list"></div>
@@ -34727,7 +35259,7 @@ function renderCardTypeAndCountryConfig(config) {
34727
35259
  countryDom.classList.add('dropdown-country-list-item');
34728
35260
  countryDom.innerHTML = `
34729
35261
  <div class="dropdown-country-list-item-frame">
34730
- <div class="dropdown-country-list-item-text">${translate(`sdk.home.selectCountry.${country}`)}</div>
35262
+ <div class="dropdown-country-list-item-text">${translate(`sdk.general.country.${country}`)}</div>
34731
35263
  </div>
34732
35264
  `;
34733
35265
  countryDom.addEventListener('click', event => {
@@ -35114,8 +35646,8 @@ class AuthmeIdentityVerification extends engine.AuthmeFunctionModule {
35114
35646
  }
35115
35647
 
35116
35648
  var name = "authme/sdk";
35117
- var version$1 = "2.8.2";
35118
- var date = "2025-02-26T06:47:43+0000";
35649
+ var version$1 = "2.8.4";
35650
+ var date = "2025-03-13T06:47:53+0000";
35119
35651
  var packageInfo = {
35120
35652
  name: name,
35121
35653
  version: version$1,