@authme/util 2.4.10 → 2.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -21,12 +21,10 @@ require('core-js/modules/es.string.replace.js');
21
21
  require('core-js/modules/web.url-search-params.js');
22
22
  require('core-js/modules/es.string.search.js');
23
23
  require('core-js/modules/es.typed-array.uint32-array.js');
24
- require('core-js/modules/es.array.includes.js');
25
- require('core-js/modules/es.string.includes.js');
26
- var fileSaver = require('file-saver');
27
- var JSZip = require('jszip');
28
24
  var Lottie = require('lottie-web');
29
25
  require('core-js/modules/es.array.sort.js');
26
+ require('core-js/modules/es.array.includes.js');
27
+ require('core-js/modules/es.string.includes.js');
30
28
  require('core-js/modules/es.parse-int.js');
31
29
  require('core-js/modules/es.string.trim.js');
32
30
  require('core-js/modules/es.string.starts-with.js');
@@ -35,7 +33,6 @@ require('core-js/modules/es.symbol.description.js');
35
33
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
36
34
 
37
35
  var jwt_decode__default = /*#__PURE__*/_interopDefaultLegacy(jwt_decode);
38
- var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
39
36
  var Lottie__default = /*#__PURE__*/_interopDefaultLegacy(Lottie);
40
37
 
41
38
  const GLOBAL_KEY = '_AuthmeConfig';
@@ -483,44 +480,6 @@ const isIphone14proOrProMax = () => {
483
480
  return isIphone() && (screen.width === 430 && screen.height === 932 || screen.width === 393 && screen.height === 852);
484
481
  };
485
482
 
486
- function fileSaverService() {
487
- const filesQueue = [];
488
- function pushFile(file) {
489
- filesQueue.push(file);
490
- }
491
- function popAllFiles() {
492
- filesQueue.splice(0, filesQueue.length);
493
- }
494
- function saveFiles(fileName, json) {
495
- return __awaiter(this, void 0, void 0, function* () {
496
- const zip = new JSZip__default["default"]();
497
- filesQueue.forEach(fileItem => {
498
- zip.file(fileItem.name, fileItem.file);
499
- });
500
- if (json) zip.file('data.json', JSON.stringify(json));
501
- const content = yield zip.generateAsync({
502
- type: 'blob'
503
- });
504
- fileSaver.saveAs(content, `${fileName}.zip`);
505
- popAllFiles();
506
- });
507
- }
508
- return {
509
- pushFile,
510
- saveFiles
511
- };
512
- }
513
-
514
- const {
515
- saveFiles,
516
- pushFile
517
- } = fileSaverService();
518
- exports.RUN_FUNCTION_NAME = void 0;
519
- (function (RUN_FUNCTION_NAME) {
520
- RUN_FUNCTION_NAME["RECOGNITION"] = "service.recognition";
521
- RUN_FUNCTION_NAME["ANTI_FARUD_RECOGNITION"] = "antiFraudInstance.recognition";
522
- RUN_FUNCTION_NAME["API_REQUEST"] = "api.request";
523
- })(exports.RUN_FUNCTION_NAME || (exports.RUN_FUNCTION_NAME = {}));
524
483
  function debugLog(message, ...others) {
525
484
  if (new URLSearchParams(location.search).get('authme-debug') === 'true') {
526
485
  console.log(message, ...others);
@@ -542,49 +501,35 @@ function generateUniqueId(length = 32) {
542
501
  }
543
502
  return result;
544
503
  }
545
- function debugTools() {
546
- const debugMode = new URLSearchParams(location.search).get('authme-debug') === 'true';
547
- const debugModeUI = new URLSearchParams(location.search).get('authme-debug-info') === 'true';
548
- const shouldGetDebugImage = new URLSearchParams(location.search).get('authme-debug-get-image') === 'true';
504
+ function downloadObjectAsJson(exportObj, exportName) {
505
+ const dataStr = `data:application/octet-stream;headers=Content-Disposition%3A%20attachment%3B%20filename=${exportName}.json,${encodeURIComponent(JSON.stringify(exportObj, null, 4))}`;
506
+ //'data:text/json;charset=utf-8,' +
507
+ const downloadAnchorNode = document.createElement('a');
508
+ downloadAnchorNode.setAttribute('href', dataStr);
509
+ downloadAnchorNode.setAttribute('download', exportName + '.json');
510
+ document.body.appendChild(downloadAnchorNode); // required for firefox
511
+ downloadAnchorNode.click();
512
+ downloadAnchorNode.remove();
513
+ }
514
+ function debugTools(config) {
549
515
  const debugLogs = [];
550
- const logInfo = {
551
- userAgent: navigator.userAgent,
552
- token: '',
553
- message: ''
554
- };
555
516
  let currentRoundId = generateUniqueId(8);
556
517
  let currentType = null;
557
- const interiaTimeObj = {};
558
518
  function pushNewDebugLog(logParams) {
559
519
  var _a;
560
- if (!debugMode) return;
520
+ if (!config.debugMode) return;
561
521
  const now = new Date();
562
522
  const _logParams = JSON.parse(JSON.stringify(logParams));
563
523
  if (_logParams.result) {
564
524
  (_a = _logParams.result) === null || _a === void 0 ? true : delete _a.imageData;
565
525
  }
566
- const newDebugLog = Object.assign(Object.assign({
526
+ const newDebugLog = Object.assign({
527
+ time: now.getTime(),
567
528
  dateTime: now.toLocaleString(),
568
529
  roundId: currentRoundId,
569
530
  type: currentType !== null && currentType !== void 0 ? currentType : undefined
570
- }, _logParams), {
571
- time: now.getTime(),
572
- _id: generateUniqueId()
573
- });
531
+ }, _logParams);
574
532
  debugLogs.push(newDebugLog);
575
- return newDebugLog;
576
- }
577
- function pushNewDebugImage(image, log, options) {
578
- var _a, _b;
579
- if (!debugMode) return;
580
- const newLog = pushNewDebugLog(log);
581
- const recognitionFunctions = [exports.RUN_FUNCTION_NAME.ANTI_FARUD_RECOGNITION, exports.RUN_FUNCTION_NAME.RECOGNITION];
582
- const currentRoundRecognitionResultItem = debugLogs.find(item => item.roundId === (newLog === null || newLog === void 0 ? void 0 : newLog.roundId) && item.status === 'run-end' && (item.runFunction ? recognitionFunctions.includes(item.runFunction) : false));
583
- const imageStatus = (_a = currentRoundRecognitionResultItem === null || currentRoundRecognitionResultItem === void 0 ? void 0 : currentRoundRecognitionResultItem.result) === null || _a === void 0 ? void 0 : _a.eStatus;
584
- pushFile({
585
- name: `${(_b = options === null || options === void 0 ? void 0 : options.prefix) !== null && _b !== void 0 ? _b : ''}${newLog === null || newLog === void 0 ? void 0 : newLog.time}-${newLog === null || newLog === void 0 ? void 0 : newLog._id}${imageStatus ? `__${imageStatus}` : ''}.jpeg`,
586
- file: image
587
- });
588
533
  }
589
534
  function functionLogging(func, logParams) {
590
535
  return new Promise((resolve, reject) => {
@@ -608,209 +553,28 @@ function debugTools() {
608
553
  });
609
554
  });
610
555
  }
611
- function renderDebugTips() {
612
- if (document.getElementById('debug-tips')) {
613
- return;
614
- }
615
- const debugTips = document.createElement('div');
616
- debugTips.style.position = 'fixed';
617
- debugTips.style.top = '50px';
618
- debugTips.style.right = '0';
619
- debugTips.style.zIndex = '999';
620
- debugTips.innerHTML = 'Debug Mode';
621
- debugTips.style.color = 'red';
622
- debugTips.style.fontWeight = 'bold';
623
- debugTips.setAttribute('id', 'debug-tips');
624
- document.body.appendChild(debugTips);
625
- }
626
- function renderDebugUI() {
627
- if (document.getElementById('debug-ui')) {
628
- return;
629
- }
630
- const debugUI = document.createElement('div');
631
- debugUI.style.position = 'fixed';
632
- debugUI.style.top = '0';
633
- debugUI.style.right = '0';
634
- debugUI.style.zIndex = '777';
635
- debugUI.style.backgroundColor = 'black';
636
- debugUI.style.color = 'white';
637
- debugUI.style.padding = '10px';
638
- debugUI.style.paddingRight = '150px';
639
- debugUI.style.fontSize = '12px';
640
- debugUI.style.opacity = '0.7';
641
- debugUI.style.boxSizing = 'border-box';
642
- debugUI.style.width = '100%';
643
- debugUI.style.maxHeight = '50vh';
644
- debugUI.style.overflow = 'auto';
645
- debugUI.setAttribute('id', 'debug-ui');
646
- const closeUI = document.createElement('button');
647
- closeUI.style.position = 'fixed';
648
- closeUI.style.top = '0';
649
- closeUI.style.right = '100px';
650
- closeUI.innerHTML = 'close';
651
- closeUI.addEventListener('click', () => {
652
- debugUI.style.display = 'none';
653
- });
654
- debugUI.appendChild(closeUI);
655
- const accordionUI = document.createElement('button');
656
- accordionUI.style.position = 'fixed';
657
- accordionUI.style.top = '0';
658
- accordionUI.style.right = '0';
659
- accordionUI.innerHTML = '收合/展開';
660
- accordionUI.addEventListener('click', () => {
661
- if (debugUI.style.maxHeight === '50vh') {
662
- debugUI.style.maxHeight = '5vh';
663
- } else {
664
- debugUI.style.maxHeight = '50vh';
665
- }
666
- });
667
- debugUI.appendChild(accordionUI);
668
- document.body.appendChild(debugUI);
669
- }
670
- function setTimeStart(behavior) {
671
- if (!debugModeUI) {
672
- return;
673
- }
674
- const dStart = new Date();
675
- const nStart = dStart.getTime();
676
- if (interiaTimeObj && interiaTimeObj[behavior]) {
677
- console.error('debugmode: setTimeStart duplicate', behavior);
678
- return false;
679
- }
680
- interiaTimeObj[behavior] = {
681
- behavior,
682
- start: nStart / 1000,
683
- duration: 0,
684
- end: 0
685
- };
686
- // console.log(interiaTimeObj[behavior])
687
- renderTimeInfo(behavior);
688
- return interiaTimeObj[behavior];
689
- }
690
- function setTimeEnd(behavior) {
691
- if (!debugModeUI) {
692
- return;
693
- }
694
- const dEnd = new Date();
695
- const nEnd = dEnd.getTime();
696
- if (!interiaTimeObj[behavior]) {
697
- console.error('debugmode: setTimeEnd not found', behavior);
698
- return false;
699
- }
700
- interiaTimeObj[behavior].end = nEnd / 1000;
701
- interiaTimeObj[behavior].duration = interiaTimeObj[behavior].end - interiaTimeObj[behavior].start;
702
- // console.log(interiaTimeObj[behavior])
703
- renderTimeInfo(behavior);
704
- return interiaTimeObj[behavior];
705
- }
706
- function setTimeDuration(behavior) {
707
- const ts = Date.now();
708
- setTimeStart(`${behavior}_${ts}`);
709
- return {
710
- end: () => {
711
- setTimeEnd(`${behavior}_${ts}`);
712
- }
713
- };
714
- }
715
- function renderTimeInfo(behavior) {
716
- const dom = document.querySelector(`#debug-ui-${behavior}`);
717
- const info = `{"behavior":<span style="color:green;">"${behavior}"</span>, "start": ${interiaTimeObj[behavior].start}, "duration": ${interiaTimeObj[behavior].duration}, "end": ${interiaTimeObj[behavior].end}}`;
718
- // const info = `<span style="color:green;">${behavior}</span>: Duration: ${interiaTimeObj[behavior].duration}s`;
719
- if (dom) {
720
- dom.innerHTML = info;
721
- return;
722
- }
723
- const debugUI = document.getElementById('debug-ui');
724
- const div = document.createElement('div');
725
- div.setAttribute('class', 'debug-ui-item');
726
- div.setAttribute('id', `debug-ui-${behavior}`);
727
- div.innerHTML = info;
728
- debugUI.appendChild(div);
729
- }
730
- function functionRunTime() {
731
- const arr = [];
732
- const items = document.querySelectorAll('.debug-ui-item');
733
- items.forEach(item => {
734
- arr.push(JSON.parse(item.innerText));
735
- });
736
- return arr;
737
- }
738
- if (debugMode) {
739
- renderDebugTips();
740
- // setRequestLoggingFunc(functionLogging)
741
- }
742
-
743
- if (debugModeUI) {
744
- console.log('debugModeUI Init');
745
- renderDebugUI();
746
- }
747
- function saveDebugImage({
748
- getDebugImageData,
749
- data,
750
- width,
751
- height,
752
- result,
753
- type
754
- }) {
755
- return __awaiter(this, void 0, void 0, function* () {
756
- if (!debugMode || !shouldGetDebugImage) return;
757
- const debugImage = yield getDebugImageData(data);
758
- // 創建一個虛擬的 canvas
759
- const canvas = document.createElement('canvas');
760
- const ctx = canvas.getContext('2d');
761
- // 設置 canvas 的尺寸
762
- canvas.width = width;
763
- canvas.height = height;
764
- // 使用 Uint8ClampedArray 將圖像數據繪製到 canvas 上
765
- const imgData = ctx === null || ctx === void 0 ? void 0 : ctx.createImageData(width, height);
766
- if (imgData) {
767
- imgData.data.set(debugImage);
768
- ctx === null || ctx === void 0 ? void 0 : ctx.putImageData(imgData, 0, 0);
769
- canvas.toBlob(blob => {
770
- if (blob) {
771
- pushNewDebugImage(blob, {
772
- result: result,
773
- status: 'recognition',
774
- type: type
775
- }, {
776
- prefix: 'debugImage_'
777
- });
778
- }
779
- }, 'image/jpeg');
780
- }
781
- });
782
- }
783
556
  return {
784
- debugMode,
785
- debugModeUI,
786
557
  pushNewDebugLog,
787
558
  getDebugLogs: () => debugLogs,
788
559
  getDebugLogsLength: () => debugLogs.length,
789
560
  modifyDeubgLog: (index, logParams) => {
790
- if (!debugMode) return;
561
+ if (!config.debugMode) return;
791
562
  debugLogs[index] = Object.assign(Object.assign({}, debugLogs[index]), logParams);
792
563
  },
793
564
  downloadDebugLogs: () => {
794
- if (!debugMode) return;
795
- saveFiles(`debugLog${new Date().getTime().toString()}`, {
796
- info: logInfo,
797
- logs: debugLogs,
798
- functionRunTime: functionRunTime()
799
- });
565
+ if (!config.debugMode) return;
566
+ downloadObjectAsJson(debugLogs, `debugLog${new Date().getTime().toString()}`);
800
567
  },
801
568
  functionLogging,
802
569
  nextDebugRound: type => {
803
- if (!debugMode) return;
570
+ if (!config.debugMode) return;
804
571
  currentRoundId = generateUniqueId(8);
805
572
  if (type) currentType = type;
806
573
  },
807
574
  modifyDebugType: type => {
808
- if (!debugMode) return;
575
+ if (!config.debugMode) return;
809
576
  currentType = type;
810
- },
811
- pushNewDebugImage,
812
- setTimeDuration: setTimeDuration,
813
- saveDebugImage
577
+ }
814
578
  };
815
579
  }
816
580
 
@@ -1003,9 +767,8 @@ function showErrorMessage(text, showRetryBtn, callback, buttonText, _titleText)
1003
767
  errorMessagePanel.appendChild(retryText);
1004
768
  if (callback) {
1005
769
  retryText.addEventListener('click', e => {
1006
- callback(e, {
1007
- hideErrorMessage
1008
- });
770
+ target.removeChild(errorMessagePanel);
771
+ callback(e);
1009
772
  });
1010
773
  }
1011
774
  }
@@ -1068,12 +831,13 @@ function asyncShowErrorMessage(text, showRetryBtn, options) {
1068
831
  function asyncOnLineShowErrorMessage(text, showRetryBtn) {
1069
832
  return __awaiter(this, void 0, void 0, function* () {
1070
833
  return new Promise((res, rej) => {
1071
- showErrorMessage(text, showRetryBtn, (_, tools) => {
834
+ const callback = () => {
1072
835
  if (window.navigator.onLine) {
1073
836
  res(true);
1074
- tools === null || tools === void 0 ? void 0 : tools.hideErrorMessage();
837
+ hideErrorMessage();
1075
838
  }
1076
- });
839
+ };
840
+ showErrorMessage(text, showRetryBtn, callback);
1077
841
  });
1078
842
  });
1079
843
  }
@@ -1141,8 +905,6 @@ var BROWSER_CAMERA_ERRORS;
1141
905
  BROWSER_CAMERA_ERRORS["NO_CAMERA"] = "NO_CAMERA";
1142
906
  BROWSER_CAMERA_ERRORS["NOT_ALLOWED_ERROR"] = "NotAllowedError";
1143
907
  BROWSER_CAMERA_ERRORS["NOT_FOUND_ERROR"] = "NotFoundError";
1144
- BROWSER_CAMERA_ERRORS["NOT_READABLE_ERROR"] = "NotReadableError";
1145
- BROWSER_CAMERA_ERRORS["ABORT_ERROR"] = "AbortError";
1146
908
  })(BROWSER_CAMERA_ERRORS || (BROWSER_CAMERA_ERRORS = {}));
1147
909
  let stream;
1148
910
  const videoConstraintsFactory = (isPC, facingMode) => {
@@ -1402,15 +1164,6 @@ function requestCamera({
1402
1164
  showMessage(translate('camera.error.notFound'));
1403
1165
  throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
1404
1166
  }
1405
- if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_READABLE_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.ABORT_ERROR) {
1406
- showMessage(translate('camera.error.notFound'));
1407
- /* NOT_READABLE_ERROR,ABORT_ERROR 這兩個錯誤是用戶授權了,但在呼叫裝置時出現錯誤,
1408
- * 常發生在APP webview ,例如: 手機開啟 web 使用 sdk,儘管在 webview 層級上授權了,但手機在設定層級沒有授權 app 使用相機,會導致此問題。
1409
- * 但每個 android 手機的在這方面的實作不一致,不是每個手機在這種情況下都會拋出錯誤。
1410
- * 參考 https://developer.mozilla.org/zh-CN/docs/Web/API/MediaDevices/getUserMedia#notreadableerror
1411
- */
1412
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
1413
- }
1414
1167
  if (isOverconstrainedError(error)) {
1415
1168
  showMessage(translate('camera.error.lowResolution'));
1416
1169
  throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
@@ -2406,46 +2159,15 @@ function RGBToLottieColor(color) {
2406
2159
  return color.map(c => c / 255);
2407
2160
  }
2408
2161
 
2409
- const QUEUE_LENGTH = 10;
2410
- const requstQueue = [];
2411
- function pushRequest(request) {
2412
- if (requstQueue.length > QUEUE_LENGTH - 1) {
2413
- requstQueue.shift();
2414
- }
2415
- requstQueue.push(request);
2416
- }
2417
- function clearRequest() {
2418
- requstQueue.splice(0, requstQueue.length);
2419
- }
2420
- function backgroundRequest(request) {
2421
- const requestPromise = request();
2422
- requestPromise.catch(err => {
2423
- if (err._code === exports.ErrorCode.NETWORK_ERROR) {
2424
- pushRequest(request);
2425
- }
2426
- });
2427
- }
2428
- window.ononline = () => {
2429
- const tasks = [...requstQueue];
2430
- clearRequest();
2431
- tasks.forEach(request => {
2432
- backgroundRequest(request);
2433
- });
2434
- };
2435
-
2436
2162
  var name = "@authme/util";
2437
- var version$1 = "2.4.10";
2163
+ var version$1 = "2.4.11";
2438
2164
  var peerDependencies = {
2439
2165
  "core-js": "^3.6.0"
2440
2166
  };
2441
- var devDependencies = {
2442
- "@types/file-saver": "^2.0.5"
2443
- };
2444
2167
  var packageInfo = {
2445
2168
  name: name,
2446
2169
  version: version$1,
2447
- peerDependencies: peerDependencies,
2448
- devDependencies: devDependencies
2170
+ peerDependencies: peerDependencies
2449
2171
  };
2450
2172
 
2451
2173
  var _a;
@@ -2461,7 +2183,6 @@ exports.UintArrayToBlob = UintArrayToBlob;
2461
2183
  exports.asyncOnLineShowErrorMessage = asyncOnLineShowErrorMessage;
2462
2184
  exports.asyncShowErrorMessage = asyncShowErrorMessage;
2463
2185
  exports.asyncShowPopup = asyncShowPopup;
2464
- exports.backgroundRequest = backgroundRequest;
2465
2186
  exports.checkOnlineStatus = checkOnlineStatus;
2466
2187
  exports.clearCanvas = clearCanvas;
2467
2188
  exports.colorStringToRGB = colorStringToRGB;
package/index.js CHANGED
@@ -17,12 +17,10 @@ import 'core-js/modules/es.string.replace.js';
17
17
  import 'core-js/modules/web.url-search-params.js';
18
18
  import 'core-js/modules/es.string.search.js';
19
19
  import 'core-js/modules/es.typed-array.uint32-array.js';
20
- import 'core-js/modules/es.array.includes.js';
21
- import 'core-js/modules/es.string.includes.js';
22
- import { saveAs } from 'file-saver';
23
- import JSZip from 'jszip';
24
20
  import Lottie from 'lottie-web';
25
21
  import 'core-js/modules/es.array.sort.js';
22
+ import 'core-js/modules/es.array.includes.js';
23
+ import 'core-js/modules/es.string.includes.js';
26
24
  import 'core-js/modules/es.parse-int.js';
27
25
  import 'core-js/modules/es.string.trim.js';
28
26
  import 'core-js/modules/es.string.starts-with.js';
@@ -473,44 +471,6 @@ const isIphone14proOrProMax = () => {
473
471
  return isIphone() && (screen.width === 430 && screen.height === 932 || screen.width === 393 && screen.height === 852);
474
472
  };
475
473
 
476
- function fileSaverService() {
477
- const filesQueue = [];
478
- function pushFile(file) {
479
- filesQueue.push(file);
480
- }
481
- function popAllFiles() {
482
- filesQueue.splice(0, filesQueue.length);
483
- }
484
- function saveFiles(fileName, json) {
485
- return __awaiter(this, void 0, void 0, function* () {
486
- const zip = new JSZip();
487
- filesQueue.forEach(fileItem => {
488
- zip.file(fileItem.name, fileItem.file);
489
- });
490
- if (json) zip.file('data.json', JSON.stringify(json));
491
- const content = yield zip.generateAsync({
492
- type: 'blob'
493
- });
494
- saveAs(content, `${fileName}.zip`);
495
- popAllFiles();
496
- });
497
- }
498
- return {
499
- pushFile,
500
- saveFiles
501
- };
502
- }
503
-
504
- const {
505
- saveFiles,
506
- pushFile
507
- } = fileSaverService();
508
- var RUN_FUNCTION_NAME;
509
- (function (RUN_FUNCTION_NAME) {
510
- RUN_FUNCTION_NAME["RECOGNITION"] = "service.recognition";
511
- RUN_FUNCTION_NAME["ANTI_FARUD_RECOGNITION"] = "antiFraudInstance.recognition";
512
- RUN_FUNCTION_NAME["API_REQUEST"] = "api.request";
513
- })(RUN_FUNCTION_NAME || (RUN_FUNCTION_NAME = {}));
514
474
  function debugLog(message, ...others) {
515
475
  if (new URLSearchParams(location.search).get('authme-debug') === 'true') {
516
476
  console.log(message, ...others);
@@ -532,49 +492,35 @@ function generateUniqueId(length = 32) {
532
492
  }
533
493
  return result;
534
494
  }
535
- function debugTools() {
536
- const debugMode = new URLSearchParams(location.search).get('authme-debug') === 'true';
537
- const debugModeUI = new URLSearchParams(location.search).get('authme-debug-info') === 'true';
538
- const shouldGetDebugImage = new URLSearchParams(location.search).get('authme-debug-get-image') === 'true';
495
+ function downloadObjectAsJson(exportObj, exportName) {
496
+ const dataStr = `data:application/octet-stream;headers=Content-Disposition%3A%20attachment%3B%20filename=${exportName}.json,${encodeURIComponent(JSON.stringify(exportObj, null, 4))}`;
497
+ //'data:text/json;charset=utf-8,' +
498
+ const downloadAnchorNode = document.createElement('a');
499
+ downloadAnchorNode.setAttribute('href', dataStr);
500
+ downloadAnchorNode.setAttribute('download', exportName + '.json');
501
+ document.body.appendChild(downloadAnchorNode); // required for firefox
502
+ downloadAnchorNode.click();
503
+ downloadAnchorNode.remove();
504
+ }
505
+ function debugTools(config) {
539
506
  const debugLogs = [];
540
- const logInfo = {
541
- userAgent: navigator.userAgent,
542
- token: '',
543
- message: ''
544
- };
545
507
  let currentRoundId = generateUniqueId(8);
546
508
  let currentType = null;
547
- const interiaTimeObj = {};
548
509
  function pushNewDebugLog(logParams) {
549
510
  var _a;
550
- if (!debugMode) return;
511
+ if (!config.debugMode) return;
551
512
  const now = new Date();
552
513
  const _logParams = JSON.parse(JSON.stringify(logParams));
553
514
  if (_logParams.result) {
554
515
  (_a = _logParams.result) === null || _a === void 0 ? true : delete _a.imageData;
555
516
  }
556
- const newDebugLog = Object.assign(Object.assign({
517
+ const newDebugLog = Object.assign({
518
+ time: now.getTime(),
557
519
  dateTime: now.toLocaleString(),
558
520
  roundId: currentRoundId,
559
521
  type: currentType !== null && currentType !== void 0 ? currentType : undefined
560
- }, _logParams), {
561
- time: now.getTime(),
562
- _id: generateUniqueId()
563
- });
522
+ }, _logParams);
564
523
  debugLogs.push(newDebugLog);
565
- return newDebugLog;
566
- }
567
- function pushNewDebugImage(image, log, options) {
568
- var _a, _b;
569
- if (!debugMode) return;
570
- const newLog = pushNewDebugLog(log);
571
- const recognitionFunctions = [RUN_FUNCTION_NAME.ANTI_FARUD_RECOGNITION, RUN_FUNCTION_NAME.RECOGNITION];
572
- const currentRoundRecognitionResultItem = debugLogs.find(item => item.roundId === (newLog === null || newLog === void 0 ? void 0 : newLog.roundId) && item.status === 'run-end' && (item.runFunction ? recognitionFunctions.includes(item.runFunction) : false));
573
- const imageStatus = (_a = currentRoundRecognitionResultItem === null || currentRoundRecognitionResultItem === void 0 ? void 0 : currentRoundRecognitionResultItem.result) === null || _a === void 0 ? void 0 : _a.eStatus;
574
- pushFile({
575
- name: `${(_b = options === null || options === void 0 ? void 0 : options.prefix) !== null && _b !== void 0 ? _b : ''}${newLog === null || newLog === void 0 ? void 0 : newLog.time}-${newLog === null || newLog === void 0 ? void 0 : newLog._id}${imageStatus ? `__${imageStatus}` : ''}.jpeg`,
576
- file: image
577
- });
578
524
  }
579
525
  function functionLogging(func, logParams) {
580
526
  return new Promise((resolve, reject) => {
@@ -598,209 +544,28 @@ function debugTools() {
598
544
  });
599
545
  });
600
546
  }
601
- function renderDebugTips() {
602
- if (document.getElementById('debug-tips')) {
603
- return;
604
- }
605
- const debugTips = document.createElement('div');
606
- debugTips.style.position = 'fixed';
607
- debugTips.style.top = '50px';
608
- debugTips.style.right = '0';
609
- debugTips.style.zIndex = '999';
610
- debugTips.innerHTML = 'Debug Mode';
611
- debugTips.style.color = 'red';
612
- debugTips.style.fontWeight = 'bold';
613
- debugTips.setAttribute('id', 'debug-tips');
614
- document.body.appendChild(debugTips);
615
- }
616
- function renderDebugUI() {
617
- if (document.getElementById('debug-ui')) {
618
- return;
619
- }
620
- const debugUI = document.createElement('div');
621
- debugUI.style.position = 'fixed';
622
- debugUI.style.top = '0';
623
- debugUI.style.right = '0';
624
- debugUI.style.zIndex = '777';
625
- debugUI.style.backgroundColor = 'black';
626
- debugUI.style.color = 'white';
627
- debugUI.style.padding = '10px';
628
- debugUI.style.paddingRight = '150px';
629
- debugUI.style.fontSize = '12px';
630
- debugUI.style.opacity = '0.7';
631
- debugUI.style.boxSizing = 'border-box';
632
- debugUI.style.width = '100%';
633
- debugUI.style.maxHeight = '50vh';
634
- debugUI.style.overflow = 'auto';
635
- debugUI.setAttribute('id', 'debug-ui');
636
- const closeUI = document.createElement('button');
637
- closeUI.style.position = 'fixed';
638
- closeUI.style.top = '0';
639
- closeUI.style.right = '100px';
640
- closeUI.innerHTML = 'close';
641
- closeUI.addEventListener('click', () => {
642
- debugUI.style.display = 'none';
643
- });
644
- debugUI.appendChild(closeUI);
645
- const accordionUI = document.createElement('button');
646
- accordionUI.style.position = 'fixed';
647
- accordionUI.style.top = '0';
648
- accordionUI.style.right = '0';
649
- accordionUI.innerHTML = '收合/展開';
650
- accordionUI.addEventListener('click', () => {
651
- if (debugUI.style.maxHeight === '50vh') {
652
- debugUI.style.maxHeight = '5vh';
653
- } else {
654
- debugUI.style.maxHeight = '50vh';
655
- }
656
- });
657
- debugUI.appendChild(accordionUI);
658
- document.body.appendChild(debugUI);
659
- }
660
- function setTimeStart(behavior) {
661
- if (!debugModeUI) {
662
- return;
663
- }
664
- const dStart = new Date();
665
- const nStart = dStart.getTime();
666
- if (interiaTimeObj && interiaTimeObj[behavior]) {
667
- console.error('debugmode: setTimeStart duplicate', behavior);
668
- return false;
669
- }
670
- interiaTimeObj[behavior] = {
671
- behavior,
672
- start: nStart / 1000,
673
- duration: 0,
674
- end: 0
675
- };
676
- // console.log(interiaTimeObj[behavior])
677
- renderTimeInfo(behavior);
678
- return interiaTimeObj[behavior];
679
- }
680
- function setTimeEnd(behavior) {
681
- if (!debugModeUI) {
682
- return;
683
- }
684
- const dEnd = new Date();
685
- const nEnd = dEnd.getTime();
686
- if (!interiaTimeObj[behavior]) {
687
- console.error('debugmode: setTimeEnd not found', behavior);
688
- return false;
689
- }
690
- interiaTimeObj[behavior].end = nEnd / 1000;
691
- interiaTimeObj[behavior].duration = interiaTimeObj[behavior].end - interiaTimeObj[behavior].start;
692
- // console.log(interiaTimeObj[behavior])
693
- renderTimeInfo(behavior);
694
- return interiaTimeObj[behavior];
695
- }
696
- function setTimeDuration(behavior) {
697
- const ts = Date.now();
698
- setTimeStart(`${behavior}_${ts}`);
699
- return {
700
- end: () => {
701
- setTimeEnd(`${behavior}_${ts}`);
702
- }
703
- };
704
- }
705
- function renderTimeInfo(behavior) {
706
- const dom = document.querySelector(`#debug-ui-${behavior}`);
707
- const info = `{"behavior":<span style="color:green;">"${behavior}"</span>, "start": ${interiaTimeObj[behavior].start}, "duration": ${interiaTimeObj[behavior].duration}, "end": ${interiaTimeObj[behavior].end}}`;
708
- // const info = `<span style="color:green;">${behavior}</span>: Duration: ${interiaTimeObj[behavior].duration}s`;
709
- if (dom) {
710
- dom.innerHTML = info;
711
- return;
712
- }
713
- const debugUI = document.getElementById('debug-ui');
714
- const div = document.createElement('div');
715
- div.setAttribute('class', 'debug-ui-item');
716
- div.setAttribute('id', `debug-ui-${behavior}`);
717
- div.innerHTML = info;
718
- debugUI.appendChild(div);
719
- }
720
- function functionRunTime() {
721
- const arr = [];
722
- const items = document.querySelectorAll('.debug-ui-item');
723
- items.forEach(item => {
724
- arr.push(JSON.parse(item.innerText));
725
- });
726
- return arr;
727
- }
728
- if (debugMode) {
729
- renderDebugTips();
730
- // setRequestLoggingFunc(functionLogging)
731
- }
732
-
733
- if (debugModeUI) {
734
- console.log('debugModeUI Init');
735
- renderDebugUI();
736
- }
737
- function saveDebugImage({
738
- getDebugImageData,
739
- data,
740
- width,
741
- height,
742
- result,
743
- type
744
- }) {
745
- return __awaiter(this, void 0, void 0, function* () {
746
- if (!debugMode || !shouldGetDebugImage) return;
747
- const debugImage = yield getDebugImageData(data);
748
- // 創建一個虛擬的 canvas
749
- const canvas = document.createElement('canvas');
750
- const ctx = canvas.getContext('2d');
751
- // 設置 canvas 的尺寸
752
- canvas.width = width;
753
- canvas.height = height;
754
- // 使用 Uint8ClampedArray 將圖像數據繪製到 canvas 上
755
- const imgData = ctx === null || ctx === void 0 ? void 0 : ctx.createImageData(width, height);
756
- if (imgData) {
757
- imgData.data.set(debugImage);
758
- ctx === null || ctx === void 0 ? void 0 : ctx.putImageData(imgData, 0, 0);
759
- canvas.toBlob(blob => {
760
- if (blob) {
761
- pushNewDebugImage(blob, {
762
- result: result,
763
- status: 'recognition',
764
- type: type
765
- }, {
766
- prefix: 'debugImage_'
767
- });
768
- }
769
- }, 'image/jpeg');
770
- }
771
- });
772
- }
773
547
  return {
774
- debugMode,
775
- debugModeUI,
776
548
  pushNewDebugLog,
777
549
  getDebugLogs: () => debugLogs,
778
550
  getDebugLogsLength: () => debugLogs.length,
779
551
  modifyDeubgLog: (index, logParams) => {
780
- if (!debugMode) return;
552
+ if (!config.debugMode) return;
781
553
  debugLogs[index] = Object.assign(Object.assign({}, debugLogs[index]), logParams);
782
554
  },
783
555
  downloadDebugLogs: () => {
784
- if (!debugMode) return;
785
- saveFiles(`debugLog${new Date().getTime().toString()}`, {
786
- info: logInfo,
787
- logs: debugLogs,
788
- functionRunTime: functionRunTime()
789
- });
556
+ if (!config.debugMode) return;
557
+ downloadObjectAsJson(debugLogs, `debugLog${new Date().getTime().toString()}`);
790
558
  },
791
559
  functionLogging,
792
560
  nextDebugRound: type => {
793
- if (!debugMode) return;
561
+ if (!config.debugMode) return;
794
562
  currentRoundId = generateUniqueId(8);
795
563
  if (type) currentType = type;
796
564
  },
797
565
  modifyDebugType: type => {
798
- if (!debugMode) return;
566
+ if (!config.debugMode) return;
799
567
  currentType = type;
800
- },
801
- pushNewDebugImage,
802
- setTimeDuration: setTimeDuration,
803
- saveDebugImage
568
+ }
804
569
  };
805
570
  }
806
571
 
@@ -993,9 +758,8 @@ function showErrorMessage(text, showRetryBtn, callback, buttonText, _titleText)
993
758
  errorMessagePanel.appendChild(retryText);
994
759
  if (callback) {
995
760
  retryText.addEventListener('click', e => {
996
- callback(e, {
997
- hideErrorMessage
998
- });
761
+ target.removeChild(errorMessagePanel);
762
+ callback(e);
999
763
  });
1000
764
  }
1001
765
  }
@@ -1058,12 +822,13 @@ function asyncShowErrorMessage(text, showRetryBtn, options) {
1058
822
  function asyncOnLineShowErrorMessage(text, showRetryBtn) {
1059
823
  return __awaiter(this, void 0, void 0, function* () {
1060
824
  return new Promise((res, rej) => {
1061
- showErrorMessage(text, showRetryBtn, (_, tools) => {
825
+ const callback = () => {
1062
826
  if (window.navigator.onLine) {
1063
827
  res(true);
1064
- tools === null || tools === void 0 ? void 0 : tools.hideErrorMessage();
828
+ hideErrorMessage();
1065
829
  }
1066
- });
830
+ };
831
+ showErrorMessage(text, showRetryBtn, callback);
1067
832
  });
1068
833
  });
1069
834
  }
@@ -1131,8 +896,6 @@ var BROWSER_CAMERA_ERRORS;
1131
896
  BROWSER_CAMERA_ERRORS["NO_CAMERA"] = "NO_CAMERA";
1132
897
  BROWSER_CAMERA_ERRORS["NOT_ALLOWED_ERROR"] = "NotAllowedError";
1133
898
  BROWSER_CAMERA_ERRORS["NOT_FOUND_ERROR"] = "NotFoundError";
1134
- BROWSER_CAMERA_ERRORS["NOT_READABLE_ERROR"] = "NotReadableError";
1135
- BROWSER_CAMERA_ERRORS["ABORT_ERROR"] = "AbortError";
1136
899
  })(BROWSER_CAMERA_ERRORS || (BROWSER_CAMERA_ERRORS = {}));
1137
900
  let stream;
1138
901
  const videoConstraintsFactory = (isPC, facingMode) => {
@@ -1392,15 +1155,6 @@ function requestCamera({
1392
1155
  showMessage(translate('camera.error.notFound'));
1393
1156
  throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
1394
1157
  }
1395
- if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_READABLE_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.ABORT_ERROR) {
1396
- showMessage(translate('camera.error.notFound'));
1397
- /* NOT_READABLE_ERROR,ABORT_ERROR 這兩個錯誤是用戶授權了,但在呼叫裝置時出現錯誤,
1398
- * 常發生在APP webview ,例如: 手機開啟 web 使用 sdk,儘管在 webview 層級上授權了,但手機在設定層級沒有授權 app 使用相機,會導致此問題。
1399
- * 但每個 android 手機的在這方面的實作不一致,不是每個手機在這種情況下都會拋出錯誤。
1400
- * 參考 https://developer.mozilla.org/zh-CN/docs/Web/API/MediaDevices/getUserMedia#notreadableerror
1401
- */
1402
- throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
1403
- }
1404
1158
  if (isOverconstrainedError(error)) {
1405
1159
  showMessage(translate('camera.error.lowResolution'));
1406
1160
  throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
@@ -2396,46 +2150,15 @@ function RGBToLottieColor(color) {
2396
2150
  return color.map(c => c / 255);
2397
2151
  }
2398
2152
 
2399
- const QUEUE_LENGTH = 10;
2400
- const requstQueue = [];
2401
- function pushRequest(request) {
2402
- if (requstQueue.length > QUEUE_LENGTH - 1) {
2403
- requstQueue.shift();
2404
- }
2405
- requstQueue.push(request);
2406
- }
2407
- function clearRequest() {
2408
- requstQueue.splice(0, requstQueue.length);
2409
- }
2410
- function backgroundRequest(request) {
2411
- const requestPromise = request();
2412
- requestPromise.catch(err => {
2413
- if (err._code === ErrorCode.NETWORK_ERROR) {
2414
- pushRequest(request);
2415
- }
2416
- });
2417
- }
2418
- window.ononline = () => {
2419
- const tasks = [...requstQueue];
2420
- clearRequest();
2421
- tasks.forEach(request => {
2422
- backgroundRequest(request);
2423
- });
2424
- };
2425
-
2426
2153
  var name = "@authme/util";
2427
- var version$1 = "2.4.10";
2154
+ var version$1 = "2.4.11";
2428
2155
  var peerDependencies = {
2429
2156
  "core-js": "^3.6.0"
2430
2157
  };
2431
- var devDependencies = {
2432
- "@types/file-saver": "^2.0.5"
2433
- };
2434
2158
  var packageInfo = {
2435
2159
  name: name,
2436
2160
  version: version$1,
2437
- peerDependencies: peerDependencies,
2438
- devDependencies: devDependencies
2161
+ peerDependencies: peerDependencies
2439
2162
  };
2440
2163
 
2441
2164
  var _a;
@@ -2444,4 +2167,4 @@ const version = packageInfo.version;
2444
2167
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
2445
2168
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
2446
2169
 
2447
- export { AuthmeError, ErrorCode, Icon, RGBToLottieColor, RUN_FUNCTION_NAME, STORAGE_KEY, Storage, TIME_UNIT, UintArrayToBlob, asyncOnLineShowErrorMessage, asyncShowErrorMessage, asyncShowPopup, backgroundRequest, checkOnlineStatus, clearCanvas, colorStringToRGB, colorToRGB, combineResult, cropByRatio, dataURItoBlob, debugLog, debugTools, decodeToken, getCanvasSize, getCssVariable, getDeviceInfo, getImageData, getSystemInfo, getUserAgent, hexToRGB, hideElement, hideErrorMessage, hidePopup, isIphone14proOrProMax, isMobile, isMobileOrTablet, requestCamera, resize, retryPromiseWithCondition, showElement, showErrorMessage, showErrorMessageEventName, showPopup, splitResult, startLoadingSDK, startSpinner, stopLoadingSDK, stopSpinner, switchCamera, useState, version, videoConstraintsFactory, waitTime };
2170
+ export { AuthmeError, ErrorCode, Icon, RGBToLottieColor, STORAGE_KEY, Storage, TIME_UNIT, UintArrayToBlob, asyncOnLineShowErrorMessage, asyncShowErrorMessage, asyncShowPopup, checkOnlineStatus, clearCanvas, colorStringToRGB, colorToRGB, combineResult, cropByRatio, dataURItoBlob, debugLog, debugTools, decodeToken, getCanvasSize, getCssVariable, getDeviceInfo, getImageData, getSystemInfo, getUserAgent, hexToRGB, hideElement, hideErrorMessage, hidePopup, isIphone14proOrProMax, isMobile, isMobileOrTablet, requestCamera, resize, retryPromiseWithCondition, showElement, showErrorMessage, showErrorMessageEventName, showPopup, splitResult, startLoadingSDK, startSpinner, stopLoadingSDK, stopSpinner, switchCamera, useState, version, videoConstraintsFactory, waitTime };
package/package.json CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "@authme/util",
3
- "version": "2.4.10",
3
+ "version": "2.4.11",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
6
  "jwt-decode": "3.1.2",
7
7
  "rxjs": "7.5.7",
8
- "file-saver": "2.0.5",
9
- "jszip": "3.10.1",
10
8
  "lottie-web": "5.9.6"
11
9
  },
12
- "devDependencies": {
13
- "@types/file-saver": "^2.0.5"
14
- },
15
10
  "module": "./index.js",
16
11
  "main": "./index.cjs",
17
12
  "type": "module",
package/src/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './lib/shared-util';
2
2
  export * from './ui';
3
- export * from './lib/background-request-process';
4
3
  export { version } from './lib/version';
@@ -1,34 +1,22 @@
1
- export declare enum RUN_FUNCTION_NAME {
2
- RECOGNITION = "service.recognition",
3
- ANTI_FARUD_RECOGNITION = "antiFraudInstance.recognition",
4
- API_REQUEST = "api.request"
5
- }
6
- interface GetDebugImageParams<T> {
7
- data: Uint8ClampedArray;
8
- type?: T;
9
- getDebugImageData: (data: Uint8ClampedArray | Uint8Array) => Promise<Uint8Array>;
10
- result: any;
11
- width: number;
12
- height: number;
13
- }
14
1
  export declare function debugLog(message?: any, ...others: any[]): void;
15
2
  export interface DebugLog<T> {
3
+ image?: string;
4
+ resultOcrImg?: string;
16
5
  result?: any;
17
6
  report?: any;
18
7
  status?: 'recognition' | 'confirm' | 'run-start' | 'run-end' | 'run-error';
19
- runFunction?: RUN_FUNCTION_NAME;
8
+ runFunction?: string;
20
9
  roundId?: string;
21
- _id: string;
22
10
  type?: T;
23
- time: number;
11
+ time?: number;
24
12
  dateTime?: string;
25
13
  message?: any;
26
14
  isAntiFraud?: boolean;
27
15
  }
28
- export declare function debugTools<T>(): {
16
+ export declare function debugTools<T>(config: {
29
17
  debugMode: boolean;
30
- debugModeUI: boolean;
31
- pushNewDebugLog: (logParams: Partial<DebugLog<T>>) => DebugLog<T> | undefined;
18
+ }): {
19
+ pushNewDebugLog: (logParams: DebugLog<T>) => void;
32
20
  getDebugLogs: () => DebugLog<T>[];
33
21
  getDebugLogsLength: () => number;
34
22
  modifyDeubgLog: (index: number, logParams: Partial<DebugLog<T>>) => void;
@@ -36,12 +24,4 @@ export declare function debugTools<T>(): {
36
24
  functionLogging: <P>(func: () => Promise<P>, logParams?: Partial<DebugLog<T>>) => Promise<P>;
37
25
  nextDebugRound: (type?: T) => void;
38
26
  modifyDebugType: (type: T) => void;
39
- pushNewDebugImage: (image: Blob, log: Partial<DebugLog<T>>, options?: {
40
- prefix?: string;
41
- }) => void;
42
- setTimeDuration: (behavior: string) => {
43
- end: () => void;
44
- };
45
- saveDebugImage: ({ getDebugImageData, data, width, height, result, type, }: GetDebugImageParams<T>) => Promise<void>;
46
27
  };
47
- export {};
@@ -1,15 +1,12 @@
1
- export declare type ShowErrorMessageHandler = (text: string, showRetryBtn?: boolean, callback?: CallBackType, buttonText?: string, titleText?: string) => void;
2
- export declare type CallBackType = (e: Event, tools?: {
3
- hideErrorMessage: () => void;
4
- }) => void;
5
- export declare function showErrorMessage(text: string, showRetryBtn?: boolean, callback?: CallBackType, buttonText?: string, _titleText?: string): Promise<void>;
6
- export declare function showErrorMessageEventName(text: string, showRetryBtn?: boolean, callback?: CallBackType, buttonText?: string, titleText?: string): Promise<void>;
1
+ export declare function showErrorMessage(text: string, showRetryBtn?: boolean, callback?: (e: Event) => void, buttonText?: string, _titleText?: string): Promise<void>;
2
+ export declare function showErrorMessageEventName(text: string, showRetryBtn?: boolean, callback?: (e: Event) => void, buttonText?: string, titleText?: string): Promise<void>;
7
3
  export declare function hideErrorMessage(): void;
8
4
  export declare function asyncShowErrorMessage(text: string, showRetryBtn?: boolean, options?: {
9
- callback?: CallBackType;
5
+ callback?: (e: Event) => void;
10
6
  buttonText?: string;
11
7
  titleText?: string;
12
- showErrorMessageHandler?: ShowErrorMessageHandler;
8
+ errorTextHandler?: (text: Error) => string;
9
+ showErrorMessageHandler?: (text: string) => void;
13
10
  }): Promise<boolean>;
14
11
  export declare function asyncOnLineShowErrorMessage(text: string, showRetryBtn?: boolean): Promise<boolean>;
15
12
  export declare function checkOnlineStatus(msg: string): Promise<void>;
@@ -1 +0,0 @@
1
- export declare function backgroundRequest<T = unknown>(request: () => Promise<T>): void;
@@ -1,11 +0,0 @@
1
- interface FileItem {
2
- name: string;
3
- file: Blob;
4
- }
5
- export declare function fileSaverService(): {
6
- pushFile: (file: FileItem) => void;
7
- saveFiles: (fileName: string, json?: {
8
- [key: string]: any;
9
- }) => Promise<void>;
10
- };
11
- export {};